diff --git a/.asf.yaml b/.asf.yaml index a8f1482cf4a..092e06d9716 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -59,6 +59,7 @@ github: - abh1sar - rosi-shapeblue - sudo87 + - erikbocks protected_branches: ~ diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yml similarity index 100% rename from .github/ISSUE_TEMPLATE/feature_request.yaml rename to .github/ISSUE_TEMPLATE/feature_request.yml diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml index 531c26ace44..6a8a26f4849 100644 --- a/.github/linters/.markdown-lint.yml +++ b/.github/linters/.markdown-lint.yml @@ -18,9 +18,6 @@ # MD001/heading-increment Heading levels should only increment by one level at a time MD001: false -# MD003/heading-style Heading style -MD003: false - # MD004/ul-style Unordered list style MD004: false diff --git a/.github/linters/.yamllint.yml b/.github/linters/.yamllint.yml index 8a72aee0adb..97b66848696 100644 --- a/.github/linters/.yamllint.yml +++ b/.github/linters/.yamllint.yml @@ -15,13 +15,14 @@ # specific language governing permissions and limitations # under the License. --- -extends: relaxed +extends: default rules: line-length: max: 400 # Very forgiving for GitHub Actions and infrastructure files indentation: disable # Disable indentation checking for existing files comments: disable # Disable comment formatting checks + braces: disable brackets: disable # Disable bracket spacing checks colons: max-spaces-after: -1 # Allow any number of spaces after colon diff --git a/.github/linters/codespell.txt b/.github/linters/codespell.txt index 55918266312..67cbeaa7cbb 100644 --- a/.github/linters/codespell.txt +++ b/.github/linters/codespell.txt @@ -4,6 +4,7 @@ acount actuall acuiring acumulate +addin addreess addtion adminstrator @@ -12,10 +13,8 @@ afrer afterall againt ags -aktive algoritm allo -alloacate allocted alocation alogrithm @@ -65,6 +64,7 @@ bject boardcast bootstraper bu +callin cant capabilites capablity @@ -73,6 +73,7 @@ carrefully cavaet chaing checkd +checkin childs choosen chould @@ -93,7 +94,6 @@ confg configruation configuable conneciton -connexion constrait constraits containg @@ -101,9 +101,7 @@ contex continuesly contro controler -controles controll -convienient convinience coputer correcponding @@ -158,13 +156,13 @@ differnet differnt direcotry directroy -disale disbale discrepency disover dissapper dissassociated divice +dockin doesn' doesnot doesnt @@ -175,7 +173,6 @@ eanbled earch ect elemnt -eles elments emmited enble @@ -187,22 +184,19 @@ environmnet equivalant erro erronous -everthing everytime excute execept execption +exects execut executeable exeeded exisitng exisits -existin existsing -exitting expcted expection -explaination explicitely faield faild @@ -215,7 +209,6 @@ fillled findout fisrt fo -folowing fowarding frist fro @@ -234,6 +227,7 @@ hanling happend hasing hasnt +havin hda hostanme hould @@ -253,20 +247,14 @@ implmeneted implmentation incase includeing -incosistency indecates -indien infor informations informaton -infrastrcuture ingore -inital initalize initator -initilization inspite -instace instal instnace intefaces @@ -284,12 +272,8 @@ ist klunky lable leve -lief limite -linke listner -lokal -lokales maintainence maintenace maintenence @@ -298,7 +282,6 @@ mambers manaully manuel maxium -mehtod mergable mesage messge @@ -308,7 +291,6 @@ minumum mis modifers mor -mot mulitply multipl multple @@ -322,7 +304,7 @@ nin nodel nome noone -nowe +notin numbe numer occured @@ -375,6 +357,7 @@ propogate provison psudo pyhsical +re-use readabilty readd reccuring @@ -389,12 +372,9 @@ remaning remore remvoing renabling -repeatly reponse reqest reqiured -requieres -requried reserv reserverd reseted @@ -411,17 +391,15 @@ retriving retrun retuned returing -re-use rever rocessor +roperty runing runnign sate scalled -scipt scirpt scrip -seconadry seconday seesion sepcified @@ -434,12 +412,10 @@ settig sevices shoul shoule -sie signle simplier singature skiping -snaphsot snpashot specied specifed @@ -450,7 +426,6 @@ standy statics stickyness stil -stip storeage strat streched @@ -459,7 +434,6 @@ succesfull successfull suceessful suces -sucessfully suiteable suppots suppport @@ -492,7 +466,6 @@ uncompressible uneccessarily unexepected unexpect -unknow unkonw unkown unneccessary @@ -500,14 +473,12 @@ unparseable unrecoginized unsupport unxpected -updat uptodate usera usign usin utlization vaidate -valiate valule valus varibles @@ -516,8 +487,6 @@ verfying verifing virutal visable -wakup wil wit -wll wth diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06f9f424c7f..84020f4a6b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,17 +30,17 @@ jobs: build: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '17' cache: 'maven' - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: '3.10' architecture: 'x64' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 471e56e3f07..4edd448067a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ permissions: jobs: build: if: github.repository == 'apache/cloudstack' - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false @@ -216,19 +216,19 @@ jobs: smoke/test_list_volumes"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '17' cache: 'maven' - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: '3.10' architecture: 'x64' @@ -236,7 +236,25 @@ jobs: - name: Install Build Dependencies run: | sudo apt-get update - sudo apt-get install -y git uuid-runtime genisoimage netcat ipmitool build-essential libgcrypt20 libgpg-error-dev libgpg-error0 libopenipmi0 ipmitool libpython3-dev libssl-dev libffi-dev python3-openssl python3-dev python3-setuptools + sudo apt-get install -y git uuid-runtime genisoimage netcat-openbsd ipmitool build-essential libgcrypt20 libgpg-error-dev libgpg-error0 libopenipmi0 ipmitool libpython3-dev libssl-dev libffi-dev python3-openssl python3-dev python3-setuptools + + - name: Setup IPMI Tool for CloudStack + run: | + # Create cloudstack-common directory if it doesn't exist + sudo mkdir -p /usr/share/cloudstack-common + + # Copy ipmitool to cloudstack-common directory if it doesn't exist + if [ ! -f /usr/share/cloudstack-common/ipmitool ]; then + sudo cp /usr/bin/ipmitool /usr/share/cloudstack-common/ipmitool + sudo chmod 755 /usr/share/cloudstack-common/ipmitool + fi + + # Create ipmitool-C3 wrapper script + sudo tee /usr/bin/ipmitool > /dev/null << 'EOF' + #!/bin/bash + /usr/share/cloudstack-common/ipmitool -C3 $@ + EOF + sudo chmod 755 /usr/bin/ipmitool - name: Install Python dependencies run: | @@ -275,7 +293,7 @@ jobs: - name: Setup Simulator Prerequisites run: | sudo python3 -m pip install --upgrade netaddr mysql-connector-python - python3 -m pip install --user --upgrade tools/marvin/dist/Marvin-*.tar.gz + python3 -m pip install --user --upgrade tools/marvin/dist/[mM]arvin-*.tar.gz mvn -q -Pdeveloper -pl developer -Ddeploydb mvn -q -Pdeveloper -pl developer -Ddeploydb-simulator diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index c77783746ca..fbd944a758f 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -32,12 +32,12 @@ jobs: name: codecov runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '17' diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 85f348b35bf..74e59aa821d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,7 +35,7 @@ jobs: language: ["actions"] steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: diff --git a/.github/workflows/dependabot.yaml b/.github/workflows/dependabot.yaml new file mode 100644 index 00000000000..88985cbdef1 --- /dev/null +++ b/.github/workflows/dependabot.yaml @@ -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. + +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "maven" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" diff --git a/.github/workflows/docker-cloudstack-simulator.yml b/.github/workflows/docker-cloudstack-simulator.yml index 21a09d04e0b..af6cbf49f5e 100644 --- a/.github/workflows/docker-cloudstack-simulator.yml +++ b/.github/workflows/docker-cloudstack-simulator.yml @@ -47,7 +47,7 @@ jobs: - name: Set Docker repository name run: echo "DOCKER_REPOSITORY=apache" >> $GITHUB_ENV - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set ACS version run: echo "ACS_VERSION=$(grep '' pom.xml | head -2 | tail -1 | cut -d'>' -f2 |cut -d'<' -f1)" >> $GITHUB_ENV diff --git a/.github/workflows/license-templates/LICENSE.txt b/.github/workflows/license-templates/LICENSE.txt new file mode 100644 index 00000000000..60b675e3101 --- /dev/null +++ b/.github/workflows/license-templates/LICENSE.txt @@ -0,0 +1,16 @@ +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. diff --git a/.github/workflows/main-sonar-check.yml b/.github/workflows/main-sonar-check.yml index dccd7174e54..70cc3fbe19f 100644 --- a/.github/workflows/main-sonar-check.yml +++ b/.github/workflows/main-sonar-check.yml @@ -32,12 +32,12 @@ jobs: name: Main Sonar JaCoCo Build runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up JDK17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '17' diff --git a/.github/workflows/linter.yml b/.github/workflows/pre-commit.yml similarity index 87% rename from .github/workflows/linter.yml rename to .github/workflows/pre-commit.yml index 0bc87c6cc13..1518cfec014 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/pre-commit.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Check Out - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install run: | python -m pip install --upgrade pip @@ -44,4 +44,6 @@ jobs: path: ~/.cache/pre-commit key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - name: Run pre-commit - run: pre-commit run --all-files + run: pre-commit run --color=always --all-files + - name: Run manual pre-commit hooks + run: pre-commit run --color=always --all-files --hook-stage manual diff --git a/.github/workflows/rat.yml b/.github/workflows/rat.yml index 52ce343841b..d71f4b0852d 100644 --- a/.github/workflows/rat.yml +++ b/.github/workflows/rat.yml @@ -30,9 +30,9 @@ jobs: build: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: '17' distribution: 'adopt' diff --git a/.github/workflows/sonar-check.yml b/.github/workflows/sonar-check.yml index d31f55980a8..46bfdd7d015 100644 --- a/.github/workflows/sonar-check.yml +++ b/.github/workflows/sonar-check.yml @@ -33,13 +33,13 @@ jobs: name: Sonar JaCoCo Coverage runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: ref: "refs/pull/${{ github.event.number }}/merge" fetch-depth: 0 - name: Set up JDK17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '17' diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml index 88d4a70e4c2..56b04a6f9c9 100644 --- a/.github/workflows/ui.yml +++ b/.github/workflows/ui.yml @@ -31,10 +31,10 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v5 with: node-version: 16 diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 00000000000..9fc9e21de77 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1 @@ +CHANGES.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70d7e39cdf3..b42eb6c4ee5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,18 +25,88 @@ repos: hooks: - id: identity - id: check-hooks-apply + - repo: https://github.com/thlorenz/doctoc.git + rev: v2.2.0 + hooks: + - id: doctoc + name: Add TOC for Markdown files + files: ^CONTRIBUTING\.md$|^INSTALL\.md$|^README\.md$ + - repo: https://github.com/oxipng/oxipng + rev: v9.1.5 + hooks: + - id: oxipng + name: run oxipng + description: optimize PNG images with lossless compression + args: ['-o', '4', '--strip', 'safe', '--alpha'] - repo: https://github.com/gitleaks/gitleaks rev: v8.27.2 hooks: - id: gitleaks name: run gitleaks description: detect hardcoded secrets + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: chmod + name: set file permissions + args: ['644'] + files: \.md$ + stages: [manual] + - id: insert-license + name: add license for all Markdown files + files: \.md$ + args: + - --comment-style + - '' + - --license-filepath + - .github/workflows/license-templates/LICENSE.txt + - --fuzzy-match-generates-todo + exclude: ^(CHANGES|ISSUE_TEMPLATE|PULL_REQUEST_TEMPLATE)\.md$|^ui/docs/(full|smoke)-test-plan\.template\.md$ + - id: insert-license + name: add license for all Shell files + description: automatically adds a licence header to all Shell files that don't have a license header + files: \.sh$ + args: + - --comment-style + - '|#|' + - --license-filepath + - .github/workflows/license-templates/LICENSE.txt + - --fuzzy-match-generates-todo + - id: insert-license + name: add license for all SQL files + files: \.sql$ + args: + - --comment-style + - '|--|' + - --license-filepath + - .github/workflows/license-templates/LICENSE.txt + - --fuzzy-match-generates-todo + - id: insert-license + name: add license for all Vue files + files: \.vue$ + args: + - --comment-style + - '|//|' + - --license-filepath + - .github/workflows/license-templates/LICENSE.txt + - --fuzzy-match-generates-todo + - id: insert-license + name: add license for all YAML files + description: automatically adds a licence header to all YAML files that don't have a license header + files: \.ya?ml$ + args: + - --comment-style + - '|#|' + - --license-filepath + - .github/workflows/license-templates/LICENSE.txt + - --fuzzy-match-generates-todo - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: #- id: check-added-large-files - id: check-case-conflict #- id: check-executables-have-shebangs + - id: check-illegal-windows-names - id: check-merge-conflict - id: check-shebang-scripts-are-executable files: \.sh$ @@ -50,7 +120,7 @@ repos: exclude: > (?x) ^scripts/vm/systemvm/id_rsa\.cloud$| - ^server/src/test/java/org/apache/cloudstack/network/ssl/CertServiceTest.java$| + ^server/src/test/java/org/apache/cloudstack/network/ssl/CertServiceTest\.java$| ^server/src/test/java/com/cloud/keystore/KeystoreTest\.java$| ^server/src/test/resources/certs/dsa_self_signed\.key$| ^server/src/test/resources/certs/non_root\.key$| @@ -61,19 +131,21 @@ repos: ^services/console-proxy/rdpconsole/src/test/doc/rdp-key\.pem$| ^systemvm/agent/certs/localhost\.key$| ^systemvm/agent/certs/realhostip\.key$| - ^test/integration/smoke/test_ssl_offloading.py$ + ^test/integration/smoke/test_ssl_offloading\.py$ - id: end-of-file-fixer - exclude: \.vhd$ + exclude: \.vhd$|\.svg$ + - id: file-contents-sorter + args: [--unique] + files: ^\.github/linters/codespell\.txt$ - id: fix-byte-order-marker - id: forbid-submodules - id: mixed-line-ending - exclude: \.cs$ - id: trailing-whitespace files: \.(bat|cfg|cs|css|gitignore|header|in|install|java|md|properties|py|rb|rc|sh|sql|te|template|txt|ucls|vue|xml|xsl|yaml|yml)$|^cloud-cli/bindir/cloud-tool$|^debian/changelog$ args: [--markdown-linebreak-ext=md] exclude: ^services/console-proxy/rdpconsole/src/test/doc/freerdp-debug-log\.txt$ - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.4.1 hooks: - id: codespell name: run codespell diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 17ff4badc97..f0678ed7649 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,31 +1,65 @@ -Contributing to Apache CloudStack (ACS) -======================================= + + +# Contributing to Apache CloudStack (ACS) + +## Summary + + + + +- [Summary](#summary) +- [Bug fixes](#bug-fixes) +- [Developing new features](#developing-new-features) +- [PendingReleaseNotes file](#pendingreleasenotes-file) +- [Fork the code](#fork-the-code) +- [Making changes](#making-changes) +- [Rebase `feature_x` to include updates from `upstream/main`](#rebase-feature_x-to-include-updates-from-upstreammain) +- [Make a GitHub Pull Request to contribute your changes](#make-a-github-pull-request-to-contribute-your-changes) +- [Cleaning up after a successful pull request](#cleaning-up-after-a-successful-pull-request) +- [Release Principles](#release-principles) + + + +## Summary -Summary -------- This document covers how to contribute to the ACS project. ACS uses GitHub PRs to manage code contributions. These instructions assume you have a GitHub.com account, so if you don't have one you will have to create one. Your proposed code changes will be published to your own fork of the ACS project, and you will submit a Pull Request for your changes to be added. _Let's get started!!!_ -Bug fixes ---------- +## Bug fixes It's very important that we can easily track bug fix commits, so their hashes should remain the same in all branches. Therefore, a pull request (PR) that fixes a bug, should be sent against a release branch. This can be either the "current release" or the "previous release", depending on which ones are maintained. Since the goal is a stable main, bug fixes should be "merged forward" to the next branch in order: "previous release" -> "current release" -> main (in other words: old to new) -Developing new features ------------------------ +## Developing new features Development should be done in a feature branch, branched off of main. Send a PR(steps below) to get it into main (2x LGTM applies). PR will only be merged when main is open, will be held otherwise until main is open again. No back porting / cherry-picking features to existing branches! -PendingReleaseNotes file ------------------------- +## PendingReleaseNotes file + When developing a new feature or making a (major) change to an existing feature you are encouraged to append this to the PendingReleaseNotes file so that the Release Manager can use this file as a source of information when compiling the Release Notes for a new release. @@ -33,8 +67,7 @@ When adding information to the PendingReleaseNotes file make sure that you write Updating the PendingReleaseNotes file is preferably a part of the original Pull Request, but that is up to the developers' discretion. -Fork the code -------------- +## Fork the code In your browser, navigate to: [https://github.com/apache/cloudstack](https://github.com/apache/cloudstack) @@ -51,8 +84,7 @@ $ git fetch upstream $ git rebase upstream/main ``` -Making changes --------------- +## 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. @@ -68,8 +100,7 @@ $ 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` ------------------------------------------------------------- +## Rebase `feature_x` to include updates from `upstream/main` It is important that you maintain an up-to-date `main` branch in your local repository. This is done by rebasing in the code changes from `upstream/main` (the official ACS project repository) into your local repository. You will want to do this before you start working on a feature as well as right before you submit your changes as a pull request. I recommend you do this process periodically while you work to make sure you are working off the most recent project code. @@ -89,8 +120,7 @@ $ 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 ------------------------------------------------------ +## Make a GitHub Pull Request to contribute your changes When you are happy with your changes, and you are ready to contribute them, you will create a Pull Request on GitHub to do so. This is done by pushing your local changes to your forked repository (default remote name is `origin`) and then initiating a pull request on GitHub. @@ -114,8 +144,7 @@ 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 -------------------------------------------- +## Cleaning up after a successful pull request Once the `feature_x` branch has been committed into the `upstream/main` branch, your local `feature_x` branch and the `origin/feature_x` branch are no longer needed. If you want to make additional changes, restart the process with a new branch. @@ -129,6 +158,6 @@ $ git branch -D feature_x $ git push origin :feature_x ``` -Release Principles ------------------- +## Release Principles + Detailed information about ACS release principles is available at https://cwiki.apache.org/confluence/display/CLOUDSTACK/Release+principles+for+Apache+CloudStack+4.6+and+up diff --git a/INSTALL.md b/INSTALL.md index b9dfd908efc..52f109b0a41 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,3 +1,22 @@ + + # Apache CloudStack Installation basics This document describes how to develop, build, package and install Apache @@ -7,9 +26,21 @@ or the developer [wiki](https://cwiki.apache.org/confluence/display/CLOUDSTACK/H Apache CloudStack developers use various platforms for development, this guide was tested against a CentOS 7 x86_64 setup. -* [Setting up development environment](https://cwiki.apache.org/confluence/display/CLOUDSTACK/Setting+up+CloudStack+Development+Environment) for Apache CloudStack. -* [Building](https://cwiki.apache.org/confluence/display/CLOUDSTACK/How+to+build+CloudStack) Apache CloudStack. -* [Appliance based development](https://github.com/rhtyd/monkeybox) + + + +- [Setting up Development Environment](#setting-up-development-environment) + - [Using jenv and/or pyenv for Version Management](#using-jenv-andor-pyenv-for-version-management) +- [Getting the Source Code](#getting-the-source-code) +- [Building](#building) +- [To bring up CloudStack UI](#to-bring-up-cloudstack-ui) +- [Building with non-redistributable plugins](#building-with-non-redistributable-plugins) +- [Packaging and Installation](#packaging-and-installation) + - [Debian/Ubuntu](#debianubuntu) + - [RHEL/CentOS](#rhelcentos) +- [Notes](#notes) + + ## Setting up Development Environment diff --git a/PRE_COMMIT.md b/PRE_COMMIT.md new file mode 100644 index 00000000000..62dc296c99e --- /dev/null +++ b/PRE_COMMIT.md @@ -0,0 +1,62 @@ + + +# pre-commit + +We run [pre-commit](https://pre-commit.com/) with +[GitHub Actions](https://github.com/apache/cloudstack/blob/main/.github/workflows/pre-commit.yml) so installation on your +local machine is currently optional. + +The `pre-commit` [configuration file](https://github.com/apache/cloudstack/blob/main/.pre-commit-config.yaml) +is in the repository root. Before you can run the hooks, you need to have `pre-commit` installed. `pre-commit` is a +[Python package](https://pypi.org/project/pre-commit/). + +From the repository root run: `pip install -r requirements-dev.txt` to install `pre-commit` and after you install +`pre-commit` you will then need to install the pre-commit hooks by running `pre-commit install`. + +The hooks run when running `git commit` and also from the command line with `pre-commit`. Some of the hooks will auto +fix the code after the hooks fail whilst most will print error messages from the linters. If a hook fails the overall +commit will fail, and you will need to fix the issues or problems and `git add` and `git commit` again. On `git commit` +the hooks will run mostly only against modified files so if you want to test all hooks against all files and when you +are adding a new hook you should always run: + +`pre-commit run --all-files` + +Sometimes you might need to skip a hook to commit because the hook is stopping you from committing or your computer +might not have all the installation requirements for all the hooks. The `SKIP` variable is comma separated for two or +more hooks: + +`SKIP=codespell git commit -m "foo"` + +The same applies when running pre-commit: + +`SKIP=codespell pre-commit run --all-files` + +Occasionally you can have more serious problems when using `pre-commit` with `git commit`. You can use `--no-verify` to +commit and stop `pre-commit` from checking the hooks. For example: + +`git commit --no-verify -m "foo"` + +If you are having major problems using `pre-commit` you can always uninstall it. + +To run a single hook use `pre-commit run --all-files ` + +For example just run the `codespell` hook: + +`pre-commit run --all-files codespell` diff --git a/README.md b/README.md index 08540a0628d..a5aacb49f6b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ + + # 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) @@ -12,6 +31,24 @@ [![Apache CloudStack](tools/logo/apache_cloudstack.png)](https://cloudstack.apache.org/) + + + +- [Who Uses CloudStack?](#who-uses-cloudstack) +- [Demo](#demo) +- [Getting Started](#getting-started) +- [Getting Source Repository](#getting-source-repository) +- [Documentation](#documentation) +- [News and Events](#news-and-events) +- [Getting Involved and Contributing](#getting-involved-and-contributing) +- [Reporting Security Vulnerabilities](#reporting-security-vulnerabilities) +- [License](#license) +- [Notice of Cryptographic Software](#notice-of-cryptographic-software) +- [Star History](#star-history) +- [Contributors](#contributors) + + + Apache CloudStack is open source software designed to deploy and manage large networks of virtual machines, as a highly available, highly scalable Infrastructure as a Service (IaaS) cloud computing platform. CloudStack is used diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties index 2a083de6fe5..0dc5b8211e0 100644 --- a/agent/conf/agent.properties +++ b/agent/conf/agent.properties @@ -451,3 +451,9 @@ iscsi.session.cleanup.enabled=false # If set to true, creates VMs as full clones of their templates on KVM hypervisor. Creates as linked clones otherwise. # create.full.clone=false + +# Instance conversion TMPDIR env var +#convert.instance.env.tmpdir= + +# Instance conversion VIRT_V2V_TMPDIR env var +#convert.instance.env.virtv2v.tmpdir= diff --git a/agent/conf/uefi.properties.in b/agent/conf/uefi.properties.in new file mode 100644 index 00000000000..3c8866f634b --- /dev/null +++ b/agent/conf/uefi.properties.in @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Configuration file for UEFI + +guest.nvram.template.legacy=@GUESTNVRAMTEMPLATELEGACY@ +guest.loader.legacy=@GUESTLOADERLEGACY@ +guest.nvram.template.secure=@GUESTNVRAMTEMPLATESECURE@ +guest.loader.secure=@GUESTLOADERSECURE@ +guest.nvram.path=@GUESTNVRAMPATH@ diff --git a/agent/pom.xml b/agent/pom.xml index 0fd7d35823e..5ab6cfe17c1 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/agent/src/main/java/com/cloud/agent/Agent.java b/agent/src/main/java/com/cloud/agent/Agent.java index e86557e9681..275fd41edc3 100644 --- a/agent/src/main/java/com/cloud/agent/Agent.java +++ b/agent/src/main/java/com/cloud/agent/Agent.java @@ -613,7 +613,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater } protected String getAgentArch() { - String arch = Script.runSimpleBashScript(Script.getExecutableAbsolutePath("arch"), 1000); + String arch = Script.runSimpleBashScript(Script.getExecutableAbsolutePath("arch"), 2000); logger.debug("Arch for agent: {} found: {}", _name, arch); return arch; } @@ -1322,7 +1322,6 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater processResponse((Response)request, task.getLink()); } else { //put the requests from mgt server into another thread pool, as the request may take a longer time to finish. Don't block the NIO main thread pool - //processRequest(request, task.getLink()); requestHandler.submit(new AgentRequestHandler(getType(), getLink(), request)); } } catch (final ClassNotFoundException e) { @@ -1332,13 +1331,14 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater } } else if (task.getType() == Task.Type.DISCONNECT) { try { - // an issue has been found if reconnect immediately after disconnecting. please refer to https://github.com/apache/cloudstack/issues/8517 + // an issue has been found if reconnect immediately after disconnecting. // wait 5 seconds before reconnecting + logger.debug("Wait for 5 secs before reconnecting, disconnect task - {}", () -> getLinkLog(task.getLink())); Thread.sleep(5000); } catch (InterruptedException e) { } shell.setConnectionTransfer(false); - logger.debug("Executing disconnect task - {}", () -> getLinkLog(task.getLink())); + logger.debug("Executing disconnect task - {} and reconnecting", () -> getLinkLog(task.getLink())); reconnect(task.getLink()); } else if (task.getType() == Task.Type.OTHER) { processOtherTask(task); diff --git a/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java b/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java index 57dc607b920..3364f9708cf 100644 --- a/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java +++ b/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java @@ -117,7 +117,7 @@ public class AgentProperties{ /** * Local storage path.
- * This property allows multiple values to be entered in a single String. The differente values must be separated by commas.
+ * This property allows multiple values to be entered in a single String. The different values must be separated by commas.
* Data type: String.
* Default value: /var/lib/libvirt/images/ */ @@ -134,7 +134,7 @@ public class AgentProperties{ /** * MANDATORY: The UUID for the local storage pool.
- * This property allows multiple values to be entered in a single String. The differente values must be separated by commas.
+ * This property allows multiple values to be entered in a single String. The different values must be separated by commas.
* Data type: String.
* Default value: null */ @@ -794,6 +794,20 @@ public class AgentProperties{ */ public static final Property VIRTV2V_VERBOSE_ENABLED = new Property<>("virtv2v.verbose.enabled", false); + /** + * Set env TMPDIR var for virt-v2v Instance Conversion from VMware to KVM + * Data type: String.
+ * Default value: null + */ + public static final Property CONVERT_ENV_TMPDIR = new Property<>("convert.instance.env.tmpdir", null, String.class); + + /** + * Set env VIRT_V2V_TMPDIR var for virt-v2v Instance Conversion from VMware to KVM + * Data type: String.
+ * Default value: null + */ + public static final Property CONVERT_ENV_VIRTV2V_TMPDIR = new Property<>("convert.instance.env.virtv2v.tmpdir", null, String.class); + /** * BGP controll CIDR * Data type: String.
diff --git a/api/pom.xml b/api/pom.xml index 6270eb2dead..c80c3559345 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/api/src/main/java/com/cloud/agent/api/to/VirtualMachineMetadataTO.java b/api/src/main/java/com/cloud/agent/api/to/VirtualMachineMetadataTO.java new file mode 100644 index 00000000000..5b22afdedd5 --- /dev/null +++ b/api/src/main/java/com/cloud/agent/api/to/VirtualMachineMetadataTO.java @@ -0,0 +1,182 @@ +// 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.to; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class VirtualMachineMetadataTO { + // VM details + private final String name; + private final String internalName; + private final String displayName; + private final String instanceUuid; + private final Integer cpuCores; + private final Integer memory; + private final Long created; + private final Long started; + + // Owner details + private final String ownerDomainUuid; + private final String ownerDomainName; + private final String ownerAccountUuid; + private final String ownerAccountName; + private final String ownerProjectUuid; + private final String ownerProjectName; + + // Host and service offering + private final String serviceOfferingName; + private final List serviceOfferingHostTags; + + // zone, pod, and cluster details + private final String zoneName; + private final String zoneUuid; + private final String podName; + private final String podUuid; + private final String clusterName; + private final String clusterUuid; + + // resource tags + private final Map resourceTags; + + public VirtualMachineMetadataTO( + String name, String internalName, String displayName, String instanceUuid, Integer cpuCores, Integer memory, Long created, Long started, + String ownerDomainUuid, String ownerDomainName, String ownerAccountUuid, String ownerAccountName, String ownerProjectUuid, String ownerProjectName, + String serviceOfferingName, List serviceOfferingHostTags, + String zoneName, String zoneUuid, String podName, String podUuid, String clusterName, String clusterUuid, Map resourceTags) { + /* + * Something failed in the metadata shall not be a fatal error, the VM can still be started + * Thus, the unknown fields just get an explicit "unknown" value so it can be fixed in case + * there are bugs on some execution paths. + * */ + + this.name = (name != null) ? name : "unknown"; + this.internalName = (internalName != null) ? internalName : "unknown"; + this.displayName = (displayName != null) ? displayName : "unknown"; + this.instanceUuid = (instanceUuid != null) ? instanceUuid : "unknown"; + this.cpuCores = (cpuCores != null) ? cpuCores : -1; + this.memory = (memory != null) ? memory : -1; + this.created = (created != null) ? created : 0; + this.started = (started != null) ? started : 0; + this.ownerDomainUuid = (ownerDomainUuid != null) ? ownerDomainUuid : "unknown"; + this.ownerDomainName = (ownerDomainName != null) ? ownerDomainName : "unknown"; + this.ownerAccountUuid = (ownerAccountUuid != null) ? ownerAccountUuid : "unknown"; + this.ownerAccountName = (ownerAccountName != null) ? ownerAccountName : "unknown"; + this.ownerProjectUuid = (ownerProjectUuid != null) ? ownerProjectUuid : "unknown"; + this.ownerProjectName = (ownerProjectName != null) ? ownerProjectName : "unknown"; + this.serviceOfferingName = (serviceOfferingName != null) ? serviceOfferingName : "unknown"; + this.serviceOfferingHostTags = (serviceOfferingHostTags != null) ? serviceOfferingHostTags : new ArrayList<>(); + this.zoneName = (zoneName != null) ? zoneName : "unknown"; + this.zoneUuid = (zoneUuid != null) ? zoneUuid : "unknown"; + this.podName = (podName != null) ? podName : "unknown"; + this.podUuid = (podUuid != null) ? podUuid : "unknown"; + this.clusterName = (clusterName != null) ? clusterName : "unknown"; + this.clusterUuid = (clusterUuid != null) ? clusterUuid : "unknown"; + + this.resourceTags = (resourceTags != null) ? resourceTags : new HashMap<>(); + } + + public String getName() { + return name; + } + + public String getInternalName() { + return internalName; + } + + public String getDisplayName() { + return displayName; + } + + public String getInstanceUuid() { + return instanceUuid; + } + + public Integer getCpuCores() { + return cpuCores; + } + + public Integer getMemory() { + return memory; + } + + public Long getCreated() { return created; } + + public Long getStarted() { + return started; + } + + public String getOwnerDomainUuid() { + return ownerDomainUuid; + } + + public String getOwnerDomainName() { + return ownerDomainName; + } + + public String getOwnerAccountUuid() { + return ownerAccountUuid; + } + + public String getOwnerAccountName() { + return ownerAccountName; + } + + public String getOwnerProjectUuid() { + return ownerProjectUuid; + } + + public String getOwnerProjectName() { + return ownerProjectName; + } + + public String getserviceOfferingName() { + return serviceOfferingName; + } + + public List getserviceOfferingHostTags() { + return serviceOfferingHostTags; + } + + public String getZoneName() { + return zoneName; + } + + public String getZoneUuid() { + return zoneUuid; + } + + public String getPodName() { + return podName; + } + + public String getPodUuid() { + return podUuid; + } + + public String getClusterName() { + return clusterName; + } + + public String getClusterUuid() { + return clusterUuid; + } + + public Map getResourceTags() { return resourceTags; } +} diff --git a/api/src/main/java/com/cloud/agent/api/to/VirtualMachineTO.java b/api/src/main/java/com/cloud/agent/api/to/VirtualMachineTO.java index cffb9874080..e26cc1e9f02 100644 --- a/api/src/main/java/com/cloud/agent/api/to/VirtualMachineTO.java +++ b/api/src/main/java/com/cloud/agent/api/to/VirtualMachineTO.java @@ -89,6 +89,7 @@ public class VirtualMachineTO { private DeployAsIsInfoTO deployAsIsInfo; private String metadataManufacturer; private String metadataProductName; + private VirtualMachineMetadataTO metadata; public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader, String os, boolean enableHA, boolean limitCpuUse, String vncPassword) { @@ -494,6 +495,14 @@ public class VirtualMachineTO { this.metadataProductName = metadataProductName; } + public VirtualMachineMetadataTO getMetadata() { + return metadata; + } + + public void setMetadata(VirtualMachineMetadataTO metadata) { + this.metadata = metadata; + } + @Override public String toString() { return String.format("VM {id: \"%s\", name: \"%s\", uuid: \"%s\", type: \"%s\"}", id, name, uuid, type); diff --git a/api/src/main/java/com/cloud/host/HostStats.java b/api/src/main/java/com/cloud/host/HostStats.java index d14794401fa..0e72b5f2d9d 100644 --- a/api/src/main/java/com/cloud/host/HostStats.java +++ b/api/src/main/java/com/cloud/host/HostStats.java @@ -36,5 +36,4 @@ public interface HostStats { public HostStats getHostStats(); public double getLoadAverage(); - // public double getXapiMemoryUsageKBs(); } diff --git a/api/src/main/java/com/cloud/kubernetes/cluster/KubernetesCluster.java b/api/src/main/java/com/cloud/kubernetes/cluster/KubernetesCluster.java index 60966798cbb..ce905b293ff 100644 --- a/api/src/main/java/com/cloud/kubernetes/cluster/KubernetesCluster.java +++ b/api/src/main/java/com/cloud/kubernetes/cluster/KubernetesCluster.java @@ -172,4 +172,5 @@ public interface KubernetesCluster extends ControlledEntity, com.cloud.utils.fsm Long getEtcdNodeCount(); Long getCniConfigId(); String getCniConfigDetails(); + boolean isCsiEnabled(); } diff --git a/api/src/main/java/com/cloud/network/Networks.java b/api/src/main/java/com/cloud/network/Networks.java index 9f06a044111..5f767686dc9 100644 --- a/api/src/main/java/com/cloud/network/Networks.java +++ b/api/src/main/java/com/cloud/network/Networks.java @@ -78,7 +78,7 @@ public class Networks { } @Override public String getValueFrom(URI uri) { - return uri.getAuthority(); + return uri == null ? null : uri.getAuthority(); } }, Vswitch("vs", String.class), LinkLocal(null, null), Vnet("vnet", Long.class), Storage("storage", Integer.class), Lswitch("lswitch", String.class) { @@ -96,7 +96,7 @@ public class Networks { */ @Override public String getValueFrom(URI uri) { - return uri.getSchemeSpecificPart(); + return uri == null ? null : uri.getSchemeSpecificPart(); } }, Mido("mido", String.class), Pvlan("pvlan", String.class), @@ -177,7 +177,7 @@ public class Networks { * @return the scheme as BroadcastDomainType */ public static BroadcastDomainType getSchemeValue(URI uri) { - return toEnumValue(uri.getScheme()); + return toEnumValue(uri == null ? null : uri.getScheme()); } /** @@ -191,7 +191,7 @@ public class Networks { if (com.cloud.dc.Vlan.UNTAGGED.equalsIgnoreCase(str)) { return Native; } - return getSchemeValue(new URI(str)); + return getSchemeValue(str == null ? null : new URI(str)); } /** @@ -220,7 +220,7 @@ public class Networks { * @return the host part as String */ public String getValueFrom(URI uri) { - return uri.getHost(); + return uri == null ? null : uri.getHost(); } /** @@ -243,7 +243,7 @@ public class Networks { * @throws URISyntaxException the string is not even an uri */ public static String getValue(String uriString) throws URISyntaxException { - return getValue(new URI(uriString)); + return getValue(uriString == null ? null : new URI(uriString)); } /** diff --git a/api/src/main/java/com/cloud/network/PhysicalNetworkTrafficType.java b/api/src/main/java/com/cloud/network/PhysicalNetworkTrafficType.java index 9676badb4e9..d3804cd29da 100644 --- a/api/src/main/java/com/cloud/network/PhysicalNetworkTrafficType.java +++ b/api/src/main/java/com/cloud/network/PhysicalNetworkTrafficType.java @@ -41,4 +41,6 @@ public interface PhysicalNetworkTrafficType extends InternalIdentity, Identity { String getHypervNetworkLabel(); String getOvm3NetworkLabel(); + + String getVlan(); } diff --git a/api/src/main/java/com/cloud/network/as/AutoScaleService.java b/api/src/main/java/com/cloud/network/as/AutoScaleService.java index ceca4de6842..4aef10f8de9 100644 --- a/api/src/main/java/com/cloud/network/as/AutoScaleService.java +++ b/api/src/main/java/com/cloud/network/as/AutoScaleService.java @@ -70,6 +70,8 @@ public interface AutoScaleService { Counter createCounter(CreateCounterCmd cmd); + Counter getCounter(long counterId); + boolean deleteCounter(long counterId) throws ResourceInUseException; List listCounters(ListCountersCmd cmd); diff --git a/api/src/main/java/com/cloud/network/rules/LbStickinessMethod.java b/api/src/main/java/com/cloud/network/rules/LbStickinessMethod.java index 56a0622a52b..5143611ee82 100644 --- a/api/src/main/java/com/cloud/network/rules/LbStickinessMethod.java +++ b/api/src/main/java/com/cloud/network/rules/LbStickinessMethod.java @@ -108,8 +108,7 @@ public class LbStickinessMethod { } public void addParam(String name, Boolean required, String description, Boolean isFlag) { - /* FIXME : UI is breaking if the capability string length is larger , temporarily description is commented out */ - // LbStickinessMethodParam param = new LbStickinessMethodParam(name, required, description); + /* is this still a valid comment: FIXME : UI is breaking if the capability string length is larger , temporarily description is commented out */ LbStickinessMethodParam param = new LbStickinessMethodParam(name, required, " ", isFlag); _paramList.add(param); return; @@ -133,7 +132,6 @@ public class LbStickinessMethod { public void setDescription(String description) { /* FIXME : UI is breaking if the capability string length is larger , temporarily description is commented out */ - //this.description = description; this._description = " "; } } diff --git a/api/src/main/java/com/cloud/offering/DiskOffering.java b/api/src/main/java/com/cloud/offering/DiskOffering.java index e1c41f77cbf..d74f5703cc9 100644 --- a/api/src/main/java/com/cloud/offering/DiskOffering.java +++ b/api/src/main/java/com/cloud/offering/DiskOffering.java @@ -37,7 +37,7 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId State getState(); enum DiskCacheMode { - NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough"); + NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough"), HYPERVISOR_DEFAULT("hypervisor_default"); private final String _diskCacheMode; @@ -69,6 +69,8 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId boolean isCustomized(); + boolean isShared(); + void setDiskSize(long diskSize); long getDiskSize(); @@ -99,7 +101,6 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId Long getBytesReadRateMaxLength(); - void setBytesWriteRate(Long bytesWriteRate); Long getBytesWriteRate(); @@ -112,7 +113,6 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId Long getBytesWriteRateMaxLength(); - void setIopsReadRate(Long iopsReadRate); Long getIopsReadRate(); @@ -133,7 +133,6 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId Long getIopsWriteRateMax(); - void setIopsWriteRateMaxLength(Long iopsWriteRateMaxLength); Long getIopsWriteRateMaxLength(); diff --git a/api/src/main/java/com/cloud/server/ManagementService.java b/api/src/main/java/com/cloud/server/ManagementService.java index f7b2456ce5c..d2a987bb078 100644 --- a/api/src/main/java/com/cloud/server/ManagementService.java +++ b/api/src/main/java/com/cloud/server/ManagementService.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.cloud.user.UserData; import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd; import org.apache.cloudstack.api.command.admin.config.ListCfgGroupsByCmd; import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd; @@ -72,6 +71,7 @@ import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd; import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd; import org.apache.cloudstack.config.Configuration; import org.apache.cloudstack.config.ConfigurationGroup; +import org.apache.cloudstack.framework.config.ConfigKey; import com.cloud.alert.Alert; import com.cloud.capacity.Capacity; @@ -91,6 +91,7 @@ import com.cloud.storage.GuestOSHypervisor; import com.cloud.storage.GuestOsCategory; import com.cloud.storage.StoragePool; import com.cloud.user.SSHKeyPair; +import com.cloud.user.UserData; import com.cloud.utils.Pair; import com.cloud.utils.Ternary; import com.cloud.vm.InstanceGroup; @@ -104,6 +105,14 @@ import com.cloud.vm.VirtualMachine.Type; public interface ManagementService { static final String Name = "management-server"; + ConfigKey JsInterpretationEnabled = new ConfigKey<>("Hidden" + , Boolean.class + , "js.interpretation.enabled" + , "false" + , "Enable/Disable all JavaScript interpretation related functionalities to create or update Javascript rules." + , false + , ConfigKey.Scope.Global); + /** * returns the a map of the names/values in the configuration table * @@ -509,4 +518,6 @@ public interface ManagementService { boolean removeManagementServer(RemoveManagementServerCmd cmd); + void checkJsInterpretationAllowedIfNeededForParameterValue(String paramName, boolean paramValue); + } diff --git a/api/src/main/java/com/cloud/server/ResourceManagerUtil.java b/api/src/main/java/com/cloud/server/ResourceManagerUtil.java index 9a3b51a70d5..f5081cbe307 100644 --- a/api/src/main/java/com/cloud/server/ResourceManagerUtil.java +++ b/api/src/main/java/com/cloud/server/ResourceManagerUtil.java @@ -18,6 +18,7 @@ package com.cloud.server; public interface ResourceManagerUtil { long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType); + long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType, boolean checkAccess); String getUuid(String resourceId, ResourceTag.ResourceObjectType resourceType); ResourceTag.ResourceObjectType getResourceType(String resourceTypeStr); void checkResourceAccessible(Long accountId, Long domainId, String exceptionMessage); diff --git a/api/src/main/java/com/cloud/storage/Storage.java b/api/src/main/java/com/cloud/storage/Storage.java index 1ad3731b9ea..5b3e97698fd 100644 --- a/api/src/main/java/com/cloud/storage/Storage.java +++ b/api/src/main/java/com/cloud/storage/Storage.java @@ -128,7 +128,7 @@ public class Storage { public static enum TemplateType { ROUTING, // Router template SYSTEM, /* routing, system vm template */ - BUILTIN, /* buildin template */ + BUILTIN, /* builtin template */ PERHOST, /* every host has this template, don't need to install it in secondary storage */ USER, /* User supplied template/iso */ VNF, /* VNFs (virtual network functions) template */ diff --git a/api/src/main/java/com/cloud/storage/VolumeApiService.java b/api/src/main/java/com/cloud/storage/VolumeApiService.java index 4140d51a800..19c2ebe455a 100644 --- a/api/src/main/java/com/cloud/storage/VolumeApiService.java +++ b/api/src/main/java/com/cloud/storage/VolumeApiService.java @@ -180,6 +180,8 @@ public interface VolumeApiService { */ boolean doesStoragePoolSupportDiskOfferingTags(StoragePool destPool, String diskOfferingTags); + boolean validateConditionsToReplaceDiskOfferingOfVolume(Volume volume, DiskOffering newDiskOffering, StoragePool destPool); + Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge); void destroyVolume(long volumeId); diff --git a/api/src/main/java/com/cloud/storage/snapshot/SnapshotApiService.java b/api/src/main/java/com/cloud/storage/snapshot/SnapshotApiService.java index 67afd6aa4e2..d52e645ec79 100644 --- a/api/src/main/java/com/cloud/storage/snapshot/SnapshotApiService.java +++ b/api/src/main/java/com/cloud/storage/snapshot/SnapshotApiService.java @@ -85,7 +85,7 @@ public interface SnapshotApiService { * the command that specifies the volume criteria * @return list of snapshot policies */ - Pair, Integer> listPoliciesforVolume(ListSnapshotPoliciesCmd cmd); + Pair, Integer> listSnapshotPolicies(ListSnapshotPoliciesCmd cmd); boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd); diff --git a/api/src/main/java/com/cloud/storage/snapshot/SnapshotPolicy.java b/api/src/main/java/com/cloud/storage/snapshot/SnapshotPolicy.java index 22d5dfb9c1b..13009a9808a 100644 --- a/api/src/main/java/com/cloud/storage/snapshot/SnapshotPolicy.java +++ b/api/src/main/java/com/cloud/storage/snapshot/SnapshotPolicy.java @@ -16,11 +16,12 @@ // under the License. package com.cloud.storage.snapshot; +import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.api.Displayable; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; -public interface SnapshotPolicy extends Identity, InternalIdentity, Displayable { +public interface SnapshotPolicy extends ControlledEntity, Identity, InternalIdentity, Displayable { long getVolumeId(); diff --git a/api/src/main/java/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java b/api/src/main/java/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java index 083a1be00f5..028aab24757 100644 --- a/api/src/main/java/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java @@ -81,6 +81,34 @@ public abstract class AbstractGetUploadParamsCmd extends BaseCmd { return projectId; } + public void setName(String name) { + this.name = name; + } + + public void setFormat(String format) { + this.format = format; + } + + public void setZoneId(Long zoneId) { + this.zoneId = zoneId; + } + + public void setChecksum(String checksum) { + this.checksum = checksum; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public void setDomainId(Long domainId) { + this.domainId = domainId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + public GetUploadParamsResponse createGetUploadParamsResponse(UUID id, URL postURL, String metadata, String timeout, String signature) { return new GetUploadParamsResponse(id, postURL, metadata, timeout, signature); } 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 475b845af9b..8fca652518f 100644 --- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java @@ -64,6 +64,7 @@ public class ApiConstants { public static final String BACKUP_STORAGE_LIMIT = "backupstoragelimit"; public static final String BACKUP_STORAGE_TOTAL = "backupstoragetotal"; public static final String BACKUP_VM_OFFERING_REMOVED = "vmbackupofferingremoved"; + public static final String IS_BACKUP_VM_EXPUNGED = "isbackupvmexpunged"; public static final String BACKUP_TOTAL = "backuptotal"; public static final String BASE64_IMAGE = "base64image"; public static final String BGP_PEERS = "bgppeers"; @@ -134,6 +135,7 @@ public class ApiConstants { public static final String CNI_CONFIG_ID = "cniconfigurationid"; public static final String CNI_CONFIG_DETAILS = "cniconfigdetails"; public static final String CNI_CONFIG_NAME = "cniconfigname"; + public static final String CSI_ENABLED = "csienabled"; public static final String COMPONENT = "component"; public static final String CPU = "CPU"; public static final String CPU_CORE_PER_SOCKET = "cpucorepersocket"; @@ -214,6 +216,7 @@ public class ApiConstants { public static final String DURATION = "duration"; public static final String ELIGIBLE = "eligible"; public static final String EMAIL = "email"; + public static final String ENABLE_CSI = "enablecsi"; public static final String END_ASN = "endasn"; public static final String END_DATE = "enddate"; public static final String END_IP = "endip"; @@ -225,6 +228,7 @@ public class ApiConstants { public static final String EVENT_TYPE = "eventtype"; public static final String EXPIRES = "expires"; public static final String EXTRA_CONFIG = "extraconfig"; + public static final String EXTRA_PARAMS = "extraparams"; public static final String EXTRA_DHCP_OPTION = "extradhcpoption"; public static final String EXTRA_DHCP_OPTION_NAME = "extradhcpoptionname"; public static final String EXTRA_DHCP_OPTION_CODE = "extradhcpoptioncode"; @@ -243,6 +247,8 @@ public class ApiConstants { public static final String FIRSTNAME = "firstname"; public static final String FORCED = "forced"; public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage"; + public static final String FORCE_CONVERT_TO_POOL = "forceconverttopool"; + public static final String FORCE_DELETE_HOST = "forcedeletehost"; public static final String FORCE_MS_TO_IMPORT_VM_FILES = "forcemstoimportvmfiles"; public static final String FORCE_UPDATE_OS_TYPE = "forceupdateostype"; @@ -578,6 +584,7 @@ public class ApiConstants { public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine"; public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot"; public static final String TARGET_IQN = "targetiqn"; + public static final String TASKS_FILTER = "tasksfilter"; public static final String TEMPLATE_FILTER = "templatefilter"; public static final String TEMPLATE_ID = "templateid"; public static final String TEMPLATE_IDS = "templateids"; @@ -1157,6 +1164,7 @@ public class ApiConstants { public static final String OVM3_CLUSTER = "ovm3cluster"; public static final String OVM3_VIP = "ovm3vip"; public static final String CLEAN_UP_DETAILS = "cleanupdetails"; + public static final String CLEAN_UP_EXTERNAL_DETAILS = "cleanupexternaldetails"; public static final String CLEAN_UP_PARAMETERS = "cleanupparameters"; public static final String VIRTUAL_SIZE = "virtualsize"; public static final String NETSCALER_CONTROLCENTER_ID = "netscalercontrolcenterid"; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java index 7fa66ffff1f..013d0f966dd 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java @@ -17,6 +17,7 @@ package org.apache.cloudstack.api.command.admin.autoscale; +import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandResourceType; @@ -89,9 +90,6 @@ public class CreateCounterCmd extends BaseAsyncCreateCmd { if (ctr != null) { this.setEntityId(ctr.getId()); this.setEntityUuid(ctr.getUuid()); - CounterResponse response = _responseGenerator.createCounterResponse(ctr); - response.setResponseName(getCommandName()); - this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Counter with name " + getName()); } @@ -99,6 +97,11 @@ public class CreateCounterCmd extends BaseAsyncCreateCmd { @Override public void execute() { + CallContext.current().setEventDetails("Counter ID: " + getEntityId()); + Counter ctr = _autoScaleService.getCounter(getEntityId()); + CounterResponse response = _responseGenerator.createCounterResponse(ctr); + response.setResponseName(getCommandName()); + this.setResponseObject(response); } @Override diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java index 9baea58b7b5..86f002b9b7d 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java @@ -72,6 +72,14 @@ public class UpdateHostCmd extends BaseCmd { @Parameter(name = ApiConstants.EXTERNAL_DETAILS, type = CommandType.MAP, description = "Details in key/value pairs using format externaldetails[i].keyname=keyvalue. Example: externaldetails[0].endpoint.url=urlvalue", since = "4.21.0") protected Map externalDetails; + @Parameter(name = ApiConstants.CLEAN_UP_EXTERNAL_DETAILS, + type = CommandType.BOOLEAN, + description = "Optional boolean field, which indicates if external details should be cleaned up or not " + + "(If set to true, external details removed for this host, externaldetails field ignored; " + + "if false or not set, no action)", + since = "4.22.0") + protected Boolean cleanupExternalDetails; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -112,6 +120,10 @@ public class UpdateHostCmd extends BaseCmd { return convertExternalDetailsToMap(externalDetails); } + public boolean isCleanupExternalDetails() { + return Boolean.TRUE.equals(cleanupExternalDetails); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/iso/ListIsoPermissionsCmdByAdmin.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/iso/ListIsoPermissionsCmdByAdmin.java index 46bd4f3766e..57cb461a07a 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/iso/ListIsoPermissionsCmdByAdmin.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/iso/ListIsoPermissionsCmdByAdmin.java @@ -1,4 +1,4 @@ -// Licensedname = "listIsoPermissions", to the Apache Software Foundation (ASF) under one +// 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 diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java index c46e4cd6b44..557c76d63c3 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java @@ -151,7 +151,7 @@ public class CreateDiskOfferingCmd extends BaseCmd { @Parameter(name = ApiConstants.CACHE_MODE, type = CommandType.STRING, required = false, - description = "the cache mode to use for this disk offering. none, writeback or writethrough", + description = "the cache mode to use for this disk offering. none, writeback, writethrough or hypervisor default. If the hypervisor default cache mode is used on other hypervisors than KVM, it will fall back to none cache mode", since = "4.14") private String cacheMode; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java index 3d20ed50a5d..ec109a2a4f3 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java @@ -190,7 +190,7 @@ public class CreateServiceOfferingCmd extends BaseCmd { @Parameter(name = ApiConstants.CACHE_MODE, type = CommandType.STRING, required = false, - description = "the cache mode to use for this disk offering. none, writeback or writethrough", + description = "the cache mode to use for this disk offering. none, writeback, writethrough or hypervisor default. If the hypervisor default cache mode is used on other hypervisors than KVM, it will fall back to none cache mode", since = "4.14") private String cacheMode; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java index 7f66ac7058a..9d973dfc524 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java @@ -101,6 +101,14 @@ public class UpdateServiceOfferingCmd extends BaseCmd { since = "4.21.0") private Map externalDetails; + @Parameter(name = ApiConstants.CLEAN_UP_EXTERNAL_DETAILS, + type = CommandType.BOOLEAN, + description = "Optional boolean field, which indicates if external details should be cleaned up or not " + + "(If set to true, external details removed for this offering, externaldetails field ignored; " + + "if false or not set, no action)", + since = "4.22.0") + protected Boolean cleanupExternalDetails; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -205,6 +213,10 @@ public class UpdateServiceOfferingCmd extends BaseCmd { return convertExternalDetailsToMap(externalDetails); } + public boolean isCleanupExternalDetails() { + return Boolean.TRUE.equals(cleanupExternalDetails); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java index f2d7bbeb189..6f522fe1e8c 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java @@ -153,6 +153,8 @@ public class UpdateStoragePoolCmd extends BaseCmd { if (ObjectUtils.anyNotNull(name, capacityIops, capacityBytes, url, isTagARule, tags) || MapUtils.isNotEmpty(details)) { result = _storageService.updateStoragePool(this); + } else { + result = _storageService.getStoragePool(getId()); } if (enabled != null) { diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/template/ListTemplatePermissionsCmdByAdmin.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/template/ListTemplatePermissionsCmdByAdmin.java index ae0e220b495..5792de737a5 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/template/ListTemplatePermissionsCmdByAdmin.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/template/ListTemplatePermissionsCmdByAdmin.java @@ -1,4 +1,4 @@ -// Licensedname = "listTemplatePermissions", to the Apache Software Foundation (ASF) under one +// 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 diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java index d106a736fca..c204c67d465 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java @@ -26,14 +26,13 @@ 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.PhysicalNetworkResponse; -import org.apache.cloudstack.api.response.ProviderResponse; import org.apache.cloudstack.api.response.TrafficTypeResponse; import com.cloud.network.PhysicalNetworkTrafficType; import com.cloud.user.Account; import com.cloud.utils.Pair; -@APICommand(name = "listTrafficTypes", description = "Lists traffic types of a given physical network.", responseObject = ProviderResponse.class, since = "3.0.0", +@APICommand(name = "listTrafficTypes", description = "Lists traffic types of a given physical network.", responseObject = TrafficTypeResponse.class, since = "3.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListTrafficTypesCmd extends BaseListCmd { 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 db43b53ab9a..f7940460d6c 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 @@ -159,6 +159,18 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd { 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; + @Parameter(name = ApiConstants.EXTRA_PARAMS, + type = CommandType.STRING, + since = "4.22", + description = "(only for importing VMs from VMware to KVM) optional - extra parameters to be passed on the virt-v2v command, if allowed by the administrator") + private String extraParams; + + @Parameter(name = ApiConstants.FORCE_CONVERT_TO_POOL, + type = CommandType.BOOLEAN, + since = "4.22", + description = "(only for importing VMs from VMware to KVM) optional - if true, forces virt-v2v conversions to write directly on the provided storage pool (avoid using temporary conversion pool).") + private Boolean forceConvertToPool; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -248,6 +260,14 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd { return EventTypes.EVENT_VM_IMPORT; } + public String getExtraParams() { + return extraParams; + } + + public boolean getForceConvertToPool() { + return BooleanUtils.toBooleanDefaultIfNull(forceConvertToPool, false); + } + @Override public String getEventDescription() { String vmName = getName(); diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ListImportVMTasksCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ListImportVMTasksCmd.java new file mode 100644 index 00000000000..94b547ff426 --- /dev/null +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ListImportVMTasksCmd.java @@ -0,0 +1,116 @@ +// 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.admin.vm; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.NetworkRuleConflictException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.user.Account; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseListCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.AccountResponse; +import org.apache.cloudstack.api.response.HostResponse; +import org.apache.cloudstack.api.response.ImportVMTaskResponse; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.ZoneResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.vm.ImportVmTasksManager; + +import javax.inject.Inject; + +@APICommand(name = "listImportVmTasks", + description = "List running import virtual machine tasks from a unmanaged hosts into CloudStack", + responseObject = ImportVMTaskResponse.class, + responseView = ResponseObject.ResponseView.Full, + requestHasSensitiveInfo = false, + authorized = {RoleType.Admin}, + since = "4.22") +public class ListImportVMTasksCmd extends BaseListCmd { + + @Inject + public ImportVmTasksManager importVmTasksManager; + + @Parameter(name = ApiConstants.ZONE_ID, + type = CommandType.UUID, + entityType = ZoneResponse.class, + required = true, + description = "the zone ID") + private Long zoneId; + + @Parameter(name = ApiConstants.ACCOUNT_ID, + type = CommandType.UUID, + entityType = AccountResponse.class, + description = "the ID of the Account") + private Long accountId; + + @Parameter(name = ApiConstants.VCENTER, + type = CommandType.STRING, + description = "The name/ip of vCenter. Make sure it is IP address or full qualified domain name for host running vCenter server.") + private String vcenter; + + @Parameter(name = ApiConstants.CONVERT_INSTANCE_HOST_ID, + type = CommandType.UUID, + entityType = HostResponse.class, + description = "Conversion host of the importing task") + private Long convertHostId; + + @Parameter(name = ApiConstants.TASKS_FILTER, type = CommandType.STRING, description = "Filter tasks by state, valid options are: All, Running, Completed, Failed") + private String tasksFilter; + + public Long getZoneId() { + return zoneId; + } + + public Long getAccountId() { + return accountId; + } + + public String getVcenter() { + return vcenter; + } + + public Long getConvertHostId() { + return convertHostId; + } + + public String getTasksFilter() { + return tasksFilter; + } + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { + ListResponse response = importVmTasksManager.listImportVMTasks(this); + response.setResponseName(getCommandName()); + setResponseObject(response); + } + + @Override + public long getEntityOwnerId() { + Account account = CallContext.current().getCallingAccount(); + if (account != null) { + return account.getId(); + } + return Account.ACCOUNT_ID_SYSTEM; + } +} diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java index 357f0c83ed7..57fd733d51d 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java @@ -53,7 +53,7 @@ public class ListPublicIpAddressesCmd extends BaseListRetrieveOnlyResourceCountC @Parameter(name = ApiConstants.ALLOCATED_ONLY, type = CommandType.BOOLEAN, description = "limits search results to allocated public IP addresses") private Boolean allocatedOnly; - @Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "lists all public IP addresses by state") + @Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "lists all public IP addresses by state. A comma-separated list of states can be passed") private String state; @Parameter(name = ApiConstants.FOR_VIRTUAL_NETWORK, type = CommandType.BOOLEAN, description = "the virtual network for the IP address") 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 fa6e3ea5d45..d68e4a9296e 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 @@ -24,7 +24,7 @@ import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.BackupScheduleResponse; @@ -39,7 +39,6 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -import com.cloud.utils.exception.CloudRuntimeException; import java.util.ArrayList; import java.util.List; @@ -48,10 +47,10 @@ import java.util.List; description = "List backup schedule of a VM", responseObject = BackupScheduleResponse.class, since = "4.14.0", authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User}) -public class ListBackupScheduleCmd extends BaseCmd { +public class ListBackupScheduleCmd extends BaseListProjectAndAccountResourcesCmd { @Inject - private BackupManager backupManager; + BackupManager backupManager; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -60,10 +59,16 @@ public class ListBackupScheduleCmd extends BaseCmd { @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, - required = true, description = "ID of the VM") private Long vmId; + @Parameter(name = ApiConstants.ID, + type = CommandType.UUID, + entityType = BackupScheduleResponse.class, + description = "the ID of the backup schedule", + since = "4.22.0") + private Long id; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -72,6 +77,10 @@ public class ListBackupScheduleCmd extends BaseCmd { return vmId; } + public Long getId() { + return id; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -79,19 +88,18 @@ public class ListBackupScheduleCmd extends BaseCmd { @Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { try{ - List schedules = backupManager.listBackupSchedule(getVmId()); + List schedules = backupManager.listBackupSchedules(this); ListResponse response = new ListResponse<>(); List scheduleResponses = new ArrayList<>(); + if (!CollectionUtils.isNullOrEmpty(schedules)) { for (BackupSchedule schedule : schedules) { scheduleResponses.add(_responseGenerator.createBackupScheduleResponse(schedule)); } - response.setResponses(scheduleResponses, schedules.size()); - response.setResponseName(getCommandName()); - setResponseObject(response); - } else { - throw new CloudRuntimeException("No backup schedule exists for the VM"); } + response.setResponses(scheduleResponses, schedules.size()); + response.setResponseName(getCommandName()); + setResponseObject(response); } catch (Exception e) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/iso/GetUploadParamsForIsoCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/iso/GetUploadParamsForIsoCmd.java index 01a47f22b72..d52e53d3bb4 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/iso/GetUploadParamsForIsoCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/iso/GetUploadParamsForIsoCmd.java @@ -104,6 +104,29 @@ public class GetUploadParamsForIsoCmd extends AbstractGetUploadParamsCmd { return osTypeId; } + public void setBootable(Boolean bootable) { + this.bootable = bootable; + } + + public void setDisplayText(String displayText) { + this.displayText = displayText; + } + + public void setFeatured(Boolean featured) { + this.featured = featured; + } + + public void setPublicIso(Boolean publicIso) { + this.publicIso = publicIso; + } + + public void setExtractable(Boolean extractable) { + this.extractable = extractable; + } + + public void setOsTypeId(Long osTypeId) { + this.osTypeId = osTypeId; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java index 6f220c774b8..95c7f5fe309 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java @@ -1,4 +1,4 @@ -// Licensedname = "listIsoPermissions", to the Apache Software Foundation (ASF) under one +// 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 diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java index fdd98fc3a0a..8609c87d8f1 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java @@ -63,7 +63,7 @@ public class UpdateLBHealthCheckPolicyCmd extends BaseAsyncCustomIdCmd{ @Override public String getEventDescription() { - return "Update load balancer health check policy ID= " + id; + return "Update load balancer health check policy ID = " + id; } @Override diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java index b2137cf262d..21c18d584ab 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java @@ -62,7 +62,7 @@ public class UpdateLBStickinessPolicyCmd extends BaseAsyncCustomIdCmd{ @Override public String getEventDescription() { - return "Update load balancer stickiness policy ID= " + id; + return "Update load balancer stickiness policy ID = " + id; } @Override diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java index 0e8425b14b4..0eb5ddc5ebe 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java @@ -53,6 +53,9 @@ public class ListNetworksCmd extends BaseListRetrieveOnlyResourceCountCmd implem @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list networks by ID") private Long id; + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list networks by name", since = "4.22.0") + private String name; + @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the zone ID of the network") private Long zoneId; @@ -125,6 +128,10 @@ public class ListNetworksCmd extends BaseListRetrieveOnlyResourceCountCmd implem return id; } + public String getName() { + return name; + } + public Long getZoneId() { return zoneId; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java index 126a4080e6d..f4dfbe58cf2 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java @@ -23,7 +23,7 @@ import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.BaseListCmd; +import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.SnapshotPolicyResponse; @@ -34,7 +34,7 @@ import com.cloud.utils.Pair; @APICommand(name = "listSnapshotPolicies", description = "Lists snapshot policies.", responseObject = SnapshotPolicyResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) -public class ListSnapshotPoliciesCmd extends BaseListCmd { +public class ListSnapshotPoliciesCmd extends BaseListProjectAndAccountResourcesCmd { ///////////////////////////////////////////////////// @@ -69,13 +69,14 @@ public class ListSnapshotPoliciesCmd extends BaseListCmd { public Long getId() { return id; } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @Override public void execute() { - Pair, Integer> result = _snapshotService.listPoliciesforVolume(this); + Pair, Integer> result = _snapshotService.listSnapshotPolicies(this); ListResponse response = new ListResponse(); List policyResponses = new ArrayList(); for (SnapshotPolicy policy : result.first()) { diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java index 6d544df4187..408f916abda 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java @@ -1,4 +1,4 @@ -// Licensedname = "listTemplatePermissions", to the Apache Software Foundation (ASF) under one +// 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 diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java index 59ba7e94b04..781edff52e3 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java @@ -28,7 +28,6 @@ import org.apache.cloudstack.api.response.ProjectResponse; import org.apache.cloudstack.api.response.VpnUsersResponse; import org.apache.cloudstack.context.CallContext; -import com.cloud.domain.Domain; import com.cloud.event.EventTypes; import com.cloud.network.VpnUser; import com.cloud.user.Account; @@ -110,7 +109,6 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd { @Override public void execute() { VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId()); - Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId()); try { if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user"); @@ -118,24 +116,10 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd { } catch (Exception ex) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } - - VpnUsersResponse vpnResponse = new VpnUsersResponse(); - vpnResponse.setId(vpnUser.getUuid()); - vpnResponse.setUserName(vpnUser.getUsername()); - vpnResponse.setAccountName(account.getAccountName()); // re-retrieve the vpnuser, as the call to `applyVpnUsers` might have changed the state vpnUser = _entityMgr.findById(VpnUser.class, getEntityId()); - vpnResponse.setState(vpnUser.getState().toString()); - - Domain domain = _entityMgr.findById(Domain.class, account.getDomainId()); - if (domain != null) { - vpnResponse.setDomainId(domain.getUuid()); - vpnResponse.setDomainName(domain.getName()); - vpnResponse.setDomainPath(domain.getPath()); - } - + VpnUsersResponse vpnResponse = _responseGenerator.createVpnUserResponse(vpnUser); vpnResponse.setResponseName(getCommandName()); - vpnResponse.setObjectName("vpnuser"); setResponseObject(vpnResponse); } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnConnectionCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnConnectionCmd.java index 62dd6167b75..efa809a2d78 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnConnectionCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnConnectionCmd.java @@ -66,7 +66,7 @@ public class UpdateVpnConnectionCmd extends BaseAsyncCustomIdCmd { @Override public String getEventDescription() { - return "Updating site-to-site VPN connection id= " + id; + return "Updating site-to-site VPN connection ID = " + id; } @Override diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java index 9fe5ae0480f..e614920d8de 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java @@ -63,7 +63,7 @@ public class UpdateVpnGatewayCmd extends BaseAsyncCustomIdCmd { @Override public String getEventDescription() { - return "Update site-to-site VPN gateway id= " + id; + return "Update site-to-site VPN gateway ID = " + id; } @Override diff --git a/api/src/main/java/org/apache/cloudstack/api/response/BackupOfferingResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/BackupOfferingResponse.java index 0e895fa4e96..4120f68d9da 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/BackupOfferingResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/BackupOfferingResponse.java @@ -61,6 +61,10 @@ public class BackupOfferingResponse extends BaseResponse { @Param(description = "zone name") private String zoneName; + @SerializedName(ApiConstants.CROSS_ZONE_INSTANCE_CREATION) + @Param(description = "the backups with this offering can be used to create Instances on all Zones", since = "4.22.0") + private Boolean crossZoneInstanceCreation; + @SerializedName(ApiConstants.CREATED) @Param(description = "the date this backup offering was created") private Date created; @@ -97,6 +101,10 @@ public class BackupOfferingResponse extends BaseResponse { this.zoneName = zoneName; } + public void setCrossZoneInstanceCreation(Boolean crossZoneInstanceCreation) { + this.crossZoneInstanceCreation = crossZoneInstanceCreation; + } + public void setCreated(Date created) { this.created = created; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/BackupResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/BackupResponse.java index 0ae558ac803..b9eca67d9a8 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/BackupResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/BackupResponse.java @@ -123,6 +123,10 @@ public class BackupResponse extends BaseResponse { @Param(description = "The backup offering corresponding to this backup was removed from the VM", since = "4.21.0") private Boolean vmOfferingRemoved; + @SerializedName(ApiConstants.IS_BACKUP_VM_EXPUNGED) + @Param(description = "Indicates whether the VM from which the backup was taken is expunged or not", since = "4.22.0") + private Boolean isVmExpunged; + public String getId() { return id; } @@ -306,4 +310,8 @@ public class BackupResponse extends BaseResponse { public void setVmOfferingRemoved(Boolean vmOfferingRemoved) { this.vmOfferingRemoved = vmOfferingRemoved; } + + public void setVmExpunged(Boolean isVmExpunged) { + this.isVmExpunged = isVmExpunged; + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/GetUploadParamsResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/GetUploadParamsResponse.java index b9be06ecc8f..00f7e7740c2 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/GetUploadParamsResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/GetUploadParamsResponse.java @@ -62,6 +62,10 @@ public class GetUploadParamsResponse extends BaseResponse { setObjectName("getuploadparams"); } + public UUID getId() { + return id; + } + public void setId(UUID id) { this.id = id; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ImportVMTaskResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ImportVMTaskResponse.java new file mode 100644 index 00000000000..aa85554f567 --- /dev/null +++ b/api/src/main/java/org/apache/cloudstack/api/response/ImportVMTaskResponse.java @@ -0,0 +1,257 @@ +// +// 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 java.util.Date; + +public class ImportVMTaskResponse extends BaseResponse { + + @SerializedName(ApiConstants.ID) + @Param(description = "the ID of importing task") + private String id; + + @SerializedName(ApiConstants.ZONE_ID) + @Param(description = "the Zone ID") + private String zoneId; + + @SerializedName(ApiConstants.ZONE_NAME) + @Param(description = "the Zone name") + private String zoneName; + + @SerializedName(ApiConstants.ACCOUNT) + @Param(description = "the account name") + private String accountName; + + @SerializedName(ApiConstants.ACCOUNT_ID) + @Param(description = "the ID of account") + private String accountId; + + @SerializedName(ApiConstants.VIRTUAL_MACHINE_ID) + @Param(description = "the ID of the imported VM (after task is completed)") + private String virtualMachineId; + + @SerializedName(ApiConstants.DISPLAY_NAME) + @Param(description = "the display name of the importing VM") + private String displayName; + + @SerializedName(ApiConstants.STATE) + @Param(description = "the state of the importing VM task") + private String state; + + @SerializedName(ApiConstants.VCENTER) + @Param(description = "the vcenter name of the importing VM task") + private String vcenter; + + @SerializedName(ApiConstants.DATACENTER_NAME) + @Param(description = "the datacenter name of the importing VM task") + private String datacenterName; + + @SerializedName("sourcevmname") + @Param(description = "the source VM name") + private String sourceVMName; + + @SerializedName("step") + @Param(description = "the current step on the importing VM task") + private String step; + + @SerializedName("stepduration") + @Param(description = "the duration of the current step") + private String stepDuration; + + @SerializedName(ApiConstants.DURATION) + @Param(description = "the total task duration") + private String duration; + + @SerializedName(ApiConstants.DESCRIPTION) + @Param(description = "the current step description on the importing VM task") + private String description; + + @SerializedName(ApiConstants.CONVERT_INSTANCE_HOST_ID) + @Param(description = "the ID of the host on which the instance is being converted") + private String convertInstanceHostId; + + @SerializedName("convertinstancehostname") + @Param(description = "the name of the host on which the instance is being converted") + private String convertInstanceHostName; + + @SerializedName(ApiConstants.CREATED) + @Param(description = "the create date of the importing task") + private Date created; + + @SerializedName(ApiConstants.LAST_UPDATED) + @Param(description = "the last updated date of the importing task") + private Date lastUpdated; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getZoneId() { + return zoneId; + } + + public void setZoneId(String zoneId) { + this.zoneId = zoneId; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getVirtualMachineId() { + return virtualMachineId; + } + + public void setVirtualMachineId(String virtualMachineId) { + this.virtualMachineId = virtualMachineId; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getVcenter() { + return vcenter; + } + + public void setVcenter(String vcenter) { + this.vcenter = vcenter; + } + + public String getDatacenterName() { + return datacenterName; + } + + public void setDatacenterName(String datacenterName) { + this.datacenterName = datacenterName; + } + + public String getSourceVMName() { + return sourceVMName; + } + + public void setSourceVMName(String sourceVMName) { + this.sourceVMName = sourceVMName; + } + + public String getStep() { + return step; + } + + public void setStep(String step) { + this.step = step; + } + + public String getStepDuration() { + return stepDuration; + } + + public void setStepDuration(String stepDuration) { + this.stepDuration = stepDuration; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getConvertInstanceHostId() { + return convertInstanceHostId; + } + + public void setConvertInstanceHostId(String convertInstanceHostId) { + this.convertInstanceHostId = convertInstanceHostId; + } + + public String getConvertInstanceHostName() { + return convertInstanceHostName; + } + + public void setConvertInstanceHostName(String convertInstanceHostName) { + this.convertInstanceHostName = convertInstanceHostName; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(Date lastUpdated) { + this.lastUpdated = lastUpdated; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } +} diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ServiceOfferingResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ServiceOfferingResponse.java index 4565a878b34..69f80b54010 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/ServiceOfferingResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/ServiceOfferingResponse.java @@ -197,7 +197,7 @@ public class ServiceOfferingResponse extends BaseResponseWithAnnotations { private Boolean isCustomized; @SerializedName("cacheMode") - @Param(description = "the cache mode to use for this disk offering. none, writeback or writethrough", since = "4.14") + @Param(description = "the cache mode to use for this disk offering. none, writeback, writethrough or hypervisor default", since = "4.14") private String cacheMode; @SerializedName("vspherestoragepolicy") diff --git a/api/src/main/java/org/apache/cloudstack/api/response/SnapshotPolicyResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/SnapshotPolicyResponse.java index 4ce77cfdf6e..998d6af871d 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/SnapshotPolicyResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/SnapshotPolicyResponse.java @@ -37,6 +37,10 @@ public class SnapshotPolicyResponse extends BaseResponseWithTagInformation { @Param(description = "the ID of the disk volume") private String volumeId; + @SerializedName("volumename") + @Param(description = "the name of the disk volume") + private String volumeName; + @SerializedName("schedule") @Param(description = "time the snapshot is scheduled to be taken.") private String schedule; @@ -87,6 +91,10 @@ public class SnapshotPolicyResponse extends BaseResponseWithTagInformation { this.volumeId = volumeId; } + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + public String getSchedule() { return schedule; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/SslCertResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/SslCertResponse.java index aa729f123b4..f7022cecb70 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/SslCertResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/SslCertResponse.java @@ -27,8 +27,6 @@ import org.apache.cloudstack.api.EntityReference; import org.apache.cloudstack.network.tls.SslCert; import com.cloud.serializer.Param; -//import org.apache.cloudstack.api.EntityReference; - @EntityReference(value = SslCert.class) public class SslCertResponse extends BaseResponse { diff --git a/api/src/main/java/org/apache/cloudstack/api/response/TrafficTypeResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/TrafficTypeResponse.java index 9a79b072465..281ed6736ee 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/TrafficTypeResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/TrafficTypeResponse.java @@ -56,6 +56,14 @@ public class TrafficTypeResponse extends BaseResponse { @Param(description = "The network name label of the physical device dedicated to this traffic on a HyperV host") private String hypervNetworkLabel; + @SerializedName(ApiConstants.VLAN) + @Param(description = "The VLAN id to be used for Management traffic by VMware host") + private String vlan; + + @SerializedName(ApiConstants.ISOLATION_METHODS) + @Param(description = "isolation methods for the physical network traffic") + private String isolationMethods; + @SerializedName(ApiConstants.OVM3_NETWORK_LABEL) @Param(description = "The network name of the physical device dedicated to this traffic on an OVM3 host") private String ovm3NetworkLabel; @@ -128,4 +136,20 @@ public class TrafficTypeResponse extends BaseResponse { public void setOvm3Label(String ovm3Label) { this.ovm3NetworkLabel = ovm3Label; } + + public String getIsolationMethods() { + return isolationMethods; + } + + public void setIsolationMethods(String isolationMethods) { + this.isolationMethods = isolationMethods; + } + + public String getVlan() { + return vlan; + } + + public void setVlan(String vlan) { + this.vlan = vlan; + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UpgradeRouterTemplateResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UpgradeRouterTemplateResponse.java index d89631ae428..dbe990c6dbd 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/UpgradeRouterTemplateResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/UpgradeRouterTemplateResponse.java @@ -16,27 +16,10 @@ // under the License. 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 org.apache.cloudstack.api.EntityReference; import org.apache.cloudstack.jobs.JobInfo; -import com.cloud.serializer.Param; - @EntityReference(value = JobInfo.class) -@SuppressWarnings("unused") public class UpgradeRouterTemplateResponse extends BaseResponse { - @SerializedName(ApiConstants.JOB_ID) - @Param(description = "the id of AsyncJob") - private String asyncJobId; - - public String getAsyncJobId() { - return asyncJobId; - } - - public void setAsyncJobId(String asyncJobId) { - this.asyncJobId = asyncJobId; - } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java index ca5bd09a9aa..29681b5e38f 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java @@ -41,7 +41,7 @@ import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") @EntityReference(value = {VirtualMachine.class, UserVm.class, VirtualRouter.class}) -public class UserVmResponse extends BaseResponseWithTagInformation implements ControlledEntityResponse, SetResourceIconResponse { +public class UserVmResponse extends BaseResponseWithTagInformation implements ControlledViewEntityResponse, SetResourceIconResponse { @SerializedName(ApiConstants.ID) @Param(description = "the ID of the virtual machine") private String id; diff --git a/api/src/main/java/org/apache/cloudstack/backup/BackupManager.java b/api/src/main/java/org/apache/cloudstack/backup/BackupManager.java index f1f0c3c31ee..db051313d96 100644 --- a/api/src/main/java/org/apache/cloudstack/backup/BackupManager.java +++ b/api/src/main/java/org/apache/cloudstack/backup/BackupManager.java @@ -28,6 +28,7 @@ import org.apache.cloudstack.api.command.user.backup.CreateBackupCmd; import org.apache.cloudstack.api.command.user.backup.CreateBackupScheduleCmd; import org.apache.cloudstack.api.command.user.backup.DeleteBackupScheduleCmd; import org.apache.cloudstack.api.command.user.backup.ListBackupOfferingsCmd; +import org.apache.cloudstack.api.command.user.backup.ListBackupScheduleCmd; import org.apache.cloudstack.api.command.user.backup.ListBackupsCmd; import org.apache.cloudstack.api.response.BackupResponse; import org.apache.cloudstack.framework.config.ConfigKey; @@ -174,7 +175,7 @@ public interface BackupManager extends BackupService, Configurable, PluggableSer * @param vmId * @return */ - List listBackupSchedule(Long vmId); + List listBackupSchedules(ListBackupScheduleCmd cmd); /** * Deletes VM backup schedule for a VM diff --git a/api/src/main/java/org/apache/cloudstack/backup/BackupProvider.java b/api/src/main/java/org/apache/cloudstack/backup/BackupProvider.java index 32a714370df..23b8092425d 100644 --- a/api/src/main/java/org/apache/cloudstack/backup/BackupProvider.java +++ b/api/src/main/java/org/apache/cloudstack/backup/BackupProvider.java @@ -124,6 +124,10 @@ public interface BackupProvider { */ boolean supportsInstanceFromBackup(); + default boolean supportsMemoryVmSnapshot() { + return true; + } + /** * Returns the backup storage usage (Used, Total) for a backup provider * @param zoneId the zone for which to return metrics diff --git a/api/src/main/java/org/apache/cloudstack/backup/BackupSchedule.java b/api/src/main/java/org/apache/cloudstack/backup/BackupSchedule.java index b5138d34de1..44fdf70c4c1 100644 --- a/api/src/main/java/org/apache/cloudstack/backup/BackupSchedule.java +++ b/api/src/main/java/org/apache/cloudstack/backup/BackupSchedule.java @@ -19,11 +19,12 @@ package org.apache.cloudstack.backup; import java.util.Date; +import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.api.InternalIdentity; import com.cloud.utils.DateUtil; -public interface BackupSchedule extends InternalIdentity { +public interface BackupSchedule extends ControlledEntity, InternalIdentity { Long getVmId(); DateUtil.IntervalType getScheduleType(); String getSchedule(); diff --git a/api/src/main/java/org/apache/cloudstack/backup/BackupService.java b/api/src/main/java/org/apache/cloudstack/backup/BackupService.java index d4beb629fe0..3ba2978c0fa 100644 --- a/api/src/main/java/org/apache/cloudstack/backup/BackupService.java +++ b/api/src/main/java/org/apache/cloudstack/backup/BackupService.java @@ -34,4 +34,11 @@ public interface BackupService { * @return backup provider */ BackupProvider getBackupProvider(final Long zoneId); + + /** + * Find backup provider by name + * @param name backup provider name + * @return backup provider + */ + BackupProvider getBackupProvider(final String name); } diff --git a/api/src/main/java/org/apache/cloudstack/vm/ImportVmTask.java b/api/src/main/java/org/apache/cloudstack/vm/ImportVmTask.java new file mode 100644 index 00000000000..5bb51dfcbcb --- /dev/null +++ b/api/src/main/java/org/apache/cloudstack/vm/ImportVmTask.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.vm; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +public interface ImportVmTask extends Identity, InternalIdentity { + enum Step { + Prepare, CloningInstance, ConvertingInstance, Importing, Completed + } + + enum TaskState { + Running, Completed, Failed; + + public static TaskState getValue(String state) { + for (TaskState s : TaskState.values()) { + if (s.name().equalsIgnoreCase(state)) { + return s; + } + } + throw new IllegalArgumentException("Invalid task state: " + state); + } + } +} diff --git a/api/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManager.java b/api/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManager.java new file mode 100644 index 00000000000..233511fbce8 --- /dev/null +++ b/api/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManager.java @@ -0,0 +1,38 @@ +// 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.vm; + +import com.cloud.dc.DataCenter; +import com.cloud.host.Host; +import com.cloud.user.Account; +import org.apache.cloudstack.api.command.admin.vm.ListImportVMTasksCmd; +import org.apache.cloudstack.api.response.ImportVMTaskResponse; +import org.apache.cloudstack.api.response.ListResponse; + +public interface ImportVmTasksManager { + + ListResponse listImportVMTasks(ListImportVMTasksCmd cmd); + + ImportVmTask createImportVMTaskRecord(DataCenter zone, Account owner, long userId, String displayName, + String vcenter, String datacenterName, String sourceVMName, + Host convertHost, Host importHost); + + void updateImportVMTaskStep(ImportVmTask importVMTaskVO, DataCenter zone, Account owner, Host convertHost, + Host importHost, Long vmId, ImportVmTask.Step step); + + void updateImportVMTaskErrorState(ImportVmTask importVMTaskVO, ImportVmTask.TaskState state, String errorMsg); +} diff --git a/api/src/test/java/com/cloud/network/NetworksTest.java b/api/src/test/java/com/cloud/network/NetworksTest.java index ef582924342..6f0f3fbd1ef 100644 --- a/api/src/test/java/com/cloud/network/NetworksTest.java +++ b/api/src/test/java/com/cloud/network/NetworksTest.java @@ -37,6 +37,24 @@ public class NetworksTest { public void setUp() { } + @Test + public void nullBroadcastDomainTypeTest() throws URISyntaxException { + BroadcastDomainType type = BroadcastDomainType.getTypeOf(null); + Assert.assertEquals("a null uri should mean a broadcasttype of undecided", BroadcastDomainType.UnDecided, type); + } + + @Test + public void nullBroadcastDomainTypeValueTest() { + URI uri = null; + Assert.assertNull(BroadcastDomainType.getValue(uri)); + } + + @Test + public void nullBroadcastDomainTypeStringValueTest() throws URISyntaxException { + String uriString = null; + Assert.assertNull(BroadcastDomainType.getValue(uriString)); + } + @Test public void emptyBroadcastDomainTypeTest() throws URISyntaxException { BroadcastDomainType type = BroadcastDomainType.getTypeOf(""); diff --git a/api/src/test/java/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java index 3ed1d9389d4..b76041755f5 100644 --- a/api/src/test/java/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java +++ b/api/src/test/java/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java @@ -78,10 +78,6 @@ public class ScaleVMCmdTest extends TestCase { scaleVMCmd._responseGenerator = responseGenerator; UserVmResponse userVmResponse = Mockito.mock(UserVmResponse.class); - //List list = Mockito.mock(UserVmResponse.class); - //list.add(userVmResponse); - //LinkedList mockedList = Mockito.mock(LinkedList.class); - //Mockito.when(mockedList.get(0)).thenReturn(userVmResponse); List list = new LinkedList(); list.add(userVmResponse); diff --git a/api/src/test/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmdTest.java new file mode 100644 index 00000000000..a0d88bbc84e --- /dev/null +++ b/api/src/test/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmdTest.java @@ -0,0 +1,98 @@ +// 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.user.backup; + +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.NetworkRuleConflictException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.user.Account; +import org.apache.cloudstack.api.ResponseGenerator; +import org.apache.cloudstack.api.response.BackupScheduleResponse; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.backup.BackupManager; +import org.apache.cloudstack.backup.BackupSchedule; +import org.apache.cloudstack.context.CallContext; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +import java.util.ArrayList; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class ListBackupScheduleCmdTest { + + @Mock + private BackupManager backupManager; + + @Mock + private ResponseGenerator responseGenerator; + + private ListBackupScheduleCmd cmd; + + @Before + public void setUp() { + cmd = new ListBackupScheduleCmd(); + cmd.backupManager = backupManager; + cmd._responseGenerator = responseGenerator; + } + + @Test + public void testExecuteWithSchedules() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException, NetworkRuleConflictException { + BackupSchedule schedule = Mockito.mock(BackupSchedule.class); + BackupScheduleResponse scheduleResponse = Mockito.mock(BackupScheduleResponse.class); + List schedules = new ArrayList<>(); + schedules.add(schedule); + + Mockito.when(backupManager.listBackupSchedules(cmd)).thenReturn(schedules); + Mockito.when(responseGenerator.createBackupScheduleResponse(schedule)).thenReturn(scheduleResponse); + + Account mockAccount = Mockito.mock(Account.class); + CallContext callContext = Mockito.mock(CallContext.class); + try (org.mockito.MockedStatic mocked = Mockito.mockStatic(CallContext.class)) { + cmd.execute(); + } + + ListResponse response = (ListResponse) cmd.getResponseObject(); + Assert.assertNotNull(response); + Assert.assertEquals(1, response.getResponses().size()); + Assert.assertEquals(scheduleResponse, response.getResponses().get(0)); + } + + @Test + public void testExecuteWithNoSchedules() { + Mockito.when(backupManager.listBackupSchedules(cmd)).thenReturn(new ArrayList<>()); + CallContext callContext = Mockito.mock(CallContext.class); + + try (org.mockito.MockedStatic mocked = Mockito.mockStatic(CallContext.class)) { + mocked.when(CallContext::current).thenReturn(callContext); + cmd.execute(); + } catch (ResourceUnavailableException | InsufficientCapacityException | ResourceAllocationException | + NetworkRuleConflictException e) { + throw new RuntimeException(e); + } + + ListResponse response = (ListResponse) cmd.getResponseObject(); + Assert.assertNotNull(response); + Assert.assertEquals(0, response.getResponses().size()); + } +} diff --git a/api/src/test/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmdTest.java new file mode 100644 index 00000000000..36cfcf5cb9a --- /dev/null +++ b/api/src/test/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmdTest.java @@ -0,0 +1,79 @@ +// 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.user.snapshot; + +import com.cloud.storage.snapshot.SnapshotApiService; +import com.cloud.storage.snapshot.SnapshotPolicy; +import com.cloud.utils.Pair; +import org.apache.cloudstack.api.ResponseGenerator; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.SnapshotPolicyResponse; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import java.util.ArrayList; +import java.util.List; + +public class ListSnapshotPoliciesCmdTest { + private ListSnapshotPoliciesCmd cmd; + private SnapshotApiService snapshotService; + private ResponseGenerator responseGenerator; + + @Before + public void setUp() { + cmd = new ListSnapshotPoliciesCmd(); + snapshotService = Mockito.mock(SnapshotApiService.class); + responseGenerator = Mockito.mock(ResponseGenerator.class); + + cmd._snapshotService = snapshotService; + cmd._responseGenerator = responseGenerator; + } + + @Test + public void testExecuteWithPolicies() { + SnapshotPolicy policy = Mockito.mock(SnapshotPolicy.class); + SnapshotPolicyResponse policyResponse = Mockito.mock(SnapshotPolicyResponse.class); + List policies = new ArrayList<>(); + policies.add(policy); + + Mockito.when(snapshotService.listSnapshotPolicies(cmd)) + .thenReturn(new Pair<>(policies, 1)); + Mockito.when(responseGenerator.createSnapshotPolicyResponse(policy)) + .thenReturn(policyResponse); + + cmd.execute(); + + ListResponse response = (ListResponse) cmd.getResponseObject(); + Assert.assertNotNull(response); + Assert.assertEquals(1, response.getResponses().size()); + Assert.assertEquals(policyResponse, response.getResponses().get(0)); + } + + @Test + public void testExecuteWithNoPolicies() { + Mockito.when(snapshotService.listSnapshotPolicies(cmd)) + .thenReturn(new Pair<>(new ArrayList<>(), 0)); + + cmd.execute(); + + ListResponse response = (ListResponse) cmd.getResponseObject(); + Assert.assertNotNull(response); + Assert.assertTrue(response.getResponses().isEmpty()); + } +} diff --git a/client/pom.xml b/client/pom.xml index 605487404a8..d8fa433d5be 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/core/pom.xml b/core/pom.xml index e4cd84357d1..f91a330b7ba 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java b/core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java index f938d0ac55d..24336747ccf 100644 --- a/core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java +++ b/core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java @@ -23,30 +23,37 @@ import com.cloud.hypervisor.Hypervisor; public class ConvertInstanceCommand extends Command { private RemoteInstanceTO sourceInstance; + private String originalVMName; private Hypervisor.HypervisorType destinationHypervisorType; private DataStoreTO conversionTemporaryLocation; private String templateDirOnConversionLocation; private boolean checkConversionSupport; private boolean exportOvfToConversionLocation; private int threadsCountToExportOvf = 0; + private String extraParams; public ConvertInstanceCommand() { } public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType, DataStoreTO conversionTemporaryLocation, - String templateDirOnConversionLocation, boolean checkConversionSupport, boolean exportOvfToConversionLocation) { + String templateDirOnConversionLocation, boolean checkConversionSupport, boolean exportOvfToConversionLocation, String sourceVMName) { this.sourceInstance = sourceInstance; this.destinationHypervisorType = destinationHypervisorType; this.conversionTemporaryLocation = conversionTemporaryLocation; this.templateDirOnConversionLocation = templateDirOnConversionLocation; this.checkConversionSupport = checkConversionSupport; this.exportOvfToConversionLocation = exportOvfToConversionLocation; + this.originalVMName = sourceVMName; } public RemoteInstanceTO getSourceInstance() { return sourceInstance; } + public String getOriginalVMName() { + return originalVMName; + } + public Hypervisor.HypervisorType getDestinationHypervisorType() { return destinationHypervisorType; } @@ -75,6 +82,14 @@ public class ConvertInstanceCommand extends Command { this.threadsCountToExportOvf = threadsCountToExportOvf; } + public String getExtraParams() { + return extraParams; + } + + public void setExtraParams(String extraParams) { + this.extraParams = extraParams; + } + @Override public boolean executeInSequence() { return false; diff --git a/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java b/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java index 9d50e852ced..eadfa6556f8 100644 --- a/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java +++ b/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java @@ -27,17 +27,20 @@ public class ImportConvertedInstanceCommand extends Command { private List destinationStoragePools; private DataStoreTO conversionTemporaryLocation; private String temporaryConvertUuid; + private boolean forceConvertToPool; public ImportConvertedInstanceCommand() { } public ImportConvertedInstanceCommand(RemoteInstanceTO sourceInstance, List destinationStoragePools, - DataStoreTO conversionTemporaryLocation, String temporaryConvertUuid) { + DataStoreTO conversionTemporaryLocation, String temporaryConvertUuid, + boolean forceConvertToPool) { this.sourceInstance = sourceInstance; this.destinationStoragePools = destinationStoragePools; this.conversionTemporaryLocation = conversionTemporaryLocation; this.temporaryConvertUuid = temporaryConvertUuid; + this.forceConvertToPool = forceConvertToPool; } public RemoteInstanceTO getSourceInstance() { @@ -56,6 +59,10 @@ public class ImportConvertedInstanceCommand extends Command { return temporaryConvertUuid; } + public boolean isForceConvertToPool() { + return forceConvertToPool; + } + @Override public boolean executeInSequence() { return false; diff --git a/core/src/main/java/com/cloud/network/HAProxyConfigurator.java b/core/src/main/java/com/cloud/network/HAProxyConfigurator.java index 7736bea3cda..128652fc64f 100644 --- a/core/src/main/java/com/cloud/network/HAProxyConfigurator.java +++ b/core/src/main/java/com/cloud/network/HAProxyConfigurator.java @@ -629,9 +629,6 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator { } } result.addAll(gSection); - // TODO decide under what circumstances these options are needed - // result.add("\tnokqueue"); - // result.add("\tnopoll"); result.add(blankLine); final List dSection = Arrays.asList(defaultsSection); diff --git a/core/src/main/java/org/apache/cloudstack/backup/RestoreBackupCommand.java b/core/src/main/java/org/apache/cloudstack/backup/RestoreBackupCommand.java index 9cbb87da19a..8e68f4f1e41 100644 --- a/core/src/main/java/org/apache/cloudstack/backup/RestoreBackupCommand.java +++ b/core/src/main/java/org/apache/cloudstack/backup/RestoreBackupCommand.java @@ -149,7 +149,7 @@ public class RestoreBackupCommand extends Command { } public Integer getMountTimeout() { - return this.mountTimeout; + return this.mountTimeout == null ? 0 : this.mountTimeout; } public void setMountTimeout(Integer mountTimeout) { diff --git a/core/src/main/java/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/core/src/main/java/org/apache/cloudstack/storage/to/VolumeObjectTO.java index 92f9ee497a4..827403ac5ef 100644 --- a/core/src/main/java/org/apache/cloudstack/storage/to/VolumeObjectTO.java +++ b/core/src/main/java/org/apache/cloudstack/storage/to/VolumeObjectTO.java @@ -116,8 +116,8 @@ public class VolumeObjectTO extends DownloadableObjectTO implements DataTO { iopsWriteRate = volume.getIopsWriteRate(); iopsWriteRateMax = volume.getIopsWriteRateMax(); iopsWriteRateMaxLength = volume.getIopsWriteRateMaxLength(); - cacheMode = volume.getCacheMode(); hypervisorType = volume.getHypervisorType(); + setCacheMode(volume.getCacheMode()); setDeviceId(volume.getDeviceId()); this.migrationOptions = volume.getMigrationOptions(); this.directDownload = volume.isDirectDownload(); @@ -343,6 +343,10 @@ public class VolumeObjectTO extends DownloadableObjectTO implements DataTO { } public void setCacheMode(DiskCacheMode cacheMode) { + if (DiskCacheMode.HYPERVISOR_DEFAULT.equals(cacheMode) && !Hypervisor.HypervisorType.KVM.equals(hypervisorType)) { + this.cacheMode = DiskCacheMode.NONE; + return; + } this.cacheMode = cacheMode; } diff --git a/core/src/test/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/src/test/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java index 201242564ba..4196587cc3f 100644 --- a/core/src/test/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java +++ b/core/src/test/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java @@ -417,8 +417,6 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer { // FIXME Check the json content assertEquals(VRScripts.UPDATE_CONFIG, script); assertEquals(VRScripts.NETWORK_ACL_CONFIG, args); - // assertEquals(args, " -d eth3 -M 01:23:45:67:89:AB -i 192.168.1.1 -m 24 -a Egress:ALL:0:0:192.168.0.1/24-192.168.0.2/24:ACCEPT:," + - // "Ingress:ICMP:0:0:192.168.0.1/24-192.168.0.2/24:DROP:,Ingress:TCP:20:80:192.168.0.1/24-192.168.0.2/24:ACCEPT:,"); break; case 2: assertEquals(VRScripts.UPDATE_CONFIG, script); @@ -464,8 +462,6 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer { private void verifyArgs(final SetupGuestNetworkCommand cmd, final String script, final String args) { // TODO Check the contents of the json file - //assertEquals(script, VRScripts.VPC_GUEST_NETWORK); - //assertEquals(args, " -C -M 01:23:45:67:89:AB -d eth4 -i 10.1.1.2 -g 10.1.1.1 -m 24 -n 10.1.1.0 -s 8.8.8.8,8.8.4.4 -e cloud.test"); } @Test diff --git a/debian/changelog b/debian/changelog index ace6697a09e..02251137e9d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,12 @@ -cloudstack (4.22.0.0-SNAPSHOT) unstable; urgency=low +cloudstack (4.23.0.0-SNAPSHOT) unstable; urgency=low - * Update the version to 4.22.0.0-SNAPSHOT + * Update the version to 4.23.0.0-SNAPSHOT + + -- the Apache CloudStack project Thu, 30 Oct 2025 19:23:55 +0530 + +cloudstack (4.23.0.0-SNAPSHOT-SNAPSHOT) unstable; urgency=low + + * Update the version to 4.23.0.0-SNAPSHOT-SNAPSHOT -- the Apache CloudStack project Thu, Aug 28 11:58:36 2025 +0530 diff --git a/debian/cloudstack-agent.install b/debian/cloudstack-agent.install index 58715e0746b..0b9e874cb42 100644 --- a/debian/cloudstack-agent.install +++ b/debian/cloudstack-agent.install @@ -16,6 +16,7 @@ # under the License. /etc/cloudstack/agent/agent.properties +/etc/cloudstack/agent/uefi.properties /etc/cloudstack/agent/environment.properties /etc/cloudstack/agent/log4j-cloud.xml /etc/default/cloudstack-agent diff --git a/debian/cloudstack-agent.postinst b/debian/cloudstack-agent.postinst index 758af6e068f..cd070c2f785 100755 --- a/debian/cloudstack-agent.postinst +++ b/debian/cloudstack-agent.postinst @@ -23,7 +23,7 @@ case "$1" in configure) OLDCONFDIR="/etc/cloud/agent" NEWCONFDIR="/etc/cloudstack/agent" - CONFFILES="agent.properties log4j.xml log4j-cloud.xml" + CONFFILES="agent.properties uefi.properties log4j.xml log4j-cloud.xml" mkdir -m 0755 -p /usr/share/cloudstack-agent/tmp diff --git a/debian/cloudstack-management.install b/debian/cloudstack-management.install index b2a32bd93c1..befc7049c30 100644 --- a/debian/cloudstack-management.install +++ b/debian/cloudstack-management.install @@ -24,6 +24,7 @@ /etc/cloudstack/management/config.json /etc/cloudstack/extensions/Proxmox/proxmox.sh /etc/cloudstack/extensions/HyperV/hyperv.py +/etc/cloudstack/extensions/MaaS/maas.py /etc/default/cloudstack-management /etc/security/limits.d/cloudstack-limits.conf /etc/sudoers.d/cloudstack diff --git a/debian/control b/debian/control index 1292639ef30..78842e38ed2 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, libvirt-daemon-driver-storage-rbd, sysstat +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, ovmf, swtpm, lsb-release, ufw, apparmor, cpu-checker, libvirt-daemon-driver-storage-rbd, sysstat 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 c11415e04fa..e2fd782fd25 100644 --- a/developer/pom.xml +++ b/developer/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/engine/api/pom.xml b/engine/api/pom.xml index 9dcdb8e8f52..cb50ef0cd46 100644 --- a/engine/api/pom.xml +++ b/engine/api/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java index ccb5bba1c0a..168822c21eb 100644 --- a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java +++ b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; import com.cloud.exception.ResourceAllocationException; +import com.cloud.storage.Storage; import com.cloud.utils.Pair; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; @@ -182,10 +183,10 @@ public interface VolumeOrchestrationService { */ DiskProfile importVolume(Type type, String name, DiskOffering offering, Long sizeInBytes, Long minIops, Long maxIops, Long zoneId, HypervisorType hypervisorType, VirtualMachine vm, VirtualMachineTemplate template, - Account owner, Long deviceId, Long poolId, String path, String chainInfo); + Account owner, Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo); DiskProfile updateImportedVolume(Type type, DiskOffering offering, VirtualMachine vm, VirtualMachineTemplate template, - Long deviceId, Long poolId, String path, String chainInfo, DiskProfile diskProfile); + Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo, DiskProfile diskProfile); /** * Unmanage VM volumes diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java index b0ed7d7d52b..68c7ed40d8f 100644 --- a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java +++ b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage; import com.cloud.storage.ScopeType; +import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; public class ClusterScope extends AbstractScope { private ScopeType type = ScopeType.CLUSTER; @@ -51,4 +52,9 @@ public class ClusterScope extends AbstractScope { return this.zoneId; } + @Override + public String toString() { + return String.format("ClusterScope %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields( + this, "zoneId", "clusterId", "podId")); + } } diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java index 6e0bc618bfe..7e6ffe7d4f7 100644 --- a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java +++ b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java @@ -19,8 +19,10 @@ package org.apache.cloudstack.engine.subsystem.api.storage; import com.cloud.storage.ScopeType; +import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; public class HostScope extends AbstractScope { + private ScopeType type = ScopeType.HOST; private Long hostId; private Long clusterId; private Long zoneId; @@ -34,7 +36,7 @@ public class HostScope extends AbstractScope { @Override public ScopeType getScopeType() { - return ScopeType.HOST; + return this.type; } @Override @@ -49,4 +51,10 @@ public class HostScope extends AbstractScope { public Long getZoneId() { return zoneId; } + + @Override + public String toString() { + return String.format("HostScope %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields( + this, "zoneId", "clusterId", "hostId")); + } } diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java index a0d75b5cc7c..fa704d05b1a 100644 --- a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java +++ b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage; import com.cloud.storage.ScopeType; +import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; public class ZoneScope extends AbstractScope { private ScopeType type = ScopeType.ZONE; @@ -39,4 +40,9 @@ public class ZoneScope extends AbstractScope { return this.zoneId; } + @Override + public String toString() { + return String.format("ZoneScope %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields( + this, "zoneId")); + } } diff --git a/engine/components-api/pom.xml b/engine/components-api/pom.xml index ed67de2e0d8..49d41d36f83 100644 --- a/engine/components-api/pom.xml +++ b/engine/components-api/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/engine/components-api/src/main/java/com/cloud/event/UsageEventUtils.java b/engine/components-api/src/main/java/com/cloud/event/UsageEventUtils.java index 94fbb7a80af..1c88c7df124 100644 --- a/engine/components-api/src/main/java/com/cloud/event/UsageEventUtils.java +++ b/engine/components-api/src/main/java/com/cloud/event/UsageEventUtils.java @@ -94,6 +94,14 @@ public class UsageEventUtils { } + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, + Long size, String entityType, String entityUUID, Long vmId, boolean displayResource) { + if (displayResource) { + saveUsageEvent(usageType, accountId, zoneId, resourceId, offeringId, templateId, size, vmId, resourceName); + } + publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); + } + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size, Long virtualSize, String entityType, String entityUUID, Map details) { saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size, virtualSize, details); @@ -202,6 +210,10 @@ public class UsageEventUtils { s_usageEventDao.persist(new UsageEventVO(usageType, accountId, zoneId, vmId, securityGroupId)); } + public static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, Long offeringId, Long templateId, Long size, Long vmId, String resourceName) { + s_usageEventDao.persist(new UsageEventVO(usageType, accountId, zoneId, resourceId, offeringId, templateId, size, vmId, resourceName)); + } + private static void publishUsageEvent(String usageEventType, Long accountId, Long zoneId, String resourceType, String resourceUUID) { String configKey = "publish.usage.events"; String value = s_configDao.getValue(configKey); 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 a87d3235489..77e97b00c1e 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 @@ -230,7 +230,7 @@ public interface StorageManager extends StorageService { /** * should we execute in sequence not involving any storages? - * @return tru if commands should execute in sequence + * @return true if commands should execute in sequence */ static boolean shouldExecuteInSequenceOnVmware() { return shouldExecuteInSequenceOnVmware(null, null); @@ -302,6 +302,8 @@ public interface StorageManager extends StorageService { Answer sendToPool(StoragePool pool, long[] hostIdsToTryFirst, Command cmd) throws StorageUnavailableException; + void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer); + CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId); CapacityVO getStoragePoolUsedStats(Long poolId, Long clusterId, Long podId, Long zoneId); diff --git a/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java b/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java index 28f41c677cb..f363deffc1f 100644 --- a/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java +++ b/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java @@ -57,6 +57,13 @@ public interface TemplateManager { + "will validate if the provided URL is resolvable during the register of templates/ISOs before persisting them in the database.", true); + ConfigKey TemplateDeleteFromPrimaryStorage = new ConfigKey("Advanced", + Boolean.class, + "template.delete.from.primary.storage", "true", + "Template when deleted will be instantly deleted from the Primary Storage", + true, + ConfigKey.Scope.Global); + static final String VMWARE_TOOLS_ISO = "vmware-tools.iso"; static final String XS_TOOLS_ISO = "xs-tools.iso"; @@ -104,6 +111,8 @@ public interface TemplateManager { */ List getUnusedTemplatesInPool(StoragePoolVO pool); + void evictTemplateFromStoragePoolsForZones(Long templateId, List zoneId); + /** * Deletes a template in the specified storage pool. * diff --git a/engine/components-api/src/main/java/com/cloud/vm/VmWorkSerializer.java b/engine/components-api/src/main/java/com/cloud/vm/VmWorkSerializer.java index bd6b52d261f..e4fdc0c4f37 100644 --- a/engine/components-api/src/main/java/com/cloud/vm/VmWorkSerializer.java +++ b/engine/components-api/src/main/java/com/cloud/vm/VmWorkSerializer.java @@ -61,7 +61,6 @@ public class VmWorkSerializer { // use java binary serialization instead // return JobSerializerHelper.toObjectSerializedString(work); - // return s_gson.toJson(work); } public static T deserialize(Class clazz, String workInJsonText) { @@ -69,6 +68,5 @@ public class VmWorkSerializer { // use java binary serialization instead // return (T)JobSerializerHelper.fromObjectSerializedString(workInJsonText); - // return (T)s_gson.fromJson(workInJsonText, clazz); } } 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 997b413c099..6478469f190 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 @@ -42,7 +42,7 @@ public interface VMSnapshotManager extends VMSnapshotService, Manager { boolean deleteAllVMSnapshots(long id, VMSnapshot.Type type); /** - * Sync VM snapshot state when VM snapshot in reverting or snapshoting or expunging state + * Sync VM snapshot state when VM snapshot in reverting or snapshotting or expunging state * Used for fullsync after agent connects * * @param vm, the VM in question diff --git a/engine/orchestration/pom.xml b/engine/orchestration/pom.xml index c5040b6382b..fda63d2558b 100755 --- a/engine/orchestration/pom.xml +++ b/engine/orchestration/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index 3d398ca5dd9..439bdf92ddd 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@ -1652,7 +1652,6 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl final String reason = shutdown.getReason(); logger.info("Host {} has informed us that it is shutting down with reason {} and detail {}", attache, reason, shutdown.getDetail()); if (reason.equals(ShutdownCommand.Update)) { - // disconnectWithoutInvestigation(attache, Event.UpdateNeeded); throw new CloudRuntimeException("Agent update not implemented"); } else if (reason.equals(ShutdownCommand.Requested)) { disconnectWithoutInvestigation(attache, Event.ShutdownRequested); @@ -1753,7 +1752,6 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl } } catch (final UnsupportedVersionException e) { logger.warn(e.getMessage()); - // upgradeAgent(task.getLink(), data, e.getReason()); } catch (final ClassNotFoundException e) { final String message = String.format("Exception occurred when executing tasks! Error '%s'", e.getMessage()); logger.error(message); diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index c6448982803..e80b0219f55 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -965,7 +965,6 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust synchronized (_agentToTransferIds) { if (!_agentToTransferIds.isEmpty()) { logger.debug("Found {} agents to transfer", _agentToTransferIds.size()); - // for (Long hostId : _agentToTransferIds) { for (final Iterator iterator = _agentToTransferIds.iterator(); iterator.hasNext(); ) { final Long hostId = iterator.next(); final AgentAttache attache = findAttache(hostId); diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index a8a92d6b3db..b3e672e2c17 100755 --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@ -2859,6 +2859,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } volume.setPath(result.getPath()); volume.setPoolId(pool.getId()); + volume.setPoolType(pool.getPoolType()); if (result.getChainInfo() != null) { volume.setChainInfo(result.getChainInfo()); } diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java index 2ad8d15d0b7..7f6571becc8 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java @@ -213,7 +213,6 @@ public class EngineHostDaoImpl extends GenericDaoBase implem SequenceSearch = createSearchBuilder(); SequenceSearch.and("id", SequenceSearch.entity().getId(), SearchCriteria.Op.EQ); - // SequenceSearch.addRetrieve("sequence", SequenceSearch.entity().getSequence()); SequenceSearch.done(); DirectlyConnectedSearch = createSearchBuilder(); diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 38cf6ed05be..ae07c4c7bc4 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -4799,6 +4799,18 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra } }); + if (selectedIp != null && GuestType.Shared.equals(network.getGuestType())) { + IPAddressVO ipAddressVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), selectedIp); + if (ipAddressVO != null && IpAddress.State.Free.equals(ipAddressVO.getState())) { + ipAddressVO.setState(IPAddressVO.State.Allocated); + ipAddressVO.setAllocatedTime(new Date()); + Account account = _accountDao.findById(vm.getAccountId()); + ipAddressVO.setAllocatedInDomainId(account.getDomainId()); + ipAddressVO.setAllocatedToAccountId(account.getId()); + _ipAddressDao.update(ipAddressVO.getId(), ipAddressVO); + } + } + final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId()); final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vm.getHypervisorType(), network)); @@ -4810,15 +4822,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (network.getGuestType() == GuestType.L2) { return null; } - return dataCenter.getNetworkType() == NetworkType.Basic ? - getSelectedIpForNicImportOnBasicZone(ipAddresses.getIp4Address(), network, dataCenter): + return GuestType.Shared.equals(network.getGuestType()) ? + getSelectedIpForNicImportOnSharedNetwork(ipAddresses.getIp4Address(), network, dataCenter): _ipAddrMgr.acquireGuestIpAddress(network, ipAddresses.getIp4Address()); } - protected String getSelectedIpForNicImportOnBasicZone(String requestedIp, Network network, DataCenter dataCenter) { + protected String getSelectedIpForNicImportOnSharedNetwork(String requestedIp, Network network, DataCenter dataCenter) { IPAddressVO ipAddressVO = StringUtils.isBlank(requestedIp) ? _ipAddressDao.findBySourceNetworkIdAndDatacenterIdAndState(network.getId(), dataCenter.getId(), IpAddress.State.Free): - _ipAddressDao.findByIp(requestedIp); + _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), requestedIp); if (ipAddressVO == null || ipAddressVO.getState() != IpAddress.State.Free) { String msg = String.format("Cannot find a free IP to assign to VM NIC on network %s", network.getName()); logger.error(msg); diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index 7af9b6b8492..281dd2a3cfe 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -903,7 +903,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati // Save usage event and update resource count for user vm volumes if (vm.getType() == VirtualMachine.Type.User) { UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), offering.getId(), null, size, - Volume.class.getName(), vol.getUuid(), vol.isDisplayVolume()); + Volume.class.getName(), vol.getUuid(), vol.getInstanceId(), vol.isDisplayVolume()); _resourceLimitMgr.incrementVolumeResourceCount(vm.getAccountId(), vol.isDisplayVolume(), vol.getSize(), offering); } DiskProfile diskProfile = toDiskProfile(vol, offering); @@ -981,7 +981,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), offeringId, vol.getTemplateId(), size, - Volume.class.getName(), vol.getUuid(), vol.isDisplayVolume()); + Volume.class.getName(), vol.getUuid(), vol.getInstanceId(), vol.isDisplayVolume()); _resourceLimitMgr.incrementVolumeResourceCount(vm.getAccountId(), vol.isDisplayVolume(), vol.getSize(), offering); } @@ -1423,7 +1423,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati String volumeToString = getVolumeIdentificationInfos(volume); VolumeInfo vol = volFactory.getVolume(volume.getId()); - if (vol == null){ + if (vol == null) { throw new CloudRuntimeException(String.format("Volume migration failed because volume [%s] is null.", volumeToString)); } if (destPool == null) { @@ -1583,12 +1583,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati vm.addDisk(disk); } - //if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) { if (vm.getType() == VirtualMachine.Type.User) { _tmpltMgr.prepareIsoForVmProfile(vm, dest); - //DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO(); - //DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO); - //vm.addDisk(iso); } } @@ -2308,6 +2304,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati StoragePoolVO pool = _storagePoolDao.findByUuid(updatedDataStoreUUID); if (pool != null) { vol.setPoolId(pool.getId()); + vol.setPoolType(pool.getPoolType()); } } _volsDao.update(volumeId, vol); @@ -2317,7 +2314,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati @Override public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long sizeInBytes, Long minIops, Long maxIops, Long zoneId, HypervisorType hypervisorType, VirtualMachine vm, VirtualMachineTemplate template, Account owner, - Long deviceId, Long poolId, String path, String chainInfo) { + Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo) { if (sizeInBytes == null) { sizeInBytes = offering.getDiskSize(); } @@ -2358,6 +2355,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati vol.setFormat(getSupportedImageFormatForCluster(hypervisorType)); vol.setPoolId(poolId); + vol.setPoolType(poolType); vol.setPath(path); vol.setChainInfo(chainInfo); vol.setState(Volume.State.Ready); @@ -2367,7 +2365,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati @Override public DiskProfile updateImportedVolume(Type type, DiskOffering offering, VirtualMachine vm, VirtualMachineTemplate template, - Long deviceId, Long poolId, String path, String chainInfo, DiskProfile diskProfile) { + Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo, DiskProfile diskProfile) { VolumeVO vol = _volsDao.findById(diskProfile.getVolumeId()); if (vm != null) { @@ -2401,6 +2399,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType())); vol.setPoolId(poolId); + vol.setPoolType(poolType); vol.setPath(path); vol.setChainInfo(chainInfo); vol.setSize(diskProfile.getSize()); diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java index 51e87663919..ff75aa0cbb6 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java @@ -140,20 +140,12 @@ public class ProvisioningServiceImpl implements ProvisioningService { @Override public List listPods() { - /* - * Not in use now, just commented out. - */ - //List pods = new ArrayList(); - //pods.add(new PodEntityImpl("pod-uuid-1", "pod1")); - //pods.add(new PodEntityImpl("pod-uuid-2", "pod2")); return null; } @Override public List listZones() { List zones = new ArrayList(); - //zones.add(new ZoneEntityImpl("zone-uuid-1")); - //zones.add(new ZoneEntityImpl("zone-uuid-2")); return zones; } diff --git a/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java b/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java index 064ca44c69a..a95f0e36475 100644 --- a/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java +++ b/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java @@ -822,7 +822,7 @@ public class NetworkOrchestratorTest extends TestCase { Mockito.when(network.getId()).thenReturn(networkId); Mockito.when(dataCenter.getId()).thenReturn(dataCenterId); Mockito.when(ipAddresses.getIp4Address()).thenReturn(requestedIp); - Mockito.when(testOrchestrator._ipAddressDao.findByIp(requestedIp)).thenReturn(ipAddressVO); + Mockito.when(testOrchestrator._ipAddressDao.findByIpAndSourceNetworkId(networkId, requestedIp)).thenReturn(ipAddressVO); String ipAddress = testOrchestrator.getSelectedIpForNicImport(network, dataCenter, ipAddresses); Assert.assertEquals(requestedIp, ipAddress); } diff --git a/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestratorTest.java b/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestratorTest.java index 817ff02ef74..b4a26c17e2e 100644 --- a/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestratorTest.java +++ b/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestratorTest.java @@ -241,7 +241,7 @@ public class VolumeOrchestratorTest { volumeOrchestrator.importVolume(volumeType, name, diskOffering, sizeInBytes, null, null, zoneId, hypervisorType, null, null, owner, - deviceId, poolId, path, chainInfo); + deviceId, poolId, Storage.StoragePoolType.NetworkFilesystem, path, chainInfo); VolumeVO volume = volumeVOMockedConstructionConstruction.constructed().get(0); Mockito.verify(volume, Mockito.never()).setInstanceId(Mockito.anyLong()); diff --git a/engine/pom.xml b/engine/pom.xml index b771138dc8c..2de84eab85a 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/engine/schema/pom.xml b/engine/schema/pom.xml index 2f216884c8b..654cd14a25d 100644 --- a/engine/schema/pom.xml +++ b/engine/schema/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/engine/schema/src/main/java/com/cloud/dc/dao/ClusterVSMMapDaoImpl.java b/engine/schema/src/main/java/com/cloud/dc/dao/ClusterVSMMapDaoImpl.java index 02a7ac6977c..76058d21333 100644 --- a/engine/schema/src/main/java/com/cloud/dc/dao/ClusterVSMMapDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/dc/dao/ClusterVSMMapDaoImpl.java @@ -36,7 +36,6 @@ public class ClusterVSMMapDaoImpl extends GenericDaoBase final SearchBuilder VsmSearch; public ClusterVSMMapDaoImpl() { - //super(); ClusterSearch = createSearchBuilder(); ClusterSearch.and("clusterId", ClusterSearch.entity().getClusterId(), SearchCriteria.Op.EQ); @@ -82,8 +81,6 @@ public class ClusterVSMMapDaoImpl extends GenericDaoBase TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); ClusterVSMMapVO cluster = createForUpdate(); - //cluster.setClusterId(null); - //cluster.setVsmId(null); update(id, cluster); diff --git a/engine/schema/src/main/java/com/cloud/event/UsageEventVO.java b/engine/schema/src/main/java/com/cloud/event/UsageEventVO.java index 3fc9fda9487..41ecec0c7fb 100644 --- a/engine/schema/src/main/java/com/cloud/event/UsageEventVO.java +++ b/engine/schema/src/main/java/com/cloud/event/UsageEventVO.java @@ -75,6 +75,9 @@ public class UsageEventVO implements UsageEvent { @Column(name = "virtual_size") private Long virtualSize; + @Column(name = "vm_id") + private Long vmId; + public UsageEventVO() { } @@ -143,6 +146,18 @@ public class UsageEventVO implements UsageEvent { this.offeringId = securityGroupId; } + public UsageEventVO(String usageType, long accountId, long zoneId, long resourceId, Long offeringId, Long templateId, Long size, Long vmId, String resourceName) { + this.type = usageType; + this.accountId = accountId; + this.zoneId = zoneId; + this.resourceId = resourceId; + this.offeringId = offeringId; + this.templateId = templateId; + this.size = size; + this.vmId = vmId; + this.resourceName = resourceName; + } + @Override public long getId() { return id; @@ -248,4 +263,11 @@ public class UsageEventVO implements UsageEvent { this.virtualSize = virtualSize; } + public Long getVmId() { + return vmId; + } + + public void setVmId(Long vmId) { + this.vmId = vmId; + } } diff --git a/engine/schema/src/main/java/com/cloud/event/dao/UsageEventDaoImpl.java b/engine/schema/src/main/java/com/cloud/event/dao/UsageEventDaoImpl.java index fdef509da5b..bce9c474e2d 100644 --- a/engine/schema/src/main/java/com/cloud/event/dao/UsageEventDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/event/dao/UsageEventDaoImpl.java @@ -45,11 +45,11 @@ public class UsageEventDaoImpl extends GenericDaoBase implem private final SearchBuilder latestEventsSearch; private final SearchBuilder IpeventsSearch; private static final String COPY_EVENTS = - "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size) " - + "SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size FROM cloud.usage_event vmevt WHERE vmevt.id > ? and vmevt.id <= ? "; + "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size, vm_id) " + + "SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size, vm_id FROM cloud.usage_event vmevt WHERE vmevt.id > ? and vmevt.id <= ? "; private static final String COPY_ALL_EVENTS = - "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size) " - + "SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size FROM cloud.usage_event vmevt WHERE vmevt.id <= ?"; + "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size, vm_id) " + + "SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size, resource_type, virtual_size, vm_id FROM cloud.usage_event vmevt WHERE vmevt.id <= ?"; private static final String COPY_EVENT_DETAILS = "INSERT INTO cloud_usage.usage_event_details (id, usage_event_id, name, value) " + "SELECT id, usage_event_id, name, value FROM cloud.usage_event_details vmevtDetails WHERE vmevtDetails.usage_event_id > ? and vmevtDetails.usage_event_id <= ? "; private static final String COPY_ALL_EVENT_DETAILS = "INSERT INTO cloud_usage.usage_event_details (id, usage_event_id, name, value) " diff --git a/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDao.java b/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDao.java index 5d8bd0a0a3a..b72ec5239ff 100644 --- a/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDao.java +++ b/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDao.java @@ -33,6 +33,8 @@ public interface HostDetailsDao extends GenericDao { List findByName(String name); + void removeExternalDetails(long hostId); + void replaceExternalDetails(long hostId, Map details); } diff --git a/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDaoImpl.java b/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDaoImpl.java index 3eb9faeb1c1..0f8e8623506 100644 --- a/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/host/dao/HostDetailsDaoImpl.java @@ -39,6 +39,7 @@ public class HostDetailsDaoImpl extends GenericDaoBase implement protected final SearchBuilder HostSearch; protected final SearchBuilder DetailSearch; protected final SearchBuilder DetailNameSearch; + protected final SearchBuilder ExternalDetailSearch; public HostDetailsDaoImpl() { HostSearch = createSearchBuilder(); @@ -53,6 +54,11 @@ public class HostDetailsDaoImpl extends GenericDaoBase implement DetailNameSearch = createSearchBuilder(); DetailNameSearch.and("name", DetailNameSearch.entity().getName(), SearchCriteria.Op.EQ); DetailNameSearch.done(); + + ExternalDetailSearch = createSearchBuilder(); + ExternalDetailSearch.and("hostId", ExternalDetailSearch.entity().getHostId(), SearchCriteria.Op.EQ); + ExternalDetailSearch.and("name", ExternalDetailSearch.entity().getName(), SearchCriteria.Op.LIKE); + ExternalDetailSearch.done(); } @Override @@ -133,6 +139,17 @@ public class HostDetailsDaoImpl extends GenericDaoBase implement return listBy(sc); } + @Override + public void removeExternalDetails(long hostId) { + TransactionLegacy txn = TransactionLegacy.currentTxn(); + txn.start(); + SearchCriteria sc = ExternalDetailSearch.create(); + sc.setParameters("hostId", hostId); + sc.setParameters("name", VmDetailConstants.EXTERNAL_DETAIL_PREFIX + "%"); + remove(sc); + txn.commit(); + } + @Override public void replaceExternalDetails(long hostId, Map details) { if (details.isEmpty()) { @@ -149,11 +166,7 @@ public class HostDetailsDaoImpl extends GenericDaoBase implement } detailVOs.add(new DetailVO(hostId, name, value)); } - SearchBuilder sb = createSearchBuilder(); - sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ); - sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); - sb.done(); - SearchCriteria sc = sb.create(); + SearchCriteria sc = ExternalDetailSearch.create(); sc.setParameters("hostId", hostId); sc.setParameters("name", VmDetailConstants.EXTERNAL_DETAIL_PREFIX + "%"); remove(sc); diff --git a/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDao.java b/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDao.java index 4c9df8e749f..372dc930b68 100644 --- a/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDao.java +++ b/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDao.java @@ -24,6 +24,7 @@ import com.cloud.utils.db.Filter; import com.cloud.utils.db.GenericDao; public interface CounterDao extends GenericDao { + CounterVO findByNameProviderValue(String name, String value, String provider); public List listCounters(Long id, String name, String source, String provider, String keyword, Filter filter); } diff --git a/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDaoImpl.java b/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDaoImpl.java index 2d3906b8341..0badbe449ac 100644 --- a/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/network/as/dao/CounterDaoImpl.java @@ -32,6 +32,7 @@ import com.cloud.utils.db.SearchCriteria.Op; @Component public class CounterDaoImpl extends GenericDaoBase implements CounterDao { final SearchBuilder AllFieldsSearch; + final SearchBuilder CounterValueSearch; protected CounterDaoImpl() { AllFieldsSearch = createSearchBuilder(); @@ -40,6 +41,21 @@ public class CounterDaoImpl extends GenericDaoBase implements C AllFieldsSearch.and("source", AllFieldsSearch.entity().getSource(), Op.EQ); AllFieldsSearch.and("provider", AllFieldsSearch.entity().getProvider(), Op.EQ); AllFieldsSearch.done(); + + CounterValueSearch = createSearchBuilder(); + CounterValueSearch.and("name", CounterValueSearch.entity().getName(), Op.EQ); + CounterValueSearch.and("value", CounterValueSearch.entity().getValue(), Op.EQ); + CounterValueSearch.and("provider", CounterValueSearch.entity().getProvider(), Op.EQ); + CounterValueSearch.done(); + } + + @Override + public CounterVO findByNameProviderValue(String name, String value, String provider) { + SearchCriteria sc = CounterValueSearch.create(); + sc.setParameters("name", name); + sc.setParameters("value", value); + sc.setParameters("provider", provider); + return findOneBy(sc); } @Override diff --git a/engine/schema/src/main/java/com/cloud/network/dao/NetworkDao.java b/engine/schema/src/main/java/com/cloud/network/dao/NetworkDao.java index 0861a424ebb..fdca6e43f00 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/NetworkDao.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/NetworkDao.java @@ -18,6 +18,7 @@ package com.cloud.network.dao; import java.util.List; import java.util.Map; +import java.util.Set; import com.cloud.network.Network; import com.cloud.network.Network.GuestType; @@ -47,6 +48,12 @@ public interface NetworkDao extends GenericDao, StateDao listByNetworkDomains(Set uniqueNtwkDomains); + + List listByNetworkDomainsAndAccountIds(Set uniqueNtwkDomains, Set accountIds); + + List listByNetworkDomainsAndDomainIds(Set uniqueNtwkDomains, Set domainIds); + /** * Retrieves the next available mac address in this network configuration. * diff --git a/engine/schema/src/main/java/com/cloud/network/dao/NetworkDaoImpl.java b/engine/schema/src/main/java/com/cloud/network/dao/NetworkDaoImpl.java index 0aae532eac5..4b299085612 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/NetworkDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/NetworkDaoImpl.java @@ -86,6 +86,7 @@ public class NetworkDaoImpl extends GenericDaoBaseimplements Ne GenericSearchBuilder GarbageCollectedSearch; SearchBuilder PrivateNetworkSearch; + SearchBuilder NetworkDomainSearch; @Inject ResourceTagDao _tagsDao; @@ -198,6 +199,12 @@ public class NetworkDaoImpl extends GenericDaoBaseimplements Ne PersistentNetworkSearch.join("persistent", persistentNtwkOffJoin, PersistentNetworkSearch.entity().getNetworkOfferingId(), persistentNtwkOffJoin.entity().getId(), JoinType.INNER); PersistentNetworkSearch.done(); + NetworkDomainSearch = createSearchBuilder(); + NetworkDomainSearch.and("networkDomains", NetworkDomainSearch.entity().getNetworkDomain(), Op.IN); + NetworkDomainSearch.and("accounts", NetworkDomainSearch.entity().getAccountId(), Op.IN); + NetworkDomainSearch.and("domains", NetworkDomainSearch.entity().getDomainId(), Op.IN); + NetworkDomainSearch.done(); + PhysicalNetworkSearch = createSearchBuilder(); PhysicalNetworkSearch.and("physicalNetworkId", PhysicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ); PhysicalNetworkSearch.done(); @@ -428,6 +435,29 @@ public class NetworkDaoImpl extends GenericDaoBaseimplements Ne return search(sc, null); } + @Override + public List listByNetworkDomains(Set uniqueNtwkDomains) { + SearchCriteria sc = NetworkDomainSearch.create(); + sc.setParameters("networkDomains", uniqueNtwkDomains.toArray()); + return search(sc, null); + } + + @Override + public List listByNetworkDomainsAndAccountIds(Set uniqueNtwkDomains, Set accountIds) { + SearchCriteria sc = NetworkDomainSearch.create(); + sc.setParameters("networkDomains", uniqueNtwkDomains.toArray()); + sc.setParameters("accounts", accountIds.toArray()); + return search(sc, null); + } + + @Override + public List listByNetworkDomainsAndDomainIds(Set uniqueNtwkDomains, Set domainIds) { + SearchCriteria sc = NetworkDomainSearch.create(); + sc.setParameters("networkDomains", uniqueNtwkDomains.toArray()); + sc.setParameters("domains", domainIds.toArray()); + return search(sc, null); + } + @Override public String getNextAvailableMacAddress(final long networkConfigId, Integer zoneMacIdentifier) { final SequenceFetcher fetch = SequenceFetcher.getInstance(); diff --git a/engine/schema/src/main/java/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java b/engine/schema/src/main/java/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java index 9a9ca80bce5..7ed0ad0bcc5 100644 --- a/engine/schema/src/main/java/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java @@ -76,7 +76,6 @@ public class VmRulesetLogDaoImpl extends GenericDaoBase im @Override public int createOrUpdate(Set workItems) { - //return createOrUpdateUsingBatch(workItems); return createOrUpdateUsingMultiInsert(workItems); } diff --git a/engine/schema/src/main/java/com/cloud/storage/DiskOfferingVO.java b/engine/schema/src/main/java/com/cloud/storage/DiskOfferingVO.java index 79f5bcb5157..7f6b6d8adf0 100644 --- a/engine/schema/src/main/java/com/cloud/storage/DiskOfferingVO.java +++ b/engine/schema/src/main/java/com/cloud/storage/DiskOfferingVO.java @@ -577,11 +577,11 @@ public class DiskOfferingVO implements DiskOffering { @Override public void setEncrypt(boolean encrypt) { this.encrypt = encrypt; } + @Override public boolean isShared() { return !useLocalStorage; } - public boolean getDiskSizeStrictness() { return diskSizeStrictness; } diff --git a/engine/schema/src/main/java/com/cloud/storage/SnapshotPolicyVO.java b/engine/schema/src/main/java/com/cloud/storage/SnapshotPolicyVO.java index f57d9d3dccf..299c6380ab6 100644 --- a/engine/schema/src/main/java/com/cloud/storage/SnapshotPolicyVO.java +++ b/engine/schema/src/main/java/com/cloud/storage/SnapshotPolicyVO.java @@ -59,6 +59,12 @@ public class SnapshotPolicyVO implements SnapshotPolicy { @Column(name = "uuid") String uuid; + @Column(name = "account_id") + long accountId; + + @Column(name = "domain_id") + long domainId; + @Column(name = "display", updatable = true, nullable = false) protected boolean display = true; @@ -66,7 +72,7 @@ public class SnapshotPolicyVO implements SnapshotPolicy { this.uuid = UUID.randomUUID().toString(); } - public SnapshotPolicyVO(long volumeId, String schedule, String timezone, IntervalType intvType, int maxSnaps, boolean display) { + public SnapshotPolicyVO(long volumeId, String schedule, String timezone, IntervalType intvType, int maxSnaps, long accountId, long domainId, boolean display) { this.volumeId = volumeId; this.schedule = schedule; this.timezone = timezone; @@ -75,6 +81,8 @@ public class SnapshotPolicyVO implements SnapshotPolicy { this.active = true; this.display = display; this.uuid = UUID.randomUUID().toString(); + this.accountId = accountId; + this.domainId = domainId; } @Override @@ -160,4 +168,32 @@ public class SnapshotPolicyVO implements SnapshotPolicy { public void setDisplay(boolean display) { this.display = display; } + + @Override + public long getAccountId() { + return accountId; + } + + public void setAccountId(long accountId) { + this.accountId = accountId; + } + + @Override + public long getDomainId() { + return domainId; + } + + public void setDomainId(long domainId) { + this.domainId = domainId; + } + + @Override + public Class getEntityType() { + return SnapshotPolicy.class; + } + + @Override + public String getName() { + return null; + } } diff --git a/engine/schema/src/main/java/com/cloud/storage/StoragePoolHostVO.java b/engine/schema/src/main/java/com/cloud/storage/StoragePoolHostVO.java index 53c08322e0c..73a11b02c05 100644 --- a/engine/schema/src/main/java/com/cloud/storage/StoragePoolHostVO.java +++ b/engine/schema/src/main/java/com/cloud/storage/StoragePoolHostVO.java @@ -28,6 +28,7 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import com.cloud.utils.db.GenericDaoBase; +import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; /** * Join table for storage pools and hosts @@ -100,4 +101,9 @@ public class StoragePoolHostVO implements StoragePoolHostAssoc { this.localPath = localPath; } + @Override + public String toString() { + return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "hostId", "poolId"); + } + } diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDao.java b/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDao.java index f726bca3c5d..9beea003744 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDao.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDao.java @@ -31,6 +31,8 @@ public interface DiskOfferingDao extends GenericDao { List listAllBySizeAndProvisioningType(long size, Storage.ProvisioningType provisioningType); List findCustomDiskOfferings(); + List listByStorageTag(String tag); + List listAllActiveAndNonComputeDiskOfferings(); } diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDaoImpl.java b/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDaoImpl.java index 93e74766277..4ca3fe9f12a 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/DiskOfferingDaoImpl.java @@ -26,6 +26,7 @@ import java.util.List; import javax.inject.Inject; import javax.persistence.EntityExistsException; +import com.cloud.offering.DiskOffering; import org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDao; import org.springframework.stereotype.Component; @@ -45,6 +46,8 @@ public class DiskOfferingDaoImpl extends GenericDaoBase im protected DiskOfferingDetailsDao detailsDao; protected final SearchBuilder UniqueNameSearch; + protected final SearchBuilder ActiveAndNonComputeSearch; + private final String SizeDiskOfferingSearch = "SELECT * FROM disk_offering WHERE " + "disk_size = ? AND provisioning_type = ? AND removed IS NULL"; @@ -56,6 +59,11 @@ public class DiskOfferingDaoImpl extends GenericDaoBase im UniqueNameSearch.and("name", UniqueNameSearch.entity().getUniqueName(), SearchCriteria.Op.EQ); UniqueNameSearch.done(); + ActiveAndNonComputeSearch = createSearchBuilder(); + ActiveAndNonComputeSearch.and("state", ActiveAndNonComputeSearch.entity().getState(), SearchCriteria.Op.EQ); + ActiveAndNonComputeSearch.and("computeOnly", ActiveAndNonComputeSearch.entity().isComputeOnly(), SearchCriteria.Op.EQ); + ActiveAndNonComputeSearch.done(); + _computeOnlyAttr = _allAttributes.get("computeOnly"); } @@ -164,4 +172,12 @@ public class DiskOfferingDaoImpl extends GenericDaoBase im sc.setParameters("tagEndLike", "%," + tag); return listBy(sc); } + + @Override + public List listAllActiveAndNonComputeDiskOfferings() { + SearchCriteria sc = ActiveAndNonComputeSearch.create(); + sc.setParameters("state", DiskOffering.State.Active); + sc.setParameters("computeOnly", false); + return listBy(sc); + } } diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java index 08b82cbb45b..727035855f9 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -100,7 +100,6 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem private SearchBuilder PublicIsoSearch; private SearchBuilder UserIsoSearch; private GenericSearchBuilder CountTemplatesByAccount; - // private SearchBuilder updateStateSearch; private SearchBuilder AllFieldsSearch; protected SearchBuilder ParentTemplateIdSearch; private SearchBuilder InactiveUnremovedTmpltSearch; @@ -404,12 +403,6 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem CountTemplatesByAccount.and("state", CountTemplatesByAccount.entity().getState(), SearchCriteria.Op.EQ); CountTemplatesByAccount.done(); - // updateStateSearch = this.createSearchBuilder(); - // updateStateSearch.and("id", updateStateSearch.entity().getId(), Op.EQ); - // updateStateSearch.and("state", updateStateSearch.entity().getState(), Op.EQ); - // updateStateSearch.and("updatedCount", updateStateSearch.entity().getUpdatedCount(), Op.EQ); - // updateStateSearch.done(); - AllFieldsSearch = createSearchBuilder(); AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), SearchCriteria.Op.EQ); AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ); diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDao.java b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDao.java index a3ce03a74c3..a208590e23a 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDao.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDao.java @@ -35,6 +35,8 @@ public interface VMTemplatePoolDao extends GenericDao listByPoolIdAndState(long poolId, ObjectInDataStoreStateMachine.State state); + List listByPoolIdsAndTemplate(List poolIds, Long templateId); + List listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState); List listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState, long poolId); diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java index 5a2ec1163fb..5dfc138d8e1 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java @@ -150,6 +150,16 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase listByPoolIdsAndTemplate(List poolIds, Long templateId) { + SearchCriteria sc = PoolTemplateSearch.create(); + if (CollectionUtils.isNotEmpty(poolIds)) { + sc.setParameters("pool_id", poolIds.toArray()); + } + sc.setParameters("template_id", templateId); + return listBy(sc); + } + @Override public List listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState) { SearchCriteria sc = TemplateStatusSearch.create(); diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDaoImpl.java index f8b6bb3ed68..6814636bc66 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDaoImpl.java @@ -822,6 +822,7 @@ public class VolumeDaoImpl extends GenericDaoBase implements Vol if (volume.getState() != Volume.State.Destroy) { volume.setState(Volume.State.Destroy); volume.setPoolId(null); + volume.setPoolType(null); volume.setInstanceId(null); update(volume.getId(), volume); remove(volume.getId()); 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 c211b3e9728..004a5f9dd65 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -33,11 +33,10 @@ import java.util.List; import javax.inject.Inject; -import com.cloud.utils.FileUtil; import org.apache.cloudstack.utils.CloudStackVersion; import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.cloud.upgrade.dao.DbUpgrade; import com.cloud.upgrade.dao.DbUpgradeSystemVmTemplate; @@ -91,8 +90,10 @@ import com.cloud.upgrade.dao.Upgrade41910to42000; import com.cloud.upgrade.dao.Upgrade42000to42010; import com.cloud.upgrade.dao.Upgrade42010to42100; import com.cloud.upgrade.dao.Upgrade42100to42200; +import com.cloud.upgrade.dao.Upgrade42200to42210; import com.cloud.upgrade.dao.Upgrade420to421; import com.cloud.upgrade.dao.Upgrade421to430; +import com.cloud.upgrade.dao.Upgrade42210to42300; import com.cloud.upgrade.dao.Upgrade430to440; import com.cloud.upgrade.dao.Upgrade431to440; import com.cloud.upgrade.dao.Upgrade432to440; @@ -121,6 +122,7 @@ import com.cloud.upgrade.dao.VersionDao; import com.cloud.upgrade.dao.VersionDaoImpl; import com.cloud.upgrade.dao.VersionVO; import com.cloud.upgrade.dao.VersionVO.Step; +import com.cloud.utils.FileUtil; import com.cloud.utils.component.SystemIntegrityChecker; import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.db.GlobalLock; @@ -236,6 +238,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { .next("4.20.0.0", new Upgrade42000to42010()) .next("4.20.1.0", new Upgrade42010to42100()) .next("4.21.0.0", new Upgrade42100to42200()) + .next("4.22.0.0", new Upgrade42200to42210()) + .next("4.22.1.0", new Upgrade42210to42300()) .build(); } @@ -313,20 +317,20 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { } protected void executeProcedureScripts() { - LOGGER.info(String.format("Executing Stored Procedure scripts that are under resource directory [%s].", PROCEDURES_DIRECTORY)); + LOGGER.info("Executing Stored Procedure scripts that are under resource directory [{}].", PROCEDURES_DIRECTORY); List filesPathUnderViewsDirectory = FileUtil.getFilesPathsUnderResourceDirectory(PROCEDURES_DIRECTORY); try (TransactionLegacy txn = TransactionLegacy.open("execute-procedure-scripts")) { Connection conn = txn.getConnection(); for (String filePath : filesPathUnderViewsDirectory) { - LOGGER.debug(String.format("Executing PROCEDURE script [%s].", filePath)); + LOGGER.debug("Executing PROCEDURE script [{}].", filePath); InputStream viewScript = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath); runScript(conn, viewScript); } - LOGGER.info(String.format("Finished execution of PROCEDURE scripts that are under resource directory [%s].", PROCEDURES_DIRECTORY)); + LOGGER.info("Finished execution of PROCEDURE scripts that are under resource directory [{}].", PROCEDURES_DIRECTORY); } catch (SQLException e) { String message = String.format("Unable to execute PROCEDURE scripts due to [%s].", e.getMessage()); LOGGER.error(message, e); @@ -335,7 +339,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { } private DbUpgrade[] executeUpgrades(CloudStackVersion dbVersion, CloudStackVersion currentVersion) { - LOGGER.info("Database upgrade must be performed from " + dbVersion + " to " + currentVersion); + LOGGER.info("Database upgrade must be performed from {} to {}", dbVersion, currentVersion); final DbUpgrade[] upgrades = calculateUpgradePath(dbVersion, currentVersion); @@ -348,8 +352,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { private VersionVO executeUpgrade(DbUpgrade upgrade) { VersionVO version; - LOGGER.debug("Running upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + upgrade - .getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion()); + LOGGER.debug("Running upgrade {} to upgrade from {}-{} to {}", upgrade.getClass().getSimpleName(), upgrade.getUpgradableVersionRange()[0], upgrade + .getUpgradableVersionRange()[1], upgrade.getUpgradedVersion()); TransactionLegacy txn = TransactionLegacy.open("Upgrade"); txn.start(); try { @@ -392,8 +396,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { // Run the corresponding '-cleanup.sql' script txn = TransactionLegacy.open("Cleanup"); try { - LOGGER.info("Cleanup upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + upgrade - .getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion()); + LOGGER.info("Cleanup upgrade {} to upgrade from {}-{} to {}", upgrade.getClass().getSimpleName(), upgrade.getUpgradableVersionRange()[0], upgrade + .getUpgradableVersionRange()[1], upgrade.getUpgradedVersion()); txn.start(); Connection conn; @@ -408,7 +412,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { if (scripts != null) { for (InputStream script : scripts) { runScript(conn, script); - LOGGER.debug("Cleanup script " + upgrade.getClass().getSimpleName() + " is executed successfully"); + LOGGER.debug("Cleanup script {} is executed successfully", upgrade.getClass().getSimpleName()); } } txn.commit(); @@ -418,27 +422,27 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { version.setUpdated(new Date()); _dao.update(version.getId(), version); txn.commit(); - LOGGER.debug("Upgrade completed for version " + version.getVersion()); + LOGGER.debug("Upgrade completed for version {}", version.getVersion()); } finally { txn.close(); } } protected void executeViewScripts() { - LOGGER.info(String.format("Executing VIEW scripts that are under resource directory [%s].", VIEWS_DIRECTORY)); + LOGGER.info("Executing VIEW scripts that are under resource directory [{}].", VIEWS_DIRECTORY); List filesPathUnderViewsDirectory = FileUtil.getFilesPathsUnderResourceDirectory(VIEWS_DIRECTORY); try (TransactionLegacy txn = TransactionLegacy.open("execute-view-scripts")) { Connection conn = txn.getConnection(); for (String filePath : filesPathUnderViewsDirectory) { - LOGGER.debug(String.format("Executing VIEW script [%s].", filePath)); + LOGGER.debug("Executing VIEW script [{}].", filePath); InputStream viewScript = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath); runScript(conn, viewScript); } - LOGGER.info(String.format("Finished execution of VIEW scripts that are under resource directory [%s].", VIEWS_DIRECTORY)); + LOGGER.info("Finished execution of VIEW scripts that are under resource directory [{}].", VIEWS_DIRECTORY); } catch (SQLException e) { String message = String.format("Unable to execute VIEW scripts due to [%s].", e.getMessage()); LOGGER.error(message, e); @@ -468,10 +472,10 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { String csVersion = SystemVmTemplateRegistration.parseMetadataFile(); final CloudStackVersion sysVmVersion = CloudStackVersion.parse(csVersion); final CloudStackVersion currentVersion = CloudStackVersion.parse(currentVersionValue); - SystemVmTemplateRegistration.CS_MAJOR_VERSION = String.valueOf(sysVmVersion.getMajorRelease()) + "." + String.valueOf(sysVmVersion.getMinorRelease()); + SystemVmTemplateRegistration.CS_MAJOR_VERSION = sysVmVersion.getMajorRelease() + "." + sysVmVersion.getMinorRelease(); SystemVmTemplateRegistration.CS_TINY_VERSION = String.valueOf(sysVmVersion.getPatchRelease()); - LOGGER.info("DB version = " + dbVersion + " Code Version = " + currentVersion); + LOGGER.info("DB version = {} Code Version = {}", dbVersion, currentVersion); if (dbVersion.compareTo(currentVersion) > 0) { throw new CloudRuntimeException("Database version " + dbVersion + " is higher than management software version " + currentVersionValue); @@ -520,7 +524,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { ResultSet result = pstmt.executeQuery()) { if (result.next()) { String init = result.getString(1); - LOGGER.info("init = " + DBEncryptionUtil.decrypt(init)); + LOGGER.info("init = {}", DBEncryptionUtil.decrypt(init)); } } } @@ -551,21 +555,11 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { return upgradedVersion; } - @Override - public boolean supportsRollingUpgrade() { - return false; - } - @Override public InputStream[] getPrepareScripts() { return new InputStream[0]; } - @Override - public void performDataMigration(Connection conn) { - - } - @Override public InputStream[] getCleanupScripts() { return new InputStream[0]; diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade2214to30.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade2214to30.java index 524b6a34893..d4cdbcb9707 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade2214to30.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade2214to30.java @@ -77,8 +77,6 @@ public class Upgrade2214to30 extends Upgrade30xBase { encryptData(conn); // drop keys dropKeysIfExist(conn); - //update template ID for system Vms - //updateSystemVms(conn); This is not required as system template update is handled during 4.2 upgrade // update domain network ref updateDomainNetworkRef(conn); // update networks that use redundant routers to the new network offering diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade302to40.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade302to40.java index aa427252585..bd8ddaa7c49 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade302to40.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade302to40.java @@ -62,7 +62,6 @@ public class Upgrade302to40 extends Upgrade30xBase { @Override public void performDataMigration(Connection conn) { - //updateVmWareSystemVms(conn); This is not required as system template update is handled during 4.2 upgrade correctVRProviders(conn); correctMultiplePhysicaNetworkSetups(conn); addHostDetailsUniqueKey(conn); diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade304to305.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade304to305.java index bb4c73f67b6..21c016c7cc1 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade304to305.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade304to305.java @@ -65,7 +65,6 @@ public class Upgrade304to305 extends Upgrade30xBase { addVpcProvider(conn); updateRouterNetworkRef(conn); fixZoneUsingExternalDevices(conn); -// updateSystemVms(conn); fixForeignKeys(conn); encryptClusterDetails(conn); } @@ -81,54 +80,6 @@ public class Upgrade304to305 extends Upgrade30xBase { return new InputStream[] {script}; } - private void updateSystemVms(Connection conn) { - PreparedStatement pstmt = null; - ResultSet rs = null; - boolean VMware = false; - try { - pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); - rs = pstmt.executeQuery(); - while (rs.next()) { - if ("VMware".equals(rs.getString(1))) { - VMware = true; - } - } - } catch (SQLException e) { - throw new CloudRuntimeException("Error while iterating through list of hypervisors in use", e); - } - // Just update the VMware system template. Other hypervisor templates are unchanged from previous 3.0.x versions. - logger.debug("Updating VMware System Vms"); - try { - //Get 3.0.5 VMware system Vm template Id - pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-vmware-3.0.5' and removed is null"); - rs = pstmt.executeQuery(); - if (rs.next()) { - long templateId = rs.getLong(1); - rs.close(); - pstmt.close(); - // change template type to SYSTEM - pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?"); - pstmt.setLong(1, templateId); - pstmt.executeUpdate(); - pstmt.close(); - // update template ID of system Vms - pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'VMware'"); - pstmt.setLong(1, templateId); - pstmt.executeUpdate(); - pstmt.close(); - } else { - if (VMware) { - throw new CloudRuntimeException("3.0.5 VMware SystemVm template not found. Cannot upgrade system Vms"); - } else { - logger.warn("3.0.5 VMware SystemVm template not found. VMware hypervisor is not used, so not failing upgrade"); - } - } - } catch (SQLException e) { - throw new CloudRuntimeException("Error while updating VMware systemVm template", e); - } - logger.debug("Updating System Vm Template IDs Complete"); - } - private void addVpcProvider(Connection conn) { //Encrypt config params and change category to Hidden logger.debug("Adding vpc provider to all physical networks in the system"); diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41810to41900.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41810to41900.java index e2b1ae1399b..28cf91ec6b0 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41810to41900.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41810to41900.java @@ -159,7 +159,7 @@ public class Upgrade41810to41900 extends DbUpgradeAbstractImpl implements DbUpgr try (PreparedStatement pstmt = conn.prepareStatement(createNewColumn)) { pstmt.execute(); } catch (SQLException e) { - String message = String.format("Unable to crate new backups' column date due to [%s].", e.getMessage()); + String message = String.format("Unable to create new backups' column date due to [%s].", e.getMessage()); logger.error(message, e); throw new CloudRuntimeException(message, e); } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42100to42200.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42100to42200.java index c2cfd02c15c..5138d51bb1b 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42100to42200.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42100to42200.java @@ -16,6 +16,14 @@ // under the License. package com.cloud.upgrade.dao; +import com.cloud.utils.exception.CloudRuntimeException; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + public class Upgrade42100to42200 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate { @Override @@ -27,4 +35,69 @@ public class Upgrade42100to42200 extends DbUpgradeAbstractImpl implements DbUpgr public String getUpgradedVersion() { return "4.22.0.0"; } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-42100to42200.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) { + updateSnapshotPolicyOwnership(conn); + updateBackupScheduleOwnership(conn); + } + + protected void updateSnapshotPolicyOwnership(Connection conn) { + // set account_id and domain_id in snapshot_policy table from volume table + String selectSql = "SELECT sp.id, v.account_id, v.domain_id FROM snapshot_policy sp, volumes v WHERE sp.volume_id = v.id AND (sp.account_id IS NULL AND sp.domain_id IS NULL)"; + String updateSql = "UPDATE snapshot_policy SET account_id = ?, domain_id = ? WHERE id = ?"; + + try (PreparedStatement selectPstmt = conn.prepareStatement(selectSql); + ResultSet rs = selectPstmt.executeQuery(); + PreparedStatement updatePstmt = conn.prepareStatement(updateSql)) { + + while (rs.next()) { + long policyId = rs.getLong(1); + long accountId = rs.getLong(2); + long domainId = rs.getLong(3); + + updatePstmt.setLong(1, accountId); + updatePstmt.setLong(2, domainId); + updatePstmt.setLong(3, policyId); + updatePstmt.executeUpdate(); + } + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to update snapshot_policy table with account_id and domain_id", e); + } + } + + protected void updateBackupScheduleOwnership(Connection conn) { + // Set account_id and domain_id in backup_schedule table from vm_instance table + String selectSql = "SELECT bs.id, vm.account_id, vm.domain_id FROM backup_schedule bs, vm_instance vm WHERE bs.vm_id = vm.id AND (bs.account_id IS NULL AND bs.domain_id IS NULL)"; + String updateSql = "UPDATE backup_schedule SET account_id = ?, domain_id = ? WHERE id = ?"; + + try (PreparedStatement selectPstmt = conn.prepareStatement(selectSql); + ResultSet rs = selectPstmt.executeQuery(); + PreparedStatement updatePstmt = conn.prepareStatement(updateSql)) { + + while (rs.next()) { + long scheduleId = rs.getLong(1); + long accountId = rs.getLong(2); + long domainId = rs.getLong(3); + + updatePstmt.setLong(1, accountId); + updatePstmt.setLong(2, domainId); + updatePstmt.setLong(3, scheduleId); + updatePstmt.executeUpdate(); + } + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to update backup_schedule table with account_id and domain_id", e); + } + } } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java new file mode 100644 index 00000000000..c9610f7b9ff --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java @@ -0,0 +1,30 @@ +// 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; + +public class Upgrade42200to42210 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate { + + @Override + public String[] getUpgradableVersionRange() { + return new String[] {"4.22.0.0", "4.22.1.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.22.1.0"; + } +} diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java new file mode 100644 index 00000000000..cb87e730f83 --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java @@ -0,0 +1,30 @@ +// 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; + +public class Upgrade42210to42300 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate { + + @Override + public String[] getUpgradableVersionRange() { + return new String[]{"4.22.1.0", "4.23.0.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.23.0.0"; + } +} diff --git a/engine/schema/src/main/java/com/cloud/usage/UsageVolumeVO.java b/engine/schema/src/main/java/com/cloud/usage/UsageVolumeVO.java index 96abd2d69c0..6d5315e3346 100644 --- a/engine/schema/src/main/java/com/cloud/usage/UsageVolumeVO.java +++ b/engine/schema/src/main/java/com/cloud/usage/UsageVolumeVO.java @@ -59,6 +59,9 @@ public class UsageVolumeVO implements InternalIdentity { @Column(name = "size") private long size; + @Column(name = "vm_id") + private Long vmId; + @Column(name = "created") @Temporal(value = TemporalType.TIMESTAMP) private Date created = null; @@ -70,13 +73,14 @@ public class UsageVolumeVO implements InternalIdentity { protected UsageVolumeVO() { } - public UsageVolumeVO(long id, long zoneId, long accountId, long domainId, Long diskOfferingId, Long templateId, long size, Date created, Date deleted) { + public UsageVolumeVO(long id, long zoneId, long accountId, long domainId, Long diskOfferingId, Long templateId, Long vmId, long size, Date created, Date deleted) { this.volumeId = id; this.zoneId = zoneId; this.accountId = accountId; this.domainId = domainId; this.diskOfferingId = diskOfferingId; this.templateId = templateId; + this.vmId = vmId; this.size = size; this.created = created; this.deleted = deleted; @@ -126,4 +130,12 @@ public class UsageVolumeVO implements InternalIdentity { public long getVolumeId() { return volumeId; } + + public Long getVmId() { + return vmId; + } + + public void setVmId(Long vmId) { + this.vmId = vmId; + } } diff --git a/engine/schema/src/main/java/com/cloud/usage/dao/UsageStorageDaoImpl.java b/engine/schema/src/main/java/com/cloud/usage/dao/UsageStorageDaoImpl.java index 1da53349399..f863cd1e3a3 100644 --- a/engine/schema/src/main/java/com/cloud/usage/dao/UsageStorageDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/usage/dao/UsageStorageDaoImpl.java @@ -57,6 +57,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase im IdSearch.and("accountId", IdSearch.entity().getAccountId(), SearchCriteria.Op.EQ); IdSearch.and("id", IdSearch.entity().getEntityId(), SearchCriteria.Op.EQ); IdSearch.and("type", IdSearch.entity().getStorageType(), SearchCriteria.Op.EQ); + IdSearch.and("deleted", IdSearch.entity().getDeleted(), SearchCriteria.Op.NULL); IdSearch.done(); IdZoneSearch = createSearchBuilder(); @@ -74,6 +75,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase im sc.setParameters("accountId", accountId); sc.setParameters("id", id); sc.setParameters("type", type); + sc.setParameters("deleted", null); return listBy(sc, null); } diff --git a/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDao.java b/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDao.java index 09590b73993..05287240f25 100644 --- a/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDao.java +++ b/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDao.java @@ -23,9 +23,7 @@ import com.cloud.usage.UsageVolumeVO; import com.cloud.utils.db.GenericDao; public interface UsageVolumeDao extends GenericDao { - public void removeBy(long userId, long id); - - public void update(UsageVolumeVO usage); - public List getUsageRecords(Long accountId, Long domainId, Date startDate, Date endDate, boolean limit, int page); + + List listByVolumeId(long volumeId, long accountId); } diff --git a/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDaoImpl.java b/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDaoImpl.java index 4662a6f26ce..095070feac1 100644 --- a/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/usage/dao/UsageVolumeDaoImpl.java @@ -18,81 +18,46 @@ package com.cloud.usage.dao; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.TimeZone; -import com.cloud.exception.CloudException; +import javax.annotation.PostConstruct; + import org.springframework.stereotype.Component; import com.cloud.usage.UsageVolumeVO; import com.cloud.utils.DateUtil; import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.TransactionLegacy; @Component public class UsageVolumeDaoImpl extends GenericDaoBase implements UsageVolumeDao { - protected static final String REMOVE_BY_USERID_VOLID = "DELETE FROM usage_volume WHERE account_id = ? AND volume_id = ?"; - protected static final String UPDATE_DELETED = "UPDATE usage_volume SET deleted = ? WHERE account_id = ? AND volume_id = ? and deleted IS NULL"; - protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted " + protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, vm_id, size, created, deleted " + "FROM usage_volume " + "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))"; - protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted " + protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, vm_id, size, created, deleted " + "FROM usage_volume " + "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))"; - protected static final String GET_ALL_USAGE_RECORDS = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted " + protected static final String GET_ALL_USAGE_RECORDS = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, vm_id, size, created, deleted " + "FROM usage_volume " + "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))"; + private SearchBuilder volumeSearch; public UsageVolumeDaoImpl() { } - @Override - public void removeBy(long accountId, long volId) { - TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); - try { - txn.start(); - try(PreparedStatement pstmt = txn.prepareStatement(REMOVE_BY_USERID_VOLID);) { - if (pstmt != null) { - pstmt.setLong(1, accountId); - pstmt.setLong(2, volId); - pstmt.executeUpdate(); - } - }catch (SQLException e) { - throw new CloudException("Error removing usageVolumeVO:"+e.getMessage(), e); - } - txn.commit(); - } catch (Exception e) { - txn.rollback(); - logger.warn("Error removing usageVolumeVO:"+e.getMessage(), e); - } finally { - txn.close(); - } - } - - @Override - public void update(UsageVolumeVO usage) { - TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); - PreparedStatement pstmt = null; - try { - txn.start(); - if (usage.getDeleted() != null) { - pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED); - pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted())); - pstmt.setLong(2, usage.getAccountId()); - pstmt.setLong(3, usage.getVolumeId()); - pstmt.executeUpdate(); - } - txn.commit(); - } catch (Exception e) { - txn.rollback(); - logger.warn("Error updating UsageVolumeVO", e); - } finally { - txn.close(); - } + @PostConstruct + protected void init() { + volumeSearch = createSearchBuilder(); + volumeSearch.and("accountId", volumeSearch.entity().getAccountId(), SearchCriteria.Op.EQ); + volumeSearch.and("volumeId", volumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); + volumeSearch.and("deleted", volumeSearch.entity().getDeleted(), SearchCriteria.Op.NULL); + volumeSearch.done(); } @Override @@ -150,11 +115,15 @@ public class UsageVolumeDaoImpl extends GenericDaoBase impl if (tId == 0) { tId = null; } - long size = Long.valueOf(rs.getLong(7)); + Long vmId = Long.valueOf(rs.getLong(7)); + if (vmId == 0) { + vmId = null; + } + long size = Long.valueOf(rs.getLong(8)); Date createdDate = null; Date deletedDate = null; - String createdTS = rs.getString(8); - String deletedTS = rs.getString(9); + String createdTS = rs.getString(9); + String deletedTS = rs.getString(10); if (createdTS != null) { createdDate = DateUtil.parseDateString(s_gmtTimeZone, createdTS); @@ -163,7 +132,7 @@ public class UsageVolumeDaoImpl extends GenericDaoBase impl deletedDate = DateUtil.parseDateString(s_gmtTimeZone, deletedTS); } - usageRecords.add(new UsageVolumeVO(vId, zoneId, acctId, dId, doId, tId, size, createdDate, deletedDate)); + usageRecords.add(new UsageVolumeVO(vId, zoneId, acctId, dId, doId, tId, vmId, size, createdDate, deletedDate)); } } catch (Exception e) { txn.rollback(); @@ -174,4 +143,13 @@ public class UsageVolumeDaoImpl extends GenericDaoBase impl return usageRecords; } + + @Override + public List listByVolumeId(long volumeId, long accountId) { + SearchCriteria sc = volumeSearch.create(); + sc.setParameters("accountId", accountId); + sc.setParameters("volumeId", volumeId); + sc.setParameters("deleted", null); + return listBy(sc); + } } diff --git a/engine/schema/src/main/java/com/cloud/user/UserAccountVO.java b/engine/schema/src/main/java/com/cloud/user/UserAccountVO.java index e4fcbad6b02..c5ca410fc53 100644 --- a/engine/schema/src/main/java/com/cloud/user/UserAccountVO.java +++ b/engine/schema/src/main/java/com/cloud/user/UserAccountVO.java @@ -226,10 +226,6 @@ public class UserAccountVO implements UserAccount, InternalIdentity { return created; } -// public void setCreated(Date created) { -// this.created = created; -// } - @Override public Date getRemoved() { return removed; diff --git a/engine/schema/src/main/java/com/cloud/vm/ImportVMTaskVO.java b/engine/schema/src/main/java/com/cloud/vm/ImportVMTaskVO.java new file mode 100644 index 00000000000..9a8a769f0a5 --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/vm/ImportVMTaskVO.java @@ -0,0 +1,270 @@ +// +// 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.vm; + +import org.apache.cloudstack.vm.ImportVmTask; + +import javax.persistence.Column; +import javax.persistence.Entity; +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 java.util.Date; +import java.util.UUID; + +@Entity +@Table(name = "import_vm_task") +public class ImportVMTaskVO implements ImportVmTask { + + public ImportVMTaskVO(long zoneId, long accountId, long userId, String displayName, + String vcenter, String datacenter, String sourceVMName, long convertHostId, long importHostId) { + this.zoneId = zoneId; + this.accountId = accountId; + this.userId = userId; + this.displayName = displayName; + this.vcenter = vcenter; + this.datacenter = datacenter; + this.sourceVMName = sourceVMName; + this.step = Step.Prepare; + this.uuid = UUID.randomUUID().toString(); + this.convertHostId = convertHostId; + this.importHostId = importHostId; + } + + public ImportVMTaskVO() { + } + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "uuid") + private String uuid; + + @Column(name = "zone_id") + private long zoneId; + + @Column(name = "account_id") + private long accountId; + + @Column(name = "user_id") + private long userId; + + @Column(name = "vm_id") + private Long vmId; + @Column(name = "display_name") + private String displayName; + + @Column(name = "vcenter") + private String vcenter; + + @Column(name = "datacenter") + private String datacenter; + + @Column(name = "source_vm_name") + private String sourceVMName; + + @Column(name = "convert_host_id") + private long convertHostId; + + @Column(name = "import_host_id") + private long importHostId; + + @Column(name = "step") + private Step step; + + @Column(name = "state") + private TaskState state; + + @Column(name = "description") + private String description; + + @Column(name = "duration") + private Long duration; + + @Column(name = "created") + @Temporal(value = TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "updated") + @Temporal(value = TemporalType.TIMESTAMP) + private Date updated; + + @Column(name = "removed") + @Temporal(value = TemporalType.TIMESTAMP) + private Date removed; + + @Override + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Override + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public long getZoneId() { + return zoneId; + } + + public void setZoneId(long zoneId) { + this.zoneId = zoneId; + } + + public long getAccountId() { + return accountId; + } + + public void setAccountId(long accountId) { + this.accountId = accountId; + } + + public long getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + + public Long getVmId() { + return vmId; + } + + public void setVmId(Long vmId) { + this.vmId = vmId; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getVcenter() { + return vcenter; + } + + public void setVcenter(String vcenter) { + this.vcenter = vcenter; + } + + public String getDatacenter() { + return datacenter; + } + + public void setDatacenter(String datacenter) { + this.datacenter = datacenter; + } + + public String getSourceVMName() { + return sourceVMName; + } + + public void setSourceVMName(String sourceVMName) { + this.sourceVMName = sourceVMName; + } + + public long getConvertHostId() { + return convertHostId; + } + + public void setConvertHostId(long convertHostId) { + this.convertHostId = convertHostId; + } + + public long getImportHostId() { + return importHostId; + } + + public void setImportHostId(long importHostId) { + this.importHostId = importHostId; + } + + public Step getStep() { + return step; + } + + public void setStep(Step step) { + this.step = step; + } + + public TaskState getState() { + return state; + } + + public void setState(TaskState state) { + this.state = state; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getDuration() { + return duration; + } + + public void setDuration(Long duration) { + this.duration = duration; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getUpdated() { + return updated; + } + + public void setUpdated(Date updated) { + this.updated = updated; + } + + public Date getRemoved() { + return removed; + } + + public void setRemoved(Date removed) { + this.removed = removed; + } +} diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/ImportVMTaskDao.java b/engine/schema/src/main/java/com/cloud/vm/dao/ImportVMTaskDao.java new file mode 100644 index 00000000000..a4f0a155da4 --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/vm/dao/ImportVMTaskDao.java @@ -0,0 +1,31 @@ +// +// 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.vm.dao; + +import com.cloud.utils.Pair; +import com.cloud.utils.db.GenericDao; +import com.cloud.vm.ImportVMTaskVO; +import org.apache.cloudstack.vm.ImportVmTask; +import java.util.List; + +public interface ImportVMTaskDao extends GenericDao { + + Pair, Integer> listImportVMTasks(Long zoneId, Long accountId, String vcenter, Long convertHostId, + ImportVmTask.TaskState state, Long startIndex, Long pageSizeVal); +} diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/ImportVMTaskDaoImpl.java b/engine/schema/src/main/java/com/cloud/vm/dao/ImportVMTaskDaoImpl.java new file mode 100644 index 00000000000..da9c391af9d --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/vm/dao/ImportVMTaskDaoImpl.java @@ -0,0 +1,74 @@ +// 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.vm.dao; + +import com.cloud.utils.Pair; +import com.cloud.utils.db.Filter; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.vm.ImportVMTaskVO; +import org.apache.cloudstack.vm.ImportVmTask; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.List; + +@Component +public class ImportVMTaskDaoImpl extends GenericDaoBase implements ImportVMTaskDao { + + private SearchBuilder AllFieldsSearch; + + public ImportVMTaskDaoImpl() { + } + + @PostConstruct + void init() { + AllFieldsSearch = createSearchBuilder(); + AllFieldsSearch.and("zoneId", AllFieldsSearch.entity().getZoneId(), SearchCriteria.Op.EQ); + AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ); + AllFieldsSearch.and("vcenter", AllFieldsSearch.entity().getVcenter(), SearchCriteria.Op.EQ); + AllFieldsSearch.and("convertHostId", AllFieldsSearch.entity().getConvertHostId(), SearchCriteria.Op.EQ); + AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), SearchCriteria.Op.EQ); + AllFieldsSearch.done(); + } + + + @Override + public Pair, Integer> listImportVMTasks(Long zoneId, Long accountId, String vcenter, Long convertHostId, + ImportVmTask.TaskState state, Long startIndex, Long pageSizeVal) { + SearchCriteria sc = AllFieldsSearch.create(); + if (zoneId != null) { + sc.setParameters("zoneId", zoneId); + } + if (accountId != null) { + sc.setParameters("accountId", accountId); + } + if (StringUtils.isNotBlank(vcenter)) { + sc.setParameters("vcenter", vcenter); + } + if (convertHostId != null) { + sc.setParameters("convertHostId", convertHostId); + } + if (state != null) { + sc.setParameters("state", state); + } + Filter filter = new Filter(ImportVMTaskVO.class, "created", false, startIndex, pageSizeVal); + return searchAndCount(sc, filter); + } +} diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java b/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java index 41bcb3155e5..2431e63f5e8 100644 --- a/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java @@ -101,7 +101,7 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use ReservationDao reservationDao; private static final String LIST_PODS_HAVING_VMS_FOR_ACCOUNT = - "SELECT pod_id FROM cloud.vm_instance WHERE data_center_id = ? AND account_id = ? AND pod_id IS NOT NULL AND (state = 'Running' OR state = 'Stopped') " + "SELECT pod_id FROM cloud.vm_instance WHERE data_center_id = ? AND account_id = ? AND pod_id IS NOT NULL AND state IN ('Starting', 'Running', 'Stopped') " + "GROUP BY pod_id HAVING count(id) > 0 ORDER BY count(id) DESC"; private static final String VM_DETAILS = "select vm_instance.id, " @@ -782,7 +782,7 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use result.add(new Ternary(rs.getInt(1), rs.getInt(2), rs.getInt(3))); } } catch (Exception e) { - logger.warn("Error counting vms by size for dcId= " + dcId, e); + logger.warn("Error counting vms by size for Data Center ID = " + dcId, e); } return result; } diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java index 6ac49967540..339573c10fa 100755 --- a/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java @@ -886,7 +886,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem return rs.getLong(1); } } catch (Exception e) { - logger.warn(String.format("Error counting vms by host tag for dcId= %s, hostTag= %s", dcId, hostTag), e); + logger.warn(String.format("Error counting vms by host tag for dcId = %s, hostTag = %s", dcId, hostTag), e); } return 0L; } diff --git a/engine/schema/src/main/java/org/apache/cloudstack/backup/BackupScheduleVO.java b/engine/schema/src/main/java/org/apache/cloudstack/backup/BackupScheduleVO.java index 37e8105e3d5..1ee2cff78b6 100644 --- a/engine/schema/src/main/java/org/apache/cloudstack/backup/BackupScheduleVO.java +++ b/engine/schema/src/main/java/org/apache/cloudstack/backup/BackupScheduleVO.java @@ -68,10 +68,16 @@ public class BackupScheduleVO implements BackupSchedule { @Column(name = "quiescevm") Boolean quiesceVM = false; + @Column(name = "account_id") + Long accountId; + + @Column(name = "domain_id") + Long domainId; + public BackupScheduleVO() { } - public BackupScheduleVO(Long vmId, DateUtil.IntervalType scheduleType, String schedule, String timezone, Date scheduledTimestamp, int maxBackups, Boolean quiesceVM) { + public BackupScheduleVO(Long vmId, DateUtil.IntervalType scheduleType, String schedule, String timezone, Date scheduledTimestamp, int maxBackups, Boolean quiesceVM, Long accountId, Long domainId) { this.vmId = vmId; this.scheduleType = (short) scheduleType.ordinal(); this.schedule = schedule; @@ -79,6 +85,8 @@ public class BackupScheduleVO implements BackupSchedule { this.scheduledTimestamp = scheduledTimestamp; this.maxBackups = maxBackups; this.quiesceVM = quiesceVM; + this.accountId = accountId; + this.domainId = domainId; } @Override @@ -161,4 +169,32 @@ public class BackupScheduleVO implements BackupSchedule { public Boolean getQuiesceVM() { return quiesceVM; } + + @Override + public Class getEntityType() { + return BackupSchedule.class; + } + + @Override + public String getName() { + return null; + } + + @Override + public long getDomainId() { + return domainId; + } + + @Override + public long getAccountId() { + return accountId; + } + + public void setAccountId(Long accountId) { + this.accountId = accountId; + } + + public void setDomainId(Long domainId) { + this.domainId = domainId; + } } diff --git a/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDao.java b/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDao.java index d001de8b6c6..d40e828121e 100644 --- a/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDao.java +++ b/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDao.java @@ -24,7 +24,7 @@ import org.apache.cloudstack.backup.BackupOfferingVO; import com.cloud.utils.db.GenericDao; public interface BackupOfferingDao extends GenericDao { - BackupOfferingResponse newBackupOfferingResponse(BackupOffering policy); + BackupOfferingResponse newBackupOfferingResponse(BackupOffering policy, Boolean crossZoneInstanceCreation); BackupOffering findByExternalId(String externalId, Long zoneId); BackupOffering findByName(String name, Long zoneId); } diff --git a/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDaoImpl.java b/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDaoImpl.java index 9d67d07fe5e..a41e4e70d33 100644 --- a/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDaoImpl.java +++ b/engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupOfferingDaoImpl.java @@ -50,7 +50,7 @@ public class BackupOfferingDaoImpl extends GenericDaoBase { List findPoolsByStorageTypeAndZone(Storage.StoragePoolType storageType, Long zoneId); + List listByDataCenterIds(List dataCenterIds); } diff --git a/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java index 6da02d7716b..b5d6415e3a1 100644 --- a/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java +++ b/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java @@ -65,6 +65,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase private final GenericSearchBuilder StatusCountSearch; private final SearchBuilder ClustersSearch; private final SearchBuilder IdsSearch; + private final SearchBuilder DcsSearch; @Inject private StoragePoolDetailsDao _detailsDao; @@ -167,6 +168,9 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase IdsSearch.and("ids", IdsSearch.entity().getId(), SearchCriteria.Op.IN); IdsSearch.done(); + DcsSearch = createSearchBuilder(); + DcsSearch.and("dataCenterId", DcsSearch.entity().getDataCenterId(), SearchCriteria.Op.IN); + DcsSearch.done(); } @Override @@ -927,6 +931,16 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase return listBy(sc); } + @Override + public List listByDataCenterIds(List dataCenterIds) { + if (CollectionUtils.isEmpty(dataCenterIds)) { + return Collections.emptyList(); + } + SearchCriteria sc = DcsSearch.create(); + sc.setParameters("dataCenterId", dataCenterIds.toArray()); + return listBy(sc); + } + private SearchCriteria createStoragePoolSearchCriteria(Long storagePoolId, String storagePoolName, Long zoneId, String path, Long podId, Long clusterId, Long hostId, String address, ScopeType scopeType, StoragePoolStatus status, String keyword, String storageAccessGroup) { diff --git a/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java index d57dec8fbfd..c475a4203a7 100644 --- a/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java +++ b/engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java @@ -209,10 +209,8 @@ public class VolumeDataStoreVO implements StateObject + diff --git a/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_drop_unique_key.sql b/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_drop_unique_key.sql new file mode 100644 index 00000000000..fdcca6fb408 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_drop_unique_key.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. + +-- in cloud +DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_DROP_UNIQUE_KEY`; + +CREATE PROCEDURE `cloud`.`IDEMPOTENT_DROP_UNIQUE_KEY` ( + IN in_table_name VARCHAR(200), + IN in_index_name VARCHAR(200) +) +BEGIN + DECLARE CONTINUE HANDLER FOR 1091, 1025 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name, ' DROP KEY ', in_index_name); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-307to410.sql b/engine/schema/src/main/resources/META-INF/db/schema-307to410.sql index 55d78b59437..3b0cfa8e6ce 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-307to410.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-307to410.sql @@ -3,7 +3,7 @@ -- 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 compliances +-- "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 diff --git a/engine/schema/src/main/resources/META-INF/db/schema-410to420.sql b/engine/schema/src/main/resources/META-INF/db/schema-410to420.sql index 35f73b35d3c..d62a9bb9303 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-410to420.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-410to420.sql @@ -2305,7 +2305,7 @@ CREATE TABLE `cloud_usage`.`usage_vmsnapshot` ( ) ENGINE=InnoDB CHARSET=utf8; INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'healthcheck.update.interval', '600', 'Time Interval to fetch the LB health check states (in sec)'); -INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Snapshots', 'DEFAULT', 'SnapshotManager', 'kvm.snapshot.enabled', 'false', 'whether snapshot is enabled for KVM hosts'); +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Snapshots', 'DEFAULT', 'SnapshotManager', 'kvm.snapshot.enabled', 'true', 'whether snapshot is enabled for KVM hosts'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'eip.use.multiple.netscalers', 'false', 'Should be set to true, if there will be multiple NetScaler devices providing EIP service in a zone'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Snapshots', 'DEFAULT', 'SnapshotManager', 'snapshot.backup.rightafter', 'true', 'backup snapshot right after snapshot is taken'); diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql b/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql index 1b60b492dc3..e62694228b6 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql @@ -26,6 +26,15 @@ CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('router_health_check', 'check_result', ' -- Increase length of scripts_version column to 128 due to md5sum to sha512sum change CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('cloud.domain_router', 'scripts_version', 'scripts_version', 'VARCHAR(128)'); +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.snapshot_policy','domain_id', 'BIGINT(20) DEFAULT NULL'); +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.snapshot_policy','account_id', 'BIGINT(20) DEFAULT NULL'); + +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_schedule','domain_id', 'BIGINT(20) DEFAULT NULL'); +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_schedule','account_id', 'BIGINT(20) DEFAULT NULL'); + +-- Increase the cache_mode column size from cloud.disk_offering table +CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('cloud.disk_offering', 'cache_mode', 'cache_mode', 'varchar(18) DEFAULT "none" COMMENT "The disk cache mode to use for disks created with this offering"'); + -- Add uuid column to ldap_configuration table CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.ldap_configuration', 'uuid', 'VARCHAR(40) NOT NULL'); @@ -39,31 +48,43 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_repository', 'cross_zone_inst UPDATE `cloud`.`storage_pool_details` SET display = 0 WHERE name LIKE '%password%'; UPDATE `cloud`.`storage_pool_details` SET display = 0 WHERE name LIKE '%token%'; --- Disk controller mappings -CREATE TABLE IF NOT EXISTS `cloud`.`disk_controller_mapping` ( - `id` bigint(20) unsigned NOT NULL auto_increment, - `uuid` varchar(255) UNIQUE NOT NULL, - `name` varchar(255) NOT NULL, - `controller_reference` varchar(255) NOT NULL, - `bus_name` varchar(255) NOT NULL, - `hypervisor` varchar(40) NOT NULL, - `max_device_count` bigint unsigned DEFAULT NULL, - `max_controller_count` bigint unsigned DEFAULT NULL, - `vmdk_adapter_type` varchar(255) DEFAULT NULL, - `min_hardware_version` varchar(20) DEFAULT NULL, - `created` datetime NOT NULL, - `removed` datetime DEFAULT NULL, - PRIMARY KEY (`id`) - ); +-- Add csi_enabled column to kubernetes_cluster table to indicate if the cluster is using csi or not +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.kubernetes_cluster', 'csi_enabled', 'TINYINT(1) unsigned NOT NULL DEFAULT 0 COMMENT "true if kubernetes cluster is using csi, false otherwise" '); + +-- VMware to KVM migration improvements +CREATE TABLE IF NOT EXISTS `cloud`.`import_vm_task`( + `id` bigint unsigned NOT NULL auto_increment COMMENT 'id', + `uuid` varchar(40), + `zone_id` bigint unsigned NOT NULL COMMENT 'Zone ID', + `account_id` bigint unsigned NOT NULL COMMENT 'Account ID', + `user_id` bigint unsigned NOT NULL COMMENT 'User ID', + `vm_id` bigint unsigned COMMENT 'VM ID', + `display_name` varchar(255) COMMENT 'Display VM Name', + `vcenter` varchar(255) COMMENT 'VCenter', + `datacenter` varchar(255) COMMENT 'VCenter Datacenter name', + `source_vm_name` varchar(255) COMMENT 'Source VM name on vCenter', + `convert_host_id` bigint unsigned COMMENT 'Convert Host ID', + `import_host_id` bigint unsigned COMMENT 'Import Host ID', + `step` varchar(20) COMMENT 'Importing VM Task Step', + `state` varchar(20) COMMENT 'Importing VM Task State', + `description` varchar(255) COMMENT 'Importing VM Task Description', + `duration` bigint unsigned COMMENT 'Duration in milliseconds for the completed tasks', + `created` datetime NOT NULL COMMENT 'date created', + `updated` datetime COMMENT 'date updated if not null', + `removed` datetime COMMENT 'date removed if not null', + PRIMARY KEY (`id`), + CONSTRAINT `fk_import_vm_task__zone_id` FOREIGN KEY `fk_import_vm_task__zone_id` (`zone_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_import_vm_task__account_id` FOREIGN KEY `fk_import_vm_task__account_id` (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_import_vm_task__user_id` FOREIGN KEY `fk_import_vm_task__user_id` (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_import_vm_task__vm_id` FOREIGN KEY `fk_import_vm_task__vm_id` (`vm_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_import_vm_task__convert_host_id` FOREIGN KEY `fk_import_vm_task__convert_host_id` (`convert_host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_import_vm_task__import_host_id` FOREIGN KEY `fk_import_vm_task__import_host_id` (`import_host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE, + INDEX `i_import_vm_task__zone_id`(`zone_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CALL `cloud`.`INSERT_EXTENSION_IF_NOT_EXISTS`('MaaS', 'Baremetal Extension for Canonical MaaS written in Python', 'MaaS/maas.py'); +CALL `cloud`.`INSERT_EXTENSION_DETAIL_IF_NOT_EXISTS`('MaaS', 'orchestratorrequirespreparevm', 'true', 0); + +CALL `cloud`.`IDEMPOTENT_DROP_UNIQUE_KEY`('counter', 'uc_counter__provider__source__value'); +CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.counter', 'uc_counter__provider__source__value__removed', '(provider, source, value, removed)'); --- Add VMware's default disk controller mappings -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('osdefault', 'unused', 'unused', 'VMware', NULL, NULL, NULL, NULL); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('ide', 'com.vmware.vim25.VirtualIDEController', 'ide', 'VMware', 2, 2, 'ide', NULL); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('scsi', 'com.vmware.vim25.VirtualLsiLogicController', 'scsi', 'VMware', 16, 4, 'lsilogic', NULL); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('buslogic', 'com.vmware.vim25.VirtualBusLogicController', 'scsi', 'VMware', 16, 4, 'buslogic', NULL); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('lsilogic', 'com.vmware.vim25.VirtualLsiLogicController', 'scsi', 'VMware', 16, 4, 'lsilogic', NULL); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('lsisas1068', 'com.vmware.vim25.VirtualLsiLogicSASController', 'scsi', 'VMware', 16, 4, 'lsilogic', NULL); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('pvscsi', 'com.vmware.vim25.ParaVirtualSCSIController', 'scsi', 'VMware', 16, 4, 'lsilogic', '7'); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('sata', 'com.vmware.vim25.VirtualAHCIController', 'sata', 'VMware', 30, 4, 'ide', '10'); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('ahci', 'com.vmware.vim25.VirtualAHCIController', 'sata', 'VMware', 30, 4, 'ide', '10'); -CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('nvme', 'com.vmware.vim25.VirtualNVMEController', 'nvme', 'VMware', 15, 4, 'ide', '13'); diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql new file mode 100644 index 00000000000..54baf226ac4 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210-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.22.0.0 to 4.22.1.0 +--; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql new file mode 100644 index 00000000000..6aafa7ba81e --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql @@ -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. + +--; +-- Schema upgrade from 4.22.0.0 to 4.22.1.0 +--; + +-- Add vm_id column to usage_event table for volume usage events +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.usage_event','vm_id', 'bigint UNSIGNED NULL COMMENT "VM ID associated with volume usage events"'); +CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_event','vm_id', 'bigint UNSIGNED NULL COMMENT "VM ID associated with volume usage events"'); + +-- Add vm_id column to cloud_usage.usage_volume table +CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_volume','vm_id', 'bigint UNSIGNED NULL COMMENT "VM ID associated with the volume usage"'); diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42210to42300-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-42210to42300-cleanup.sql new file mode 100644 index 00000000000..e2b066af780 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42210to42300-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.22.1.0 to 4.23.0.0 +--; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql b/engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql new file mode 100644 index 00000000000..7475ad55cd5 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql @@ -0,0 +1,49 @@ +-- 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.22.1.0 to 4.23.0.0 +--; + +-- Disk controller mappings +CREATE TABLE IF NOT EXISTS `cloud`.`disk_controller_mapping` ( + `id` bigint(20) unsigned NOT NULL auto_increment, + `uuid` varchar(255) UNIQUE NOT NULL, + `name` varchar(255) NOT NULL, + `controller_reference` varchar(255) NOT NULL, + `bus_name` varchar(255) NOT NULL, + `hypervisor` varchar(40) NOT NULL, + `max_device_count` bigint unsigned DEFAULT NULL, + `max_controller_count` bigint unsigned DEFAULT NULL, + `vmdk_adapter_type` varchar(255) DEFAULT NULL, + `min_hardware_version` varchar(20) DEFAULT NULL, + `created` datetime NOT NULL, + `removed` datetime DEFAULT NULL, + PRIMARY KEY (`id`) + ); + +-- Add VMware's default disk controller mappings +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('osdefault', 'unused', 'unused', 'VMware', NULL, NULL, NULL, NULL); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('ide', 'com.vmware.vim25.VirtualIDEController', 'ide', 'VMware', 2, 2, 'ide', NULL); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('scsi', 'com.vmware.vim25.VirtualLsiLogicController', 'scsi', 'VMware', 16, 4, 'lsilogic', NULL); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('buslogic', 'com.vmware.vim25.VirtualBusLogicController', 'scsi', 'VMware', 16, 4, 'buslogic', NULL); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('lsilogic', 'com.vmware.vim25.VirtualLsiLogicController', 'scsi', 'VMware', 16, 4, 'lsilogic', NULL); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('lsisas1068', 'com.vmware.vim25.VirtualLsiLogicSASController', 'scsi', 'VMware', 16, 4, 'lsilogic', NULL); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('pvscsi', 'com.vmware.vim25.ParaVirtualSCSIController', 'scsi', 'VMware', 16, 4, 'lsilogic', '7'); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('sata', 'com.vmware.vim25.VirtualAHCIController', 'sata', 'VMware', 30, 4, 'ide', '10'); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('ahci', 'com.vmware.vim25.VirtualAHCIController', 'sata', 'VMware', 30, 4, 'ide', '10'); +CALL `cloud`.`ADD_DISK_CONTROLLER_MAPPING` ('nvme', 'com.vmware.vim25.VirtualNVMEController', 'nvme', 'VMware', 15, 4, 'ide', '13'); diff --git a/engine/schema/src/test/java/com/cloud/upgrade/dao/Upgrade42100to42200Test.java b/engine/schema/src/test/java/com/cloud/upgrade/dao/Upgrade42100to42200Test.java new file mode 100644 index 00000000000..cff34fb4e20 --- /dev/null +++ b/engine/schema/src/test/java/com/cloud/upgrade/dao/Upgrade42100to42200Test.java @@ -0,0 +1,242 @@ +// 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 static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.inOrder; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InOrder; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class Upgrade42100to42200Test { + + @Spy + Upgrade42100to42200 upgrade; + + @Mock + private Connection conn; + + @Mock + private PreparedStatement selectStmt; + + @Mock + private PreparedStatement updateStmt; + + @Mock + private ResultSet resultSet; + + @Test + public void testUpdateSnapshotPolicyOwnership() throws SQLException { + // Setup mock data for snapshot policies without ownership + when(conn.prepareStatement("SELECT sp.id, v.account_id, v.domain_id FROM snapshot_policy sp, volumes v WHERE sp.volume_id = v.id AND (sp.account_id IS NULL AND sp.domain_id IS NULL)")) + .thenReturn(selectStmt); + when(conn.prepareStatement("UPDATE snapshot_policy SET account_id = ?, domain_id = ? WHERE id = ?")) + .thenReturn(updateStmt); + when(selectStmt.executeQuery()).thenReturn(resultSet); + + when(resultSet.next()) + .thenReturn(true) + .thenReturn(true) + .thenReturn(false); + + when(resultSet.getLong(1)) + .thenReturn(1L) + .thenReturn(2L); + when(resultSet.getLong(2)) + .thenReturn(100L) + .thenReturn(200L); + when(resultSet.getLong(3)) + .thenReturn(1L) + .thenReturn(2L); + + upgrade.updateSnapshotPolicyOwnership(conn); + + verify(conn).prepareStatement("SELECT sp.id, v.account_id, v.domain_id FROM snapshot_policy sp, volumes v WHERE sp.volume_id = v.id AND (sp.account_id IS NULL AND sp.domain_id IS NULL)"); + verify(conn).prepareStatement("UPDATE snapshot_policy SET account_id = ?, domain_id = ? WHERE id = ?"); + + InOrder inOrder = inOrder(updateStmt); + + inOrder.verify(updateStmt).setLong(1, 100L); // account_id + inOrder.verify(updateStmt).setLong(2, 1L); // domain_id + inOrder.verify(updateStmt).setLong(3, 1L); // policy_id + inOrder.verify(updateStmt).executeUpdate(); + + inOrder.verify(updateStmt).setLong(1, 200L); // account_id + inOrder.verify(updateStmt).setLong(2, 2L); // domain_id + inOrder.verify(updateStmt).setLong(3, 2L); // policy_id + inOrder.verify(updateStmt).executeUpdate(); + + verify(updateStmt, times(2)).executeUpdate(); + } + + @Test + public void testUpdateBackupScheduleOwnership() throws SQLException { + when(conn.prepareStatement("SELECT bs.id, vm.account_id, vm.domain_id FROM backup_schedule bs, vm_instance vm WHERE bs.vm_id = vm.id AND (bs.account_id IS NULL AND bs.domain_id IS NULL)")) + .thenReturn(selectStmt); + when(conn.prepareStatement("UPDATE backup_schedule SET account_id = ?, domain_id = ? WHERE id = ?")) + .thenReturn(updateStmt); + when(selectStmt.executeQuery()).thenReturn(resultSet); + + when(resultSet.next()) + .thenReturn(true) + .thenReturn(true) + .thenReturn(true) + .thenReturn(false); + + when(resultSet.getLong(1)) + .thenReturn(10L) + .thenReturn(20L) + .thenReturn(30L); + when(resultSet.getLong(2)) + .thenReturn(500L) + .thenReturn(600L) + .thenReturn(700L); + when(resultSet.getLong(3)) + .thenReturn(5L) + .thenReturn(6L) + .thenReturn(7L); + + upgrade.updateBackupScheduleOwnership(conn); + + verify(conn).prepareStatement("SELECT bs.id, vm.account_id, vm.domain_id FROM backup_schedule bs, vm_instance vm WHERE bs.vm_id = vm.id AND (bs.account_id IS NULL AND bs.domain_id IS NULL)"); + verify(conn).prepareStatement("UPDATE backup_schedule SET account_id = ?, domain_id = ? WHERE id = ?"); + + InOrder inOrder = inOrder(updateStmt); + + inOrder.verify(updateStmt).setLong(1, 500L); + inOrder.verify(updateStmt).setLong(2, 5L); + inOrder.verify(updateStmt).setLong(3, 10L); + inOrder.verify(updateStmt).executeUpdate(); + + inOrder.verify(updateStmt).setLong(1, 600L); + inOrder.verify(updateStmt).setLong(2, 6L); + inOrder.verify(updateStmt).setLong(3, 20L); + inOrder.verify(updateStmt).executeUpdate(); + + inOrder.verify(updateStmt).setLong(1, 700L); + inOrder.verify(updateStmt).setLong(2, 7L); + inOrder.verify(updateStmt).setLong(3, 30L); + inOrder.verify(updateStmt).executeUpdate(); + + verify(updateStmt, times(3)).executeUpdate(); + } + + @Test + public void testUpdateSnapshotPolicyOwnershipNoResults() throws SQLException { + when(conn.prepareStatement("SELECT sp.id, v.account_id, v.domain_id FROM snapshot_policy sp, volumes v WHERE sp.volume_id = v.id AND (sp.account_id IS NULL AND sp.domain_id IS NULL)")) + .thenReturn(selectStmt); + when(conn.prepareStatement("UPDATE snapshot_policy SET account_id = ?, domain_id = ? WHERE id = ?")) + .thenReturn(updateStmt); + when(selectStmt.executeQuery()).thenReturn(resultSet); + + when(resultSet.next()).thenReturn(false); + + upgrade.updateSnapshotPolicyOwnership(conn); + + verify(selectStmt).executeQuery(); + verify(updateStmt, times(0)).executeUpdate(); + } + + @Test + public void testUpdateBackupScheduleOwnershipNoResults() throws SQLException { + when(conn.prepareStatement("SELECT bs.id, vm.account_id, vm.domain_id FROM backup_schedule bs, vm_instance vm WHERE bs.vm_id = vm.id AND (bs.account_id IS NULL AND bs.domain_id IS NULL)")) + .thenReturn(selectStmt); + when(conn.prepareStatement("UPDATE backup_schedule SET account_id = ?, domain_id = ? WHERE id = ?")) + .thenReturn(updateStmt); + when(selectStmt.executeQuery()).thenReturn(resultSet); + + when(resultSet.next()).thenReturn(false); + + upgrade.updateBackupScheduleOwnership(conn); + + verify(selectStmt).executeQuery(); + verify(updateStmt, times(0)).executeUpdate(); + } + + @Test + public void testPerformDataMigration() throws SQLException { + when(conn.prepareStatement(anyString())).thenReturn(selectStmt); + when(selectStmt.executeQuery()).thenReturn(resultSet); + when(resultSet.next()).thenReturn(false); + + upgrade.performDataMigration(conn); + + verify(conn).prepareStatement("SELECT sp.id, v.account_id, v.domain_id FROM snapshot_policy sp, volumes v WHERE sp.volume_id = v.id AND (sp.account_id IS NULL AND sp.domain_id IS NULL)"); + verify(conn).prepareStatement("SELECT bs.id, vm.account_id, vm.domain_id FROM backup_schedule bs, vm_instance vm WHERE bs.vm_id = vm.id AND (bs.account_id IS NULL AND bs.domain_id IS NULL)"); + } + + @Test + public void testUpdateSnapshotPolicyOwnershipSingleRecord() throws SQLException { + when(conn.prepareStatement("SELECT sp.id, v.account_id, v.domain_id FROM snapshot_policy sp, volumes v WHERE sp.volume_id = v.id AND (sp.account_id IS NULL AND sp.domain_id IS NULL)")) + .thenReturn(selectStmt); + when(conn.prepareStatement("UPDATE snapshot_policy SET account_id = ?, domain_id = ? WHERE id = ?")) + .thenReturn(updateStmt); + when(selectStmt.executeQuery()).thenReturn(resultSet); + + when(resultSet.next()) + .thenReturn(true) + .thenReturn(false); + + when(resultSet.getLong(1)).thenReturn(42L); + when(resultSet.getLong(2)).thenReturn(999L); + when(resultSet.getLong(3)).thenReturn(10L); + + upgrade.updateSnapshotPolicyOwnership(conn); + + verify(updateStmt).setLong(1, 999L); + verify(updateStmt).setLong(2, 10L); + verify(updateStmt).setLong(3, 42L); + verify(updateStmt, times(1)).executeUpdate(); + } + + @Test + public void testUpdateBackupScheduleOwnershipSingleRecord() throws SQLException { + when(conn.prepareStatement("SELECT bs.id, vm.account_id, vm.domain_id FROM backup_schedule bs, vm_instance vm WHERE bs.vm_id = vm.id AND (bs.account_id IS NULL AND bs.domain_id IS NULL)")) + .thenReturn(selectStmt); + when(conn.prepareStatement("UPDATE backup_schedule SET account_id = ?, domain_id = ? WHERE id = ?")) + .thenReturn(updateStmt); + when(selectStmt.executeQuery()).thenReturn(resultSet); + + when(resultSet.next()) + .thenReturn(true) + .thenReturn(false); + + when(resultSet.getLong(1)).thenReturn(55L); + when(resultSet.getLong(2)).thenReturn(888L); + when(resultSet.getLong(3)).thenReturn(15L); + + upgrade.updateBackupScheduleOwnership(conn); + + verify(updateStmt).setLong(1, 888L); + verify(updateStmt).setLong(2, 15L); + verify(updateStmt).setLong(3, 55L); + verify(updateStmt, times(1)).executeUpdate(); + } +} diff --git a/engine/service/pom.xml b/engine/service/pom.xml index 3ea24cfd4af..9b833804064 100644 --- a/engine/service/pom.xml +++ b/engine/service/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT cloud-engine-service war diff --git a/engine/storage/cache/pom.xml b/engine/storage/cache/pom.xml index fbdb7d2c548..ac330ca6997 100644 --- a/engine/storage/cache/pom.xml +++ b/engine/storage/cache/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java b/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java index fc432ac020d..7042ee45333 100644 --- a/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java +++ b/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java @@ -62,7 +62,6 @@ public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacem /* Avoid using configDao at this time, we can't be sure that the database is already upgraded * and there might be fatal errors when using a dao. */ - //unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30); } public void setUnusedTimeInterval(Integer interval) { diff --git a/engine/storage/configdrive/pom.xml b/engine/storage/configdrive/pom.xml index 3ba607a6ad9..43eb249b538 100644 --- a/engine/storage/configdrive/pom.xml +++ b/engine/storage/configdrive/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/datamotion/pom.xml b/engine/storage/datamotion/pom.xml index 9652f804f1d..d3b6bb54352 100644 --- a/engine/storage/datamotion/pom.xml +++ b/engine/storage/datamotion/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java index 0b0065361d0..c494ca31594 100644 --- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java +++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java @@ -18,9 +18,11 @@ */ package org.apache.cloudstack.storage.motion; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.inject.Inject; @@ -67,6 +69,7 @@ import com.cloud.configuration.Config; import com.cloud.host.Host; import com.cloud.hypervisor.Hypervisor; import com.cloud.storage.DataStoreRole; +import com.cloud.storage.ScopeType; import com.cloud.storage.Snapshot.Type; import com.cloud.storage.SnapshotVO; import com.cloud.storage.StorageManager; @@ -85,6 +88,11 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { protected Logger logger = LogManager.getLogger(getClass()); private static final String NO_REMOTE_ENDPOINT_SSVM = "No remote endpoint to send command, check if host or ssvm is down?"; private static final String NO_REMOTE_ENDPOINT_WITH_ENCRYPTION = "No remote endpoint to send command, unable to find a valid endpoint. Requires encryption support: %s"; + private static final List SUPPORTED_POOL_TYPES_TO_BYPASS_SECONDARY_STORE = Arrays.asList( + StoragePoolType.NetworkFilesystem, + StoragePoolType.Filesystem, + StoragePoolType.RBD + ); @Inject EndPointSelector selector; @@ -240,7 +248,6 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { return dataTO; } - protected Answer copyObject(DataObject srcData, DataObject destData) { return copyObject(srcData, destData, null); } @@ -352,14 +359,12 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { Scope destScope = getZoneScope(destData.getDataStore().getScope()); DataStore cacheStore = cacheMgr.getCacheStorage(destScope); - boolean bypassSecondaryStorage = false; - if (srcData instanceof VolumeInfo && ((VolumeInfo)srcData).isDirectDownload()) { - bypassSecondaryStorage = true; - } + boolean bypassSecondaryStorage = canBypassSecondaryStorage(srcData, destData); boolean encryptionRequired = anyVolumeRequiresEncryption(srcData, destData); if (cacheStore == null) { if (bypassSecondaryStorage) { + logger.debug("Secondary storage is bypassed, copy volume between pools directly"); CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value()); EndPoint ep = selector.select(srcData, destData, encryptionRequired); Answer answer = null; @@ -388,8 +393,8 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { answer = copyObject(srcData, objOnImageStore); if (answer == null || !answer.getResult()) { - if (answer != null) { - if (logger.isDebugEnabled()) logger.debug("copy to image store failed: " + answer.getDetails()); + if (answer != null && logger.isDebugEnabled()) { + logger.debug("copy to image store failed: {}", answer.getDetails()); } objOnImageStore.processEvent(Event.OperationFailed); imageStore.delete(objOnImageStore); @@ -411,8 +416,8 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { } if (answer == null || !answer.getResult()) { - if (answer != null) { - if (logger.isDebugEnabled()) logger.debug("copy to primary store failed: " + answer.getDetails()); + if (answer != null && logger.isDebugEnabled()) { + logger.debug("copy to primary store failed: {}", answer.getDetails()); } objOnImageStore.processEvent(Event.OperationFailed); imageStore.delete(objOnImageStore); @@ -423,7 +428,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { objOnImageStore.processEvent(Event.OperationFailed); imageStore.delete(objOnImageStore); } - logger.error("Failed to perform operation: "+ e.getLocalizedMessage()); + logger.error("Failed to perform operation: {}", e.getLocalizedMessage()); throw e; } @@ -448,7 +453,78 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { } return answer; } + } + private boolean canBypassSecondaryStorage(DataObject srcData, DataObject destData) { + if (srcData instanceof VolumeInfo) { + if (((VolumeInfo)srcData).isDirectDownload()) { + return true; + } + + if (destData instanceof VolumeInfo) { + Scope srcDataStoreScope = srcData.getDataStore().getScope(); + Scope destDataStoreScope = destData.getDataStore().getScope(); + logger.info("srcDataStoreScope: {}, srcData pool type: {}; destDataStoreScope: {}, destData pool type: {}", + srcDataStoreScope, ((VolumeInfo)srcData).getStoragePoolType(), destDataStoreScope, ((VolumeInfo)destData).getStoragePoolType()); + + if (srcDataStoreScope != null && destDataStoreScope != null && + SUPPORTED_POOL_TYPES_TO_BYPASS_SECONDARY_STORE.contains(((VolumeInfo)srcData).getStoragePoolType()) && + SUPPORTED_POOL_TYPES_TO_BYPASS_SECONDARY_STORE.contains(((VolumeInfo)destData).getStoragePoolType())) { + + return canDirectlyCopyBetweenDataStoreScopes(srcDataStoreScope, destDataStoreScope); + } + } + } + + return false; + } + + private boolean canDirectlyCopyBetweenDataStoreScopes(Scope srcDataStoreScope, Scope destDataStoreScope) { + if (srcDataStoreScope == null || destDataStoreScope == null) { + return false; + } + + if (srcDataStoreScope.isSameScope(destDataStoreScope)) { + return true; + } + + if (srcDataStoreScope.getScopeType() == ScopeType.HOST) { + if (destDataStoreScope.getScopeType() == ScopeType.CLUSTER && + (Objects.equals(((HostScope) srcDataStoreScope).getClusterId(), ((ClusterScope) destDataStoreScope).getScopeId()))) { + return true; + } + if (destDataStoreScope.getScopeType() == ScopeType.ZONE && + (Objects.equals(((HostScope) srcDataStoreScope).getZoneId(), ((ZoneScope) destDataStoreScope).getScopeId()))) { + return true; + } + } + + if (destDataStoreScope.getScopeType() == ScopeType.HOST) { + if (srcDataStoreScope.getScopeType() == ScopeType.CLUSTER && + (Objects.equals(((ClusterScope) srcDataStoreScope).getScopeId(), ((HostScope) destDataStoreScope).getClusterId()))) { + return true; + } + if (srcDataStoreScope.getScopeType() == ScopeType.ZONE && + (Objects.equals(((ZoneScope) srcDataStoreScope).getScopeId(), ((HostScope) destDataStoreScope).getZoneId()))) { + return true; + } + } + + if (srcDataStoreScope.getScopeType() == ScopeType.CLUSTER) { + if (destDataStoreScope.getScopeType() == ScopeType.ZONE && + (Objects.equals(((ClusterScope) srcDataStoreScope).getZoneId(), ((ZoneScope) destDataStoreScope).getScopeId()))) { + return true; + } + } + + if (destDataStoreScope.getScopeType() == ScopeType.CLUSTER) { + if (srcDataStoreScope.getScopeType() == ScopeType.ZONE && + (Objects.equals(((ZoneScope) srcDataStoreScope).getScopeId(), ((ClusterScope) destDataStoreScope).getZoneId()))) { + return true; + } + } + + return false; } protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) { @@ -492,6 +568,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { } volumeVo.setPodId(destPool.getPodId()); volumeVo.setPoolId(destPool.getId()); + volumeVo.setPoolType(destPool.getPoolType()); volumeVo.setLastPoolId(oldPoolId); // For SMB, pool credentials are also stored in the uri query string. We trim the query string // part here to make sure the credentials do not get stored in the db unencrypted. 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 0a211ab1934..fa8a7a79aa3 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 @@ -122,6 +122,7 @@ import com.cloud.storage.VMTemplateStoragePoolVO; import com.cloud.storage.VMTemplateStorageResourceAssoc; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.Volume; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeDetailVO; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.DiskOfferingDao; @@ -194,6 +195,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { @Inject private VolumeService _volumeService; @Inject + public VolumeApiService _volumeApiService; + @Inject private StorageCacheManager cacheMgr; @Inject private EndPointSelector selector; @@ -796,6 +799,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { volumeVO.setPodId(destPool.getPodId()); volumeVO.setPoolId(destPool.getId()); + volumeVO.setPoolType(destPool.getPoolType()); volumeVO.setLastPoolId(srcVolumeInfo.getPoolId()); _volumeDao.update(srcVolumeInfo.getId(), volumeVO); @@ -2348,11 +2352,22 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { volumeVO.setFormat(ImageFormat.QCOW2); volumeVO.setLastId(srcVolumeInfo.getId()); + if (Objects.equals(srcVolumeInfo.getDiskOfferingId(), destVolumeInfo.getDiskOfferingId())) { + StoragePoolVO srcPoolVO = _storagePoolDao.findById(srcVolumeInfo.getPoolId()); + StoragePoolVO destPoolVO = _storagePoolDao.findById(destVolumeInfo.getPoolId()); + if (srcPoolVO != null && destPoolVO != null && + ((srcPoolVO.isShared() && destPoolVO.isLocal()) || (srcPoolVO.isLocal() && destPoolVO.isShared()))) { + Long offeringId = getSuitableDiskOfferingForVolumeOnPool(volumeVO, destPoolVO); + if (offeringId != null) { + volumeVO.setDiskOfferingId(offeringId); + } + } + } + _volumeDao.update(volumeVO.getId(), volumeVO); _volumeService.copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(Event.OperationSuccessed, null, srcVolumeInfo, destVolumeInfo, false); - // Update the volume ID for snapshots on secondary storage if (!_snapshotDao.listByVolumeId(srcVolumeInfo.getId()).isEmpty()) { _snapshotDao.updateVolumeIds(srcVolumeInfo.getId(), destVolumeInfo.getId()); @@ -2394,17 +2409,32 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { } } + private Long getSuitableDiskOfferingForVolumeOnPool(VolumeVO volume, StoragePoolVO pool) { + List diskOfferings = _diskOfferingDao.listAllActiveAndNonComputeDiskOfferings(); + for (DiskOfferingVO diskOffering : diskOfferings) { + try { + if (_volumeApiService.validateConditionsToReplaceDiskOfferingOfVolume(volume, diskOffering, pool)) { + logger.debug("Found suitable disk offering {} for the volume {}", diskOffering, volume); + return diskOffering.getId(); + } + } catch (Exception ignore) { + } + } + logger.warn("Unable to find suitable disk offering for the volume {}", volume); + return null; + } + private VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePoolVO storagePoolVO) { Long lastPoolId = volume.getPoolId(); VolumeVO newVol = new VolumeVO(volume); - newVol.setInstanceId(null); newVol.setChainInfo(null); newVol.setPath(null); newVol.setFolder(null); newVol.setPodId(storagePoolVO.getPodId()); newVol.setPoolId(storagePoolVO.getId()); + newVol.setPoolType(storagePoolVO.getPoolType()); newVol.setLastPoolId(lastPoolId); newVol.setLastId(volume.getId()); diff --git a/engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategyTest.java b/engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategyTest.java index 67e3ea844d5..e167cc0a965 100755 --- a/engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategyTest.java +++ b/engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategyTest.java @@ -21,20 +21,34 @@ package org.apache.cloudstack.storage.motion; import static org.mockito.Mockito.when; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.never; import static org.mockito.Mockito.any; +import com.cloud.storage.Storage; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePool; +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; +import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope; +import org.apache.cloudstack.engine.subsystem.api.storage.HostScope; +import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager; +import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope; import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.storage.image.store.TemplateObject; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; +import org.apache.cloudstack.storage.volume.VolumeObject; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; @@ -57,6 +71,10 @@ public class AncientDataMotionStrategyTest { StorageManager storageManager; @Mock StoragePool storagePool; + @Mock + StorageCacheManager cacheMgr; + @Mock + ConfigurationDao configDao; private static final long POOL_ID = 1l; private static final Boolean FULL_CLONE_FLAG = true; @@ -88,4 +106,186 @@ public class AncientDataMotionStrategyTest { verify(dataStoreTO, never()).setFullCloneFlag(any(Boolean.class)); } + @Test + public void testCanBypassSecondaryStorageForDirectDownload() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + Mockito.doReturn(true).when(srcVolumeInfo).isDirectDownload(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageForUnsupportedDataObject() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + + TemplateObject destTemplateInfo = Mockito.spy(new TemplateObject()); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destTemplateInfo); + Assert.assertFalse(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageForUnsupportedSrcPoolType() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore srcDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(srcDataStore).getScope(); + Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.PowerFlex).when(srcVolumeInfo).getStoragePoolType(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore destDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope(); + Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(destVolumeInfo).getStoragePoolType(); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertFalse(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageForUnsupportedDestPoolType() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore srcDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(srcDataStore).getScope(); + Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore destDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope(); + Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.Iscsi).when(destVolumeInfo).getStoragePoolType(); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertFalse(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageWithZoneWideNFSPoolsInSameZone() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore srcDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(srcDataStore).getScope(); + Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore destDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope(); + Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(destVolumeInfo).getStoragePoolType(); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageWithClusterWideNFSPoolsInSameCluster() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore srcDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ClusterScope(5L, 2L, 1L)).when(srcDataStore).getScope(); + Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore destDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ClusterScope(5L, 2L, 1L)).when(destDataStore).getScope(); + Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(destVolumeInfo).getStoragePoolType(); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageWithLocalAndClusterWideNFSPoolsInSameCluster() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore srcDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new HostScope(1L, 1L, 1L)).when(srcDataStore).getScope(); + Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.Filesystem).when(srcVolumeInfo).getStoragePoolType(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore destDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ClusterScope(1L, 1L, 1L)).when(destDataStore).getScope(); + Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(destVolumeInfo).getStoragePoolType(); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + + canBypassSecondaryStorage = (boolean) method.invoke(strategy, destVolumeInfo, srcVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageWithLocalAndZoneWideNFSPoolsInSameZone() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore srcDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new HostScope(1L, 1L, 1L)).when(srcDataStore).getScope(); + Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.Filesystem).when(srcVolumeInfo).getStoragePoolType(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore destDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope(); + Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(destVolumeInfo).getStoragePoolType(); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + + canBypassSecondaryStorage = (boolean) method.invoke(strategy, destVolumeInfo, srcVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + } + + @Test + public void testCanBypassSecondaryStorageWithClusterWideNFSAndZoneWideNFSPoolsInSameZone() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore srcDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ClusterScope(5L, 2L, 1L)).when(srcDataStore).getScope(); + Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType(); + + VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject()); + DataStore destDataStore = Mockito.mock(DataStore.class); + Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope(); + Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore(); + Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(destVolumeInfo).getStoragePoolType(); + + Method method; + method = AncientDataMotionStrategy.class.getDeclaredMethod("canBypassSecondaryStorage", DataObject.class, DataObject.class); + method.setAccessible(true); + boolean canBypassSecondaryStorage = (boolean) method.invoke(strategy, srcVolumeInfo, destVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + + canBypassSecondaryStorage = (boolean) method.invoke(strategy, destVolumeInfo, srcVolumeInfo); + Assert.assertTrue(canBypassSecondaryStorage); + } } diff --git a/engine/storage/image/pom.xml b/engine/storage/image/pom.xml index d286a0ec920..2cdef352e7b 100644 --- a/engine/storage/image/pom.xml +++ b/engine/storage/image/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml index 3ecd86f4f5d..13f0b45dd21 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java index 152c279547c..9868ccdf29a 100644 --- a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java +++ b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java @@ -305,7 +305,7 @@ public class SnapshotTestWithFakeData { } protected SnapshotPolicyVO createSnapshotPolicy(Long volId) { - SnapshotPolicyVO policyVO = new SnapshotPolicyVO(volId, "jfkd", "fdfd", DateUtil.IntervalType.DAILY, 8, true); + SnapshotPolicyVO policyVO = new SnapshotPolicyVO(volId, "jfkd", "fdfd", DateUtil.IntervalType.DAILY, 8, 1, 1, true); policyVO = snapshotPolicyDao.persist(policyVO); return policyVO; } diff --git a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/VolumeServiceTest.java b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/VolumeServiceTest.java index c478e2e7c63..1e6a85ecff4 100644 --- a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/VolumeServiceTest.java +++ b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/VolumeServiceTest.java @@ -87,8 +87,6 @@ import com.cloud.utils.component.ComponentContext; @ContextConfiguration(locations = {"classpath:/storageContext.xml"}) public class VolumeServiceTest extends CloudStackTestNGBase { - // @Inject - // ImageDataStoreProviderManager imageProviderMgr; @Inject TemplateService imageService; @Inject @@ -232,23 +230,7 @@ public class VolumeServiceTest extends CloudStackTestNGBase { DataStore store = createImageStore(); VMTemplateVO image = createImageData(); TemplateInfo template = imageDataFactory.getTemplate(image.getId(), store); - // AsyncCallFuture future = - // imageService.createTemplateAsync(template, store); - // future.get(); template = imageDataFactory.getTemplate(image.getId(), store); - /* - * imageProviderMgr.configure("image Provider", new HashMap()); VMTemplateVO image = createImageData(); - * ImageDataStoreProvider defaultProvider = - * imageProviderMgr.getProvider("DefaultProvider"); - * ImageDataStoreLifeCycle lifeCycle = - * defaultProvider.getLifeCycle(); ImageDataStore store = - * lifeCycle.registerDataStore("defaultHttpStore", new - * HashMap()); - * imageService.registerTemplate(image.getId(), - * store.getImageDataStoreId()); TemplateEntity te = - * imageService.getTemplateEntity(image.getId()); return te; - */ return template; } catch (Exception e) { Assert.fail("failed", e); @@ -333,30 +315,6 @@ public class VolumeServiceTest extends CloudStackTestNGBase { ClusterScope scope = new ClusterScope(clusterId, podId, dcId); lifeCycle.attachCluster(store, scope); - /* - * PrimaryDataStoreProvider provider = - * primaryDataStoreProviderMgr.getDataStoreProvider - * ("sample primary data store provider"); - * primaryDataStoreProviderMgr.configure("primary data store mgr", - * new HashMap()); - * - * List ds = - * primaryStoreDao.findPoolByName(this.primaryName); if (ds.size() - * >= 1) { PrimaryDataStoreVO store = ds.get(0); if - * (store.getRemoved() == null) { return - * provider.getDataStore(store.getId()); } } - * - * - * Map params = new HashMap(); - * params.put("url", this.getPrimaryStorageUrl()); - * params.put("dcId", dcId.toString()); params.put("clusterId", - * clusterId.toString()); params.put("name", this.primaryName); - * PrimaryDataStoreInfo primaryDataStoreInfo = - * provider.registerDataStore(params); PrimaryDataStoreLifeCycle lc - * = primaryDataStoreInfo.getLifeCycle(); ClusterScope scope = new - * ClusterScope(clusterId, podId, dcId); lc.attachCluster(scope); - * return primaryDataStoreInfo; - */ return store; } catch (Exception e) { return null; @@ -376,7 +334,6 @@ public class VolumeServiceTest extends CloudStackTestNGBase { TemplateInfo te = createTemplate(); VolumeVO volume = createVolume(te.getId(), primaryStore.getId()); VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore); - // ve.createVolumeFromTemplate(primaryStore.getId(), new VHD(), te); AsyncCallFuture future = volumeService.createVolumeFromTemplateAsync(vol, primaryStore.getId(), te); try { future.get(); diff --git a/engine/storage/object/pom.xml b/engine/storage/object/pom.xml index 334383070f1..d5f2a793948 100644 --- a/engine/storage/object/pom.xml +++ b/engine/storage/object/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/pom.xml b/engine/storage/pom.xml index d8415d0842b..a2044c6f4f8 100644 --- a/engine/storage/pom.xml +++ b/engine/storage/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/engine/storage/snapshot/pom.xml b/engine/storage/snapshot/pom.xml index 368b1d3c3a6..177ab1069d9 100644 --- a/engine/storage/snapshot/pom.xml +++ b/engine/storage/snapshot/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/DefaultSnapshotStrategy.java b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/DefaultSnapshotStrategy.java index c1981941ac0..c6d89a87014 100644 --- a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/DefaultSnapshotStrategy.java +++ b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/DefaultSnapshotStrategy.java @@ -672,6 +672,12 @@ public class DefaultSnapshotStrategy extends SnapshotStrategyBase { } } + if (CollectionUtils.isNotEmpty(vmSnapshotDao.findByVmAndByType(volumeVO.getInstanceId(), VMSnapshot.Type.DiskAndMemory))) { + logger.debug("DefaultSnapshotStrategy cannot handle snapshot [{}] for volume [{}] as the volume is attached to a VM with disk-and-memory VM snapshots." + + "Restoring the volume snapshot will corrupt any newer disk-and-memory VM snapshots.", snapshot); + return StrategyPriority.CANT_HANDLE; + } + return StrategyPriority.DEFAULT; } 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 a19fcb9eda8..527b7fbeda1 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 @@ -26,14 +26,21 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import com.cloud.hypervisor.Hypervisor; +import com.cloud.storage.Snapshot; +import com.cloud.storage.dao.SnapshotDao; import com.cloud.vm.snapshot.VMSnapshotDetailsVO; import com.cloud.vm.snapshot.dao.VMSnapshotDetailsDao; +import org.apache.cloudstack.backup.BackupManager; +import org.apache.cloudstack.backup.BackupOfferingVO; +import org.apache.cloudstack.backup.BackupProvider; +import org.apache.cloudstack.backup.dao.BackupOfferingDao; import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority; import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions; import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.to.VolumeObjectTO; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import com.cloud.agent.AgentManager; @@ -104,7 +111,16 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot PrimaryDataStoreDao primaryDataStoreDao; @Inject - VMSnapshotDetailsDao vmSnapshotDetailsDao; + private VMSnapshotDetailsDao vmSnapshotDetailsDao; + + @Inject + private BackupManager backupManager; + + @Inject + private BackupOfferingDao backupOfferingDao; + + @Inject + private SnapshotDao snapshotDao; protected static final String KVM_FILE_BASED_STORAGE_SNAPSHOT = "kvmFileBasedStorageSnapshot"; @@ -345,6 +361,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot StoragePool pool = primaryDataStoreDao.findPoolByUUID(volume.getDataStoreUuid()); if (pool != null && pool.getId() != volumeVO.getPoolId()) { volumeVO.setPoolId(pool.getId()); + volumeVO.setPoolType(pool.getPoolType()); } } if (StringUtils.isNotEmpty(volume.getPath())) { @@ -479,24 +496,44 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot @Override public StrategyPriority canHandle(Long vmId, Long rootPoolId, boolean snapshotMemory) { UserVmVO vm = userVmDao.findById(vmId); + String cantHandleLog = String.format("Default VM snapshot cannot handle VM snapshot for [%s]", vm); if (State.Running.equals(vm.getState()) && !snapshotMemory) { - logger.debug("Default VM snapshot strategy cannot handle VM snapshot for [{}] as it is running and its memory will not be affected.", vm); + logger.debug("{} as it is running and its memory will not be affected.", cantHandleLog, vm); return StrategyPriority.CANT_HANDLE; } if (vmHasKvmDiskOnlySnapshot(vm)) { - logger.debug("Default VM snapshot strategy cannot handle VM snapshot for [{}] as it has a disk-only VM snapshot using kvmFileBasedStorageSnapshot strategy." + - "These two strategies are not compatible, as reverting a disk-only VM snapshot will erase newer disk-and-memory VM snapshots.", vm); + logger.debug("{} as it is not compatible with disk-only VM snapshot on KVM. As disk-and-memory snapshots use internal snapshots and disk-only VM snapshots use" + + " external snapshots. When restoring external snapshots, any newer internal snapshots are lost.", cantHandleLog); return StrategyPriority.CANT_HANDLE; } List volumes = volumeDao.findByInstance(vmId); for (VolumeVO volume : volumes) { if (volume.getFormat() != ImageFormat.QCOW2) { - logger.debug("Default VM snapshot strategy cannot handle VM snapshot for [{}] as it has a volume [{}] that is not in the QCOW2 format.", vm, volume); + logger.debug("{} as it has a volume [{}] that is not in the QCOW2 format.", cantHandleLog, vm, volume); + return StrategyPriority.CANT_HANDLE; + } + + if (CollectionUtils.isNotEmpty(snapshotDao.listByVolumeIdAndTypeNotInAndStateNotRemoved(volume.getId(), Snapshot.Type.GROUP))) { + logger.debug("{} as it has a volume [{}] with volume snapshots. As disk-and-memory snapshots use internal snapshots and volume snapshots use external" + + " snapshots. When restoring external snapshots, any newer internal snapshots are lost.", cantHandleLog, volume); return StrategyPriority.CANT_HANDLE; } } + + + BackupOfferingVO backupOfferingVO = backupOfferingDao.findById(vm.getBackupOfferingId()); + if (backupOfferingVO == null) { + return StrategyPriority.DEFAULT; + } + + BackupProvider provider = backupManager.getBackupProvider(backupOfferingVO.getProvider()); + if (!provider.supportsMemoryVmSnapshot()) { + logger.debug("{} as the VM has a backup offering for a provider that is not supported.", cantHandleLog); + return StrategyPriority.CANT_HANDLE; + } + return StrategyPriority.DEFAULT; } @@ -507,7 +544,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot for (VMSnapshotVO vmSnapshotVO : vmSnapshotDao.findByVmAndByType(vm.getId(), VMSnapshot.Type.Disk)) { List vmSnapshotDetails = vmSnapshotDetailsDao.listDetails(vmSnapshotVO.getId()); - if (vmSnapshotDetails.stream().anyMatch(vmSnapshotDetailsVO -> vmSnapshotDetailsVO.getName().equals(KVM_FILE_BASED_STORAGE_SNAPSHOT))) { + if (vmSnapshotDetails.stream().anyMatch(detailsVO -> KVM_FILE_BASED_STORAGE_SNAPSHOT.equals(detailsVO.getName()) || STORAGE_SNAPSHOT.equals(detailsVO.getName()))) { return true; } } diff --git a/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java b/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java index 609a1225118..050c0246aba 100644 --- a/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java +++ b/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java @@ -29,6 +29,8 @@ import java.util.UUID; import javax.inject.Inject; +import org.apache.cloudstack.backup.BackupManager; +import org.apache.cloudstack.backup.dao.BackupOfferingDao; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; @@ -235,7 +237,6 @@ public class VMSnapshotStrategyKVMTest extends TestCase{ when(vol.getDataStore()).thenReturn(dataStore); when(snapshotVO.getId()).thenReturn(1L); when(_snapshotService.revertSnapshot(snapshotVO.getId())).thenReturn(snap); - // testFindSnapshotByName(name); vmStrategy.revertDiskSnapshot(vmSnapshot); } @@ -431,5 +432,15 @@ public class VMSnapshotStrategyKVMTest extends TestCase{ public VMSnapshotDetailsDao vmSnapshotDetailsDao () { return Mockito.mock(VMSnapshotDetailsDao.class); } + + @Bean + public BackupOfferingDao backupOfferingDao() { + return Mockito.mock(BackupOfferingDao.class); + } + + @Bean + public BackupManager backupManager() { + return Mockito.mock(BackupManager.class); + } } } diff --git a/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyTest.java b/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyTest.java index 829ca5ade39..a20b52fac2d 100644 --- a/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyTest.java +++ b/engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyTest.java @@ -25,7 +25,10 @@ import java.util.List; import javax.inject.Inject; +import com.cloud.storage.dao.SnapshotDao; import com.cloud.vm.snapshot.dao.VMSnapshotDetailsDao; +import org.apache.cloudstack.backup.BackupManager; +import org.apache.cloudstack.backup.dao.BackupOfferingDao; import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; @@ -318,5 +321,25 @@ public class VMSnapshotStrategyTest extends TestCase { public PrimaryDataStoreDao primaryDataStoreDao() { return Mockito.mock(PrimaryDataStoreDao.class); } + + @Bean + public BackupOfferingDao backupOfferingDao() { + return Mockito.mock(BackupOfferingDao.class); + } + + @Bean + public VMSnapshotDetailsDao VMSnapshotDetailsDao() { + return Mockito.mock(VMSnapshotDetailsDao.class); + } + + @Bean + public SnapshotDao snapshotDao() { + return Mockito.mock(SnapshotDao.class); + } + + @Bean + public BackupManager backupManager() { + return Mockito.mock(BackupManager.class); + } } } diff --git a/engine/storage/src/main/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java b/engine/storage/src/main/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java index da6b1cfede3..061d18dc376 100644 --- a/engine/storage/src/main/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java +++ b/engine/storage/src/main/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java @@ -232,7 +232,13 @@ public class DefaultEndPointSelector implements EndPointSelector { // assumption, at least one of scope should be zone, find the least // scope - if (srcScope.getScopeType() != ScopeType.ZONE) { + if (srcScope.getScopeType() == ScopeType.HOST) { + selectedScope = srcScope; + poolId = srcStore.getId(); + } else if (destScope.getScopeType() == ScopeType.HOST) { + selectedScope = destScope; + poolId = destStore.getId(); + } else if (srcScope.getScopeType() != ScopeType.ZONE) { selectedScope = srcScope; poolId = srcStore.getId(); } else if (destScope.getScopeType() != ScopeType.ZONE) { diff --git a/engine/storage/volume/pom.xml b/engine/storage/volume/pom.xml index 3c9d3c246f2..5422218ef02 100644 --- a/engine/storage/volume/pom.xml +++ b/engine/storage/volume/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java index 6a10c26cc0b..d0184359c8b 100644 --- a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java +++ b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java @@ -334,6 +334,7 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore { VolumeVO vol = volumeDao.findById(obj.getId()); if (vol != null) { vol.setPoolId(getId()); + vol.setPoolType(getPoolType()); volumeDao.update(vol.getId(), vol); } } diff --git a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java index 53fa21f3a79..5c2a774f8a2 100644 --- a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java +++ b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java @@ -30,6 +30,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; @@ -46,6 +48,8 @@ public class VolumeDataFactoryImpl implements VolumeDataFactory { DataStoreManager storeMgr; @Inject VMTemplateDao templateDao; + @Inject + PrimaryDataStoreDao storagePoolDao; @Override public VolumeInfo getVolume(long volumeId, DataStore store) { @@ -92,6 +96,10 @@ public class VolumeDataFactoryImpl implements VolumeDataFactory { vol = VolumeObject.getVolumeObject(store, volumeVO); } else { DataStore store = storeMgr.getDataStore(volumeVO.getPoolId(), DataStoreRole.Primary); + StoragePoolVO pool = storagePoolDao.findById(volumeVO.getPoolId()); + if (pool != null) { + volumeVO.setPoolType(pool.getPoolType()); + } vol = VolumeObject.getVolumeObject(store, volumeVO); } if (vol.getTemplateId() != null) { 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 e2264629952..57d9a0aec1f 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 @@ -722,7 +722,6 @@ public class VolumeServiceImpl implements VolumeService { VolumeApiResult res = new VolumeApiResult(volumeInfo); if (result.isSuccess()) { - // volumeInfo.processEvent(Event.OperationSuccessed, result.getAnswer()); VolumeVO volume = volDao.findById(volumeInfo.getId()); CopyCmdAnswer answer = (CopyCmdAnswer)result.getAnswer(); diff --git a/engine/userdata/cloud-init/pom.xml b/engine/userdata/cloud-init/pom.xml index 2a6b61e40c1..a49a8ece0ce 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/userdata/pom.xml b/engine/userdata/pom.xml index 48788ddf8a7..56c181ae060 100644 --- a/engine/userdata/pom.xml +++ b/engine/userdata/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/extensions/MaaS/maas.py b/extensions/MaaS/maas.py new file mode 100755 index 00000000000..3d97cedb02f --- /dev/null +++ b/extensions/MaaS/maas.py @@ -0,0 +1,263 @@ +#!/usr/bin/env python3 +# 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. + +import sys +import json +import time +from requests_oauthlib import OAuth1Session + + +def fail(message): + print(json.dumps({"error": message})) + sys.exit(1) + + +def succeed(data): + print(json.dumps(data)) + sys.exit(0) + + +class MaasManager: + def __init__(self, config_path): + self.config_path = config_path + self.data = self.parse_json() + self.session = self.init_session() + + def parse_json(self): + try: + with open(self.config_path, "r") as f: + json_data = json.load(f) + + extension = json_data.get("externaldetails", {}).get("extension", {}) + host = json_data.get("externaldetails", {}).get("host", {}) + vm = json_data.get("externaldetails", {}).get("virtualmachine", {}) + + endpoint = host.get("endpoint") or extension.get("endpoint") + apikey = host.get("apikey") or extension.get("apikey") + + details = json_data.get("cloudstack.vm.details", {}).get("details", {}) + + os_name = details.get("os") or vm.get("os") + architecture = details.get("architecture") or vm.get("architecture") + distro_series = details.get("distro_series") or vm.get("distro_series") + + if not endpoint or not apikey: + fail("Missing MAAS endpoint or apikey") + + if not endpoint.startswith("http://") and not endpoint.startswith("https://"): + endpoint = "http://" + endpoint + endpoint = endpoint.rstrip("/") + + parts = apikey.split(":") + if len(parts) != 3: + fail("Invalid apikey format. Expected consumer:token:secret") + + consumer, token, secret = parts + + system_id = details.get("maas_system_id") or vm.get("maas_system_id", "") + + vm_name = vm.get("vm_name") or json_data.get("cloudstack.vm.details", {}).get("name") + if not vm_name: + vm_name = f"cs-{system_id}" if system_id else "cs-unknown" + + return { + "endpoint": endpoint, + "consumer": consumer, + "token": token, + "secret": secret, + "distro_series": distro_series or "ubuntu/focal", + "os": os_name, + "architecture": architecture, + "system_id": system_id, + "vm_name": vm_name, + } + except Exception as e: + fail(f"Error parsing JSON: {str(e)}") + + def init_session(self): + return OAuth1Session( + self.data["consumer"], + resource_owner_key=self.data["token"], + resource_owner_secret=self.data["secret"], + ) + + def call_maas(self, method, path, data=None, ignore_404=False): + if not path.startswith("/"): + path = "/" + path + url = f"{self.data['endpoint']}:5240/MAAS/api/2.0{path}" + resp = self.session.request(method, url, data=data) + + if resp.status_code == 404 and ignore_404: + return None + + if not resp.ok: + fail(f"MAAS API error: {resp.status_code} {resp.text}") + + try: + return resp.json() if resp.text else {} + except ValueError: + return {} + + def prepare(self): + machines = self.call_maas("GET", "/machines/") + ready = [m for m in machines if m.get("status_name") == "Ready"] + if not ready: + fail("No Ready machines available") + + sysid = self.data.get("system_id") + + if sysid: + match = next((m for m in ready if m["system_id"] == sysid), None) + if not match: + fail(f"Provided system_id '{sysid}' not found among Ready machines") + system = match + else: + system = ready[0] + + system_id = system["system_id"] + mac = system.get("interface_set", [{}])[0].get("mac_address") + hostname = system.get("hostname", "") + + if not mac: + fail("No MAC address found") + + # Load original JSON so we can update nics + with open(self.config_path, "r") as f: + json_data = json.load(f) + + if json_data.get("cloudstack.vm.details", {}).get("nics"): + json_data["cloudstack.vm.details"]["nics"][0]["mac"] = mac + + console_url = f"http://{self.data['endpoint'].replace('http://','').replace('https://','')}:5240/MAAS/r/machine/{system_id}/summary" + + result = { + "nics": json_data["cloudstack.vm.details"]["nics"], + "details": { + "External:mac_address": mac, + "External:maas_system_id": system_id, + "External:hostname": hostname, + "External:console_url": console_url, + }, + } + succeed(result) + + def create(self): + sysid = self.data.get("system_id") + if not sysid: + fail("system_id missing for create") + + ds = self.data.get("distro_series", None) + os_name = self.data.get("os") + arch = self.data.get("architecture") + + deploy_payload = {"op": "deploy"} + + if os_name or arch: + if os_name: + deploy_payload["os"] = os_name + if arch: + deploy_payload["architecture"] = arch + if ds: + deploy_payload["distro_series"] = ds + else: + deploy_payload["distro_series"] = ds or "ubuntu/focal" + + deploy_payload["net-setup-method"] = "curtin" + + self.call_maas("POST", f"/machines/{sysid}/", deploy_payload) + + succeed({"status": "success", "message": "Instance created", "requested": deploy_payload}) + + def delete(self): + sysid = self.data.get("system_id") + if not sysid: + fail("system_id missing for delete") + + self.call_maas("POST", f"/machines/{sysid}/", {"op": "release"}, ignore_404=True) + succeed({"status": "success", "message": f"Instance deleted or not found ({sysid})"}) + + def start(self): + sysid = self.data.get("system_id") + if not sysid: + fail("system_id missing for start") + self.call_maas("POST", f"/machines/{sysid}/", {"op": "power_on"}) + succeed({"status": "success", "power_state": "PowerOn"}) + + def stop(self): + sysid = self.data.get("system_id") + if not sysid: + fail("system_id missing for stop") + self.call_maas("POST", f"/machines/{sysid}/", {"op": "power_off"}) + succeed({"status": "success", "power_state": "PowerOff"}) + + def reboot(self): + sysid = self.data.get("system_id") + if not sysid: + fail("system_id missing for reboot") + + self.call_maas("POST", f"/machines/{sysid}/", {"op": "power_off"}) + time.sleep(5) + self.call_maas("POST", f"/machines/{sysid}/", {"op": "power_on"}) + + succeed({"status": "success", "power_state": "PowerOn", "message": "Reboot completed"}) + + def status(self): + sysid = self.data.get("system_id") + if not sysid: + fail("system_id missing for status") + resp = self.call_maas("GET", f"/machines/{sysid}/") + state = resp.get("power_state", "") + if state == "on": + mapped = "PowerOn" + elif state == "off": + mapped = "PowerOff" + else: + mapped = "PowerUnknown" + succeed({"status": "success", "power_state": mapped}) + + +def main(): + if len(sys.argv) < 3: + fail("Usage: maas.py ") + + action = sys.argv[1].lower() + json_file = sys.argv[2] + + try: + manager = MaasManager(json_file) + except FileNotFoundError: + fail(f"JSON file not found: {json_file}") + + actions = { + "prepare": manager.prepare, + "create": manager.create, + "delete": manager.delete, + "start": manager.start, + "stop": manager.stop, + "reboot": manager.reboot, + "status": manager.status, + } + + if action not in actions: + fail("Invalid action") + + actions[action]() + + +if __name__ == "__main__": + main() diff --git a/extensions/Proxmox/proxmox.sh b/extensions/Proxmox/proxmox.sh index 23f30311e2b..fc27f2f3075 100755 --- a/extensions/Proxmox/proxmox.sh +++ b/extensions/Proxmox/proxmox.sh @@ -39,6 +39,10 @@ parse_json() { "template_id": (.externaldetails.virtualmachine.template_id // ""), "template_type": (.externaldetails.virtualmachine.template_type // ""), "iso_path": (.externaldetails.virtualmachine.iso_path // ""), + "iso_os_type": (.externaldetails.virtualmachine.iso_os_type // "l26"), + "disk_size_gb": (.externaldetails.virtualmachine.disk_size_gb // "64"), + "storage": (.externaldetails.virtualmachine.storage // "local-lvm"), + "is_full_clone": (.externaldetails.virtualmachine.is_full_clone // "false"), "snap_name": (.parameters.snap_name // ""), "snap_description": (.parameters.snap_description // ""), "snap_save_memory": (.parameters.snap_save_memory // ""), @@ -212,9 +216,9 @@ create() { local data="vmid=$vmid" data+="&name=$vm_name" data+="&ide2=$(urlencode "$iso_path,media=cdrom")" - data+="&ostype=l26" + data+="&ostype=$iso_os_type" data+="&scsihw=virtio-scsi-single" - data+="&scsi0=$(urlencode "local-lvm:64,iothread=on")" + data+="&scsi0=$(urlencode "$storage:$disk_size_gb,iothread=on")" data+="&sockets=1" data+="&cores=$vmcpus" data+="&numa=0" @@ -228,6 +232,8 @@ create() { check_required_fields template_id local data="newid=$vmid" data+="&name=$vm_name" + clone_flag=$(( is_full_clone == "true" )) + data+="&storage=$storage&full=$clone_flag" execute_and_wait POST "/nodes/${node}/qemu/${template_id}/clone" "$data" cleanup_vm=1 diff --git a/framework/agent-lb/pom.xml b/framework/agent-lb/pom.xml index fb57d0b8135..b9d728f9bdc 100644 --- a/framework/agent-lb/pom.xml +++ b/framework/agent-lb/pom.xml @@ -24,7 +24,7 @@ cloudstack-framework org.apache.cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/ca/pom.xml b/framework/ca/pom.xml index 118abcfda12..b090dbe40df 100644 --- a/framework/ca/pom.xml +++ b/framework/ca/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/cluster/pom.xml b/framework/cluster/pom.xml index 806236c5a4e..2dd28e8e628 100644 --- a/framework/cluster/pom.xml +++ b/framework/cluster/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/config/pom.xml b/framework/config/pom.xml index a289095431b..dea2f14420e 100644 --- a/framework/config/pom.xml +++ b/framework/config/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/db/pom.xml b/framework/db/pom.xml index dbc22be18ee..04d0fcc7e89 100644 --- a/framework/db/pom.xml +++ b/framework/db/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/db/src/main/java/com/cloud/utils/db/GlobalLock.java b/framework/db/src/main/java/com/cloud/utils/db/GlobalLock.java index 523f90b2866..b01ddaf6853 100644 --- a/framework/db/src/main/java/com/cloud/utils/db/GlobalLock.java +++ b/framework/db/src/main/java/com/cloud/utils/db/GlobalLock.java @@ -27,22 +27,23 @@ import org.apache.logging.log4j.LogManager; import com.cloud.utils.Profiler; -// -// Wrapper class for global database lock to reduce contention for database connections from within process -// -// Example of using dynamic named locks -// -// GlobalLock lock = GlobalLock.getInternLock("some table name" + rowId); -// -// if(lock.lock()) { -// try { -// do something -// } finally { -// lock.unlock(); -// } -// } -// lock.releaseRef(); -// +/** + * Wrapper class for global database lock to reduce contention for database connections from within process + * This class is used to acquire a global lock for a specific operation, identified by a unique name. + * Example of using dynamic named locks + *

+ * GlobalLock lock = GlobalLock.getInternLock("some table name" + rowId); + * + * if(lock.lock()) { + * try { + * do something + * } finally { + * lock.unlock(); + * } + * } + * lock.releaseRef(); + *

+ */ public class GlobalLock { protected Logger logger = LogManager.getLogger(getClass()); diff --git a/framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java b/framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java index 18a90749e49..42a8b27fa85 100644 --- a/framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java +++ b/framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; +import java.util.Objects; import java.util.concurrent.atomic.AtomicLong; import javax.sql.DataSource; @@ -56,14 +57,12 @@ import com.zaxxer.hikari.HikariDataSource; /** * Transaction abstracts away the Connection object in JDBC. It allows the * following things that the Connection object does not. - * * 1. Transaction can be started at an entry point and whether the DB * actions should be auto-commit or not determined at that point. * 2. DB Connection is allocated only when it is needed. * 3. Code does not need to know if a transaction has been started or not. * It just starts/ends a transaction and we resolve it correctly with * the previous actions. - * * Note that this class is not synchronous but it doesn't need to be because * it is stored with TLS and is one per thread. Use appropriately. */ @@ -73,7 +72,7 @@ public class TransactionLegacy implements Closeable { protected Logger lockLogger = LogManager.getLogger(Transaction.class.getName() + "." + "Lock"); protected static Logger CONN_LOGGER = LogManager.getLogger(Transaction.class.getName() + "." + "Connection"); - private static final ThreadLocal tls = new ThreadLocal(); + private static final ThreadLocal tls = new ThreadLocal<>(); private static final String START_TXN = "start_txn"; private static final String CURRENT_TXN = "current_txn"; private static final String CREATE_TXN = "create_txn"; @@ -103,7 +102,7 @@ public class TransactionLegacy implements Closeable { private final LinkedList _stack; private long _id; - private final LinkedList> _lockTimes = new LinkedList>(); + private final LinkedList> _lockTimes = new LinkedList<>(); private String _name; private Connection _conn; @@ -160,7 +159,7 @@ public class TransactionLegacy implements Closeable { TransactionLegacy txn = tls.get(); if (txn == null) { if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Creating the transaction: " + name); + LOGGER.trace("Creating the transaction: {}", name); } txn = new TransactionLegacy(name, false, databaseId); tls.set(txn); @@ -206,7 +205,7 @@ public class TransactionLegacy implements Closeable { public void registerLock(String sql) { if (_txn && lockLogger.isDebugEnabled()) { - Pair time = new Pair(sql, System.currentTimeMillis()); + Pair time = new Pair<>(sql, System.currentTimeMillis()); _lockTimes.add(time); } } @@ -218,7 +217,7 @@ public class TransactionLegacy implements Closeable { public static Connection getStandaloneConnectionWithException() throws SQLException { Connection conn = s_ds.getConnection(); if (CONN_LOGGER.isTraceEnabled()) { - CONN_LOGGER.trace("Retrieving a standalone connection: dbconn" + System.identityHashCode(conn)); + CONN_LOGGER.trace("Retrieving a standalone connection: dbconn{}", System.identityHashCode(conn)); } return conn; } @@ -236,7 +235,7 @@ public class TransactionLegacy implements Closeable { try { Connection conn = s_usageDS.getConnection(); if (CONN_LOGGER.isTraceEnabled()) { - CONN_LOGGER.trace("Retrieving a standalone connection for usage: dbconn" + System.identityHashCode(conn)); + CONN_LOGGER.trace("Retrieving a standalone connection for usage: dbconn{}", System.identityHashCode(conn)); } return conn; } catch (SQLException e) { @@ -249,7 +248,7 @@ public class TransactionLegacy implements Closeable { try { Connection conn = s_simulatorDS.getConnection(); if (CONN_LOGGER.isTraceEnabled()) { - CONN_LOGGER.trace("Retrieving a standalone connection for simulator: dbconn" + System.identityHashCode(conn)); + CONN_LOGGER.trace("Retrieving a standalone connection for simulator: dbconn{}", System.identityHashCode(conn)); } return conn; } catch (SQLException e) { @@ -266,7 +265,7 @@ public class TransactionLegacy implements Closeable { Iterator it = _stack.descendingIterator(); while (it.hasNext()) { StackElement element = it.next(); - if (element.type == ATTACHMENT) { + if (Objects.equals(element.type, ATTACHMENT)) { TransactionAttachment att = (TransactionAttachment)element.ref; if (name.equals(att.getName())) { it.remove(); @@ -308,7 +307,7 @@ public class TransactionLegacy implements Closeable { } // relax stack structure for several places that @DB required injection is not in place - LOGGER.warn("Non-standard stack context that Transaction context is manaully placed into the calling chain. Stack chain: " + sb); + LOGGER.warn("Non-standard stack context that Transaction context is manaully placed into the calling chain. Stack chain: {}", sb); return true; } @@ -344,7 +343,7 @@ public class TransactionLegacy implements Closeable { private TransactionLegacy(final String name, final boolean forLocking, final short databaseId) { _name = name; _conn = null; - _stack = new LinkedList(); + _stack = new LinkedList<>(); _txn = false; _dbId = databaseId; _id = s_id.incrementAndGet(); @@ -372,7 +371,7 @@ public class TransactionLegacy implements Closeable { final StringBuilder str = new StringBuilder((_name != null ? _name : "")); str.append(" : "); for (final StackElement se : _stack) { - if (se.type == CURRENT_TXN) { + if (Objects.equals(se.type, CURRENT_TXN)) { str.append(se.ref).append(", "); } } @@ -406,7 +405,7 @@ public class TransactionLegacy implements Closeable { @Deprecated public void start() { if (LOGGER.isTraceEnabled()) { - LOGGER.trace("txn: start requested by: " + buildName()); + LOGGER.trace("txn: start requested by: {}", buildName()); } _stack.push(new StackElement(START_TXN, null)); @@ -434,7 +433,7 @@ public class TransactionLegacy implements Closeable { if (_stmt != null) { try { if (stmtLogger.isTraceEnabled()) { - stmtLogger.trace("Closing: " + _stmt.toString()); + stmtLogger.trace("Closing: {}", _stmt.toString()); } try { ResultSet rs = _stmt.getResultSet(); @@ -446,7 +445,7 @@ public class TransactionLegacy implements Closeable { } _stmt.close(); } catch (final SQLException e) { - stmtLogger.trace("Unable to close statement: " + _stmt.toString()); + stmtLogger.trace("Unable to close statement: {}", _stmt.toString()); } finally { _stmt = null; } @@ -474,7 +473,7 @@ public class TransactionLegacy implements Closeable { final Connection conn = getConnection(); final PreparedStatement pstmt = conn.prepareStatement(sql); if (stmtLogger.isTraceEnabled()) { - stmtLogger.trace("Preparing: " + sql); + stmtLogger.trace("Preparing: {}", sql); } return pstmt; } @@ -494,7 +493,7 @@ public class TransactionLegacy implements Closeable { final Connection conn = getConnection(); final PreparedStatement pstmt = conn.prepareStatement(sql, autoGeneratedKeys); if (stmtLogger.isTraceEnabled()) { - stmtLogger.trace("Preparing: " + sql); + stmtLogger.trace("Preparing: {}", sql); } closePreviousStatement(); _stmt = pstmt; @@ -516,7 +515,7 @@ public class TransactionLegacy implements Closeable { final Connection conn = getConnection(); final PreparedStatement pstmt = conn.prepareStatement(sql, columnNames); if (stmtLogger.isTraceEnabled()) { - stmtLogger.trace("Preparing: " + sql); + stmtLogger.trace("Preparing: {}", sql); } closePreviousStatement(); _stmt = pstmt; @@ -537,7 +536,7 @@ public class TransactionLegacy implements Closeable { final Connection conn = getConnection(); final PreparedStatement pstmt = conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); if (stmtLogger.isTraceEnabled()) { - stmtLogger.trace("Preparing: " + sql); + stmtLogger.trace("Preparing: {}", sql); } closePreviousStatement(); _stmt = pstmt; @@ -546,7 +545,6 @@ public class TransactionLegacy implements Closeable { /** * Returns the db connection. - * * Note: that you can call getConnection() but beaware that * all prepare statements from the Connection are not garbage * collected! @@ -595,8 +593,7 @@ public class TransactionLegacy implements Closeable { // _stack.push(new StackElement(CREATE_CONN, null)); if (CONN_LOGGER.isTraceEnabled()) { - CONN_LOGGER.trace("Creating a DB connection with " + (_txn ? " txn: " : " no txn: ") + " for " + _dbId + ": dbconn" + System.identityHashCode(_conn) + - ". Stack: " + buildName()); + CONN_LOGGER.trace("Creating a DB connection with {} for {}: dbconn{}. Stack: {}", _txn ? " txn: " : " no txn: ", _dbId, System.identityHashCode(_conn), buildName()); } } else { LOGGER.trace("conn: Using existing DB connection"); @@ -615,33 +612,33 @@ public class TransactionLegacy implements Closeable { } protected boolean takeOver(final String name, final boolean create) { - if (_stack.size() != 0) { + if (!_stack.isEmpty()) { if (!create) { // If it is not a create transaction, then let's just use the current one. if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Using current transaction: " + toString()); + LOGGER.trace("Using current transaction: {}", this); } mark(name); return false; } final StackElement se = _stack.getFirst(); - if (se.type == CREATE_TXN) { + if (Objects.equals(se.type, CREATE_TXN)) { // This create is called inside of another create. Which is ok? // We will let that create be responsible for cleaning up. if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Create using current transaction: " + toString()); + LOGGER.trace("Create using current transaction: {}", this); } mark(name); return false; } - LOGGER.warn("Encountered a transaction that has leaked. Cleaning up. " + toString()); + LOGGER.warn("Encountered a transaction that has leaked. Cleaning up. {}", this); cleanup(); } if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Took over the transaction: " + name); + LOGGER.trace("Took over the transaction: {}", name); } _stack.push(new StackElement(create ? CREATE_TXN : CURRENT_TXN, name)); _name = name; @@ -671,7 +668,7 @@ public class TransactionLegacy implements Closeable { public void close() { removeUpTo(CURRENT_TXN, null); - if (_stack.size() == 0) { + if (_stack.isEmpty()) { LOGGER.trace("Transaction is done"); cleanup(); } @@ -687,7 +684,7 @@ public class TransactionLegacy implements Closeable { public boolean close(final String name) { if (_name == null) { // Already cleaned up. if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Already cleaned up." + buildName()); + LOGGER.trace("Already cleaned up.{}", buildName()); } return true; } @@ -698,7 +695,7 @@ public class TransactionLegacy implements Closeable { } if (LOGGER.isDebugEnabled() && _stack.size() > 2) { - LOGGER.debug("Transaction is not closed properly: " + toString() + ". Called by " + buildName()); + LOGGER.debug("Transaction is not closed properly: {}. Called by {}", this, buildName()); } cleanup(); @@ -714,7 +711,7 @@ public class TransactionLegacy implements Closeable { protected void clearLockTimes() { if (lockLogger.isDebugEnabled()) { for (Pair time : _lockTimes) { - lockLogger.trace("SQL " + time.first() + " took " + (System.currentTimeMillis() - time.second())); + lockLogger.trace("SQL {} took {}", time.first(), System.currentTimeMillis() - time.second()); } _lockTimes.clear(); } @@ -722,14 +719,14 @@ public class TransactionLegacy implements Closeable { public boolean commit() { if (!_txn) { - LOGGER.warn("txn: Commit called when it is not a transaction: " + buildName()); + LOGGER.warn("txn: Commit called when it is not a transaction: {}", buildName()); return false; } Iterator it = _stack.iterator(); while (it.hasNext()) { StackElement st = it.next(); - if (st.type == START_TXN) { + if (Objects.equals(st.type, START_TXN)) { it.remove(); break; } @@ -737,7 +734,7 @@ public class TransactionLegacy implements Closeable { if (hasTxnInStack()) { if (LOGGER.isTraceEnabled()) { - LOGGER.trace("txn: Not committing because transaction started elsewhere: " + buildName() + " / " + toString()); + LOGGER.trace("txn: Not committing because transaction started elsewhere: {} / {}", buildName(), this); } return false; } @@ -746,7 +743,7 @@ public class TransactionLegacy implements Closeable { try { if (_conn != null) { _conn.commit(); - LOGGER.trace("txn: DB Changes committed. Time = " + (System.currentTimeMillis() - _txnTime)); + LOGGER.trace("txn: DB Changes committed. Time = {}", System.currentTimeMillis() - _txnTime); clearLockTimes(); closeConnection(); } @@ -773,7 +770,7 @@ public class TransactionLegacy implements Closeable { // we should only close db connection when it is not user managed if (_dbId != CONNECTED_DB) { if (CONN_LOGGER.isTraceEnabled()) { - CONN_LOGGER.trace("Closing DB connection: dbconn" + System.identityHashCode(_conn)); + CONN_LOGGER.trace("Closing DB connection: dbconn{}", System.identityHashCode(_conn)); } _conn.close(); _conn = null; @@ -797,13 +794,13 @@ public class TransactionLegacy implements Closeable { break; } - if (item.type == CURRENT_TXN) { + if (Objects.equals(item.type, CURRENT_TXN)) { if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Releasing the current txn: " + (item.ref != null ? item.ref : "")); + LOGGER.trace("Releasing the current txn: {}", item.ref != null ? item.ref : ""); } - } else if (item.type == CREATE_CONN) { + } else if (Objects.equals(item.type, CREATE_CONN)) { closeConnection(); - } else if (item.type == START_TXN) { + } else if (Objects.equals(item.type, START_TXN)) { if (item.ref == null) { rollback = true; } else { @@ -814,10 +811,10 @@ public class TransactionLegacy implements Closeable { LOGGER.warn("Unable to rollback Txn.", e); } } - } else if (item.type == STATEMENT) { + } else if (Objects.equals(item.type, STATEMENT)) { try { if (stmtLogger.isTraceEnabled()) { - stmtLogger.trace("Closing: " + ref.toString()); + stmtLogger.trace("Closing: {}", ref.toString()); } Statement stmt = (Statement)ref; try { @@ -830,17 +827,17 @@ public class TransactionLegacy implements Closeable { } stmt.close(); } catch (final SQLException e) { - stmtLogger.trace("Unable to close statement: " + item); + stmtLogger.trace("Unable to close statement: {}", item); } - } else if (item.type == ATTACHMENT) { + } else if (Objects.equals(item.type, ATTACHMENT)) { TransactionAttachment att = (TransactionAttachment)item.ref; if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Cleaning up " + att.getName()); + LOGGER.trace("Cleaning up {}", att.getName()); } att.cleanup(); } } catch (Exception e) { - LOGGER.error("Unable to clean up " + item, e); + LOGGER.error("Unable to clean up {}", item, e); } } @@ -853,7 +850,7 @@ public class TransactionLegacy implements Closeable { closePreviousStatement(); if (!_txn) { if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Rollback called for " + _name + " when there's no transaction: " + buildName()); + LOGGER.trace("Rollback called for {} when there's no transaction: {}", _name, buildName()); } return; } @@ -862,7 +859,7 @@ public class TransactionLegacy implements Closeable { try { if (_conn != null) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Rolling back the transaction: Time = " + (System.currentTimeMillis() - _txnTime) + " Name = " + _name + "; called by " + buildName()); + LOGGER.debug("Rolling back the transaction: Time = {} Name = {}; called by {}", System.currentTimeMillis() - _txnTime, _name, buildName()); } _conn.rollback(); } @@ -879,7 +876,7 @@ public class TransactionLegacy implements Closeable { _conn.rollback(sp); } } catch (SQLException e) { - LOGGER.warn("Unable to rollback to savepoint " + sp); + LOGGER.warn("Unable to rollback to savepoint {}", sp); } if (!hasTxnInStack()) { @@ -892,7 +889,7 @@ public class TransactionLegacy implements Closeable { Iterator it = _stack.iterator(); while (it.hasNext()) { StackElement st = it.next(); - if (st.type == START_TXN) { + if (Objects.equals(st.type, START_TXN)) { if (st.ref == null) { it.remove(); } else { @@ -943,7 +940,7 @@ public class TransactionLegacy implements Closeable { Iterator it = _stack.iterator(); while (it.hasNext()) { StackElement se = it.next(); - if (se.type == START_TXN && se.ref == sp) { + if (Objects.equals(se.type, START_TXN) && se.ref == sp) { return true; } } @@ -960,7 +957,7 @@ public class TransactionLegacy implements Closeable { Iterator it = _stack.iterator(); while (it.hasNext()) { StackElement se = it.next(); - if (se.type == START_TXN) { + if (Objects.equals(se.type, START_TXN)) { it.remove(); if (se.ref == sp) { return; @@ -993,7 +990,7 @@ public class TransactionLegacy implements Closeable { @Override protected void finalize() throws Throwable { - if (!(_conn == null && (_stack == null || _stack.size() == 0))) { + if (!(_conn == null && (_stack == null || _stack.isEmpty()))) { assert (false) : "Oh Alex oh alex...something is wrong with how we're doing this"; LOGGER.error("Something went wrong that a transaction is orphaned before db connection is closed"); cleanup(); @@ -1052,11 +1049,11 @@ public class TransactionLegacy implements Closeable { @SuppressWarnings({"rawtypes", "unchecked"}) public static void initDataSource(Properties dbProps) { try { - if (dbProps.size() == 0) + if (dbProps.isEmpty()) return; - s_dbHAEnabled = Boolean.valueOf(dbProps.getProperty("db.ha.enabled")); - LOGGER.info("Is Data Base High Availiability enabled? Ans : " + s_dbHAEnabled); + s_dbHAEnabled = Boolean.parseBoolean(dbProps.getProperty("db.ha.enabled")); + LOGGER.info("Is Data Base High Availiability enabled? Ans : {}", s_dbHAEnabled); String loadBalanceStrategy = dbProps.getProperty("db.ha.loadBalanceStrategy"); // FIXME: If params are missing...default them???? final Integer cloudMaxActive = parseNumber(dbProps.getProperty("db.cloud.maxActive"), Integer.class); @@ -1082,7 +1079,7 @@ public class TransactionLegacy implements Closeable { } else if (cloudIsolationLevel.equalsIgnoreCase("readuncommitted")) { isolationLevel = Connection.TRANSACTION_READ_UNCOMMITTED; } else { - LOGGER.warn("Unknown isolation level " + cloudIsolationLevel + ". Using read uncommitted"); + LOGGER.warn("Unknown isolation level {}. Using read uncommitted", cloudIsolationLevel); } final boolean cloudTestOnBorrow = Boolean.parseBoolean(dbProps.getProperty("db.cloud.testOnBorrow")); @@ -1190,16 +1187,16 @@ public class TransactionLegacy implements Closeable { driver = dbProps.getProperty(String.format("db.%s.driver", schema)); connectionUri = getPropertiesAndBuildConnectionUri(dbProps, loadBalanceStrategy, driver, useSSL, schema); } else { - LOGGER.warn(String.format("db.%s.uri was set, ignoring the following properties for schema %s of db.properties: [host, port, name, driver, autoReconnect, url.params," + LOGGER.warn("db.{}.uri was set, ignoring the following properties for schema {} of db.properties: [host, port, name, driver, autoReconnect, url.params," + " replicas, ha.loadBalanceStrategy, ha.enable, failOverReadOnly, reconnectAtTxEnd, autoReconnectForPools, secondsBeforeRetrySource, queriesBeforeRetrySource, " - + "initialTimeout].", schema, schema)); + + "initialTimeout].", schema, schema); String[] splitUri = propertyUri.split(":"); driver = String.format("%s:%s", splitUri[0], splitUri[1]); connectionUri = propertyUri; } - LOGGER.info(String.format("Using the following URI to connect to %s database [%s].", schema, connectionUri)); + LOGGER.info("Using the following URI to connect to {} database [{}].", schema, connectionUri); return new Pair<>(connectionUri, driver); } @@ -1215,7 +1212,7 @@ public class TransactionLegacy implements Closeable { if (s_dbHAEnabled) { dbHaParams = getDBHAParams(schema, dbProps); replicas = dbProps.getProperty(String.format("db.%s.replicas", schema)); - LOGGER.info(String.format("The replicas configured for %s data base are %s.", schema, replicas)); + LOGGER.info("The replicas configured for {} data base are {}.", schema, replicas); } return buildConnectionUri(loadBalanceStrategy, driver, useSSL, host, replicas, port, dbName, autoReconnect, urlParams, dbHaParams); @@ -1322,8 +1319,7 @@ public class TransactionLegacy implements Closeable { config.addDataSourceProperty("elideSetAutoCommits", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); - HikariDataSource dataSource = new HikariDataSource(config); - return dataSource; + return new HikariDataSource(config); } private static DataSource createDbcpDataSource(String uri, String username, String password, @@ -1411,19 +1407,19 @@ public class TransactionLegacy implements Closeable { private static String getDBHAParams(String dbName, Properties dbProps) { StringBuilder sb = new StringBuilder(); - sb.append("failOverReadOnly=" + dbProps.getProperty("db." + dbName + ".failOverReadOnly")); - sb.append("&").append("reconnectAtTxEnd=" + dbProps.getProperty("db." + dbName + ".reconnectAtTxEnd")); - sb.append("&").append("autoReconnectForPools=" + dbProps.getProperty("db." + dbName + ".autoReconnectForPools")); - sb.append("&").append("secondsBeforeRetrySource=" + dbProps.getProperty("db." + dbName + ".secondsBeforeRetrySource")); - sb.append("&").append("queriesBeforeRetrySource=" + dbProps.getProperty("db." + dbName + ".queriesBeforeRetrySource")); - sb.append("&").append("initialTimeout=" + dbProps.getProperty("db." + dbName + ".initialTimeout")); + sb.append("failOverReadOnly=").append(dbProps.getProperty("db." + dbName + ".failOverReadOnly")); + sb.append("&").append("reconnectAtTxEnd=").append(dbProps.getProperty("db." + dbName + ".reconnectAtTxEnd")); + sb.append("&").append("autoReconnectForPools=").append(dbProps.getProperty("db." + dbName + ".autoReconnectForPools")); + sb.append("&").append("secondsBeforeRetrySource=").append(dbProps.getProperty("db." + dbName + ".secondsBeforeRetrySource")); + sb.append("&").append("queriesBeforeRetrySource=").append(dbProps.getProperty("db." + dbName + ".queriesBeforeRetrySource")); + sb.append("&").append("initialTimeout=").append(dbProps.getProperty("db." + dbName + ".initialTimeout")); return sb.toString(); } /** * Used for unit testing primarily * - * @param conn + * @param conn connection to use */ protected void setConnection(Connection conn) { _conn = conn; @@ -1433,7 +1429,7 @@ public class TransactionLegacy implements Closeable { * Receives a list of {@link PreparedStatement} and quietly closes all of them, which * triggers also closing their dependent objects, like a {@link ResultSet} * - * @param pstmt2Close + * @param pstmt2Close list of PreparedStatement to close */ public static void closePstmts(List pstmt2Close) { for (PreparedStatement pstmt : pstmt2Close) { diff --git a/framework/db/src/test/java/com/cloud/utils/db/TransactionContextBuilderTest.java b/framework/db/src/test/java/com/cloud/utils/db/TransactionContextBuilderTest.java index a0f7c803e4b..3ec635c15d9 100644 --- a/framework/db/src/test/java/com/cloud/utils/db/TransactionContextBuilderTest.java +++ b/framework/db/src/test/java/com/cloud/utils/db/TransactionContextBuilderTest.java @@ -41,9 +41,6 @@ public class TransactionContextBuilderTest { @Test public void test() { - // _derived.DbAnnotatedMethod(); - // _base.MethodWithClassDbAnnotated(); - // test @DB injection on dynamically constructed objects DbAnnotatedBase base = ComponentContext.inject(new DbAnnotatedBase()); base.MethodWithClassDbAnnotated(); diff --git a/framework/direct-download/pom.xml b/framework/direct-download/pom.xml index 42e4caa9e06..22e878178ae 100644 --- a/framework/direct-download/pom.xml +++ b/framework/direct-download/pom.xml @@ -32,7 +32,7 @@ cloudstack-framework org.apache.cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/events/pom.xml b/framework/events/pom.xml index a63af7087c6..3a0d3746868 100644 --- a/framework/events/pom.xml +++ b/framework/events/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/extensions/pom.xml b/framework/extensions/pom.xml index 66a6b5edac9..4d42d6840dd 100644 --- a/framework/extensions/pom.xml +++ b/framework/extensions/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml @@ -41,13 +41,13 @@ org.apache.cloudstack cloud-engine-schema - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT compile org.apache.cloudstack cloud-engine-components-api - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT compile diff --git a/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/api/UpdateExtensionCmd.java b/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/api/UpdateExtensionCmd.java index 713e7550a1e..ded07d2dd32 100644 --- a/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/api/UpdateExtensionCmd.java +++ b/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/api/UpdateExtensionCmd.java @@ -74,7 +74,7 @@ public class UpdateExtensionCmd extends BaseCmd { @Parameter(name = ApiConstants.CLEAN_UP_DETAILS, type = CommandType.BOOLEAN, description = "Optional boolean field, which indicates if details should be cleaned up or not " + - "(If set to true, details removed for this action, details field ignored; " + + "(If set to true, details removed for this extension, details field ignored; " + "if false or not set, no action)") private Boolean cleanupDetails; diff --git a/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java b/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java index f66c195399d..4171b9615fe 100644 --- a/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java +++ b/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java @@ -129,6 +129,7 @@ import com.cloud.org.Cluster; import com.cloud.serializer.GsonHelper; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.user.Account; +import com.cloud.user.AccountService; import com.cloud.utils.Pair; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.component.PluggableService; @@ -212,6 +213,9 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana @Inject RoleService roleService; + @Inject + AccountService accountService; + private ScheduledExecutorService extensionPathStateCheckExecutor; protected String getDefaultExtensionRelativePath(String name) { @@ -1354,6 +1358,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana clusterId = host.getClusterId(); } else if (entity instanceof VirtualMachine) { VirtualMachine virtualMachine = (VirtualMachine)entity; + accountService.checkAccess(caller, null, true, virtualMachine); if (!Hypervisor.HypervisorType.External.equals(virtualMachine.getHypervisorType())) { logger.error("Invalid {} specified as VM resource for running {}", entity, customActionVO); throw new InvalidParameterValueException(error); diff --git a/framework/extensions/src/test/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImplTest.java b/framework/extensions/src/test/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImplTest.java index bee597550a0..085ae212b28 100644 --- a/framework/extensions/src/test/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImplTest.java +++ b/framework/extensions/src/test/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImplTest.java @@ -49,6 +49,8 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import com.cloud.exception.PermissionDeniedException; +import com.cloud.user.AccountService; import org.apache.cloudstack.acl.Role; import org.apache.cloudstack.acl.RoleService; import org.apache.cloudstack.acl.RoleType; @@ -176,6 +178,8 @@ public class ExtensionsManagerImplTest { private VMTemplateDao templateDao; @Mock private RoleService roleService; + @Mock + private AccountService accountService; @Before public void setUp() { @@ -1640,6 +1644,35 @@ public class ExtensionsManagerImplTest { } } + @Test(expected = PermissionDeniedException.class) + public void runCustomAction_CheckAccessThrowsException() throws Exception { + RunCustomActionCmd cmd = mock(RunCustomActionCmd.class); + when(cmd.getCustomActionId()).thenReturn(1L); + when(cmd.getResourceId()).thenReturn("vm-123"); + when(cmd.getParameters()).thenReturn(Map.of("param1", "value1")); + + ExtensionCustomActionVO actionVO = mock(ExtensionCustomActionVO.class); + when(extensionCustomActionDao.findById(1L)).thenReturn(actionVO); + when(actionVO.isEnabled()).thenReturn(true); + when(actionVO.getResourceType()).thenReturn(ExtensionCustomAction.ResourceType.VirtualMachine); + when(actionVO.getAllowedRoleTypes()).thenReturn(RoleType.toCombinedMask(List.of(RoleType.Admin, RoleType.DomainAdmin, RoleType.User))); + + ExtensionVO extensionVO = mock(ExtensionVO.class); + when(extensionDao.findById(anyLong())).thenReturn(extensionVO); + when(extensionVO.getState()).thenReturn(Extension.State.Enabled); + + VirtualMachine vm = mock(VirtualMachine.class); + when(entityManager.findByUuid(eq(VirtualMachine.class), anyString())).thenReturn(vm); + doThrow(PermissionDeniedException.class).when(accountService).checkAccess(any(Account.class), eq(null), eq(true), eq(vm)); + + try (MockedStatic ignored = mockStatic(CallContext.class)) { + mockCallerRole(RoleType.User); + CustomActionResultResponse result = extensionsManager.runCustomAction(cmd); + + assertFalse(result.getSuccess()); + } + } + @Test public void createCustomActionResponse_SetsBasicFields() { ExtensionCustomAction action = mock(ExtensionCustomAction.class); diff --git a/framework/ipc/pom.xml b/framework/ipc/pom.xml index 14ef793cd34..d9fa9d85271 100644 --- a/framework/ipc/pom.xml +++ b/framework/ipc/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/ipc/src/test/java/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java b/framework/ipc/src/test/java/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java index 164852af4e7..0d8ddcfa5a4 100644 --- a/framework/ipc/src/test/java/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java +++ b/framework/ipc/src/test/java/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java @@ -20,6 +20,8 @@ package org.apache.cloudstack.framework.codestyle; import java.util.concurrent.ExecutionException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -36,6 +38,7 @@ import org.apache.cloudstack.framework.async.AsyncRpcContext; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:/SampleManagementServerAppContext.xml") public class AsyncSampleEventDrivenStyleCaller { + protected Logger logger = LogManager.getLogger(getClass()); private AsyncSampleCallee _ds; AsyncCallbackDriver _callbackDriver; @@ -53,12 +56,8 @@ public class AsyncSampleEventDrivenStyleCaller { try { String result = future.get(); Assert.assertEquals(result, vol); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ExecutionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } catch (InterruptedException | ExecutionException e) { + logger.info(e); } } @@ -87,10 +86,8 @@ public class AsyncSampleEventDrivenStyleCaller { if (!this.finished) { try { this.wait(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.info(e); } } return this.result; diff --git a/framework/jobs/pom.xml b/framework/jobs/pom.xml index c6e3926ed4d..ad342acf8d8 100644 --- a/framework/jobs/pom.xml +++ b/framework/jobs/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java b/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java index da7ba36c919..09a88939492 100644 --- a/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java +++ b/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java @@ -44,8 +44,6 @@ public class AsyncJobJoinMapDaoImpl extends GenericDaoBase CompleteJoinSearch; private final SearchBuilder WakeupSearch; -// private final GenericSearchBuilder JoinJobSearch; - protected AsyncJobJoinMapDaoImpl() { RecordSearch = createSearchBuilder(); RecordSearch.and("jobId", RecordSearch.entity().getJobId(), Op.EQ); @@ -65,10 +63,6 @@ public class AsyncJobJoinMapDaoImpl extends GenericDaoBase wakeupScan() { -// List standaloneList = new ArrayList(); -// -// Date cutDate = DateUtil.currentGMTTime(); -// -// TransactionLegacy txn = TransactionLegacy.currentTxn(); -// PreparedStatement pstmt = null; -// try { -// txn.start(); -// -// // -// // performance sensitive processing, do it in plain SQL -// // -// String sql = "UPDATE async_job SET job_pending_signals=? WHERE id IN " + -// "(SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ?)"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setInt(1, AsyncJob.Constants.SIGNAL_MASK_WAKEUP); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(3, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.executeUpdate(); -// pstmt.close(); -// -// sql = "UPDATE sync_queue_item SET queue_proc_msid=NULL, queue_proc_number=NULL WHERE content_id IN " + -// "(SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ?)"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.executeUpdate(); -// pstmt.close(); -// -// sql = "SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ? AND job_id NOT IN (SELECT content_id FROM sync_queue_item)"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// ResultSet rs = pstmt.executeQuery(); -// while(rs.next()) { -// standaloneList.add(rs.getLong(1)); -// } -// rs.close(); -// pstmt.close(); -// -// // update for next wake-up -// sql = "UPDATE async_job_join_map SET next_wakeup=DATE_ADD(next_wakeup, INTERVAL wakeup_interval SECOND) WHERE next_wakeup < ? AND expiration > ?"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.executeUpdate(); -// pstmt.close(); -// -// txn.commit(); -// } catch (SQLException e) { -// logger.error("Unexpected exception", e); -// } -// -// return standaloneList; -// } - @Override public List findJobsToWake(long joinedJobId) { // TODO: We should fix this. We shouldn't be crossing daos in a dao code. diff --git a/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java b/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java index fa1d175c45f..66df95426d5 100644 --- a/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java +++ b/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java @@ -193,7 +193,6 @@ public class JobSerializerHelper { json.add("class", new JsonPrimitive(th.getClass().getName())); json.add("cause", s_gson.toJsonTree(th.getCause())); json.add("msg", new JsonPrimitive(th.getMessage())); -// json.add("stack", s_gson.toJsonTree(th.getStackTrace())); return json; } diff --git a/framework/managed-context/pom.xml b/framework/managed-context/pom.xml index c74b12d6657..70f20ecb04e 100644 --- a/framework/managed-context/pom.xml +++ b/framework/managed-context/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/framework/pom.xml b/framework/pom.xml index 38fa6857456..337e5b0268b 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/framework/quota/pom.xml b/framework/quota/pom.xml index bbf08ad37dd..70cb3ac8cd5 100644 --- a/framework/quota/pom.xml +++ b/framework/quota/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.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 a03f82a4358..7949259bc82 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 @@ -32,7 +32,6 @@ import java.util.stream.Collectors; import javax.inject.Inject; import javax.naming.ConfigurationException; -import com.cloud.user.Account; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.quota.activationrule.presetvariables.Configuration; import org.apache.cloudstack.quota.activationrule.presetvariables.GenericPresetVariable; @@ -63,6 +62,7 @@ import org.springframework.stereotype.Component; import com.cloud.usage.UsageVO; import com.cloud.usage.dao.UsageDao; +import com.cloud.user.Account; import com.cloud.user.AccountVO; import com.cloud.user.dao.AccountDao; import com.cloud.utils.DateUtil; @@ -473,7 +473,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager { jsInterpreter.injectVariable("configuration", configuration.toString()); } - jsInterpreter.injectStringVariable("resourceType", presetVariables.getResourceType()); + jsInterpreter.injectVariable("resourceType", presetVariables.getResourceType()); jsInterpreter.injectVariable("value", presetVariables.getValue().toString()); jsInterpreter.injectVariable("zone", presetVariables.getZone().toString()); } diff --git a/framework/quota/src/test/java/org/apache/cloudstack/quota/QuotaManagerImplTest.java b/framework/quota/src/test/java/org/apache/cloudstack/quota/QuotaManagerImplTest.java index c62f80d4a44..3b2ea54e86d 100644 --- a/framework/quota/src/test/java/org/apache/cloudstack/quota/QuotaManagerImplTest.java +++ b/framework/quota/src/test/java/org/apache/cloudstack/quota/QuotaManagerImplTest.java @@ -270,8 +270,7 @@ public class QuotaManagerImplTest { Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("account"), Mockito.anyString()); Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("domain"), Mockito.anyString()); Mockito.verify(jsInterpreterMock, Mockito.never()).injectVariable(Mockito.eq("project"), Mockito.anyString()); - Mockito.verify(jsInterpreterMock, Mockito.never()).injectVariable(Mockito.eq("configuration"), Mockito.anyString()); - Mockito.verify(jsInterpreterMock).injectStringVariable(Mockito.eq("resourceType"), Mockito.anyString()); + Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("resourceType"), Mockito.anyString()); Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("value"), Mockito.anyString()); Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("zone"), Mockito.anyString()); } @@ -292,7 +291,7 @@ public class QuotaManagerImplTest { Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("account"), Mockito.anyString()); Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("domain"), Mockito.anyString()); Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("project"), Mockito.anyString()); - Mockito.verify(jsInterpreterMock).injectStringVariable(Mockito.eq("resourceType"), Mockito.anyString()); + Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("resourceType"), Mockito.anyString()); Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("value"), Mockito.anyString()); Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("zone"), Mockito.anyString()); } diff --git a/framework/rest/pom.xml b/framework/rest/pom.xml index 05b96731008..e2e787aec46 100644 --- a/framework/rest/pom.xml +++ b/framework/rest/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml cloud-framework-rest diff --git a/framework/security/pom.xml b/framework/security/pom.xml index e2a06c5d5af..30940b68f1a 100644 --- a/framework/security/pom.xml +++ b/framework/security/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/framework/spring/lifecycle/pom.xml b/framework/spring/lifecycle/pom.xml index acc3ee3395c..90a26a7be23 100644 --- a/framework/spring/lifecycle/pom.xml +++ b/framework/spring/lifecycle/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/framework/spring/module/pom.xml b/framework/spring/module/pom.xml index 5485e6d6e7f..f44cffa30b1 100644 --- a/framework/spring/module/pom.xml +++ b/framework/spring/module/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/packaging/README.md b/packaging/README.md index 78057b828b2..0c01ce5497c 100644 --- a/packaging/README.md +++ b/packaging/README.md @@ -1,3 +1,22 @@ + + # CloudStack RPM and DEB packaging This directory contains all the required scripts and tools needed to build RPM and DEB packages for Apache CloudStack. diff --git a/packaging/debian/replace.properties b/packaging/debian/replace.properties index 5ea4a03b275..bd0c1488959 100644 --- a/packaging/debian/replace.properties +++ b/packaging/debian/replace.properties @@ -59,3 +59,8 @@ USAGELOG=/var/log/cloudstack/usage/usage.log USAGESYSCONFDIR=/etc/cloudstack/usage PACKAGE=cloudstack EXTENSIONSDEPLOYMENTMODE=production +GUESTNVRAMTEMPLATELEGACY=/usr/share/OVMF/OVMF_VARS_4M.fd +GUESTLOADERLEGACY=/usr/share/OVMF/OVMF_CODE_4M.fd +GUESTNVRAMTEMPLATESECURE=/usr/share/OVMF/OVMF_VARS_4M.ms.fd +GUESTLOADERSECURE=/usr/share/OVMF/OVMF_CODE_4M.secboot.fd +GUESTNVRAMPATH=/var/lib/libvirt/qemu/nvram/ diff --git a/packaging/el8/cloud.spec b/packaging/el8/cloud.spec index 7e97957473c..abfab23f705 100644 --- a/packaging/el8/cloud.spec +++ b/packaging/el8/cloud.spec @@ -115,6 +115,8 @@ Requires: ipset Requires: perl Requires: rsync Requires: cifs-utils +Requires: edk2-ovmf +Requires: swtpm Requires: (python3-libvirt or python3-libvirt-python) Requires: (qemu-img or qemu-tools) Requires: qemu-kvm @@ -356,6 +358,7 @@ install -D packaging/systemd/cloudstack-agent.service ${RPM_BUILD_ROOT}%{_unitdi install -D packaging/systemd/cloudstack-rolling-maintenance@.service ${RPM_BUILD_ROOT}%{_unitdir}/%{name}-rolling-maintenance@.service install -D packaging/systemd/cloudstack-agent.default ${RPM_BUILD_ROOT}%{_sysconfdir}/default/%{name}-agent install -D agent/target/transformed/agent.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/agent.properties +install -D agent/target/transformed/uefi.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/uefi.properties install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/environment.properties install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/log4j-cloud.xml install -D agent/target/transformed/cloud-setup-agent ${RPM_BUILD_ROOT}%{_bindir}/%{name}-setup-agent @@ -523,7 +526,7 @@ mkdir -m 0755 -p /usr/share/cloudstack-agent/tmp /usr/bin/systemctl enable cloudstack-rolling-maintenance@p > /dev/null 2>&1 || true /usr/bin/systemctl enable --now rngd > /dev/null 2>&1 || true -# if saved configs from upgrade exist, copy them over +# if saved agent.properties from upgrade exist, copy them over if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then mv %{_sysconfdir}/%{name}/agent/agent.properties %{_sysconfdir}/%{name}/agent/agent.properties.rpmnew cp -p %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/%{name}/agent @@ -531,6 +534,14 @@ if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then mv %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/cloud.rpmsave/agent/agent.properties.rpmsave fi +# if saved uefi.properties from upgrade exist, copy them over +if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/uefi.properties" ]; then + mv %{_sysconfdir}/%{name}/agent/uefi.properties %{_sysconfdir}/%{name}/agent/uefi.properties.rpmnew + cp -p %{_sysconfdir}/cloud.rpmsave/agent/uefi.properties %{_sysconfdir}/%{name}/agent + # make sure we only do this on the first install of this RPM, don't want to overwrite on a reinstall + mv %{_sysconfdir}/cloud.rpmsave/agent/uefi.properties %{_sysconfdir}/cloud.rpmsave/agent/uefi.properties.rpmsave +fi + systemctl daemon-reload # Print help message diff --git a/packaging/el8/replace.properties b/packaging/el8/replace.properties index a6094b59c73..a5afab94ff2 100644 --- a/packaging/el8/replace.properties +++ b/packaging/el8/replace.properties @@ -58,3 +58,8 @@ USAGECLASSPATH= USAGELOG=/var/log/cloudstack/usage/usage.log USAGESYSCONFDIR=/etc/sysconfig EXTENSIONSDEPLOYMENTMODE=production +GUESTNVRAMTEMPLATELEGACY=/usr/share/edk2/ovmf/OVMF_VARS.fd +GUESTLOADERLEGACY=/usr/share/edk2/ovmf/OVMF_CODE.cc.fd +GUESTNVRAMTEMPLATESECURE=/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd +GUESTLOADERSECURE=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd +GUESTNVRAMPATH=/var/lib/libvirt/qemu/nvram/ diff --git a/plugins/acl/dynamic-role-based/pom.xml b/plugins/acl/dynamic-role-based/pom.xml index 2c7e099f9b5..0b0b2300e77 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/acl/project-role-based/pom.xml b/plugins/acl/project-role-based/pom.xml index 6327ffe400d..2c351bdbc8c 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/acl/static-role-based/pom.xml b/plugins/acl/static-role-based/pom.xml index cdd58bb113a..c6e790b485e 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.22.0.0-SNAPSHOT + 4.23.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 97afc9ca375..769773e9dca 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.22.0.0-SNAPSHOT + 4.23.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 e0e1f967ef3..925da93b29c 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.22.0.0-SNAPSHOT + 4.23.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 c2534fae2d0..9b83518d779 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.22.0.0-SNAPSHOT + 4.23.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 887abf726ee..f0bc9e0d7e9 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.22.0.0-SNAPSHOT + 4.23.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 cccd00547da..b12e49f62dd 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/alert-handlers/snmp-alerts/pom.xml b/plugins/alert-handlers/snmp-alerts/pom.xml index 797471e60fa..ea89037aa2b 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/alert-handlers/syslog-alerts/pom.xml b/plugins/alert-handlers/syslog-alerts/pom.xml index 98ee0f99a5a..a4ae4f08953 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/discovery/pom.xml b/plugins/api/discovery/pom.xml index 83ea736267d..b0f29612911 100644 --- a/plugins/api/discovery/pom.xml +++ b/plugins/api/discovery/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/rate-limit/pom.xml b/plugins/api/rate-limit/pom.xml index 7c93459dc33..294ff18bcc9 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/integration/APITest.java b/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/integration/APITest.java index efe8c53a51b..eb020c2c499 100644 --- a/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/integration/APITest.java +++ b/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/integration/APITest.java @@ -189,7 +189,6 @@ public abstract class APITest { * @return login response string */ protected void login(String username, String password) { - //String md5Psw = createMD5String(password); // send login request HashMap params = new HashMap(); params.put("response", "json"); diff --git a/plugins/api/solidfire-intg-test/pom.xml b/plugins/api/solidfire-intg-test/pom.xml index 04f42ad4b37..0cc9d1aba5a 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/vmware-sioc/pom.xml b/plugins/api/vmware-sioc/pom.xml index cb5c6f78ce3..e523568dc50 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/dummy/pom.xml b/plugins/backup/dummy/pom.xml index 2446e43a512..63c89cdb3e0 100644 --- a/plugins/backup/dummy/pom.xml +++ b/plugins/backup/dummy/pom.xml @@ -23,7 +23,7 @@ cloudstack-plugins org.apache.cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/nas/pom.xml b/plugins/backup/nas/pom.xml index 5b86d01df0c..3c7cd8ab681 100644 --- a/plugins/backup/nas/pom.xml +++ b/plugins/backup/nas/pom.xml @@ -25,7 +25,7 @@ cloudstack-plugins org.apache.cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java b/plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java index 3813cac0a33..a350d80d27f 100644 --- a/plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java +++ b/plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java @@ -56,6 +56,7 @@ import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; +import org.apache.commons.collections4.CollectionUtils; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; @@ -195,6 +196,12 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co throw new CloudRuntimeException("No valid backup repository found for the VM, please check the attached backup offering"); } + if (CollectionUtils.isNotEmpty(vmSnapshotDao.findByVmAndByType(vm.getId(), VMSnapshot.Type.DiskAndMemory))) { + logger.debug("NAS backup provider cannot take backups of a VM [{}] with disk-and-memory VM snapshots. Restoring the backup will corrupt any newer disk-and-memory " + + "VM snapshots.", vm); + throw new CloudRuntimeException(String.format("Cannot take backup of VM [%s] as it has disk-and-memory VM snapshots.", vm.getUuid())); + } + final Date creationDate = new Date(); final String backupPath = String.format("%s/%s", vm.getInstanceName(), new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(creationDate)); @@ -405,6 +412,7 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co restoreCommand.setVmExists(null); restoreCommand.setVmState(vmNameAndState.second()); restoreCommand.setRestoreVolumeUUID(backupVolumeInfo.getUuid()); + restoreCommand.setMountTimeout(NASBackupRestoreMountTimeout.value()); BackupAnswer answer; try { @@ -516,6 +524,11 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co return true; } + @Override + public boolean supportsMemoryVmSnapshot() { + return false; + } + @Override public Pair getBackupStorageStats(Long zoneId) { final List repositories = backupRepositoryDao.listByZoneAndProvider(zoneId, getName()); diff --git a/plugins/backup/nas/src/test/java/org/apache/cloudstack/backup/NASBackupProviderTest.java b/plugins/backup/nas/src/test/java/org/apache/cloudstack/backup/NASBackupProviderTest.java index 7540cabbbf5..a512292cd28 100644 --- a/plugins/backup/nas/src/test/java/org/apache/cloudstack/backup/NASBackupProviderTest.java +++ b/plugins/backup/nas/src/test/java/org/apache/cloudstack/backup/NASBackupProviderTest.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import com.cloud.vm.snapshot.dao.VMSnapshotDao; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -92,6 +93,9 @@ public class NASBackupProviderTest { @Mock private PrimaryDataStoreDao storagePoolDao; + @Mock + private VMSnapshotDao vmSnapshotDaoMock; + @Test public void testDeleteBackup() throws OperationTimedoutException, AgentUnavailableException { Long hostId = 1L; diff --git a/plugins/backup/networker/pom.xml b/plugins/backup/networker/pom.xml index a8a2b090a11..cad2b345435 100644 --- a/plugins/backup/networker/pom.xml +++ b/plugins/backup/networker/pom.xml @@ -25,7 +25,7 @@ cloudstack-plugins org.apache.cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/veeam/pom.xml b/plugins/backup/veeam/pom.xml index 0626c5f8e84..a2dcbd1d348 100644 --- a/plugins/backup/veeam/pom.xml +++ b/plugins/backup/veeam/pom.xml @@ -23,7 +23,7 @@ cloudstack-plugins org.apache.cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java b/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java index e2df854f16d..98851e6359a 100644 --- a/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java +++ b/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java @@ -105,7 +105,8 @@ public class VeeamClient { private static final String REPOSITORY_REFERENCE = "RepositoryReference"; private static final String RESTORE_POINT_REFERENCE = "RestorePointReference"; private static final String BACKUP_FILE_REFERENCE = "BackupFileReference"; - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + private static final ObjectMapper OBJECT_MAPPER = new XmlMapper(); private String veeamServerIp; private final Integer veeamServerVersion; @@ -124,6 +125,8 @@ public class VeeamClient { this.taskPollInterval = taskPollInterval; this.taskPollMaxRetry = taskPollMaxRetry; + OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final RequestConfig config = RequestConfig.custom() .setConnectTimeout(timeout * 1000) .setConnectionRequestTimeout(timeout * 1000) @@ -233,8 +236,7 @@ public class VeeamClient { private HttpResponse post(final String path, final Object obj) throws IOException { String xml = null; if (obj != null) { - XmlMapper xmlMapper = new XmlMapper(); - xml = xmlMapper.writer() + xml = OBJECT_MAPPER.writer() .with(ToXmlGenerator.Feature.WRITE_XML_DECLARATION) .writeValueAsString(obj); // Remove invalid/empty xmlns @@ -277,8 +279,7 @@ public class VeeamClient { try { final HttpResponse response = get("/hierarchyRoots"); checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - final EntityReferences references = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class); + final EntityReferences references = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class); for (final Ref ref : references.getRefs()) { if (ref.getName().equals(vmwareDcName) && ref.getType().equals(HIERARCHY_ROOT_REFERENCE)) { return ref.getUid(); @@ -297,8 +298,7 @@ public class VeeamClient { try { final HttpResponse response = get(String.format("/lookup?host=%s&type=Vm&name=%s", hierarchyId, vmName)); checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - final HierarchyItems items = objectMapper.readValue(response.getEntity().getContent(), HierarchyItems.class); + final HierarchyItems items = OBJECT_MAPPER.readValue(response.getEntity().getContent(), HierarchyItems.class); if (items == null || items.getItems() == null || items.getItems().isEmpty()) { throw new CloudRuntimeException("Could not find VM " + vmName + " in Veeam, please ask administrator to check Veeam B&R manager"); } @@ -316,14 +316,12 @@ public class VeeamClient { private Task parseTaskResponse(HttpResponse response) throws IOException { checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - return objectMapper.readValue(response.getEntity().getContent(), Task.class); + return OBJECT_MAPPER.readValue(response.getEntity().getContent(), Task.class); } protected RestoreSession parseRestoreSessionResponse(HttpResponse response) throws IOException { checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - return objectMapper.readValue(response.getEntity().getContent(), RestoreSession.class); + return OBJECT_MAPPER.readValue(response.getEntity().getContent(), RestoreSession.class); } private boolean checkTaskStatus(final HttpResponse response) throws IOException { @@ -410,8 +408,7 @@ public class VeeamClient { String repositoryName = getRepositoryNameFromJob(backupName); final HttpResponse response = get(String.format("/backupServers/%s/repositories", backupServerId)); checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - final EntityReferences references = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class); + final EntityReferences references = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class); for (final Ref ref : references.getRefs()) { if (ref.getType().equals(REPOSITORY_REFERENCE) && ref.getName().equals(repositoryName)) { return ref; @@ -447,8 +444,7 @@ public class VeeamClient { try { final HttpResponse response = get("/backups"); checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - final EntityReferences entityReferences = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class); + final EntityReferences entityReferences = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class); for (final Ref ref : entityReferences.getRefs()) { logger.debug("Veeam Backup found, name: " + ref.getName() + ", uid: " + ref.getUid() + ", type: " + ref.getType()); } @@ -463,8 +459,7 @@ public class VeeamClient { try { final HttpResponse response = get("/jobs"); checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - final EntityReferences entityReferences = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class); + final EntityReferences entityReferences = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class); final List policies = new ArrayList<>(); if (entityReferences == null || entityReferences.getRefs() == null) { return policies; @@ -486,9 +481,7 @@ public class VeeamClient { final HttpResponse response = get(String.format("/jobs/%s?format=Entity", jobId.replace("urn:veeam:Job:", ""))); checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - return objectMapper.readValue(response.getEntity().getContent(), Job.class); + return OBJECT_MAPPER.readValue(response.getEntity().getContent(), Job.class); } catch (final IOException e) { logger.error("Failed to list Veeam jobs due to:", e); checkResponseTimeOut(e); @@ -568,9 +561,7 @@ public class VeeamClient { final String veeamVmRefId = lookupVM(hierarchyId, vmwareInstanceName); final HttpResponse response = get(String.format("/jobs/%s/includes", jobId)); checkResponseOK(response); - final ObjectMapper objectMapper = new XmlMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - final ObjectsInJob jobObjects = objectMapper.readValue(response.getEntity().getContent(), ObjectsInJob.class); + final ObjectsInJob jobObjects = OBJECT_MAPPER.readValue(response.getEntity().getContent(), ObjectsInJob.class); if (jobObjects == null || jobObjects.getObjects() == null) { logger.warn("No objects found in the Veeam job " + jobId); return false; @@ -710,8 +701,7 @@ public class VeeamClient { protected Map processHttpResponseForBackupMetrics(final InputStream content) { Map metrics = new HashMap<>(); try { - final ObjectMapper objectMapper = new XmlMapper(); - final BackupFiles backupFiles = objectMapper.readValue(content, BackupFiles.class); + final BackupFiles backupFiles = OBJECT_MAPPER.readValue(content, BackupFiles.class); if (backupFiles == null || CollectionUtils.isEmpty(backupFiles.getBackupFiles())) { throw new CloudRuntimeException("Could not get backup metrics via Veeam B&R API"); } @@ -855,8 +845,7 @@ public class VeeamClient { public List processHttpResponseForVmRestorePoints(InputStream content, String vmwareDcName, String vmInternalName, Map metricsMap) { List vmRestorePointList = new ArrayList<>(); try { - final ObjectMapper objectMapper = new XmlMapper(); - final VmRestorePoints vmRestorePoints = objectMapper.readValue(content, VmRestorePoints.class); + final VmRestorePoints vmRestorePoints = OBJECT_MAPPER.readValue(content, VmRestorePoints.class); final String hierarchyId = findDCHierarchy(vmwareDcName); final String hierarchyUuid = StringUtils.substringAfterLast(hierarchyId, ":"); if (vmRestorePoints == null) { @@ -907,7 +896,7 @@ public class VeeamClient { } private Date formatDate(String date) throws ParseException { - return dateFormat.parse(StringUtils.substring(date, 0, 19)); + return DATE_FORMAT.parse(StringUtils.substring(date, 0, 19)); } public Pair restoreVMToDifferentLocation(String restorePointId, String restoreLocation, String hostIp, String dataStoreUuid) { diff --git a/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java b/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java index 3485f402417..0c70c75939e 100644 --- a/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java +++ b/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java @@ -483,7 +483,9 @@ public class VeeamClientTest { " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xmlns=\"http://www.veeam.com/ent/v1.0\">\n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + diff --git a/plugins/ca/root-ca/pom.xml b/plugins/ca/root-ca/pom.xml index 1cc97f88e13..2224ae06c85 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/database/mysql-ha/pom.xml b/plugins/database/mysql-ha/pom.xml index c2ac585dce2..eb1b1d571f1 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/database/quota/pom.xml b/plugins/database/quota/pom.xml index b6910079f95..52645385aab 100644 --- a/plugins/database/quota/pom.xml +++ b/plugins/database/quota/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml 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 7a987df0a35..42e94c1c017 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 @@ -80,8 +80,8 @@ import org.apache.cloudstack.quota.dao.QuotaCreditsDao; import org.apache.cloudstack.quota.dao.QuotaEmailConfigurationDao; import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao; import org.apache.cloudstack.quota.dao.QuotaTariffDao; -import org.apache.cloudstack.quota.vo.QuotaAccountVO; import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; import org.apache.cloudstack.quota.vo.QuotaBalanceVO; import org.apache.cloudstack.quota.vo.QuotaCreditsVO; import org.apache.cloudstack.quota.vo.QuotaEmailConfigurationVO; @@ -90,15 +90,17 @@ 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.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; -import org.apache.commons.lang3.ObjectUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; +import com.cloud.event.ActionEvent; +import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; import com.cloud.user.AccountManager; @@ -107,8 +109,6 @@ import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.UserDao; import com.cloud.utils.Pair; import com.cloud.utils.db.Filter; -import com.cloud.event.ActionEvent; -import com.cloud.event.EventTypes; @Component public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { @@ -150,6 +150,11 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { private final Class[] assignableClasses = {GenericPresetVariable.class, ComputingResources.class}; + protected void checkActivationRulesAllowed(String activationRule) { + if (!_quotaService.isJsInterpretationEnabled() && StringUtils.isNotEmpty(activationRule)) { + throw new PermissionDeniedException("Quota Tariff Activation Rule cannot be set, as Javascript interpretation is disabled in the configuration."); + } + } @Override public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO tariff, boolean returnActivationRule) { @@ -452,6 +457,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { throw new InvalidParameterValueException(String.format("There is no quota tariffs with name [%s].", name)); } + checkActivationRulesAllowed(activationRule); + Date currentQuotaTariffStartDate = currentQuotaTariff.getEffectiveOn(); currentQuotaTariff.setRemoved(now); @@ -706,6 +713,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { throw new InvalidParameterValueException(String.format("A quota tariff with name [%s] already exist.", name)); } + checkActivationRulesAllowed(activationRule); + if (startDate.compareTo(now) < 0) { throw new InvalidParameterValueException(String.format("The value passed as Quota tariff's start date is in the past: [%s]. " + "Please, inform a date in the future or do not pass the parameter to use the current date and time.", startDate)); diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaService.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaService.java index 8f3c34982c0..f6a34e01be8 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaService.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaService.java @@ -16,15 +16,15 @@ //under the License. package org.apache.cloudstack.quota; -import com.cloud.user.AccountVO; -import com.cloud.utils.component.PluggableService; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; import org.apache.cloudstack.quota.vo.QuotaBalanceVO; import org.apache.cloudstack.quota.vo.QuotaUsageVO; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; +import com.cloud.user.AccountVO; +import com.cloud.utils.component.PluggableService; public interface QuotaService extends PluggableService { @@ -40,4 +40,6 @@ public interface QuotaService extends PluggableService { boolean saveQuotaAccount(AccountVO account, BigDecimal aggrUsage, Date endDate); + boolean isJsInterpretationEnabled(); + } 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 e02f260c142..f455c3cba14 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 @@ -62,6 +62,7 @@ import com.cloud.configuration.Config; import com.cloud.domain.dao.DomainDao; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.PermissionDeniedException; +import com.cloud.server.ManagementService; import com.cloud.user.Account; import com.cloud.user.AccountVO; import com.cloud.user.dao.AccountDao; @@ -88,6 +89,8 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi private TimeZone _usageTimezone; + private boolean jsInterpretationEnabled = false; + public QuotaServiceImpl() { super(); } @@ -99,6 +102,8 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi String timeZoneStr = ObjectUtils.defaultIfNull(_configDao.getValue(Config.UsageAggregationTimezone.toString()), "GMT"); _usageTimezone = TimeZone.getTimeZone(timeZoneStr); + jsInterpretationEnabled = ManagementService.JsInterpretationEnabled.value(); + return true; } @@ -288,4 +293,8 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi } } + @Override + public boolean isJsInterpretationEnabled() { + return jsInterpretationEnabled; + } } diff --git a/plugins/dedicated-resources/pom.xml b/plugins/dedicated-resources/pom.xml index 31ce6da7e46..557668661f3 100644 --- a/plugins/dedicated-resources/pom.xml +++ b/plugins/dedicated-resources/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/plugins/deployment-planners/implicit-dedication/pom.xml b/plugins/deployment-planners/implicit-dedication/pom.xml index 322d4a7aa75..c33d6d07293 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.22.0.0-SNAPSHOT + 4.23.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 258d11e0c35..20420fbb080 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/deployment-planners/user-dispersing/pom.xml b/plugins/deployment-planners/user-dispersing/pom.xml index b18281a1cd4..85c839ceaca 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/drs/cluster/balanced/pom.xml b/plugins/drs/cluster/balanced/pom.xml index 51cbfc632b1..497dfcbede1 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/drs/cluster/condensed/pom.xml b/plugins/drs/cluster/condensed/pom.xml index 38a9cd48eab..6e7c33ef55d 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/event-bus/inmemory/pom.xml b/plugins/event-bus/inmemory/pom.xml index d6a3a02ec2c..5eadc3673f3 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/kafka/pom.xml b/plugins/event-bus/kafka/pom.xml index 5784434735f..c57572533ad 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/rabbitmq/pom.xml b/plugins/event-bus/rabbitmq/pom.xml index d5037b13408..3012ac1057a 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/webhook/pom.xml b/plugins/event-bus/webhook/pom.xml index a2f915c9e5f..cb19b224ce8 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/ha-planners/skip-heurestics/pom.xml b/plugins/ha-planners/skip-heurestics/pom.xml index d40f3fac648..43f3abf9cb1 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/host-allocators/random/pom.xml b/plugins/host-allocators/random/pom.xml index 28b4df56ec2..061caf1573f 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.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/baremetal/pom.xml b/plugins/hypervisors/baremetal/pom.xml index cefb0cb1d11..fc4803b7902 100755 --- a/plugins/hypervisors/baremetal/pom.xml +++ b/plugins/hypervisors/baremetal/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml cloud-plugin-hypervisor-baremetal diff --git a/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java b/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java index 99bedbff05e..9bdc2fb9ed8 100644 --- a/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java +++ b/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java @@ -149,7 +149,6 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh String errMsg = String.format("Set dhcp entry on external DHCP %1$s failed(ip=%2$s, mac=%3$s, vmname=%4$s)", h.getPrivateIpAddress(), nic.getIPv4Address(), nic.getMacAddress(), profile.getVirtualMachine().getHostName()); - // prepareBareMetalDhcpEntry(nic, dhcpCommand); try { Answer ans = _agentMgr.send(h.getId(), dhcpCommand); if (ans.getResult()) { diff --git a/plugins/hypervisors/external/pom.xml b/plugins/hypervisors/external/pom.xml index ca5ca7b9b82..1c581f3c0e5 100644 --- a/plugins/hypervisors/external/pom.xml +++ b/plugins/hypervisors/external/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml cloud-plugin-hypervisor-external diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs index 2e3de19939d..5d2e909dd11 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 required. namespace HypervResource { public class PrimaryDataStoreTO diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs index 6d8e2b2e15a..6f9e68302f8 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs @@ -1,350 +1,350 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -using System; -using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2; -using System.Management; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; -using System.IO; -using log4net; -using HypervResource; -using CloudStack.Plugin.AgentShell; -using System.Collections.Generic; -using NSubstitute; -using System.Web.Http; -using Xunit; - -namespace ServerResource.Tests -{ - public class HypervResourceController1Test - { - protected static string testCifsUrl = AgentSettings.Default.testCifsUrl; - protected static string testCifsPath = AgentSettings.Default.testCifsPath; - protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress; - protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName; - protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName; - protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName; - protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt; - protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2"; - protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool"); - protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary"); - - // TODO: differentiate between NFS and HTTP template URLs. - protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx"; - protected static String testSampleTemplateURL = testSampleTemplateUUID; - - // test volumes are both a minimal size vhdx. Changing the extension to .vhd makes on corrupt. - protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx"; - protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd"; - protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx"; - protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp"; - protected static String testSampleVolumeWorkingURIJSON; - protected static String testSampleVolumeCorruptURIJSON; - protected static String testSampleVolumeTempURIJSON; - - protected static String testSampleTemplateURLJSON; - protected static String testLocalStorePathJSON; - - protected static IWmiCallsV2 wmiCallsV2; - - - private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceController1Test)); - - /// - /// Test WmiCalls to which incoming HTTP POST requests are dispatched. - /// - /// TODO: revise beyond first approximation - /// First approximation is a quick port of the existing Java tests for Hyper-V server resource. - /// A second approximation would use the AgentShell settings files directly. - /// A third approximation would look to invoke ServerResource methods via an HTTP request - /// - - public HypervResourceController1Test() - { - wmiCallsV2 = Substitute.For(); - //AgentService.ConfigServerResource(); - HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address; - HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask; - HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress; - HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress; - HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask; - - - // Used to create existing StoragePool in preparation for the ModifyStoragePool - testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString(); - - // Make sure secondary store is available. - string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath); - s_logger.Info("Test secondary storage in " + fullPath); - DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath); - if (!testSecondarStoreDir.Exists) - { - try - { - testSecondarStoreDir.Create(); - } - catch (System.IO.IOException ex) - { - throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message); - } - } - - // Convert to secondary storage string to canonical path - testSecondaryStoreLocalPath = testSecondarStoreDir.FullName; - AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath; - - // Make sure local primary storage is available - DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath); - //Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName); - - // Convert to local primary storage string to canonical path - testLocalStorePath = testPoolDir.FullName; - AgentSettings.Default.local_storage_path = testLocalStorePath; - - // Clean up old test files in local storage folder - FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID)); - // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName); - - testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID); - s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); - - - // Capture other JSON encoded paths - testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName); - testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath); - - // TODO: may need to initialise the server resource in future. - // s_hypervresource.initialize(); - - // Verify sample template is in place storage pool - s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON - + " sample template at " + testSampleTemplateURLJSON); - } - - private String CreateTestDiskImageFromExistingImage(FileInfo srcFile, - String dstPath, - String dstFileName) - { - var newFullname = Path.Combine(dstPath, dstFileName); - var newFileInfo = new FileInfo(newFullname); - if (!newFileInfo.Exists) - { - newFileInfo = srcFile.CopyTo(newFullname); - } - newFileInfo.Refresh(); - Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName); - - return JsonConvert.SerializeObject(newFileInfo.FullName); - } - - [Fact] - public void TestCreateCommand() - { - DirectoryInfo localStorePath = new DirectoryInfo(testLocalStorePath); - if (!localStorePath.Exists) - { - try - { - localStorePath.Create(); - } - catch (System.IO.IOException ex) - { - throw new NotImplementedException("Need to be able to create the folder " + localStorePath.FullName + " failed due to " + ex.Message); - } - } - - FileInfo sampleTemplateFile = new FileInfo(Path.Combine(testLocalStorePath, testSampleTemplateUUID)); - if (!sampleTemplateFile.Exists) - { - //Create a file to write to. - using (StreamWriter sw = sampleTemplateFile.CreateText()) - { - sw.WriteLine("This is fake template file for test"); - } - } - var counter = 0; - wmiCallsV2.When(x => x.CreateDynamicVirtualHardDisk(Arg.Any(), Arg.Any())).Do(x => counter++); - // TODO: Need sample to update the test. - // Arrange - String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" + - ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," + - "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," + - "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}"; - dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd); - HypervResourceController rsrcServer = new HypervResourceController(); - HypervResourceController.wmiCallsV2 = wmiCallsV2; - - Assert.True(Directory.Exists(testLocalStorePath), testLocalStorePath + " does not exist "); - string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON)); - Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath); - int fileCount = Directory.GetFiles(testLocalStorePath).Length; - s_logger.Debug(" test local store has " + fileCount + "files"); - - // Act - // Test requires there to be a template at the tempalteUrl, which is its location in the local file system. - dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd); - s_logger.Debug("CreateDynamicVirtualHardDisk method is called " + counter + " times"); - - //Assert.Equal(counter, 1); - - JObject ansAsProperty2 = jsonResult[0]; - dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer); - Assert.NotNull(ans); - Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result); - Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1); - FileInfo newFile = new FileInfo((string)ans.volume.path); - Assert.True(newFile.Length > 0, "The new file should have a size greater than zero"); - newFile.Delete(); - sampleTemplateFile.Delete(); - } - - [Fact] - public void TestDestroyCommand() - { - testSampleVolumeTempURIJSON = "\"storagepool\""; - // Arrange - String destroyCmd = //"{\"volume\":" + getSampleVolumeObjectTO() + "}"; - "{\"volume\":{\"name\":\"" + testSampleVolumeTempUUIDNoExt - + "\",\"storagePoolType\":\"Filesystem\"," - + "\"mountPoint\":" - + testLocalStorePathJSON - + ",\"path\":" + testSampleVolumeTempURIJSON - + ",\"storagePoolUuid\":\"" + testLocalStoreUUID - + "\"," - + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}"; - - ImageManagementService imgmgr = new ImageManagementService(); - wmiCallsV2.GetImageManagementService().Returns(imgmgr); - - HypervResourceController rsrcServer = new HypervResourceController(); - HypervResourceController.wmiCallsV2 = wmiCallsV2; - - dynamic jsonDestroyCmd = JsonConvert.DeserializeObject(destroyCmd); - - // Act - dynamic destroyAns = rsrcServer.DestroyCommand(jsonDestroyCmd); - - // Assert - JObject ansAsProperty2 = destroyAns[0]; - dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.Answer); - String path = jsonDestroyCmd.volume.path; - Assert.True((bool)ans.result, "DestroyCommand did not succeed " + ans.details); - Assert.True(!File.Exists(path), "Failed to delete file " + path); - } - - [Fact] - public void TestStartCommand() - { - ComputerSystem system = new ComputerSystem(); - wmiCallsV2.DeployVirtualMachine(Arg.Any(), Arg.Any()).Returns(system); - - // Arrange - HypervResourceController rsrcServer = new HypervResourceController(); - HypervResourceController.wmiCallsV2 = wmiCallsV2; - String sample = getSampleStartCommand(); - - - dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample); - - // Act - dynamic startAns = rsrcServer.StartCommand(jsonStartCmd); - - // Assert - Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]); - Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details); - - Assert.Null((string)startAns[0][CloudStackTypes.StartAnswer].details); - } - - [Fact] - public void TestStopCommand() - { - //string vmName = "Test VM"; - var counter = 0; - wmiCallsV2.When(x => x.DestroyVm(Arg.Any())).Do(x => counter++); - - // Arrange - HypervResourceController rsrcServer = new HypervResourceController(); - HypervResourceController.wmiCallsV2 = wmiCallsV2; - - String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"checkBeforeCleanup\":false,\"wait\":0}"; - dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop); - - // Act - dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd); - - // Assert VM is gone! - Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]); - Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details); - - Assert.Null((string)stopAns[0][CloudStackTypes.StopAnswer].details); - Assert.Equal(counter, 1); - } - - public static String getSamplePrimaryDataStoreInfo() - { - String samplePrimaryDataStoreInfo = - "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" + - "{\"uuid\":\"" + testLocalStoreUUID + "\"," + - "\"id\":201," + - "\"host\":\"" + testPrimaryDataStoreHost + "\"," + - "\"type\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO - "\"poolType\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO - "\"path\":" + testLocalStorePathJSON + "," + - "\"port\":0}" + - "}"; - return samplePrimaryDataStoreInfo; - } - - public static String getSampleVolumeObjectTO() - { - String sampleVolumeObjectTO = - "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + - "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + - "\"volumeType\":\"ROOT\"," + - "\"format\":\"VHDX\"," + - "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + - "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," + - "\"size\":52428800," + - "\"volumeId\":10," + - // "\"vmName\":\"i-3-5-VM\"," + // TODO: do we have to fill in the vmName? - "\"accountId\":3,\"id\":10}" + - "}"; // end of destTO - return sampleVolumeObjectTO; - } - - public static String getSampleStartCommand() - { - String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," + - "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," + - "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," + - "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," + - "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" + - ",\"disks\":[" + - "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," + - "{\"diskSeq\":1,\"type\":\"ISO\"}" + - "]," + - "\"nics\":[" + - "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," + - "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," + - "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," + - "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" + - "]},\"contextMap\":{},\"wait\":0}"; - return sample; - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +using System; +using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2; +using System.Management; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System.IO; +using log4net; +using HypervResource; +using CloudStack.Plugin.AgentShell; +using System.Collections.Generic; +using NSubstitute; +using System.Web.Http; +using Xunit; + +namespace ServerResource.Tests +{ + public class HypervResourceController1Test + { + protected static string testCifsUrl = AgentSettings.Default.testCifsUrl; + protected static string testCifsPath = AgentSettings.Default.testCifsPath; + protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress; + protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName; + protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName; + protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName; + protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt; + protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2"; + protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool"); + protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary"); + + // TODO: differentiate between NFS and HTTP template URLs. + protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx"; + protected static String testSampleTemplateURL = testSampleTemplateUUID; + + // test volumes are both a minimal size vhdx. Changing the extension to .vhd makes on corrupt. + protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx"; + protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd"; + protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx"; + protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp"; + protected static String testSampleVolumeWorkingURIJSON; + protected static String testSampleVolumeCorruptURIJSON; + protected static String testSampleVolumeTempURIJSON; + + protected static String testSampleTemplateURLJSON; + protected static String testLocalStorePathJSON; + + protected static IWmiCallsV2 wmiCallsV2; + + + private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceController1Test)); + + /// + /// Test WmiCalls to which incoming HTTP POST requests are dispatched. + /// + /// TODO: revise beyond first approximation + /// First approximation is a quick port of the existing Java tests for Hyper-V server resource. + /// A second approximation would use the AgentShell settings files directly. + /// A third approximation would look to invoke ServerResource methods via an HTTP request + /// + + public HypervResourceController1Test() + { + wmiCallsV2 = Substitute.For(); + //AgentService.ConfigServerResource(); + HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address; + HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask; + HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress; + HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress; + HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask; + + + // Used to create existing StoragePool in preparation for the ModifyStoragePool + testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString(); + + // Make sure secondary store is available. + string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath); + s_logger.Info("Test secondary storage in " + fullPath); + DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath); + if (!testSecondarStoreDir.Exists) + { + try + { + testSecondarStoreDir.Create(); + } + catch (System.IO.IOException ex) + { + throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message); + } + } + + // Convert to secondary storage string to canonical path + testSecondaryStoreLocalPath = testSecondarStoreDir.FullName; + AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath; + + // Make sure local primary storage is available + DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath); + //Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName); + + // Convert to local primary storage string to canonical path + testLocalStorePath = testPoolDir.FullName; + AgentSettings.Default.local_storage_path = testLocalStorePath; + + // Clean up old test files in local storage folder + FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID)); + // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName); + + testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID); + s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); + + + // Capture other JSON encoded paths + testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName); + testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath); + + // TODO: may need to initialise the server resource in future. + // s_hypervresource.initialize(); + + // Verify sample template is in place storage pool + s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON + + " sample template at " + testSampleTemplateURLJSON); + } + + private String CreateTestDiskImageFromExistingImage(FileInfo srcFile, + String dstPath, + String dstFileName) + { + var newFullname = Path.Combine(dstPath, dstFileName); + var newFileInfo = new FileInfo(newFullname); + if (!newFileInfo.Exists) + { + newFileInfo = srcFile.CopyTo(newFullname); + } + newFileInfo.Refresh(); + Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName); + + return JsonConvert.SerializeObject(newFileInfo.FullName); + } + + [Fact] + public void TestCreateCommand() + { + DirectoryInfo localStorePath = new DirectoryInfo(testLocalStorePath); + if (!localStorePath.Exists) + { + try + { + localStorePath.Create(); + } + catch (System.IO.IOException ex) + { + throw new NotImplementedException("Need to be able to create the folder " + localStorePath.FullName + " failed due to " + ex.Message); + } + } + + FileInfo sampleTemplateFile = new FileInfo(Path.Combine(testLocalStorePath, testSampleTemplateUUID)); + if (!sampleTemplateFile.Exists) + { + //Create a file to write to. + using (StreamWriter sw = sampleTemplateFile.CreateText()) + { + sw.WriteLine("This is fake template file for test"); + } + } + var counter = 0; + wmiCallsV2.When(x => x.CreateDynamicVirtualHardDisk(Arg.Any(), Arg.Any())).Do(x => counter++); + // TODO: Need sample to update the test. + // Arrange + String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" + + ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," + + "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," + + "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}"; + dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd); + HypervResourceController rsrcServer = new HypervResourceController(); + HypervResourceController.wmiCallsV2 = wmiCallsV2; + + Assert.True(Directory.Exists(testLocalStorePath), testLocalStorePath + " does not exist "); + string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON)); + Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath); + int fileCount = Directory.GetFiles(testLocalStorePath).Length; + s_logger.Debug(" test local store has " + fileCount + "files"); + + // Act + // Test requires there to be a template at the tempalteUrl, which is its location in the local file system. + dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd); + s_logger.Debug("CreateDynamicVirtualHardDisk method is called " + counter + " times"); + + //Assert.Equal(counter, 1); + + JObject ansAsProperty2 = jsonResult[0]; + dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer); + Assert.NotNull(ans); + Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result); + Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1); + FileInfo newFile = new FileInfo((string)ans.volume.path); + Assert.True(newFile.Length > 0, "The new file should have a size greater than zero"); + newFile.Delete(); + sampleTemplateFile.Delete(); + } + + [Fact] + public void TestDestroyCommand() + { + testSampleVolumeTempURIJSON = "\"storagepool\""; + // Arrange + String destroyCmd = //"{\"volume\":" + getSampleVolumeObjectTO() + "}"; + "{\"volume\":{\"name\":\"" + testSampleVolumeTempUUIDNoExt + + "\",\"storagePoolType\":\"Filesystem\"," + + "\"mountPoint\":" + + testLocalStorePathJSON + + ",\"path\":" + testSampleVolumeTempURIJSON + + ",\"storagePoolUuid\":\"" + testLocalStoreUUID + + "\"," + + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}"; + + ImageManagementService imgmgr = new ImageManagementService(); + wmiCallsV2.GetImageManagementService().Returns(imgmgr); + + HypervResourceController rsrcServer = new HypervResourceController(); + HypervResourceController.wmiCallsV2 = wmiCallsV2; + + dynamic jsonDestroyCmd = JsonConvert.DeserializeObject(destroyCmd); + + // Act + dynamic destroyAns = rsrcServer.DestroyCommand(jsonDestroyCmd); + + // Assert + JObject ansAsProperty2 = destroyAns[0]; + dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.Answer); + String path = jsonDestroyCmd.volume.path; + Assert.True((bool)ans.result, "DestroyCommand did not succeed " + ans.details); + Assert.True(!File.Exists(path), "Failed to delete file " + path); + } + + [Fact] + public void TestStartCommand() + { + ComputerSystem system = new ComputerSystem(); + wmiCallsV2.DeployVirtualMachine(Arg.Any(), Arg.Any()).Returns(system); + + // Arrange + HypervResourceController rsrcServer = new HypervResourceController(); + HypervResourceController.wmiCallsV2 = wmiCallsV2; + String sample = getSampleStartCommand(); + + + dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample); + + // Act + dynamic startAns = rsrcServer.StartCommand(jsonStartCmd); + + // Assert + Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]); + Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details); + + Assert.Null((string)startAns[0][CloudStackTypes.StartAnswer].details); + } + + [Fact] + public void TestStopCommand() + { + //string vmName = "Test VM"; + var counter = 0; + wmiCallsV2.When(x => x.DestroyVm(Arg.Any())).Do(x => counter++); + + // Arrange + HypervResourceController rsrcServer = new HypervResourceController(); + HypervResourceController.wmiCallsV2 = wmiCallsV2; + + String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"checkBeforeCleanup\":false,\"wait\":0}"; + dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop); + + // Act + dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd); + + // Assert VM is gone! + Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]); + Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details); + + Assert.Null((string)stopAns[0][CloudStackTypes.StopAnswer].details); + Assert.Equal(counter, 1); + } + + public static String getSamplePrimaryDataStoreInfo() + { + String samplePrimaryDataStoreInfo = + "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" + + "{\"uuid\":\"" + testLocalStoreUUID + "\"," + + "\"id\":201," + + "\"host\":\"" + testPrimaryDataStoreHost + "\"," + + "\"type\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO + "\"poolType\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO + "\"path\":" + testLocalStorePathJSON + "," + + "\"port\":0}" + + "}"; + return samplePrimaryDataStoreInfo; + } + + public static String getSampleVolumeObjectTO() + { + String sampleVolumeObjectTO = + "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + + "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + + "\"volumeType\":\"ROOT\"," + + "\"format\":\"VHDX\"," + + "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + + "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," + + "\"size\":52428800," + + "\"volumeId\":10," + + // "\"vmName\":\"i-3-5-VM\"," + // TODO: do we have to fill in the vmName? + "\"accountId\":3,\"id\":10}" + + "}"; // end of destTO + return sampleVolumeObjectTO; + } + + public static String getSampleStartCommand() + { + String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," + + "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," + + "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," + + "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," + + "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" + + ",\"disks\":[" + + "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," + + "{\"diskSeq\":1,\"type\":\"ISO\"}" + + "]," + + "\"nics\":[" + + "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," + + "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," + + "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," + + "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" + + "]},\"contextMap\":{},\"wait\":0}"; + return sample; + } + } +} diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs index f816309c820..288d1a1c406 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs @@ -1,1147 +1,1147 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -using System; -using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION; -using System.Management; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; -using System.IO; -using log4net; -using HypervResource; -using CloudStack.Plugin.AgentShell; -using System.Collections.Generic; -using System.Xml; -using Xunit; - -namespace ServerResource.Tests -{ - public class HypervResourceControllerTest - { - protected static string testCifsUrl = AgentSettings.Default.testCifsUrl; - protected static string testCifsPath = AgentSettings.Default.testCifsPath; - protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress; - protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName; - protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName; - protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName; - protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt; - protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2"; - protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool"); - protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary"); - - // TODO: differentiate between NFS and HTTP template URLs. - protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx"; - protected static String testSampleTemplateURL = testSampleTemplateUUID; - - // test volumes are both a minimal size vhdx. Changing the extension to .vhd makes on corrupt. - protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx"; - protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd"; - protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx"; - protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp"; - protected static String testSampleVolumeWorkingURIJSON; - protected static String testSampleVolumeCorruptURIJSON; - protected static String testSampleVolumeTempURIJSON; - - protected static String testSampleTemplateURLJSON; - protected static String testLocalStorePathJSON; - - protected static WmiCallsV2 wmiCallsV2 = new WmiCallsV2(); - - private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceControllerTest)); - - /// - /// Test WmiCalls to which incoming HTTP POST requests are dispatched. - /// - /// TODO: revise beyond first approximation - /// First approximation is a quick port of the existing Java tests for Hyper-V server resource. - /// A second approximation would use the AgentShell settings files directly. - /// A third approximation would look to invoke ServerResource methods via an HTTP request - /// - public HypervResourceControllerTest() - { - AgentService.ConfigServerResource(); - HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address; - HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask; - HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress; - HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress; - HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask; - - - // Used to create existing StoragePool in preparation for the ModifyStoragePool - testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString(); - - // Make sure secondary store is available. - string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath); - s_logger.Info("Test secondary storage in " + fullPath); - DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath); - if (!testSecondarStoreDir.Exists) - { - try - { - testSecondarStoreDir.Create(); - } - catch (System.IO.IOException ex) - { - throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message); - } - } - - // Convert to secondary storage string to canonical path - testSecondaryStoreLocalPath = testSecondarStoreDir.FullName; - AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath; - - // Make sure local primary storage is available - DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath); - Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName); - - // Convert to local primary storage string to canonical path - testLocalStorePath = testPoolDir.FullName; - AgentSettings.Default.local_storage_path = testLocalStorePath; - - // Clean up old test files in local storage folder - FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID)); - Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName); - - - // Delete all temporary files in local folder save the testVolWorks - foreach (var file in testPoolDir.GetFiles()) - { - if (file.FullName == testVolWorks.FullName) - { - continue; - } - file.Delete(); - file.Refresh(); - Assert.False(file.Exists, "removed file from previous test called " + file.FullName); - } - - // Recreate starting point files for test, and record JSON encoded paths for each ... - testSampleVolumeTempURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeTempUUID); - s_logger.Info("Created " + testSampleVolumeTempURIJSON); - testSampleVolumeCorruptURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeCorruptUUID); - s_logger.Info("Created " + testSampleVolumeCorruptURIJSON); - CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleTemplateUUID); - testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID); - s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); - - // ... including a secondary storage template: - CreateTestDiskImageFromExistingImage(testVolWorks, testSecondarStoreDir.FullName, "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx"); - s_logger.Info("Created " + "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx" + " in secondary (NFS) storage."); - - - // Capture other JSON encoded paths - testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName); - testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath); - - // TODO: may need to initialise the server resource in future. - // s_hypervresource.initialize(); - - // Verify sample template is in place storage pool - s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON - + " sample template at " + testSampleTemplateURLJSON); - } - - private String CreateTestDiskImageFromExistingImage(FileInfo srcFile, - String dstPath, - String dstFileName) - { - var newFullname = Path.Combine(dstPath, dstFileName); - var newFileInfo = new FileInfo(newFullname); - if (!newFileInfo.Exists) - { - newFileInfo = srcFile.CopyTo(newFullname); - } - newFileInfo.Refresh(); - Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName); - - return JsonConvert.SerializeObject(newFileInfo.FullName); - } - - [Fact(Skip="these are functional tests")] - public void TestPrimaryStorageDownloadCommandHTTP() - { - string downloadURI = "https://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx"; - corePrimaryStorageDownloadCommandTestCycle(downloadURI); - } - - private void corePrimaryStorageDownloadCommandTestCycle(string downloadURI) - { - // Arrange - HypervResourceController rsrcServer = new HypervResourceController(); - dynamic jsonPSDCmd = JsonConvert.DeserializeObject(samplePrimaryDownloadCommand()); - jsonPSDCmd.url = downloadURI; - - // Act - dynamic jsonResult = rsrcServer.PrimaryStorageDownloadCommand(jsonPSDCmd); - - // Assert - JObject ansAsProperty = jsonResult[0]; - dynamic ans = ansAsProperty.GetValue(CloudStackTypes.PrimaryStorageDownloadAnswer); - Assert.True((bool)ans.result, "PrimaryStorageDownloadCommand did not succeed " + ans.details); - - // Test that URL of downloaded template works for file creation. - dynamic jsonCreateCmd = JsonConvert.DeserializeObject(CreateCommandSample()); - jsonCreateCmd.templateUrl = ans.installPath; - dynamic jsonAns2 = rsrcServer.CreateCommand(jsonCreateCmd); - JObject ansAsProperty2 = jsonAns2[0]; - dynamic ans2 = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer); - - Assert.True((bool)ans2.result, (string)ans2.details); - - FileInfo newFile = new FileInfo((string)ans2.volume.path); - Assert.True(newFile.Length > 0, "The new file should have a size greater than zero"); - newFile.Delete(); - } - - private string samplePrimaryDownloadCommand() - { - String cmdJson = "{\"localPath\":" + testLocalStorePathJSON + - ",\"poolUuid\":\"" + testLocalStoreUUID + "\",\"poolId\":201," + - "\"secondaryStorageUrl\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage\"," + - "\"primaryStorageUrl\":\"nfs://" + HypervResourceController.config.StorageIpAddress + "E:\\\\Disks\\\\Disks\"," + - "\"url\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage/template/tmpl//2/204//af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx\"," + - "\"format\":\"VHDX\",\"accountId\":2,\"name\":\"204-2-5a1db1ac-932b-3e7e-a0e8-5684c72cb862\"" + - ",\"contextMap\":{},\"wait\":10800}"; - return cmdJson; - } - - public string CreateCommandSample() - { - String sample = "{\"volId\":17,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" + - ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," + - "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-15\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," + - "\"volumeId\":17,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"wait\":0}"; - return sample; - } - - [Fact(Skip="these are functional tests")] - public void TestDestroyCommand() - { - // Arrange - String sampleVolume = getSampleVolumeObjectTO(); - String destroyCmd = //"{\"volume\":" + getSampleVolumeObjectTO() + "}"; - "{\"volume\":{\"name\":\"" + testSampleVolumeTempUUIDNoExt - + "\",\"storagePoolType\":\"Filesystem\"," - + "\"mountPoint\":" - + testLocalStorePathJSON - + ",\"path\":" + testSampleVolumeTempURIJSON - + ",\"storagePoolUuid\":\"" + testLocalStoreUUID - + "\"," - + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}"; - - HypervResourceController rsrcServer = new HypervResourceController(); - dynamic jsonDestroyCmd = JsonConvert.DeserializeObject(destroyCmd); - - // Act - dynamic destroyAns = rsrcServer.DestroyCommand(jsonDestroyCmd); - - // Assert - JObject ansAsProperty2 = destroyAns[0]; - dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.Answer); - String path = jsonDestroyCmd.volume.path; - Assert.True((bool)ans.result, "DestroyCommand did not succeed " + ans.details); - Assert.True(!File.Exists(path), "Failed to delete file " + path); - } - - [Fact(Skip="these are functional tests")] - public void TestCreateCommand() - { - // TODO: Need sample to update the test. - // Arrange - String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" + - ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," + - "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," + - "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}"; - dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd); - HypervResourceController rsrcServer = new HypervResourceController(); - - Assert.True(Directory.Exists(testLocalStorePath)); - string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON)); - Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath); - int fileCount = Directory.GetFiles(testLocalStorePath).Length; - s_logger.Debug(" test local store has " + fileCount + "files"); - - // Act - // Test requires there to be a template at the tempalteUrl, which is its location in the local file system. - dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd); - - JObject ansAsProperty2 = jsonResult[0]; - dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer); - Assert.NotNull(ans); - Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result); - Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1); - FileInfo newFile = new FileInfo((string)ans.volume.path); - Assert.True(newFile.Length > 0, "The new file should have a size greater than zero"); - newFile.Delete(); - } - - /// - /// Possible additional tests: place an ISO in the drive - /// - [Fact(Skip="these are functional tests")] - public void TestStartStopCommand() - { - string vmName = TestStartCommand(); - TestStopCommand(vmName); - } - - public static String getSamplePrimaryDataStoreInfo() - { - String samplePrimaryDataStoreInfo = - "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" + - "{\"uuid\":\"" + testLocalStoreUUID + "\"," + - "\"id\":201," + - "\"host\":\"" + testPrimaryDataStoreHost + "\"," + - "\"type\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO - "\"poolType\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO - "\"path\":" + testLocalStorePathJSON + "," + - "\"port\":0}" + - "}"; - return samplePrimaryDataStoreInfo; - } - - public static String getSampleVolumeObjectTO() - { - String sampleVolumeObjectTO = - "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + - "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + - "\"volumeType\":\"ROOT\"," + - "\"format\":\"VHDX\"," + - "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + - "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," + - "\"size\":52428800," + - "\"volumeId\":10," + - // "\"vmName\":\"i-3-5-VM\"," + // TODO: do we have to fill in the vmName? - "\"accountId\":3,\"id\":10}" + - "}"; // end of destTO - return sampleVolumeObjectTO; - } - - public static String getSampleStartCommand() - { - String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," + - "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," + - "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," + - "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," + - "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" + - ",\"disks\":[" + - "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," + - "{\"diskSeq\":1,\"type\":\"ISO\"}" + - "]," + - "\"nics\":[" + - "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," + - "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," + - "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," + - "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" + - "]},\"contextMap\":{},\"wait\":0}"; - return sample; - } - - - [Fact(Skip="these are functional tests")] - public void TestCopyCommandFromCifs() - { - // Arrange - string sampleCopyCommandForTemplateDownload = - #region string_literal - // org.apache.cloudstack.storage.command.CopyCommand - "{\"srcTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{\"path\":\"" + testCifsPath + "\"," + - "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + - "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + - "\"id\":206," + - "\"format\":\"VHDX\"," + - "\"accountId\":2," + - "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + - "\"hvm\":true," + - "\"displayText\":\"OS031\"," + - "\"imageDataStore\":" + - "{\"com.cloud.agent.api.to.NfsTO\":" + - "{\"_url\":\"" + testCifsUrl + "\"," + // Unique item here - "\"_role\":\"Image\"}" + - "}," + // end of imageDataStore - "\"hypervisorType\":\"Hyperv\"," + - "\"name\":\"" + testS3TemplateName + "\"}" + - "}," + // end of srcTO - "\"destTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{" + - "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + - "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + - "\"id\":206," + - "\"format\":\"VHDX\"," + - "\"accountId\":2," + - "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + - "\"hvm\":true," + - "\"displayText\":\"Test of CIFS Download\"," + - "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore - "\"name\":\"" + testS3TemplateName + "\"," + - "\"hypervisorType\":\"Hyperv\"}" + - "}," +// end of destTO - "\"wait\":10800}"; // end of CopyCommand - #endregion - - HypervResourceController rsrcServer; - dynamic jsonDownloadCopyCmd; - string dwnldDest; - dynamic jsonCloneCopyCmd; - string newVolName; - CopyCommandTestSetupCifs(null, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName); - - // Act & Assert - DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); - - // Repeat to verify ability to detect existing file. - DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); - - File.Delete(dwnldDest); - } - - [Fact(Skip="these are functional tests")] - public void TestCopyCommand() - { - // Arrange - string sampleCopyCommandToCreateVolumeFromTemplate = - #region string_literal - // org.apache.cloudstack.storage.command.CopyCommand - "{\"srcTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{" + - "\"origUrl\":\"http://people.apache.org/~bhaisaab/vms/ttylinux_pv.vhd\"," + - "\"uuid\":\"9873f1c0-bdcc-11e2-8baa-ea85dab5fcd0\"," + - "\"id\":5," + - "\"format\":\"VHDX\"," + - "\"accountId\":1," + - "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + - "\"hvm\":false," + - "\"displayText\":\"tiny Linux\"," + - "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + - "\"name\":\"" + testS3TemplateName + "\"}" + - "}," + // end of srcTO - "\"destTO\":" + - "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + - "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + - "\"volumeType\":\"ROOT\"," + - "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + - "\"name\":\"ROOT-5\"," + - "\"size\":52428800," + - "\"volumeId\":10," + - "\"vmName\":\"i-3-5-VM\"," + - "\"accountId\":3," + - "\"id\":10 }" + - "}," + // end of destTO - "\"wait\":0}"; // end of Copy Command - #endregion - //"name":"ROOT-8","size":140616708,"volumeId":8,"vmName":"s-8-VM","accountId":1,"id":8}},"contextMap":{},"wait":0} - - string sampleCopyCommandForTemplateDownload = - #region string_literal - // org.apache.cloudstack.storage.command.CopyCommand - "{\"srcTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{\"path\":\"" + testS3TemplateName + ".vhdx" + "\"," + - "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + - "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + - "\"id\":206," + - "\"format\":\"VHDX\"," + - "\"accountId\":2," + - "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + - "\"hvm\":true," + - "\"displayText\":\"OS031\"," + - "\"imageDataStore\":" + - "{\"com.cloud.agent.api.to.S3TO\":" + - "{\"id\":1," + - "\"uuid\":\"95a64c8f-2128-4502-b5b4-0d7aa77406d2\"," + - "\"accessKey\":\"" + AgentSettings.Default.testS3AccessKey + "\"," + - "\"secretKey\":\"" + AgentSettings.Default.testS3SecretKey + "\"," + - "\"endPoint\":\"" + AgentSettings.Default.testS3Endpoint + "\"," + - "\"bucketName\":\"" + AgentSettings.Default.testS3Bucket + "\"," + - "\"httpsFlag\":false," + - "\"created\":\"May 19, 2013 4:17:25 PM\"}" + - "}," + // end of imageDataStore - "\"name\":\"" + testS3TemplateName + "\"}" + - "}," + // end of srcTO - "\"destTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{" + - "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + - "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + - "\"id\":206," + - "\"format\":\"VHDX\"," + - "\"accountId\":2," + - "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + - "\"hvm\":true," + - "\"displayText\":\"OS031\"," + - "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore - "\"name\":\"" + testS3TemplateName + "\"}" + - "}," +// end of destTO - "\"wait\":10800}"; // end of CopyCommand - #endregion - - HypervResourceController rsrcServer; - dynamic jsonDownloadCopyCmd; - string dwnldDest; - dynamic jsonCloneCopyCmd; - string newVolName; - CopyCommandTestSetup(sampleCopyCommandToCreateVolumeFromTemplate, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName); - - // Act & Assert - DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); - CreateVolumeFromTemplate(rsrcServer, jsonCloneCopyCmd, newVolName); - - // Repeat to verify ability to detect existing file. - DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); - - File.Delete(dwnldDest); - File.Delete(newVolName); - } - - private static void CreateVolumeFromTemplate(HypervResourceController rsrcServer, dynamic jsonCloneCopyCmd, string newVolName) - { - dynamic copyResult = rsrcServer.CopyCommand(jsonCloneCopyCmd); - - // Assert - Assert.NotNull(copyResult[0][CloudStackTypes.CopyCmdAnswer]); - Assert.True((bool)copyResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + copyResult[0][CloudStackTypes.CopyCmdAnswer].details); - Assert.True(File.Exists(newVolName), "CopyCommand failed to generate " + newVolName); - } - - private static void DownloadTemplateToPrimaryStorage(HypervResourceController rsrcServer, dynamic jsonDownloadCopyCmd, string dwnldDest) - { - dynamic dwnldResult = rsrcServer.CopyCommand(jsonDownloadCopyCmd); - - // Assert - Assert.NotNull(dwnldResult[0][CloudStackTypes.CopyCmdAnswer]); - Assert.True((bool)dwnldResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + dwnldResult[0][CloudStackTypes.CopyCmdAnswer].details); - Assert.True(File.Exists(dwnldDest), "CopyCommand failed to generate " + dwnldDest); - } - - [Fact(Skip="these are functional tests")] - public void TestCopyCommandBz2Img() - { - // Arrange - string sampleCopyCommandToCreateVolumeFromTemplate = - #region string_literal - // org.apache.cloudstack.storage.command.CopyCommand - "{\"srcTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{" + - "\"origUrl\":\"http://people.apache.org/~bhaisaab/vms/ttylinux_pv.vhd\"," + - "\"uuid\":\"9873f1c0-bdcc-11e2-8baa-ea85dab5fcd0\"," + - "\"id\":5," + - "\"format\":\"VHD\"," + - "\"accountId\":1," + - "\"checksum\":\"f613f38c96bf039f2e5cbf92fa8ad4f8\"," + - "\"hvm\":false," + - "\"displayText\":\"tiny Linux\"," + - "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + - "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" + - "}," + // end of srcTO - "\"destTO\":" + - "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + - "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + - "\"volumeType\":\"ROOT\"," + - "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + - "\"name\":\"ROOT-5\"," + - "\"size\":52428800," + - "\"volumeId\":10," + - "\"vmName\":\"i-3-5-VM\"," + - "\"accountId\":1," + - "\"id\":10}" + - "}," + // end of destTO - "\"wait\":0}"; // end of Copy Command - #endregion - - string sampleCopyCommandForTemplateDownload = - #region string_literal - // org.apache.cloudstack.storage.command.CopyCommand - "{\"srcTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{\"path\":\"" + testSystemVMTemplateName + "\"," + - "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + - "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + - "\"id\":206," + - "\"format\":\"VHD\"," + - "\"accountId\":1," + - "\"checksum\": \"f613f38c96bf039f2e5cbf92fa8ad4f8\"," + - "\"hvm\":true," + - "\"displayText\":\"OS031\"," + - "\"imageDataStore\":" + - "{\"com.cloud.agent.api.to.S3TO\":" + - "{\"id\":1," + - "\"uuid\":\"95a64c8f-2128-4502-b5b4-0d7aa77406d2\"," + - "\"accessKey\":\"" + AgentSettings.Default.testS3AccessKey + "\"," + - "\"secretKey\":\"" + AgentSettings.Default.testS3SecretKey + "\"," + - "\"endPoint\":\"" + AgentSettings.Default.testS3Endpoint + "\"," + - "\"bucketName\":\"" + AgentSettings.Default.testS3Bucket + "\"," + - "\"httpsFlag\":false," + - "\"created\":\"May 19, 2013 4:17:25 PM\"}" + - "}," + // end of imageDataStore - "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" + - "}," + // end of srcTO - "\"destTO\":" + - "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + - "{" + - "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + - "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + - "\"id\":206," + - "\"format\":\"VHD\"," + - "\"accountId\":1," + - "\"checksum\": \"f613f38c96bf039f2e5cbf92fa8ad4f8\"," + - "\"hvm\":true," + - "\"displayText\":\"OS031\"," + - "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore - "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" + - "}," +// end of destTO - "\"wait\":10800}"; // end of CopyCommand - #endregion - - HypervResourceController rsrcServer; - dynamic jsonDownloadCopyCmd; - string dwnldDest; - dynamic jsonCloneCopyCmd; - string newVolName; - CopyCommandTestSetup(sampleCopyCommandToCreateVolumeFromTemplate, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName); - - // Act & Assert - DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); - CreateVolumeFromTemplate(rsrcServer, jsonCloneCopyCmd, newVolName); - - File.Delete(dwnldDest); - File.Delete(newVolName); - } - - private static void CopyCommandTestSetup(string sampleCopyCommandToCreateVolumeFromTemplate, string sampleCopyCommandForTemplateDownload, out HypervResourceController rsrcServer, out dynamic jsonDownloadCopyCmd, out string dwnldDest, out dynamic jsonCloneCopyCmd, out string newVolName) - { - rsrcServer = new HypervResourceController(); - jsonDownloadCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandForTemplateDownload); - TemplateObjectTO dwnldTemplate = TemplateObjectTO.ParseJson(jsonDownloadCopyCmd.destTO); - dwnldDest = dwnldTemplate.FullFileName; - - jsonCloneCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandToCreateVolumeFromTemplate); - VolumeObjectTO newVol = VolumeObjectTO.ParseJson(jsonCloneCopyCmd.destTO); - newVol.format = dwnldTemplate.format; - newVolName = dwnldTemplate.FullFileName; - - if (File.Exists(dwnldDest)) - { - File.Delete(dwnldDest); - } - if (File.Exists(newVolName)) - { - File.Delete(newVolName); - } - } - - private static void CopyCommandTestSetupCifs(string sampleCopyCommandToCreateVolumeFromTemplate, string sampleCopyCommandForTemplateDownload, out HypervResourceController rsrcServer, out dynamic jsonDownloadCopyCmd, out string dwnldDest, out dynamic jsonCloneCopyCmd, out string newVolName) - { - rsrcServer = new HypervResourceController(); - jsonDownloadCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandForTemplateDownload); - TemplateObjectTO dwnldTemplate = TemplateObjectTO.ParseJson(jsonDownloadCopyCmd.destTO); - dwnldDest = dwnldTemplate.FullFileName; - - if (File.Exists(dwnldDest)) - { - File.Delete(dwnldDest); - } - newVolName = null; - jsonCloneCopyCmd = null; - } - - [Fact(Skip="these are functional tests")] - public void TestModifyStoragePoolCommand() - { - // Create dummy folder - String folderName = Path.Combine(".", "Dummy"); - if (!Directory.Exists(folderName)) - { - Directory.CreateDirectory(folderName); - } - - var pool = new - { // From java class StorageFilerTO - type = Enum.GetName(typeof(StoragePoolType), StoragePoolType.Filesystem), - host = "127.0.0.1", - port = -1, - path = folderName, - uuid = Guid.NewGuid().ToString(), - userInfo = string.Empty // Used in future to hold credential - }; - - var cmd = new - { - add = true, - pool = pool, - localPath = folderName - }; - JToken tok = JToken.FromObject(cmd); - HypervResourceController controller = new HypervResourceController(); - - // Act - dynamic jsonResult = controller.ModifyStoragePoolCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.ModifyStoragePoolAnswer]; - Assert.True((bool)ans.result, (string)ans.details); // always succeeds - - // Clean up - var cmd2 = new - { - pool = pool, - localPath = folderName - }; - JToken tok2 = JToken.FromObject(cmd); - - // Act - dynamic jsonResult2 = controller.DeleteStoragePoolCommand(tok2); - - // Assert - dynamic ans2 = jsonResult2[0][CloudStackTypes.Answer]; - Assert.True((bool)ans2.result, (string)ans2.details); // always succeeds - } - - [Fact(Skip="these are functional tests")] - public void CreateStoragePoolCommand() - { - var cmd = new { localPath = "NULL" }; - JToken tok = JToken.FromObject(cmd); - HypervResourceController controller = new HypervResourceController(); - - // Act - dynamic jsonResult = controller.CreateStoragePoolCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.Answer]; - Assert.True((bool)ans.result, (string)ans.details); // always succeeds - } - - [Fact(Skip="these are functional tests")] - public void MaintainCommand() - { - // Omit HostEnvironment object, as this is a series of settings currently not used. - var cmd = new { }; - JToken tok = JToken.FromObject(cmd); - HypervResourceController controller = new HypervResourceController(); - - // Act - dynamic jsonResult = controller.MaintainCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.MaintainAnswer]; - Assert.True((bool)ans.result, (string)ans.details); // always succeeds - } - - [Fact(Skip="these are functional tests")] - public void SetupCommand() - { - // Omit HostEnvironment object, as this is a series of settings currently not used. - var cmd = new { multipath = false, needSetup = true }; - JToken tok = JToken.FromObject(cmd); - HypervResourceController controller = new HypervResourceController(); - - // Act - dynamic jsonResult = controller.SetupCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.SetupAnswer]; - Assert.True((bool)ans.result, (string)ans.details); // always succeeds - } - - [Fact(Skip="these are functional tests")] - public void TestPassingUserdataToVm() - { - // Sample data - String key = "cloudstack-vm-userdata"; - String value = "username=root;password=1pass@word1"; - - // Find the VM - List vmNames = wmiCallsV2.GetVmElementNames(); - - // Get associated WMI object - var vm = wmiCallsV2.GetComputerSystem(AgentSettings.Default.testKvpVmName); - - // Get existing KVP - var vmSettings = wmiCallsV2.GetVmSettings(vm); - var kvpInfo = wmiCallsV2.GetKvpSettings(vmSettings); - - // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object. - string[] kvpProps = kvpInfo.HostExchangeItems; - - // If the value already exists, delete it - foreach (var item in kvpProps) - { - String wmiObjectXml = item; - String existingKey; - String existingValue; - ParseKVP(wmiObjectXml, out existingKey, out existingValue); - - if (existingKey == key) - { - wmiCallsV2.DeleteHostKvpItem(vm, existingKey); - break; - } - } - - // Add new user data - wmiCallsV2.AddUserData(vm, value); - - // Verify key added to subsystem - kvpInfo = wmiCallsV2.GetKvpSettings(vmSettings); - - // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object. - kvpProps = kvpInfo.HostExchangeItems; - - // If the value already exists, delete it - bool userDataInPlace = false; - foreach (var item in kvpProps) - { - String wmiObjectXml = item; - String existingKey; - String existingValue; - ParseKVP(wmiObjectXml, out existingKey, out existingValue); - - if (existingKey == key && existingValue == value) - { -// wmiCallsV2.DeleteHostKvpItem(vm, existingKey); - userDataInPlace = true; - break; - } - } - - Assert.True(userDataInPlace, "User data key / value did no save properly"); - } - - private static void ParseKVP(String wmiObjectXml, out String existingKey, out String existingValue) - { - // Reference: http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/12/05/enumerating-parent-kvp-data.aspx - - // Create XML parser - var xmlDoc = new XmlDocument(); - - // Load WMI object - xmlDoc.LoadXml(wmiObjectXml); - - // Use xpath to get name and value - var namePropXpath = "/INSTANCE/PROPERTY[@NAME='Name']/VALUE"; - var nameNode = xmlDoc.SelectSingleNode(namePropXpath); - existingKey = nameNode.InnerText; - var dataPropXpath = "/INSTANCE/PROPERTY[@NAME='Data']/VALUE"; - var dataNode = xmlDoc.SelectSingleNode(dataPropXpath); - existingValue = dataNode.InnerText; - } - - [Fact(Skip="these are functional tests")] - public void GetVmStatsCommandFail() - { - // Use WMI to find existing VMs - List vmNames = new List(); - vmNames.Add("FakeVM"); - - var cmd = new - { - hostGuid = "FAKEguid", - hostName = AgentSettings.Default.host, - vmNames = vmNames - }; - JToken tok = JToken.FromObject(cmd); - HypervResourceController controller = new HypervResourceController(); - - // Act - dynamic jsonResult = controller.GetVmStatsCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer]; - Assert.True((bool)ans.result, (string)ans.details); // always succeeds, fake VM means no answer for the named VM - } - - [Fact(Skip="these are functional tests")] - public void GetVmStatsCommand() - { - // Use WMI to find existing VMs - List vmNames = wmiCallsV2.GetVmElementNames(); - - var cmd = new - { - hostGuid = "FAKEguid", - hostName = AgentSettings.Default.host, - vmNames = vmNames - }; - JToken tok = JToken.FromObject(cmd); - HypervResourceController controller = new HypervResourceController(); - - // Act - dynamic jsonResult = controller.GetVmStatsCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer]; - Assert.True((bool)ans.result, (string)ans.details); - } - - [Fact(Skip="these are functional tests")] - public void GetStorageStatsCommand() - { - // TODO: Update sample data to unsure it is using correct info. - String sample = String.Format( - #region string_literal -"{{\"" + - "id\":{0}," + - "\"localPath\":{1}," + - "\"pooltype\":\"Filesystem\"," + - "\"contextMap\":{{}}," + - "\"wait\":0}}", - JsonConvert.SerializeObject(AgentSettings.Default.testLocalStoreUUID), - JsonConvert.SerializeObject(AgentSettings.Default.testLocalStorePath) - ); - #endregion - var cmd = JsonConvert.DeserializeObject(sample); - JToken tok = JToken.FromObject(cmd); - HypervResourceController controller = new HypervResourceController(); - - // Act - dynamic jsonResult = controller.GetStorageStatsCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.GetStorageStatsAnswer]; - Assert.True((bool)ans.result, (string)ans.details); - Assert.True((long)ans.used <= (long)ans.capacity); // TODO: verify that capacity is indeed capacity and not used. - } - - // TODO: can we speed up this command? The logic takes over a second. - [Fact(Skip="these are functional tests")] - public void GetHostStatsCommand() - { - // Arrange - long hostIdVal = 5; - HypervResourceController controller = new HypervResourceController(); - string sample = string.Format( - #region string_literal -"{{" + - "\"hostGuid\":\"B4AE5970-FCBF-4780-9F8A-2D2E04FECC34-HypervResource\"," + - "\"hostName\":\"CC-SVR11\"," + - "\"hostId\":{0}," + - "\"contextMap\":{{}}," + - "\"wait\":0}}", - JsonConvert.SerializeObject(hostIdVal)); - #endregion - var cmd = JsonConvert.DeserializeObject(sample); - JToken tok = JToken.FromObject(cmd); - - // Act - dynamic jsonResult = controller.GetHostStatsCommand(tok); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer]; - Assert.True((bool)ans.result); - Assert.True(hostIdVal == (long)ans.hostStats.hostId); - Assert.True(0.0 < (double)ans.hostStats.totalMemoryKBs); - Assert.True(0.0 < (double)ans.hostStats.freeMemoryKBs); - Assert.True(0.0 <= (double)ans.hostStats.networkReadKBs); - Assert.True(0.0 <= (double)ans.hostStats.networkWriteKBs); - Assert.True(0.0 <= (double)ans.hostStats.cpuUtilization); - Assert.True(100.0 >= (double)ans.hostStats.cpuUtilization); - Assert.True("host".Equals((string)ans.hostStats.entityType)); - Assert.True(String.IsNullOrEmpty((string)ans.details)); - } - - [Fact(Skip="these are functional tests")] - public void GetHostStatsCommandFail() - { - // Arrange - HypervResourceController controller = new HypervResourceController(); - var cmd = new { GetHostStatsCommand = new { hostId = "badvalueType" } }; - JToken tokFail = JToken.FromObject(cmd); - - // Act - dynamic jsonResult = controller.GetHostStatsCommand(tokFail); - - // Assert - dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer]; - Assert.False((bool)ans.result); - Assert.Null((string)ans.hostStats); - Assert.NotNull(ans.details); - } - - [Fact(Skip="these are functional tests")] - public void TestStartupCommand() - { - // Arrange - HypervResourceController controller = new HypervResourceController(); - String sampleStartupRoutingCommand = - #region string_literal - "[{\"" + CloudStackTypes.StartupRoutingCommand + "\":{" + - "\"cpus\":0," + - "\"speed\":0," + - "\"memory\":0," + - "\"dom0MinMemory\":0," + - "\"poolSync\":false," + - "\"vms\":{}," + - "\"hypervisorType\":\"Hyperv\"," + - "\"hostDetails\":{" + - "\"com.cloud.network.Networks.RouterPrivateIpStrategy\":\"HostLocal\"" + - "}," + - "\"type\":\"Routing\"," + - "\"dataCenter\":\"1\"," + - "\"pod\":\"1\"," + - "\"cluster\":\"1\"," + - "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + - "\"name\":\"localhost\"," + - "\"version\":\"4.2.0\"," + - "\"privateIpAddress\":\"1\"," + - "\"storageIpAddress\":\"1\"," + - "\"contextMap\":{}," + - "\"wait\":0}}]"; - #endregion - - uint cores; - uint mhz; - wmiCallsV2.GetProcessorResources(out cores, out mhz); - ulong memory_mb; - ulong freememory; - wmiCallsV2.GetMemoryResources(out memory_mb, out freememory); - memory_mb *= 1024; - long capacityBytes; - long availableBytes; - HypervResourceController.GetCapacityForLocalPath(wmiCallsV2.GetDefaultVirtualDiskFolder(), - out capacityBytes, out availableBytes); - var DefaultVirtualDiskFolder = JsonConvert.SerializeObject(wmiCallsV2.GetDefaultVirtualDiskFolder()); - string expected = - #region string_literal - "[{\"" + CloudStackTypes.StartupRoutingCommand + "\":{" + - "\"cpus\":" + cores + "," + - "\"speed\":" + mhz + "," + - "\"memory\":" + memory_mb + "," + - "\"dom0MinMemory\":" + (AgentSettings.Default.dom0MinMemory * 1024 * 1024) + "," + - "\"poolSync\":false," + - "\"vms\":{}," + - "\"hypervisorType\":\"Hyperv\"," + - "\"hostDetails\":{" + - "\"com.cloud.network.Networks.RouterPrivateIpStrategy\":\"HostLocal\"" + - "}," + - "\"type\":\"Routing\"," + - "\"dataCenter\":\"1\"," + - "\"pod\":\"1\"," + - "\"cluster\":\"1\"," + - "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + - "\"name\":\"localhost\"," + - "\"version\":\"4.2.0\"," + - "\"privateIpAddress\":\"" + AgentSettings.Default.private_ip_address + "\"," + - "\"storageIpAddress\":\"" + AgentSettings.Default.private_ip_address + "\"," + - "\"contextMap\":{}," + - "\"wait\":0," + - "\"privateNetmask\":\"" + AgentSettings.Default.private_ip_netmask + "\"," + - "\"privateMacAddress\":\"" + AgentSettings.Default.private_mac_address + "\"," + - "\"storageNetmask\":\"" + AgentSettings.Default.private_ip_netmask + "\"," + - "\"storageMacAddress\":\"" + AgentSettings.Default.private_mac_address + "\"," + - "\"gatewayIpAddress\":\"" + AgentSettings.Default.gateway_ip_address + "\"" + - ",\"caps\":\"hvm\"" + - "}}," + - "{\"com.cloud.agent.api.StartupStorageCommand\":{" + - "\"poolInfo\":{" + - "\"uuid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + - "\"host\":\"" + AgentSettings.Default.private_ip_address + "\"," + - "\"localPath\":" + DefaultVirtualDiskFolder + "," + - "\"hostPath\":" + DefaultVirtualDiskFolder + "," + - "\"poolType\":\"Filesystem\"," + - "\"capacityBytes\":" + capacityBytes + "," + - "\"availableBytes\":" + availableBytes + "," + - "\"details\":null" + - "}," + - "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + - "\"dataCenter\":\"1\"," + - "\"resourceType\":\"STORAGE_POOL\"" + - "}}]"; - #endregion - - dynamic jsonArray = JsonConvert.DeserializeObject(sampleStartupRoutingCommand); - - // Act - dynamic jsonResult = controller.StartupCommand(jsonArray); - - // Assert - string actual = JsonConvert.SerializeObject(jsonResult); - Assert.Equal(expected, actual); - } - - - private static string TestStartCommand() - { - // Arrange - HypervResourceController rsrcServer = new HypervResourceController(); - String sample = getSampleStartCommand(); - - - dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample); - - // Act - dynamic startAns = rsrcServer.StartCommand(jsonStartCmd); - - // Assert - Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]); - Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details); - string vmCmdName = jsonStartCmd.vm.name.Value; - var vm = wmiCallsV2.GetComputerSystem(vmCmdName); - var vmSettings = wmiCallsV2.GetVmSettings(vm); - var memSettings = wmiCallsV2.GetMemSettings(vmSettings); - var procSettings = wmiCallsV2.GetProcSettings(vmSettings); - dynamic jsonObj = JsonConvert.DeserializeObject(sample); - var vmInfo = jsonObj.vm; - string vmName = vmInfo.name; - var nicInfo = vmInfo.nics; - int vcpus = vmInfo.cpus; - int memSize = vmInfo.maxRam / 1048576; - Assert.True((long)memSettings.VirtualQuantity == memSize); - Assert.True((long)memSettings.Reservation == memSize); - Assert.True((long)memSettings.Limit == memSize); - Assert.True((int)procSettings.VirtualQuantity == vcpus); - Assert.True((int)procSettings.Reservation == vcpus); - Assert.True((int)procSettings.Limit == 100000); - - // examine NIC for correctness - var nicSettingsViaVm = wmiCallsV2.GetEthernetPortSettings(vm); - Assert.True(nicSettingsViaVm.Length > 0, "Should be at least one ethernet port on VM"); - string expectedMac = (string)jsonStartCmd.vm.nics[0].mac; - string strippedExpectedMac = expectedMac.Replace(":", string.Empty); - Assert.Equal(nicSettingsViaVm[0].Address.ToLower(), strippedExpectedMac.ToLower()); - - // Assert switchport has correct VLAN - var ethernetConnections = wmiCallsV2.GetEthernetConnections(vm); - var vlanSettings = wmiCallsV2.GetVlanSettings(ethernetConnections[0]); - string isolationUri = (string)jsonStartCmd.vm.nics[0].isolationUri; - string vlan = isolationUri.Replace("vlan://", string.Empty); - Assert.Equal(vlanSettings.AccessVlanId.ToString(), vlan); - - return vmName; - } - - private static void TestStopCommand(string vmName) - { - // Arrange - HypervResourceController rsrcServer = new HypervResourceController(); - String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"wait\":0}"; - dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop); - - // Act - dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd); - - // Assert VM is gone! - Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]); - Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details); - var finalVm = wmiCallsV2.GetComputerSystem(vmName); - Assert.True(wmiCallsV2.GetComputerSystem(vmName) == null); - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +using System; +using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION; +using System.Management; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System.IO; +using log4net; +using HypervResource; +using CloudStack.Plugin.AgentShell; +using System.Collections.Generic; +using System.Xml; +using Xunit; + +namespace ServerResource.Tests +{ + public class HypervResourceControllerTest + { + protected static string testCifsUrl = AgentSettings.Default.testCifsUrl; + protected static string testCifsPath = AgentSettings.Default.testCifsPath; + protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress; + protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName; + protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName; + protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName; + protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt; + protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2"; + protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool"); + protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary"); + + // TODO: differentiate between NFS and HTTP template URLs. + protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx"; + protected static String testSampleTemplateURL = testSampleTemplateUUID; + + // test volumes are both a minimal size vhdx. Changing the extension to .vhd makes on corrupt. + protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx"; + protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd"; + protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx"; + protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp"; + protected static String testSampleVolumeWorkingURIJSON; + protected static String testSampleVolumeCorruptURIJSON; + protected static String testSampleVolumeTempURIJSON; + + protected static String testSampleTemplateURLJSON; + protected static String testLocalStorePathJSON; + + protected static WmiCallsV2 wmiCallsV2 = new WmiCallsV2(); + + private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceControllerTest)); + + /// + /// Test WmiCalls to which incoming HTTP POST requests are dispatched. + /// + /// TODO: revise beyond first approximation + /// First approximation is a quick port of the existing Java tests for Hyper-V server resource. + /// A second approximation would use the AgentShell settings files directly. + /// A third approximation would look to invoke ServerResource methods via an HTTP request + /// + public HypervResourceControllerTest() + { + AgentService.ConfigServerResource(); + HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address; + HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask; + HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress; + HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress; + HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask; + + + // Used to create existing StoragePool in preparation for the ModifyStoragePool + testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString(); + + // Make sure secondary store is available. + string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath); + s_logger.Info("Test secondary storage in " + fullPath); + DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath); + if (!testSecondarStoreDir.Exists) + { + try + { + testSecondarStoreDir.Create(); + } + catch (System.IO.IOException ex) + { + throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message); + } + } + + // Convert to secondary storage string to canonical path + testSecondaryStoreLocalPath = testSecondarStoreDir.FullName; + AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath; + + // Make sure local primary storage is available + DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath); + Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName); + + // Convert to local primary storage string to canonical path + testLocalStorePath = testPoolDir.FullName; + AgentSettings.Default.local_storage_path = testLocalStorePath; + + // Clean up old test files in local storage folder + FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID)); + Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName); + + + // Delete all temporary files in local folder save the testVolWorks + foreach (var file in testPoolDir.GetFiles()) + { + if (file.FullName == testVolWorks.FullName) + { + continue; + } + file.Delete(); + file.Refresh(); + Assert.False(file.Exists, "removed file from previous test called " + file.FullName); + } + + // Recreate starting point files for test, and record JSON encoded paths for each ... + testSampleVolumeTempURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeTempUUID); + s_logger.Info("Created " + testSampleVolumeTempURIJSON); + testSampleVolumeCorruptURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeCorruptUUID); + s_logger.Info("Created " + testSampleVolumeCorruptURIJSON); + CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleTemplateUUID); + testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID); + s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); + + // ... including a secondary storage template: + CreateTestDiskImageFromExistingImage(testVolWorks, testSecondarStoreDir.FullName, "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx"); + s_logger.Info("Created " + "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx" + " in secondary (NFS) storage."); + + + // Capture other JSON encoded paths + testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName); + testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath); + + // TODO: may need to initialise the server resource in future. + // s_hypervresource.initialize(); + + // Verify sample template is in place storage pool + s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON + + " sample template at " + testSampleTemplateURLJSON); + } + + private String CreateTestDiskImageFromExistingImage(FileInfo srcFile, + String dstPath, + String dstFileName) + { + var newFullname = Path.Combine(dstPath, dstFileName); + var newFileInfo = new FileInfo(newFullname); + if (!newFileInfo.Exists) + { + newFileInfo = srcFile.CopyTo(newFullname); + } + newFileInfo.Refresh(); + Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName); + + return JsonConvert.SerializeObject(newFileInfo.FullName); + } + + [Fact(Skip="these are functional tests")] + public void TestPrimaryStorageDownloadCommandHTTP() + { + string downloadURI = "https://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx"; + corePrimaryStorageDownloadCommandTestCycle(downloadURI); + } + + private void corePrimaryStorageDownloadCommandTestCycle(string downloadURI) + { + // Arrange + HypervResourceController rsrcServer = new HypervResourceController(); + dynamic jsonPSDCmd = JsonConvert.DeserializeObject(samplePrimaryDownloadCommand()); + jsonPSDCmd.url = downloadURI; + + // Act + dynamic jsonResult = rsrcServer.PrimaryStorageDownloadCommand(jsonPSDCmd); + + // Assert + JObject ansAsProperty = jsonResult[0]; + dynamic ans = ansAsProperty.GetValue(CloudStackTypes.PrimaryStorageDownloadAnswer); + Assert.True((bool)ans.result, "PrimaryStorageDownloadCommand did not succeed " + ans.details); + + // Test that URL of downloaded template works for file creation. + dynamic jsonCreateCmd = JsonConvert.DeserializeObject(CreateCommandSample()); + jsonCreateCmd.templateUrl = ans.installPath; + dynamic jsonAns2 = rsrcServer.CreateCommand(jsonCreateCmd); + JObject ansAsProperty2 = jsonAns2[0]; + dynamic ans2 = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer); + + Assert.True((bool)ans2.result, (string)ans2.details); + + FileInfo newFile = new FileInfo((string)ans2.volume.path); + Assert.True(newFile.Length > 0, "The new file should have a size greater than zero"); + newFile.Delete(); + } + + private string samplePrimaryDownloadCommand() + { + String cmdJson = "{\"localPath\":" + testLocalStorePathJSON + + ",\"poolUuid\":\"" + testLocalStoreUUID + "\",\"poolId\":201," + + "\"secondaryStorageUrl\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage\"," + + "\"primaryStorageUrl\":\"nfs://" + HypervResourceController.config.StorageIpAddress + "E:\\\\Disks\\\\Disks\"," + + "\"url\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage/template/tmpl//2/204//af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx\"," + + "\"format\":\"VHDX\",\"accountId\":2,\"name\":\"204-2-5a1db1ac-932b-3e7e-a0e8-5684c72cb862\"" + + ",\"contextMap\":{},\"wait\":10800}"; + return cmdJson; + } + + public string CreateCommandSample() + { + String sample = "{\"volId\":17,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" + + ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," + + "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-15\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," + + "\"volumeId\":17,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"wait\":0}"; + return sample; + } + + [Fact(Skip="these are functional tests")] + public void TestDestroyCommand() + { + // Arrange + String sampleVolume = getSampleVolumeObjectTO(); + String destroyCmd = //"{\"volume\":" + getSampleVolumeObjectTO() + "}"; + "{\"volume\":{\"name\":\"" + testSampleVolumeTempUUIDNoExt + + "\",\"storagePoolType\":\"Filesystem\"," + + "\"mountPoint\":" + + testLocalStorePathJSON + + ",\"path\":" + testSampleVolumeTempURIJSON + + ",\"storagePoolUuid\":\"" + testLocalStoreUUID + + "\"," + + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}"; + + HypervResourceController rsrcServer = new HypervResourceController(); + dynamic jsonDestroyCmd = JsonConvert.DeserializeObject(destroyCmd); + + // Act + dynamic destroyAns = rsrcServer.DestroyCommand(jsonDestroyCmd); + + // Assert + JObject ansAsProperty2 = destroyAns[0]; + dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.Answer); + String path = jsonDestroyCmd.volume.path; + Assert.True((bool)ans.result, "DestroyCommand did not succeed " + ans.details); + Assert.True(!File.Exists(path), "Failed to delete file " + path); + } + + [Fact(Skip="these are functional tests")] + public void TestCreateCommand() + { + // TODO: Need sample to update the test. + // Arrange + String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" + + ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," + + "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," + + "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}"; + dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd); + HypervResourceController rsrcServer = new HypervResourceController(); + + Assert.True(Directory.Exists(testLocalStorePath)); + string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON)); + Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath); + int fileCount = Directory.GetFiles(testLocalStorePath).Length; + s_logger.Debug(" test local store has " + fileCount + "files"); + + // Act + // Test requires there to be a template at the tempalteUrl, which is its location in the local file system. + dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd); + + JObject ansAsProperty2 = jsonResult[0]; + dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer); + Assert.NotNull(ans); + Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result); + Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1); + FileInfo newFile = new FileInfo((string)ans.volume.path); + Assert.True(newFile.Length > 0, "The new file should have a size greater than zero"); + newFile.Delete(); + } + + /// + /// Possible additional tests: place an ISO in the drive + /// + [Fact(Skip="these are functional tests")] + public void TestStartStopCommand() + { + string vmName = TestStartCommand(); + TestStopCommand(vmName); + } + + public static String getSamplePrimaryDataStoreInfo() + { + String samplePrimaryDataStoreInfo = + "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" + + "{\"uuid\":\"" + testLocalStoreUUID + "\"," + + "\"id\":201," + + "\"host\":\"" + testPrimaryDataStoreHost + "\"," + + "\"type\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO + "\"poolType\":\"Filesystem\"," + // Not used in PrimaryDataStoreTO + "\"path\":" + testLocalStorePathJSON + "," + + "\"port\":0}" + + "}"; + return samplePrimaryDataStoreInfo; + } + + public static String getSampleVolumeObjectTO() + { + String sampleVolumeObjectTO = + "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + + "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + + "\"volumeType\":\"ROOT\"," + + "\"format\":\"VHDX\"," + + "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + + "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," + + "\"size\":52428800," + + "\"volumeId\":10," + + // "\"vmName\":\"i-3-5-VM\"," + // TODO: do we have to fill in the vmName? + "\"accountId\":3,\"id\":10}" + + "}"; // end of destTO + return sampleVolumeObjectTO; + } + + public static String getSampleStartCommand() + { + String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," + + "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," + + "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," + + "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," + + "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" + + ",\"disks\":[" + + "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," + + "{\"diskSeq\":1,\"type\":\"ISO\"}" + + "]," + + "\"nics\":[" + + "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," + + "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," + + "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," + + "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" + + "]},\"contextMap\":{},\"wait\":0}"; + return sample; + } + + + [Fact(Skip="these are functional tests")] + public void TestCopyCommandFromCifs() + { + // Arrange + string sampleCopyCommandForTemplateDownload = + #region string_literal + // org.apache.cloudstack.storage.command.CopyCommand + "{\"srcTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{\"path\":\"" + testCifsPath + "\"," + + "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + + "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + + "\"id\":206," + + "\"format\":\"VHDX\"," + + "\"accountId\":2," + + "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + + "\"hvm\":true," + + "\"displayText\":\"OS031\"," + + "\"imageDataStore\":" + + "{\"com.cloud.agent.api.to.NfsTO\":" + + "{\"_url\":\"" + testCifsUrl + "\"," + // Unique item here + "\"_role\":\"Image\"}" + + "}," + // end of imageDataStore + "\"hypervisorType\":\"Hyperv\"," + + "\"name\":\"" + testS3TemplateName + "\"}" + + "}," + // end of srcTO + "\"destTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{" + + "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + + "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + + "\"id\":206," + + "\"format\":\"VHDX\"," + + "\"accountId\":2," + + "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + + "\"hvm\":true," + + "\"displayText\":\"Test of CIFS Download\"," + + "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore + "\"name\":\"" + testS3TemplateName + "\"," + + "\"hypervisorType\":\"Hyperv\"}" + + "}," +// end of destTO + "\"wait\":10800}"; // end of CopyCommand + #endregion + + HypervResourceController rsrcServer; + dynamic jsonDownloadCopyCmd; + string dwnldDest; + dynamic jsonCloneCopyCmd; + string newVolName; + CopyCommandTestSetupCifs(null, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName); + + // Act & Assert + DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); + + // Repeat to verify ability to detect existing file. + DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); + + File.Delete(dwnldDest); + } + + [Fact(Skip="these are functional tests")] + public void TestCopyCommand() + { + // Arrange + string sampleCopyCommandToCreateVolumeFromTemplate = + #region string_literal + // org.apache.cloudstack.storage.command.CopyCommand + "{\"srcTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{" + + "\"origUrl\":\"http://people.apache.org/~bhaisaab/vms/ttylinux_pv.vhd\"," + + "\"uuid\":\"9873f1c0-bdcc-11e2-8baa-ea85dab5fcd0\"," + + "\"id\":5," + + "\"format\":\"VHDX\"," + + "\"accountId\":1," + + "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + + "\"hvm\":false," + + "\"displayText\":\"tiny Linux\"," + + "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + + "\"name\":\"" + testS3TemplateName + "\"}" + + "}," + // end of srcTO + "\"destTO\":" + + "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + + "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + + "\"volumeType\":\"ROOT\"," + + "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + + "\"name\":\"ROOT-5\"," + + "\"size\":52428800," + + "\"volumeId\":10," + + "\"vmName\":\"i-3-5-VM\"," + + "\"accountId\":3," + + "\"id\":10 }" + + "}," + // end of destTO + "\"wait\":0}"; // end of Copy Command + #endregion + //"name":"ROOT-8","size":140616708,"volumeId":8,"vmName":"s-8-VM","accountId":1,"id":8}},"contextMap":{},"wait":0} + + string sampleCopyCommandForTemplateDownload = + #region string_literal + // org.apache.cloudstack.storage.command.CopyCommand + "{\"srcTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{\"path\":\"" + testS3TemplateName + ".vhdx" + "\"," + + "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + + "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + + "\"id\":206," + + "\"format\":\"VHDX\"," + + "\"accountId\":2," + + "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + + "\"hvm\":true," + + "\"displayText\":\"OS031\"," + + "\"imageDataStore\":" + + "{\"com.cloud.agent.api.to.S3TO\":" + + "{\"id\":1," + + "\"uuid\":\"95a64c8f-2128-4502-b5b4-0d7aa77406d2\"," + + "\"accessKey\":\"" + AgentSettings.Default.testS3AccessKey + "\"," + + "\"secretKey\":\"" + AgentSettings.Default.testS3SecretKey + "\"," + + "\"endPoint\":\"" + AgentSettings.Default.testS3Endpoint + "\"," + + "\"bucketName\":\"" + AgentSettings.Default.testS3Bucket + "\"," + + "\"httpsFlag\":false," + + "\"created\":\"May 19, 2013 4:17:25 PM\"}" + + "}," + // end of imageDataStore + "\"name\":\"" + testS3TemplateName + "\"}" + + "}," + // end of srcTO + "\"destTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{" + + "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + + "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + + "\"id\":206," + + "\"format\":\"VHDX\"," + + "\"accountId\":2," + + "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," + + "\"hvm\":true," + + "\"displayText\":\"OS031\"," + + "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore + "\"name\":\"" + testS3TemplateName + "\"}" + + "}," +// end of destTO + "\"wait\":10800}"; // end of CopyCommand + #endregion + + HypervResourceController rsrcServer; + dynamic jsonDownloadCopyCmd; + string dwnldDest; + dynamic jsonCloneCopyCmd; + string newVolName; + CopyCommandTestSetup(sampleCopyCommandToCreateVolumeFromTemplate, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName); + + // Act & Assert + DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); + CreateVolumeFromTemplate(rsrcServer, jsonCloneCopyCmd, newVolName); + + // Repeat to verify ability to detect existing file. + DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); + + File.Delete(dwnldDest); + File.Delete(newVolName); + } + + private static void CreateVolumeFromTemplate(HypervResourceController rsrcServer, dynamic jsonCloneCopyCmd, string newVolName) + { + dynamic copyResult = rsrcServer.CopyCommand(jsonCloneCopyCmd); + + // Assert + Assert.NotNull(copyResult[0][CloudStackTypes.CopyCmdAnswer]); + Assert.True((bool)copyResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + copyResult[0][CloudStackTypes.CopyCmdAnswer].details); + Assert.True(File.Exists(newVolName), "CopyCommand failed to generate " + newVolName); + } + + private static void DownloadTemplateToPrimaryStorage(HypervResourceController rsrcServer, dynamic jsonDownloadCopyCmd, string dwnldDest) + { + dynamic dwnldResult = rsrcServer.CopyCommand(jsonDownloadCopyCmd); + + // Assert + Assert.NotNull(dwnldResult[0][CloudStackTypes.CopyCmdAnswer]); + Assert.True((bool)dwnldResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + dwnldResult[0][CloudStackTypes.CopyCmdAnswer].details); + Assert.True(File.Exists(dwnldDest), "CopyCommand failed to generate " + dwnldDest); + } + + [Fact(Skip="these are functional tests")] + public void TestCopyCommandBz2Img() + { + // Arrange + string sampleCopyCommandToCreateVolumeFromTemplate = + #region string_literal + // org.apache.cloudstack.storage.command.CopyCommand + "{\"srcTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{" + + "\"origUrl\":\"http://people.apache.org/~bhaisaab/vms/ttylinux_pv.vhd\"," + + "\"uuid\":\"9873f1c0-bdcc-11e2-8baa-ea85dab5fcd0\"," + + "\"id\":5," + + "\"format\":\"VHD\"," + + "\"accountId\":1," + + "\"checksum\":\"f613f38c96bf039f2e5cbf92fa8ad4f8\"," + + "\"hvm\":false," + + "\"displayText\":\"tiny Linux\"," + + "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + + "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" + + "}," + // end of srcTO + "\"destTO\":" + + "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" + + "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," + + "\"volumeType\":\"ROOT\"," + + "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," + + "\"name\":\"ROOT-5\"," + + "\"size\":52428800," + + "\"volumeId\":10," + + "\"vmName\":\"i-3-5-VM\"," + + "\"accountId\":1," + + "\"id\":10}" + + "}," + // end of destTO + "\"wait\":0}"; // end of Copy Command + #endregion + + string sampleCopyCommandForTemplateDownload = + #region string_literal + // org.apache.cloudstack.storage.command.CopyCommand + "{\"srcTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{\"path\":\"" + testSystemVMTemplateName + "\"," + + "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + + "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + + "\"id\":206," + + "\"format\":\"VHD\"," + + "\"accountId\":1," + + "\"checksum\": \"f613f38c96bf039f2e5cbf92fa8ad4f8\"," + + "\"hvm\":true," + + "\"displayText\":\"OS031\"," + + "\"imageDataStore\":" + + "{\"com.cloud.agent.api.to.S3TO\":" + + "{\"id\":1," + + "\"uuid\":\"95a64c8f-2128-4502-b5b4-0d7aa77406d2\"," + + "\"accessKey\":\"" + AgentSettings.Default.testS3AccessKey + "\"," + + "\"secretKey\":\"" + AgentSettings.Default.testS3SecretKey + "\"," + + "\"endPoint\":\"" + AgentSettings.Default.testS3Endpoint + "\"," + + "\"bucketName\":\"" + AgentSettings.Default.testS3Bucket + "\"," + + "\"httpsFlag\":false," + + "\"created\":\"May 19, 2013 4:17:25 PM\"}" + + "}," + // end of imageDataStore + "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" + + "}," + // end of srcTO + "\"destTO\":" + + "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" + + "{" + + "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," + + "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," + + "\"id\":206," + + "\"format\":\"VHD\"," + + "\"accountId\":1," + + "\"checksum\": \"f613f38c96bf039f2e5cbf92fa8ad4f8\"," + + "\"hvm\":true," + + "\"displayText\":\"OS031\"," + + "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore + "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" + + "}," +// end of destTO + "\"wait\":10800}"; // end of CopyCommand + #endregion + + HypervResourceController rsrcServer; + dynamic jsonDownloadCopyCmd; + string dwnldDest; + dynamic jsonCloneCopyCmd; + string newVolName; + CopyCommandTestSetup(sampleCopyCommandToCreateVolumeFromTemplate, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName); + + // Act & Assert + DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest); + CreateVolumeFromTemplate(rsrcServer, jsonCloneCopyCmd, newVolName); + + File.Delete(dwnldDest); + File.Delete(newVolName); + } + + private static void CopyCommandTestSetup(string sampleCopyCommandToCreateVolumeFromTemplate, string sampleCopyCommandForTemplateDownload, out HypervResourceController rsrcServer, out dynamic jsonDownloadCopyCmd, out string dwnldDest, out dynamic jsonCloneCopyCmd, out string newVolName) + { + rsrcServer = new HypervResourceController(); + jsonDownloadCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandForTemplateDownload); + TemplateObjectTO dwnldTemplate = TemplateObjectTO.ParseJson(jsonDownloadCopyCmd.destTO); + dwnldDest = dwnldTemplate.FullFileName; + + jsonCloneCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandToCreateVolumeFromTemplate); + VolumeObjectTO newVol = VolumeObjectTO.ParseJson(jsonCloneCopyCmd.destTO); + newVol.format = dwnldTemplate.format; + newVolName = dwnldTemplate.FullFileName; + + if (File.Exists(dwnldDest)) + { + File.Delete(dwnldDest); + } + if (File.Exists(newVolName)) + { + File.Delete(newVolName); + } + } + + private static void CopyCommandTestSetupCifs(string sampleCopyCommandToCreateVolumeFromTemplate, string sampleCopyCommandForTemplateDownload, out HypervResourceController rsrcServer, out dynamic jsonDownloadCopyCmd, out string dwnldDest, out dynamic jsonCloneCopyCmd, out string newVolName) + { + rsrcServer = new HypervResourceController(); + jsonDownloadCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandForTemplateDownload); + TemplateObjectTO dwnldTemplate = TemplateObjectTO.ParseJson(jsonDownloadCopyCmd.destTO); + dwnldDest = dwnldTemplate.FullFileName; + + if (File.Exists(dwnldDest)) + { + File.Delete(dwnldDest); + } + newVolName = null; + jsonCloneCopyCmd = null; + } + + [Fact(Skip="these are functional tests")] + public void TestModifyStoragePoolCommand() + { + // Create dummy folder + String folderName = Path.Combine(".", "Dummy"); + if (!Directory.Exists(folderName)) + { + Directory.CreateDirectory(folderName); + } + + var pool = new + { // From java class StorageFilerTO + type = Enum.GetName(typeof(StoragePoolType), StoragePoolType.Filesystem), + host = "127.0.0.1", + port = -1, + path = folderName, + uuid = Guid.NewGuid().ToString(), + userInfo = string.Empty // Used in future to hold credential + }; + + var cmd = new + { + add = true, + pool = pool, + localPath = folderName + }; + JToken tok = JToken.FromObject(cmd); + HypervResourceController controller = new HypervResourceController(); + + // Act + dynamic jsonResult = controller.ModifyStoragePoolCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.ModifyStoragePoolAnswer]; + Assert.True((bool)ans.result, (string)ans.details); // always succeeds + + // Clean up + var cmd2 = new + { + pool = pool, + localPath = folderName + }; + JToken tok2 = JToken.FromObject(cmd); + + // Act + dynamic jsonResult2 = controller.DeleteStoragePoolCommand(tok2); + + // Assert + dynamic ans2 = jsonResult2[0][CloudStackTypes.Answer]; + Assert.True((bool)ans2.result, (string)ans2.details); // always succeeds + } + + [Fact(Skip="these are functional tests")] + public void CreateStoragePoolCommand() + { + var cmd = new { localPath = "NULL" }; + JToken tok = JToken.FromObject(cmd); + HypervResourceController controller = new HypervResourceController(); + + // Act + dynamic jsonResult = controller.CreateStoragePoolCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.Answer]; + Assert.True((bool)ans.result, (string)ans.details); // always succeeds + } + + [Fact(Skip="these are functional tests")] + public void MaintainCommand() + { + // Omit HostEnvironment object, as this is a series of settings currently not used. + var cmd = new { }; + JToken tok = JToken.FromObject(cmd); + HypervResourceController controller = new HypervResourceController(); + + // Act + dynamic jsonResult = controller.MaintainCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.MaintainAnswer]; + Assert.True((bool)ans.result, (string)ans.details); // always succeeds + } + + [Fact(Skip="these are functional tests")] + public void SetupCommand() + { + // Omit HostEnvironment object, as this is a series of settings currently not used. + var cmd = new { multipath = false, needSetup = true }; + JToken tok = JToken.FromObject(cmd); + HypervResourceController controller = new HypervResourceController(); + + // Act + dynamic jsonResult = controller.SetupCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.SetupAnswer]; + Assert.True((bool)ans.result, (string)ans.details); // always succeeds + } + + [Fact(Skip="these are functional tests")] + public void TestPassingUserdataToVm() + { + // Sample data + String key = "cloudstack-vm-userdata"; + String value = "username=root;password=1pass@word1"; + + // Find the VM + List vmNames = wmiCallsV2.GetVmElementNames(); + + // Get associated WMI object + var vm = wmiCallsV2.GetComputerSystem(AgentSettings.Default.testKvpVmName); + + // Get existing KVP + var vmSettings = wmiCallsV2.GetVmSettings(vm); + var kvpInfo = wmiCallsV2.GetKvpSettings(vmSettings); + + // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object. + string[] kvpProps = kvpInfo.HostExchangeItems; + + // If the value already exists, delete it + foreach (var item in kvpProps) + { + String wmiObjectXml = item; + String existingKey; + String existingValue; + ParseKVP(wmiObjectXml, out existingKey, out existingValue); + + if (existingKey == key) + { + wmiCallsV2.DeleteHostKvpItem(vm, existingKey); + break; + } + } + + // Add new user data + wmiCallsV2.AddUserData(vm, value); + + // Verify key added to subsystem + kvpInfo = wmiCallsV2.GetKvpSettings(vmSettings); + + // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object. + kvpProps = kvpInfo.HostExchangeItems; + + // If the value already exists, delete it + bool userDataInPlace = false; + foreach (var item in kvpProps) + { + String wmiObjectXml = item; + String existingKey; + String existingValue; + ParseKVP(wmiObjectXml, out existingKey, out existingValue); + + if (existingKey == key && existingValue == value) + { +// wmiCallsV2.DeleteHostKvpItem(vm, existingKey); + userDataInPlace = true; + break; + } + } + + Assert.True(userDataInPlace, "User data key / value did no save properly"); + } + + private static void ParseKVP(String wmiObjectXml, out String existingKey, out String existingValue) + { + // Reference: http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/12/05/enumerating-parent-kvp-data.aspx + + // Create XML parser + var xmlDoc = new XmlDocument(); + + // Load WMI object + xmlDoc.LoadXml(wmiObjectXml); + + // Use xpath to get name and value + var namePropXpath = "/INSTANCE/PROPERTY[@NAME='Name']/VALUE"; + var nameNode = xmlDoc.SelectSingleNode(namePropXpath); + existingKey = nameNode.InnerText; + var dataPropXpath = "/INSTANCE/PROPERTY[@NAME='Data']/VALUE"; + var dataNode = xmlDoc.SelectSingleNode(dataPropXpath); + existingValue = dataNode.InnerText; + } + + [Fact(Skip="these are functional tests")] + public void GetVmStatsCommandFail() + { + // Use WMI to find existing VMs + List vmNames = new List(); + vmNames.Add("FakeVM"); + + var cmd = new + { + hostGuid = "FAKEguid", + hostName = AgentSettings.Default.host, + vmNames = vmNames + }; + JToken tok = JToken.FromObject(cmd); + HypervResourceController controller = new HypervResourceController(); + + // Act + dynamic jsonResult = controller.GetVmStatsCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer]; + Assert.True((bool)ans.result, (string)ans.details); // always succeeds, fake VM means no answer for the named VM + } + + [Fact(Skip="these are functional tests")] + public void GetVmStatsCommand() + { + // Use WMI to find existing VMs + List vmNames = wmiCallsV2.GetVmElementNames(); + + var cmd = new + { + hostGuid = "FAKEguid", + hostName = AgentSettings.Default.host, + vmNames = vmNames + }; + JToken tok = JToken.FromObject(cmd); + HypervResourceController controller = new HypervResourceController(); + + // Act + dynamic jsonResult = controller.GetVmStatsCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer]; + Assert.True((bool)ans.result, (string)ans.details); + } + + [Fact(Skip="these are functional tests")] + public void GetStorageStatsCommand() + { + // TODO: Update sample data to unsure it is using correct info. + String sample = String.Format( + #region string_literal +"{{\"" + + "id\":{0}," + + "\"localPath\":{1}," + + "\"pooltype\":\"Filesystem\"," + + "\"contextMap\":{{}}," + + "\"wait\":0}}", + JsonConvert.SerializeObject(AgentSettings.Default.testLocalStoreUUID), + JsonConvert.SerializeObject(AgentSettings.Default.testLocalStorePath) + ); + #endregion + var cmd = JsonConvert.DeserializeObject(sample); + JToken tok = JToken.FromObject(cmd); + HypervResourceController controller = new HypervResourceController(); + + // Act + dynamic jsonResult = controller.GetStorageStatsCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.GetStorageStatsAnswer]; + Assert.True((bool)ans.result, (string)ans.details); + Assert.True((long)ans.used <= (long)ans.capacity); // TODO: verify that capacity is indeed capacity and not used. + } + + // TODO: can we speed up this command? The logic takes over a second. + [Fact(Skip="these are functional tests")] + public void GetHostStatsCommand() + { + // Arrange + long hostIdVal = 5; + HypervResourceController controller = new HypervResourceController(); + string sample = string.Format( + #region string_literal +"{{" + + "\"hostGuid\":\"B4AE5970-FCBF-4780-9F8A-2D2E04FECC34-HypervResource\"," + + "\"hostName\":\"CC-SVR11\"," + + "\"hostId\":{0}," + + "\"contextMap\":{{}}," + + "\"wait\":0}}", + JsonConvert.SerializeObject(hostIdVal)); + #endregion + var cmd = JsonConvert.DeserializeObject(sample); + JToken tok = JToken.FromObject(cmd); + + // Act + dynamic jsonResult = controller.GetHostStatsCommand(tok); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer]; + Assert.True((bool)ans.result); + Assert.True(hostIdVal == (long)ans.hostStats.hostId); + Assert.True(0.0 < (double)ans.hostStats.totalMemoryKBs); + Assert.True(0.0 < (double)ans.hostStats.freeMemoryKBs); + Assert.True(0.0 <= (double)ans.hostStats.networkReadKBs); + Assert.True(0.0 <= (double)ans.hostStats.networkWriteKBs); + Assert.True(0.0 <= (double)ans.hostStats.cpuUtilization); + Assert.True(100.0 >= (double)ans.hostStats.cpuUtilization); + Assert.True("host".Equals((string)ans.hostStats.entityType)); + Assert.True(String.IsNullOrEmpty((string)ans.details)); + } + + [Fact(Skip="these are functional tests")] + public void GetHostStatsCommandFail() + { + // Arrange + HypervResourceController controller = new HypervResourceController(); + var cmd = new { GetHostStatsCommand = new { hostId = "badvalueType" } }; + JToken tokFail = JToken.FromObject(cmd); + + // Act + dynamic jsonResult = controller.GetHostStatsCommand(tokFail); + + // Assert + dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer]; + Assert.False((bool)ans.result); + Assert.Null((string)ans.hostStats); + Assert.NotNull(ans.details); + } + + [Fact(Skip="these are functional tests")] + public void TestStartupCommand() + { + // Arrange + HypervResourceController controller = new HypervResourceController(); + String sampleStartupRoutingCommand = + #region string_literal + "[{\"" + CloudStackTypes.StartupRoutingCommand + "\":{" + + "\"cpus\":0," + + "\"speed\":0," + + "\"memory\":0," + + "\"dom0MinMemory\":0," + + "\"poolSync\":false," + + "\"vms\":{}," + + "\"hypervisorType\":\"Hyperv\"," + + "\"hostDetails\":{" + + "\"com.cloud.network.Networks.RouterPrivateIpStrategy\":\"HostLocal\"" + + "}," + + "\"type\":\"Routing\"," + + "\"dataCenter\":\"1\"," + + "\"pod\":\"1\"," + + "\"cluster\":\"1\"," + + "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + + "\"name\":\"localhost\"," + + "\"version\":\"4.2.0\"," + + "\"privateIpAddress\":\"1\"," + + "\"storageIpAddress\":\"1\"," + + "\"contextMap\":{}," + + "\"wait\":0}}]"; + #endregion + + uint cores; + uint mhz; + wmiCallsV2.GetProcessorResources(out cores, out mhz); + ulong memory_mb; + ulong freememory; + wmiCallsV2.GetMemoryResources(out memory_mb, out freememory); + memory_mb *= 1024; + long capacityBytes; + long availableBytes; + HypervResourceController.GetCapacityForLocalPath(wmiCallsV2.GetDefaultVirtualDiskFolder(), + out capacityBytes, out availableBytes); + var DefaultVirtualDiskFolder = JsonConvert.SerializeObject(wmiCallsV2.GetDefaultVirtualDiskFolder()); + string expected = + #region string_literal + "[{\"" + CloudStackTypes.StartupRoutingCommand + "\":{" + + "\"cpus\":" + cores + "," + + "\"speed\":" + mhz + "," + + "\"memory\":" + memory_mb + "," + + "\"dom0MinMemory\":" + (AgentSettings.Default.dom0MinMemory * 1024 * 1024) + "," + + "\"poolSync\":false," + + "\"vms\":{}," + + "\"hypervisorType\":\"Hyperv\"," + + "\"hostDetails\":{" + + "\"com.cloud.network.Networks.RouterPrivateIpStrategy\":\"HostLocal\"" + + "}," + + "\"type\":\"Routing\"," + + "\"dataCenter\":\"1\"," + + "\"pod\":\"1\"," + + "\"cluster\":\"1\"," + + "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + + "\"name\":\"localhost\"," + + "\"version\":\"4.2.0\"," + + "\"privateIpAddress\":\"" + AgentSettings.Default.private_ip_address + "\"," + + "\"storageIpAddress\":\"" + AgentSettings.Default.private_ip_address + "\"," + + "\"contextMap\":{}," + + "\"wait\":0," + + "\"privateNetmask\":\"" + AgentSettings.Default.private_ip_netmask + "\"," + + "\"privateMacAddress\":\"" + AgentSettings.Default.private_mac_address + "\"," + + "\"storageNetmask\":\"" + AgentSettings.Default.private_ip_netmask + "\"," + + "\"storageMacAddress\":\"" + AgentSettings.Default.private_mac_address + "\"," + + "\"gatewayIpAddress\":\"" + AgentSettings.Default.gateway_ip_address + "\"" + + ",\"caps\":\"hvm\"" + + "}}," + + "{\"com.cloud.agent.api.StartupStorageCommand\":{" + + "\"poolInfo\":{" + + "\"uuid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + + "\"host\":\"" + AgentSettings.Default.private_ip_address + "\"," + + "\"localPath\":" + DefaultVirtualDiskFolder + "," + + "\"hostPath\":" + DefaultVirtualDiskFolder + "," + + "\"poolType\":\"Filesystem\"," + + "\"capacityBytes\":" + capacityBytes + "," + + "\"availableBytes\":" + availableBytes + "," + + "\"details\":null" + + "}," + + "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," + + "\"dataCenter\":\"1\"," + + "\"resourceType\":\"STORAGE_POOL\"" + + "}}]"; + #endregion + + dynamic jsonArray = JsonConvert.DeserializeObject(sampleStartupRoutingCommand); + + // Act + dynamic jsonResult = controller.StartupCommand(jsonArray); + + // Assert + string actual = JsonConvert.SerializeObject(jsonResult); + Assert.Equal(expected, actual); + } + + + private static string TestStartCommand() + { + // Arrange + HypervResourceController rsrcServer = new HypervResourceController(); + String sample = getSampleStartCommand(); + + + dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample); + + // Act + dynamic startAns = rsrcServer.StartCommand(jsonStartCmd); + + // Assert + Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]); + Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details); + string vmCmdName = jsonStartCmd.vm.name.Value; + var vm = wmiCallsV2.GetComputerSystem(vmCmdName); + var vmSettings = wmiCallsV2.GetVmSettings(vm); + var memSettings = wmiCallsV2.GetMemSettings(vmSettings); + var procSettings = wmiCallsV2.GetProcSettings(vmSettings); + dynamic jsonObj = JsonConvert.DeserializeObject(sample); + var vmInfo = jsonObj.vm; + string vmName = vmInfo.name; + var nicInfo = vmInfo.nics; + int vcpus = vmInfo.cpus; + int memSize = vmInfo.maxRam / 1048576; + Assert.True((long)memSettings.VirtualQuantity == memSize); + Assert.True((long)memSettings.Reservation == memSize); + Assert.True((long)memSettings.Limit == memSize); + Assert.True((int)procSettings.VirtualQuantity == vcpus); + Assert.True((int)procSettings.Reservation == vcpus); + Assert.True((int)procSettings.Limit == 100000); + + // examine NIC for correctness + var nicSettingsViaVm = wmiCallsV2.GetEthernetPortSettings(vm); + Assert.True(nicSettingsViaVm.Length > 0, "Should be at least one ethernet port on VM"); + string expectedMac = (string)jsonStartCmd.vm.nics[0].mac; + string strippedExpectedMac = expectedMac.Replace(":", string.Empty); + Assert.Equal(nicSettingsViaVm[0].Address.ToLower(), strippedExpectedMac.ToLower()); + + // Assert switchport has correct VLAN + var ethernetConnections = wmiCallsV2.GetEthernetConnections(vm); + var vlanSettings = wmiCallsV2.GetVlanSettings(ethernetConnections[0]); + string isolationUri = (string)jsonStartCmd.vm.nics[0].isolationUri; + string vlan = isolationUri.Replace("vlan://", string.Empty); + Assert.Equal(vlanSettings.AccessVlanId.ToString(), vlan); + + return vmName; + } + + private static void TestStopCommand(string vmName) + { + // Arrange + HypervResourceController rsrcServer = new HypervResourceController(); + String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"wait\":0}"; + dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop); + + // Act + dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd); + + // Assert VM is gone! + Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]); + Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details); + var finalVm = wmiCallsV2.GetComputerSystem(vmName); + Assert.True(wmiCallsV2.GetComputerSystem(vmName) == null); + } + } +} 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 530275e3358..f3f1abbcc28 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 @@ -1,1818 +1,1818 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_ComputerSystem - public class ComputerSystem : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - private static string CreatedClassName = "Msvm_ComputerSystem"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public ComputerSystem() { - this.InitializeObject(null, null, null); - } - - public ComputerSystem(string keyCreationClassName, string keyName) { - this.InitializeObject(null, new System.Management.ManagementPath(ComputerSystem.ConstructPath(keyCreationClassName, keyName)), null); - } - - public ComputerSystem(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ComputerSystem.ConstructPath(keyCreationClassName, keyName)), null); - } - - public ComputerSystem(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public ComputerSystem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public ComputerSystem(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public ComputerSystem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public ComputerSystem(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public ComputerSystem(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] Dedicated { - get { - return ((ushort[])(curObj["Dedicated"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsFailedOverReplicationTypeNull { - get { - if ((curObj["FailedOverReplicationType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Type of failover that was performed for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public FailedOverReplicationTypeValues FailedOverReplicationType { - get { - if ((curObj["FailedOverReplicationType"] == null)) { - return ((FailedOverReplicationTypeValues)(System.Convert.ToInt32(4))); - } - return ((FailedOverReplicationTypeValues)(System.Convert.ToInt32(curObj["FailedOverReplicationType"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] IdentifyingDescriptions { - get { - return ((string[])(curObj["IdentifyingDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLastApplicationConsistentReplicationTimeNull { - get { - if ((curObj["LastApplicationConsistentReplicationTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The time at which the last application consistent replication is received on reco" + - "very for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime LastApplicationConsistentReplicationTime { - get { - if ((curObj["LastApplicationConsistentReplicationTime"] != null)) { - return ToDateTime(((string)(curObj["LastApplicationConsistentReplicationTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLastReplicationTimeNull { - get { - if ((curObj["LastReplicationTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The time at which the last replication is received on recovery for the virtual ma" + - "chine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime LastReplicationTime { - get { - if ((curObj["LastReplicationTime"] != null)) { - return ToDateTime(((string)(curObj["LastReplicationTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLastReplicationTypeNull { - get { - if ((curObj["LastReplicationType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Type of the last replication that was received for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public LastReplicationTypeValues LastReplicationType { - get { - if ((curObj["LastReplicationType"] == null)) { - return ((LastReplicationTypeValues)(System.Convert.ToInt32(4))); - } - return ((LastReplicationTypeValues)(System.Convert.ToInt32(curObj["LastReplicationType"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLastSuccessfulBackupTimeNull { - get { - if ((curObj["LastSuccessfulBackupTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The time at which the last successful backup has completed for the virtual machin" + - "e.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime LastSuccessfulBackupTime { - get { - if ((curObj["LastSuccessfulBackupTime"] != null)) { - return ToDateTime(((string)(curObj["LastSuccessfulBackupTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string NameFormat { - get { - return ((string)(curObj["NameFormat"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsNumberOfNumaNodesNull { - get { - if ((curObj["NumberOfNumaNodes"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"The number of non-uniform memory access (NUMA) nodes of the computer system. When Msvm_ComputerSystem represents the hosting computer system, this property contains the count of physical NUMA nodes. When Msvm_ComputerSystem represents a virtual computer system, this property contains the number of virtual NUMA nodes that are presented to the guest OS through the ACPI System Resource Affinity Table (SRAT).")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort NumberOfNumaNodes { - get { - if ((curObj["NumberOfNumaNodes"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["NumberOfNumaNodes"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOnTimeInMillisecondsNull { - get { - if ((curObj["OnTimeInMilliseconds"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"For the virtual system, this property describes the total up time, in milliseconds, since the machine was last turned on, reset, or restored. This time excludes the time the virtual system was in the paused state. For the host system, this property is set to NULL.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong OnTimeInMilliseconds { - get { - if ((curObj["OnTimeInMilliseconds"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["OnTimeInMilliseconds"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherDedicatedDescriptions { - get { - return ((string[])(curObj["OtherDedicatedDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherIdentifyingInfo { - get { - return ((string[])(curObj["OtherIdentifyingInfo"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] PowerManagementCapabilities { - get { - return ((ushort[])(curObj["PowerManagementCapabilities"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerContact { - get { - return ((string)(curObj["PrimaryOwnerContact"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerName { - get { - return ((string)(curObj["PrimaryOwnerName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsProcessIDNull { - get { - if ((curObj["ProcessID"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The identifier of the process under which this virtual machine is running. This v" + - "alue can be used to uniquely identify the instance of Vmwp.exe on the system tha" + - "t is running the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint ProcessID { - get { - if ((curObj["ProcessID"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["ProcessID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReplicationHealthNull { - get { - if ((curObj["ReplicationHealth"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Replication health for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ReplicationHealthValues ReplicationHealth { - get { - if ((curObj["ReplicationHealth"] == null)) { - return ((ReplicationHealthValues)(System.Convert.ToInt32(4))); - } - return ((ReplicationHealthValues)(System.Convert.ToInt32(curObj["ReplicationHealth"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReplicationModeNull { - get { - if ((curObj["ReplicationMode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Identifies replication type for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ReplicationModeValues ReplicationMode { - get { - if ((curObj["ReplicationMode"] == null)) { - return ((ReplicationModeValues)(System.Convert.ToInt32(4))); - } - return ((ReplicationModeValues)(System.Convert.ToInt32(curObj["ReplicationMode"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReplicationStateNull { - get { - if ((curObj["ReplicationState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Replication state for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ReplicationStateValues ReplicationState { - get { - if ((curObj["ReplicationState"] == null)) { - return ((ReplicationStateValues)(System.Convert.ToInt32(12))); - } - return ((ReplicationStateValues)(System.Convert.ToInt32(curObj["ReplicationState"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResetCapabilityNull { - get { - if ((curObj["ResetCapability"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResetCapability { - get { - if ((curObj["ResetCapability"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResetCapability"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Roles { - get { - return ((string[])(curObj["Roles"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastConfigurationChangeNull { - get { - if ((curObj["TimeOfLastConfigurationChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The date and time when the virtual machine configuration file was last modified. " + - "The configuration file is modified during certain virtual machine operations, as" + - " well as when any of the virtual machine or device settings are added, modified," + - " or removed.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastConfigurationChange { - get { - if ((curObj["TimeOfLastConfigurationChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastConfigurationChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeFailedOverReplicationType() { - if ((this.IsFailedOverReplicationTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLastApplicationConsistentReplicationTime() { - if ((this.IsLastApplicationConsistentReplicationTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLastReplicationTime() { - if ((this.IsLastReplicationTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLastReplicationType() { - if ((this.IsLastReplicationTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLastSuccessfulBackupTime() { - if ((this.IsLastSuccessfulBackupTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeNumberOfNumaNodes() { - if ((this.IsNumberOfNumaNodesNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOnTimeInMilliseconds() { - if ((this.IsOnTimeInMillisecondsNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeProcessID() { - if ((this.IsProcessIDNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReplicationHealth() { - if ((this.IsReplicationHealthNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReplicationMode() { - if ((this.IsReplicationModeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReplicationState() { - if ((this.IsReplicationStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResetCapability() { - if ((this.IsResetCapabilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastConfigurationChange() { - if ((this.IsTimeOfLastConfigurationChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_ComputerSystem"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static ComputerSystemCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static ComputerSystemCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static ComputerSystemCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static ComputerSystemCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_ComputerSystem"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new ComputerSystemCollection(clsObject.GetInstances(enumOptions)); - } - - public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ComputerSystem", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new ComputerSystemCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static ComputerSystem CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new ComputerSystem(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint RequestReplicationStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestReplicationStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestReplicationStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = RequestedState; - inParams["TimeoutPeriod"] = null; // ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) - { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint SetPowerState(uint PowerState, System.DateTime Time) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); - inParams["PowerState"] = ((uint)(PowerState)); - inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public enum FailedOverReplicationTypeValues { - - None = 0, - - Regular = 1, - - Application_consistent = 2, - - Planned = 3, - - NULL_ENUM_VALUE = 4, - } - - public enum LastReplicationTypeValues { - - None = 0, - - Regular = 1, - - Application_consistent = 2, - - Planned = 3, - - NULL_ENUM_VALUE = 4, - } - - public enum ReplicationHealthValues { - - Not_applicable = 0, - - Ok = 1, - - Warning = 2, - - Critical = 3, - - NULL_ENUM_VALUE = 4, - } - - public enum ReplicationModeValues { - - None = 0, - - Primary = 1, - - Recovery = 2, - - Test_Replica = 3, - - NULL_ENUM_VALUE = 4, - } - - public enum ReplicationStateValues { - - Disabled = 0, - - Ready_for_replication = 1, - - Waiting_to_complete_initial_replication = 2, - - Replicating = 3, - - Synced_replication_complete = 4, - - Recovered = 5, - - Committed = 6, - - Suspended = 7, - - Critical = 8, - - Waiting_to_start_resynchronization = 9, - - Resynchronizing = 10, - - Resynchronization_suspended = 11, - - NULL_ENUM_VALUE = 12, - } - - // Enumerator implementation for enumerating instances of the class. - public class ComputerSystemCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public ComputerSystemCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new ComputerSystem(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new ComputerSystemEnumerator(privColObj.GetEnumerator()); - } - - public class ComputerSystemEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public ComputerSystemEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new ComputerSystem(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_ComputerSystem + public class ComputerSystem : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + private static string CreatedClassName = "Msvm_ComputerSystem"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public ComputerSystem() { + this.InitializeObject(null, null, null); + } + + public ComputerSystem(string keyCreationClassName, string keyName) { + this.InitializeObject(null, new System.Management.ManagementPath(ComputerSystem.ConstructPath(keyCreationClassName, keyName)), null); + } + + public ComputerSystem(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ComputerSystem.ConstructPath(keyCreationClassName, keyName)), null); + } + + public ComputerSystem(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public ComputerSystem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public ComputerSystem(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public ComputerSystem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public ComputerSystem(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public ComputerSystem(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] Dedicated { + get { + return ((ushort[])(curObj["Dedicated"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsFailedOverReplicationTypeNull { + get { + if ((curObj["FailedOverReplicationType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Type of failover that was performed for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public FailedOverReplicationTypeValues FailedOverReplicationType { + get { + if ((curObj["FailedOverReplicationType"] == null)) { + return ((FailedOverReplicationTypeValues)(System.Convert.ToInt32(4))); + } + return ((FailedOverReplicationTypeValues)(System.Convert.ToInt32(curObj["FailedOverReplicationType"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] IdentifyingDescriptions { + get { + return ((string[])(curObj["IdentifyingDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastApplicationConsistentReplicationTimeNull { + get { + if ((curObj["LastApplicationConsistentReplicationTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The time at which the last application consistent replication is received on reco" + + "very for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime LastApplicationConsistentReplicationTime { + get { + if ((curObj["LastApplicationConsistentReplicationTime"] != null)) { + return ToDateTime(((string)(curObj["LastApplicationConsistentReplicationTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastReplicationTimeNull { + get { + if ((curObj["LastReplicationTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The time at which the last replication is received on recovery for the virtual ma" + + "chine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime LastReplicationTime { + get { + if ((curObj["LastReplicationTime"] != null)) { + return ToDateTime(((string)(curObj["LastReplicationTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastReplicationTypeNull { + get { + if ((curObj["LastReplicationType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Type of the last replication that was received for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public LastReplicationTypeValues LastReplicationType { + get { + if ((curObj["LastReplicationType"] == null)) { + return ((LastReplicationTypeValues)(System.Convert.ToInt32(4))); + } + return ((LastReplicationTypeValues)(System.Convert.ToInt32(curObj["LastReplicationType"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastSuccessfulBackupTimeNull { + get { + if ((curObj["LastSuccessfulBackupTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The time at which the last successful backup has completed for the virtual machin" + + "e.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime LastSuccessfulBackupTime { + get { + if ((curObj["LastSuccessfulBackupTime"] != null)) { + return ToDateTime(((string)(curObj["LastSuccessfulBackupTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string NameFormat { + get { + return ((string)(curObj["NameFormat"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsNumberOfNumaNodesNull { + get { + if ((curObj["NumberOfNumaNodes"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"The number of non-uniform memory access (NUMA) nodes of the computer system. When Msvm_ComputerSystem represents the hosting computer system, this property contains the count of physical NUMA nodes. When Msvm_ComputerSystem represents a virtual computer system, this property contains the number of virtual NUMA nodes that are presented to the guest OS through the ACPI System Resource Affinity Table (SRAT).")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort NumberOfNumaNodes { + get { + if ((curObj["NumberOfNumaNodes"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["NumberOfNumaNodes"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOnTimeInMillisecondsNull { + get { + if ((curObj["OnTimeInMilliseconds"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"For the virtual system, this property describes the total up time, in milliseconds, since the machine was last turned on, reset, or restored. This time excludes the time the virtual system was in the paused state. For the host system, this property is set to NULL.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong OnTimeInMilliseconds { + get { + if ((curObj["OnTimeInMilliseconds"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["OnTimeInMilliseconds"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherDedicatedDescriptions { + get { + return ((string[])(curObj["OtherDedicatedDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherIdentifyingInfo { + get { + return ((string[])(curObj["OtherIdentifyingInfo"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] PowerManagementCapabilities { + get { + return ((ushort[])(curObj["PowerManagementCapabilities"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerContact { + get { + return ((string)(curObj["PrimaryOwnerContact"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerName { + get { + return ((string)(curObj["PrimaryOwnerName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsProcessIDNull { + get { + if ((curObj["ProcessID"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The identifier of the process under which this virtual machine is running. This v" + + "alue can be used to uniquely identify the instance of Vmwp.exe on the system tha" + + "t is running the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint ProcessID { + get { + if ((curObj["ProcessID"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["ProcessID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReplicationHealthNull { + get { + if ((curObj["ReplicationHealth"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Replication health for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ReplicationHealthValues ReplicationHealth { + get { + if ((curObj["ReplicationHealth"] == null)) { + return ((ReplicationHealthValues)(System.Convert.ToInt32(4))); + } + return ((ReplicationHealthValues)(System.Convert.ToInt32(curObj["ReplicationHealth"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReplicationModeNull { + get { + if ((curObj["ReplicationMode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Identifies replication type for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ReplicationModeValues ReplicationMode { + get { + if ((curObj["ReplicationMode"] == null)) { + return ((ReplicationModeValues)(System.Convert.ToInt32(4))); + } + return ((ReplicationModeValues)(System.Convert.ToInt32(curObj["ReplicationMode"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReplicationStateNull { + get { + if ((curObj["ReplicationState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Replication state for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ReplicationStateValues ReplicationState { + get { + if ((curObj["ReplicationState"] == null)) { + return ((ReplicationStateValues)(System.Convert.ToInt32(12))); + } + return ((ReplicationStateValues)(System.Convert.ToInt32(curObj["ReplicationState"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResetCapabilityNull { + get { + if ((curObj["ResetCapability"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResetCapability { + get { + if ((curObj["ResetCapability"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResetCapability"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Roles { + get { + return ((string[])(curObj["Roles"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastConfigurationChangeNull { + get { + if ((curObj["TimeOfLastConfigurationChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The date and time when the virtual machine configuration file was last modified. " + + "The configuration file is modified during certain virtual machine operations, as" + + " well as when any of the virtual machine or device settings are added, modified," + + " or removed.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastConfigurationChange { + get { + if ((curObj["TimeOfLastConfigurationChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastConfigurationChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeFailedOverReplicationType() { + if ((this.IsFailedOverReplicationTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLastApplicationConsistentReplicationTime() { + if ((this.IsLastApplicationConsistentReplicationTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLastReplicationTime() { + if ((this.IsLastReplicationTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLastReplicationType() { + if ((this.IsLastReplicationTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLastSuccessfulBackupTime() { + if ((this.IsLastSuccessfulBackupTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeNumberOfNumaNodes() { + if ((this.IsNumberOfNumaNodesNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOnTimeInMilliseconds() { + if ((this.IsOnTimeInMillisecondsNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeProcessID() { + if ((this.IsProcessIDNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReplicationHealth() { + if ((this.IsReplicationHealthNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReplicationMode() { + if ((this.IsReplicationModeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReplicationState() { + if ((this.IsReplicationStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResetCapability() { + if ((this.IsResetCapabilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastConfigurationChange() { + if ((this.IsTimeOfLastConfigurationChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_ComputerSystem"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static ComputerSystemCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static ComputerSystemCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static ComputerSystemCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static ComputerSystemCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_ComputerSystem"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new ComputerSystemCollection(clsObject.GetInstances(enumOptions)); + } + + public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ComputerSystem", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new ComputerSystemCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static ComputerSystem CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new ComputerSystem(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint RequestReplicationStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestReplicationStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestReplicationStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = RequestedState; + inParams["TimeoutPeriod"] = null; // ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) + { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint SetPowerState(uint PowerState, System.DateTime Time) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); + inParams["PowerState"] = ((uint)(PowerState)); + inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public enum FailedOverReplicationTypeValues { + + None = 0, + + Regular = 1, + + Application_consistent = 2, + + Planned = 3, + + NULL_ENUM_VALUE = 4, + } + + public enum LastReplicationTypeValues { + + None = 0, + + Regular = 1, + + Application_consistent = 2, + + Planned = 3, + + NULL_ENUM_VALUE = 4, + } + + public enum ReplicationHealthValues { + + Not_applicable = 0, + + Ok = 1, + + Warning = 2, + + Critical = 3, + + NULL_ENUM_VALUE = 4, + } + + public enum ReplicationModeValues { + + None = 0, + + Primary = 1, + + Recovery = 2, + + Test_Replica = 3, + + NULL_ENUM_VALUE = 4, + } + + public enum ReplicationStateValues { + + Disabled = 0, + + Ready_for_replication = 1, + + Waiting_to_complete_initial_replication = 2, + + Replicating = 3, + + Synced_replication_complete = 4, + + Recovered = 5, + + Committed = 6, + + Suspended = 7, + + Critical = 8, + + Waiting_to_start_resynchronization = 9, + + Resynchronizing = 10, + + Resynchronization_suspended = 11, + + NULL_ENUM_VALUE = 12, + } + + // Enumerator implementation for enumerating instances of the class. + public class ComputerSystemCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public ComputerSystemCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new ComputerSystem(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new ComputerSystemEnumerator(privColObj.GetEnumerator()); + } + + public class ComputerSystemEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public ComputerSystemEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new ComputerSystem(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 256029d96a7..73b3599a8ce 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 @@ -1,1843 +1,1843 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // Time interval functions ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to System.TimeSpan and vice-versa. - // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. - // An Early Bound class generated for the WMI class.Msvm_ConcreteJob - public class ConcreteJob : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - private static string CreatedClassName = "Msvm_ConcreteJob"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public ConcreteJob() { - this.InitializeObject(null, null, null); - } - - public ConcreteJob(string keyInstanceID) { - this.InitializeObject(null, new System.Management.ManagementPath(ConcreteJob.ConstructPath(keyInstanceID)), null); - } - - public ConcreteJob(System.Management.ManagementScope mgmtScope, string keyInstanceID) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ConcreteJob.ConstructPath(keyInstanceID)), null); - } - - public ConcreteJob(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public ConcreteJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public ConcreteJob(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public ConcreteJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public ConcreteJob(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public ConcreteJob(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCancellableNull { - get { - if ((curObj["Cancellable"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates whether the job can be cancelled. The value of this property does not g" + - "uarantee that a request to cancel the job will succeed.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool Cancellable { - get { - if ((curObj["Cancellable"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["Cancellable"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDeleteOnCompletionNull { - get { - if ((curObj["DeleteOnCompletion"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool DeleteOnCompletion { - get { - if ((curObj["DeleteOnCompletion"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["DeleteOnCompletion"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsElapsedTimeNull { - get { - if ((curObj["ElapsedTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.TimeSpan ElapsedTime { - get { - if ((curObj["ElapsedTime"] != null)) { - return ToTimeSpan(((string)(curObj["ElapsedTime"]))); - } - else { - return new System.TimeSpan(0, 0, 0, 0, 0); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsErrorCodeNull { - get { - if ((curObj["ErrorCode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ErrorCode { - get { - if ((curObj["ErrorCode"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ErrorCode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ErrorDescription { - get { - return ((string)(curObj["ErrorDescription"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ErrorSummaryDescription { - get { - return ((string)(curObj["ErrorSummaryDescription"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsJobRunTimesNull { - get { - if ((curObj["JobRunTimes"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint JobRunTimes { - get { - if ((curObj["JobRunTimes"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["JobRunTimes"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsJobStateNull { - get { - if ((curObj["JobState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort JobState { - get { - if ((curObj["JobState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["JobState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string JobStatus { - get { - return ((string)(curObj["JobStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsJobTypeNull { - get { - if ((curObj["JobType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates the type of Job being tracked by this object.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort JobType { - get { - if ((curObj["JobType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["JobType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLocalOrUtcTimeNull { - get { - if ((curObj["LocalOrUtcTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort LocalOrUtcTime { - get { - if ((curObj["LocalOrUtcTime"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["LocalOrUtcTime"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Notify { - get { - return ((string)(curObj["Notify"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherRecoveryAction { - get { - return ((string)(curObj["OtherRecoveryAction"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Owner { - get { - return ((string)(curObj["Owner"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPercentCompleteNull { - get { - if ((curObj["PercentComplete"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PercentComplete { - get { - if ((curObj["PercentComplete"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PercentComplete"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPriorityNull { - get { - if ((curObj["Priority"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Priority { - get { - if ((curObj["Priority"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Priority"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRecoveryActionNull { - get { - if ((curObj["RecoveryAction"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RecoveryAction { - get { - if ((curObj["RecoveryAction"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RecoveryAction"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRunDayNull { - get { - if ((curObj["RunDay"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public sbyte RunDay { - get { - if ((curObj["RunDay"] == null)) { - return System.Convert.ToSByte(0); - } - return ((sbyte)(curObj["RunDay"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRunDayOfWeekNull { - get { - if ((curObj["RunDayOfWeek"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public sbyte RunDayOfWeek { - get { - if ((curObj["RunDayOfWeek"] == null)) { - return System.Convert.ToSByte(0); - } - return ((sbyte)(curObj["RunDayOfWeek"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRunMonthNull { - get { - if ((curObj["RunMonth"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public byte RunMonth { - get { - if ((curObj["RunMonth"] == null)) { - return System.Convert.ToByte(0); - } - return ((byte)(curObj["RunMonth"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRunStartIntervalNull { - get { - if ((curObj["RunStartInterval"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.TimeSpan RunStartInterval { - get { - if ((curObj["RunStartInterval"] != null)) { - return ToTimeSpan(((string)(curObj["RunStartInterval"]))); - } - else { - return new System.TimeSpan(0, 0, 0, 0, 0); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsScheduledStartTimeNull { - get { - if ((curObj["ScheduledStartTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime ScheduledStartTime { - get { - if ((curObj["ScheduledStartTime"] != null)) { - return ToDateTime(((string)(curObj["ScheduledStartTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStartTimeNull { - get { - if ((curObj["StartTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime StartTime { - get { - if ((curObj["StartTime"] != null)) { - return ToDateTime(((string)(curObj["StartTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeBeforeRemovalNull { - get { - if ((curObj["TimeBeforeRemoval"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.TimeSpan TimeBeforeRemoval { - get { - if ((curObj["TimeBeforeRemoval"] != null)) { - return ToTimeSpan(((string)(curObj["TimeBeforeRemoval"]))); - } - else { - return new System.TimeSpan(0, 0, 0, 0, 0); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeSubmittedNull { - get { - if ((curObj["TimeSubmitted"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeSubmitted { - get { - if ((curObj["TimeSubmitted"] != null)) { - return ToDateTime(((string)(curObj["TimeSubmitted"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsUntilTimeNull { - get { - if ((curObj["UntilTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime UntilTime { - get { - if ((curObj["UntilTime"] != null)) { - return ToDateTime(((string)(curObj["UntilTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeCancellable() { - if ((this.IsCancellableNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - // Converts a given time interval in DMTF format to System.TimeSpan object. - static System.TimeSpan ToTimeSpan(string dmtfTimespan) { - int days = 0; - int hours = 0; - int minutes = 0; - int seconds = 0; - long ticks = 0; - if ((dmtfTimespan == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtfTimespan.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtfTimespan.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtfTimespan.Substring(21, 4) != ":000")) { - throw new System.ArgumentOutOfRangeException(); - } - try { - string tempString = string.Empty; - tempString = dmtfTimespan.Substring(0, 8); - days = int.Parse(tempString); - tempString = dmtfTimespan.Substring(8, 2); - hours = int.Parse(tempString); - tempString = dmtfTimespan.Substring(10, 2); - minutes = int.Parse(tempString); - tempString = dmtfTimespan.Substring(12, 2); - seconds = int.Parse(tempString); - tempString = dmtfTimespan.Substring(15, 6); - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0); - System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks); - timespan = timespan.Add(tsTemp); - return timespan; - } - - // Converts a given System.TimeSpan object to DMTF Time interval format. - static string ToDmtfTimeInterval(System.TimeSpan timespan) { - string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0'); - System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue; - if ((timespan.Days > maxTimeSpan.Days)) { - throw new System.ArgumentOutOfRangeException(); - } - System.TimeSpan minTimeSpan = System.TimeSpan.MinValue; - if ((timespan.Days < minTimeSpan.Days)) { - throw new System.ArgumentOutOfRangeException(); - } - dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0')); - dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0')); - dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0')); - dmtftimespan = string.Concat(dmtftimespan, "."); - System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0); - long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicroSec = ((long)(microsec)).ToString(); - if ((strMicroSec.Length > 6)) { - strMicroSec = strMicroSec.Substring(0, 6); - } - dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0')); - dmtftimespan = string.Concat(dmtftimespan, ":000"); - return dmtftimespan; - } - - private bool ShouldSerializeDeleteOnCompletion() { - if ((this.IsDeleteOnCompletionNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeElapsedTime() { - if ((this.IsElapsedTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeErrorCode() { - if ((this.IsErrorCodeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeJobRunTimes() { - if ((this.IsJobRunTimesNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeJobState() { - if ((this.IsJobStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeJobType() { - if ((this.IsJobTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLocalOrUtcTime() { - if ((this.IsLocalOrUtcTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePercentComplete() { - if ((this.IsPercentCompleteNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePriority() { - if ((this.IsPriorityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRecoveryAction() { - if ((this.IsRecoveryActionNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRunDay() { - if ((this.IsRunDayNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRunDayOfWeek() { - if ((this.IsRunDayOfWeekNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRunMonth() { - if ((this.IsRunMonthNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRunStartInterval() { - if ((this.IsRunStartIntervalNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeScheduledStartTime() { - if ((this.IsScheduledStartTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStartTime() { - if ((this.IsStartTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeBeforeRemoval() { - if ((this.IsTimeBeforeRemovalNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeSubmitted() { - if ((this.IsTimeSubmittedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeUntilTime() { - if ((this.IsUntilTimeNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_ConcreteJob"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static ConcreteJobCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static ConcreteJobCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static ConcreteJobCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static ConcreteJobCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_ConcreteJob"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new ConcreteJobCollection(clsObject.GetInstances(enumOptions)); - } - - public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ConcreteJob", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new ConcreteJobCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static ConcreteJob CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new ConcreteJob(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint GetError(out string Error) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetError", inParams, null); - Error = System.Convert.ToString(outParams.Properties["Error"].Value); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Error = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GetErrorEx(out string[] Errors) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetErrorEx", inParams, null); - Errors = ((string[])(outParams.Properties["Errors"].Value)); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Errors = null; - return System.Convert.ToUInt32(0); - } - } - - public uint KillJob(bool DeleteOnKill) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("KillJob"); - inParams["DeleteOnKill"] = ((bool)(DeleteOnKill)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("KillJob", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class ConcreteJobCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public ConcreteJobCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new ConcreteJob(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new ConcreteJobEnumerator(privColObj.GetEnumerator()); - } - - public class ConcreteJobEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public ConcreteJobEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new ConcreteJob(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // Time interval functions ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to System.TimeSpan and vice-versa. + // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. + // An Early Bound class generated for the WMI class.Msvm_ConcreteJob + public class ConcreteJob : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + private static string CreatedClassName = "Msvm_ConcreteJob"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public ConcreteJob() { + this.InitializeObject(null, null, null); + } + + public ConcreteJob(string keyInstanceID) { + this.InitializeObject(null, new System.Management.ManagementPath(ConcreteJob.ConstructPath(keyInstanceID)), null); + } + + public ConcreteJob(System.Management.ManagementScope mgmtScope, string keyInstanceID) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ConcreteJob.ConstructPath(keyInstanceID)), null); + } + + public ConcreteJob(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public ConcreteJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public ConcreteJob(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public ConcreteJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public ConcreteJob(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public ConcreteJob(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCancellableNull { + get { + if ((curObj["Cancellable"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates whether the job can be cancelled. The value of this property does not g" + + "uarantee that a request to cancel the job will succeed.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool Cancellable { + get { + if ((curObj["Cancellable"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["Cancellable"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDeleteOnCompletionNull { + get { + if ((curObj["DeleteOnCompletion"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool DeleteOnCompletion { + get { + if ((curObj["DeleteOnCompletion"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["DeleteOnCompletion"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsElapsedTimeNull { + get { + if ((curObj["ElapsedTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.TimeSpan ElapsedTime { + get { + if ((curObj["ElapsedTime"] != null)) { + return ToTimeSpan(((string)(curObj["ElapsedTime"]))); + } + else { + return new System.TimeSpan(0, 0, 0, 0, 0); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsErrorCodeNull { + get { + if ((curObj["ErrorCode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ErrorCode { + get { + if ((curObj["ErrorCode"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ErrorCode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ErrorDescription { + get { + return ((string)(curObj["ErrorDescription"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ErrorSummaryDescription { + get { + return ((string)(curObj["ErrorSummaryDescription"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsJobRunTimesNull { + get { + if ((curObj["JobRunTimes"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint JobRunTimes { + get { + if ((curObj["JobRunTimes"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["JobRunTimes"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsJobStateNull { + get { + if ((curObj["JobState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort JobState { + get { + if ((curObj["JobState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["JobState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string JobStatus { + get { + return ((string)(curObj["JobStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsJobTypeNull { + get { + if ((curObj["JobType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates the type of Job being tracked by this object.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort JobType { + get { + if ((curObj["JobType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["JobType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLocalOrUtcTimeNull { + get { + if ((curObj["LocalOrUtcTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort LocalOrUtcTime { + get { + if ((curObj["LocalOrUtcTime"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["LocalOrUtcTime"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Notify { + get { + return ((string)(curObj["Notify"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherRecoveryAction { + get { + return ((string)(curObj["OtherRecoveryAction"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Owner { + get { + return ((string)(curObj["Owner"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPercentCompleteNull { + get { + if ((curObj["PercentComplete"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PercentComplete { + get { + if ((curObj["PercentComplete"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PercentComplete"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPriorityNull { + get { + if ((curObj["Priority"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Priority { + get { + if ((curObj["Priority"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Priority"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRecoveryActionNull { + get { + if ((curObj["RecoveryAction"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RecoveryAction { + get { + if ((curObj["RecoveryAction"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RecoveryAction"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRunDayNull { + get { + if ((curObj["RunDay"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public sbyte RunDay { + get { + if ((curObj["RunDay"] == null)) { + return System.Convert.ToSByte(0); + } + return ((sbyte)(curObj["RunDay"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRunDayOfWeekNull { + get { + if ((curObj["RunDayOfWeek"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public sbyte RunDayOfWeek { + get { + if ((curObj["RunDayOfWeek"] == null)) { + return System.Convert.ToSByte(0); + } + return ((sbyte)(curObj["RunDayOfWeek"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRunMonthNull { + get { + if ((curObj["RunMonth"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public byte RunMonth { + get { + if ((curObj["RunMonth"] == null)) { + return System.Convert.ToByte(0); + } + return ((byte)(curObj["RunMonth"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRunStartIntervalNull { + get { + if ((curObj["RunStartInterval"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.TimeSpan RunStartInterval { + get { + if ((curObj["RunStartInterval"] != null)) { + return ToTimeSpan(((string)(curObj["RunStartInterval"]))); + } + else { + return new System.TimeSpan(0, 0, 0, 0, 0); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsScheduledStartTimeNull { + get { + if ((curObj["ScheduledStartTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime ScheduledStartTime { + get { + if ((curObj["ScheduledStartTime"] != null)) { + return ToDateTime(((string)(curObj["ScheduledStartTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStartTimeNull { + get { + if ((curObj["StartTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime StartTime { + get { + if ((curObj["StartTime"] != null)) { + return ToDateTime(((string)(curObj["StartTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeBeforeRemovalNull { + get { + if ((curObj["TimeBeforeRemoval"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.TimeSpan TimeBeforeRemoval { + get { + if ((curObj["TimeBeforeRemoval"] != null)) { + return ToTimeSpan(((string)(curObj["TimeBeforeRemoval"]))); + } + else { + return new System.TimeSpan(0, 0, 0, 0, 0); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeSubmittedNull { + get { + if ((curObj["TimeSubmitted"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeSubmitted { + get { + if ((curObj["TimeSubmitted"] != null)) { + return ToDateTime(((string)(curObj["TimeSubmitted"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsUntilTimeNull { + get { + if ((curObj["UntilTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime UntilTime { + get { + if ((curObj["UntilTime"] != null)) { + return ToDateTime(((string)(curObj["UntilTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeCancellable() { + if ((this.IsCancellableNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + // Converts a given time interval in DMTF format to System.TimeSpan object. + static System.TimeSpan ToTimeSpan(string dmtfTimespan) { + int days = 0; + int hours = 0; + int minutes = 0; + int seconds = 0; + long ticks = 0; + if ((dmtfTimespan == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtfTimespan.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtfTimespan.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtfTimespan.Substring(21, 4) != ":000")) { + throw new System.ArgumentOutOfRangeException(); + } + try { + string tempString = string.Empty; + tempString = dmtfTimespan.Substring(0, 8); + days = int.Parse(tempString); + tempString = dmtfTimespan.Substring(8, 2); + hours = int.Parse(tempString); + tempString = dmtfTimespan.Substring(10, 2); + minutes = int.Parse(tempString); + tempString = dmtfTimespan.Substring(12, 2); + seconds = int.Parse(tempString); + tempString = dmtfTimespan.Substring(15, 6); + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0); + System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks); + timespan = timespan.Add(tsTemp); + return timespan; + } + + // Converts a given System.TimeSpan object to DMTF Time interval format. + static string ToDmtfTimeInterval(System.TimeSpan timespan) { + string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0'); + System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue; + if ((timespan.Days > maxTimeSpan.Days)) { + throw new System.ArgumentOutOfRangeException(); + } + System.TimeSpan minTimeSpan = System.TimeSpan.MinValue; + if ((timespan.Days < minTimeSpan.Days)) { + throw new System.ArgumentOutOfRangeException(); + } + dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0')); + dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0')); + dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0')); + dmtftimespan = string.Concat(dmtftimespan, "."); + System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0); + long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicroSec = ((long)(microsec)).ToString(); + if ((strMicroSec.Length > 6)) { + strMicroSec = strMicroSec.Substring(0, 6); + } + dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0')); + dmtftimespan = string.Concat(dmtftimespan, ":000"); + return dmtftimespan; + } + + private bool ShouldSerializeDeleteOnCompletion() { + if ((this.IsDeleteOnCompletionNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeElapsedTime() { + if ((this.IsElapsedTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeErrorCode() { + if ((this.IsErrorCodeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeJobRunTimes() { + if ((this.IsJobRunTimesNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeJobState() { + if ((this.IsJobStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeJobType() { + if ((this.IsJobTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLocalOrUtcTime() { + if ((this.IsLocalOrUtcTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePercentComplete() { + if ((this.IsPercentCompleteNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePriority() { + if ((this.IsPriorityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRecoveryAction() { + if ((this.IsRecoveryActionNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRunDay() { + if ((this.IsRunDayNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRunDayOfWeek() { + if ((this.IsRunDayOfWeekNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRunMonth() { + if ((this.IsRunMonthNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRunStartInterval() { + if ((this.IsRunStartIntervalNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeScheduledStartTime() { + if ((this.IsScheduledStartTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStartTime() { + if ((this.IsStartTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeBeforeRemoval() { + if ((this.IsTimeBeforeRemovalNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeSubmitted() { + if ((this.IsTimeSubmittedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeUntilTime() { + if ((this.IsUntilTimeNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_ConcreteJob"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static ConcreteJobCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static ConcreteJobCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static ConcreteJobCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static ConcreteJobCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_ConcreteJob"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new ConcreteJobCollection(clsObject.GetInstances(enumOptions)); + } + + public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ConcreteJob", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new ConcreteJobCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static ConcreteJob CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new ConcreteJob(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint GetError(out string Error) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetError", inParams, null); + Error = System.Convert.ToString(outParams.Properties["Error"].Value); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Error = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GetErrorEx(out string[] Errors) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetErrorEx", inParams, null); + Errors = ((string[])(outParams.Properties["Errors"].Value)); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Errors = null; + return System.Convert.ToUInt32(0); + } + } + + public uint KillJob(bool DeleteOnKill) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("KillJob"); + inParams["DeleteOnKill"] = ((bool)(DeleteOnKill)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("KillJob", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class ConcreteJobCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public ConcreteJobCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new ConcreteJob(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new ConcreteJobEnumerator(privColObj.GetEnumerator()); + } + + public class ConcreteJobEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public ConcreteJobEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new ConcreteJob(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 6400ec64516..3f28309e23c 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 @@ -1,1164 +1,1164 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public EthernetPortAllocationSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Address { - get { - return ((string)(curObj["Address"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AddressOnParent { - get { - return ((string)(curObj["AddressOnParent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AllocationUnits { - get { - return ((string)(curObj["AllocationUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticAllocationNull { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticAllocation { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticAllocation"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticDeallocationNull { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticDeallocation { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticDeallocation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Connection { - get { - return ((string[])(curObj["Connection"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConsumerVisibilityNull { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ConsumerVisibility { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ConsumerVisibility"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDesiredVLANEndpointModeNull { - get { - if ((curObj["DesiredVLANEndpointMode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DesiredVLANEndpointMode { - get { - if ((curObj["DesiredVLANEndpointMode"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DesiredVLANEndpointMode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"EnabledState is an integer enumeration that indicates whether the allocation request is enabled or disabled. When an allocation request is marked as Disabled (3), then the allocation is not processed. The EnabledState for an active configuration is always marked as Enabled (2).")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public EnabledStateValues EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return ((EnabledStateValues)(System.Convert.ToInt32(0))); - } - return ((EnabledStateValues)(System.Convert.ToInt32(curObj["EnabledState"]))); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] HostResource { - get { - return ((string[])(curObj["HostResource"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitNull { - get { - if ((curObj["Limit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Limit { - get { - if ((curObj["Limit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Limit"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMappingBehaviorNull { - get { - if ((curObj["MappingBehavior"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort MappingBehavior { - get { - if ((curObj["MappingBehavior"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["MappingBehavior"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEndpointMode { - get { - return ((string)(curObj["OtherEndpointMode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherResourceType { - get { - return ((string)(curObj["OtherResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PoolID { - get { - return ((string)(curObj["PoolID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The list of friendly names corresponding to each entry in the RequiredFeatures.")] - public string[] RequiredFeatureHints { - get { - return ((string[])(curObj["RequiredFeatureHints"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The list of feature identifers representing all the features that are required fo" + - "r a port.")] - public string[] RequiredFeatures { - get { - return ((string[])(curObj["RequiredFeatures"])); - } - set { - curObj["RequiredFeatures"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReservationNull { - get { - if ((curObj["Reservation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Reservation { - get { - if ((curObj["Reservation"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Reservation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ResourceSubType { - get { - return ((string)(curObj["ResourceSubType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResourceTypeNull { - get { - if ((curObj["ResourceType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResourceType { - get { - if ((curObj["ResourceType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("This property specifies the network resource pool from which a connection will be" + - " allocated to test replica system when it is created.")] - public string TestReplicaPoolID { - get { - return ((string)(curObj["TestReplicaPoolID"])); - } - set { - curObj["TestReplicaPoolID"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("This property specifies the friendly name of the virtual network switch to which " + - "a connection will be allocated for the test replica system when it is created.")] - public string TestReplicaSwitchName { - get { - return ((string)(curObj["TestReplicaSwitchName"])); - } - set { - curObj["TestReplicaSwitchName"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualQuantityNull { - get { - if ((curObj["VirtualQuantity"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualQuantity { - get { - if ((curObj["VirtualQuantity"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualQuantity"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualQuantityUnits { - get { - return ((string)(curObj["VirtualQuantityUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsWeightNull { - get { - if ((curObj["Weight"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Weight { - get { - if ((curObj["Weight"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Weight"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAutomaticAllocation() { - if ((this.IsAutomaticAllocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticDeallocation() { - if ((this.IsAutomaticDeallocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConsumerVisibility() { - if ((this.IsConsumerVisibilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDesiredVLANEndpointMode() { - if ((this.IsDesiredVLANEndpointModeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimit() { - if ((this.IsLimitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMappingBehavior() { - if ((this.IsMappingBehaviorNull == false)) { - return true; - } - return false; - } - - private void ResetRequiredFeatures() { - curObj["RequiredFeatures"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeReservation() { - if ((this.IsReservationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResourceType() { - if ((this.IsResourceTypeNull == false)) { - return true; - } - return false; - } - - private void ResetTestReplicaPoolID() { - curObj["TestReplicaPoolID"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetTestReplicaSwitchName() { - curObj["TestReplicaSwitchName"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeVirtualQuantity() { - if ((this.IsVirtualQuantityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeWeight() { - if ((this.IsWeightNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetPortAllocationSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static EthernetPortAllocationSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static EthernetPortAllocationSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static EthernetPortAllocationSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static EthernetPortAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_EthernetPortAllocationSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new EthernetPortAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetPortAllocationSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new EthernetPortAllocationSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static EthernetPortAllocationSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new EthernetPortAllocationSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public enum EnabledStateValues { - - Enabled = 2, - - Disabled = 3, - - NULL_ENUM_VALUE = 0, - } - - // Enumerator implementation for enumerating instances of the class. - public class EthernetPortAllocationSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public EthernetPortAllocationSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new EthernetPortAllocationSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class EthernetPortAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public EthernetPortAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public EthernetPortAllocationSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Address { + get { + return ((string)(curObj["Address"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AddressOnParent { + get { + return ((string)(curObj["AddressOnParent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AllocationUnits { + get { + return ((string)(curObj["AllocationUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticAllocationNull { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticAllocation { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticAllocation"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticDeallocationNull { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticDeallocation { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticDeallocation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Connection { + get { + return ((string[])(curObj["Connection"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConsumerVisibilityNull { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ConsumerVisibility { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ConsumerVisibility"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDesiredVLANEndpointModeNull { + get { + if ((curObj["DesiredVLANEndpointMode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DesiredVLANEndpointMode { + get { + if ((curObj["DesiredVLANEndpointMode"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DesiredVLANEndpointMode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"EnabledState is an integer enumeration that indicates whether the allocation request is enabled or disabled. When an allocation request is marked as Disabled (3), then the allocation is not processed. The EnabledState for an active configuration is always marked as Enabled (2).")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public EnabledStateValues EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return ((EnabledStateValues)(System.Convert.ToInt32(0))); + } + return ((EnabledStateValues)(System.Convert.ToInt32(curObj["EnabledState"]))); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] HostResource { + get { + return ((string[])(curObj["HostResource"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitNull { + get { + if ((curObj["Limit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Limit { + get { + if ((curObj["Limit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Limit"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMappingBehaviorNull { + get { + if ((curObj["MappingBehavior"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort MappingBehavior { + get { + if ((curObj["MappingBehavior"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["MappingBehavior"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEndpointMode { + get { + return ((string)(curObj["OtherEndpointMode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherResourceType { + get { + return ((string)(curObj["OtherResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PoolID { + get { + return ((string)(curObj["PoolID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The list of friendly names corresponding to each entry in the RequiredFeatures.")] + public string[] RequiredFeatureHints { + get { + return ((string[])(curObj["RequiredFeatureHints"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The list of feature identifers representing all the features that are required fo" + + "r a port.")] + public string[] RequiredFeatures { + get { + return ((string[])(curObj["RequiredFeatures"])); + } + set { + curObj["RequiredFeatures"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReservationNull { + get { + if ((curObj["Reservation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Reservation { + get { + if ((curObj["Reservation"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Reservation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ResourceSubType { + get { + return ((string)(curObj["ResourceSubType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResourceTypeNull { + get { + if ((curObj["ResourceType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResourceType { + get { + if ((curObj["ResourceType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("This property specifies the network resource pool from which a connection will be" + + " allocated to test replica system when it is created.")] + public string TestReplicaPoolID { + get { + return ((string)(curObj["TestReplicaPoolID"])); + } + set { + curObj["TestReplicaPoolID"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("This property specifies the friendly name of the virtual network switch to which " + + "a connection will be allocated for the test replica system when it is created.")] + public string TestReplicaSwitchName { + get { + return ((string)(curObj["TestReplicaSwitchName"])); + } + set { + curObj["TestReplicaSwitchName"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualQuantityNull { + get { + if ((curObj["VirtualQuantity"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualQuantity { + get { + if ((curObj["VirtualQuantity"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualQuantity"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualQuantityUnits { + get { + return ((string)(curObj["VirtualQuantityUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsWeightNull { + get { + if ((curObj["Weight"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Weight { + get { + if ((curObj["Weight"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Weight"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAutomaticAllocation() { + if ((this.IsAutomaticAllocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticDeallocation() { + if ((this.IsAutomaticDeallocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConsumerVisibility() { + if ((this.IsConsumerVisibilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDesiredVLANEndpointMode() { + if ((this.IsDesiredVLANEndpointModeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimit() { + if ((this.IsLimitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMappingBehavior() { + if ((this.IsMappingBehaviorNull == false)) { + return true; + } + return false; + } + + private void ResetRequiredFeatures() { + curObj["RequiredFeatures"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeReservation() { + if ((this.IsReservationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResourceType() { + if ((this.IsResourceTypeNull == false)) { + return true; + } + return false; + } + + private void ResetTestReplicaPoolID() { + curObj["TestReplicaPoolID"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetTestReplicaSwitchName() { + curObj["TestReplicaSwitchName"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeVirtualQuantity() { + if ((this.IsVirtualQuantityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeWeight() { + if ((this.IsWeightNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetPortAllocationSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static EthernetPortAllocationSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static EthernetPortAllocationSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static EthernetPortAllocationSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static EthernetPortAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_EthernetPortAllocationSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new EthernetPortAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetPortAllocationSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new EthernetPortAllocationSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static EthernetPortAllocationSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new EthernetPortAllocationSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public enum EnabledStateValues { + + Enabled = 2, + + Disabled = 3, + + NULL_ENUM_VALUE = 0, + } + + // Enumerator implementation for enumerating instances of the class. + public class EthernetPortAllocationSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public EthernetPortAllocationSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new EthernetPortAllocationSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class EthernetPortAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public EthernetPortAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 018e3f5021e..9626fa61916 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 @@ -1,2119 +1,2119 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_EthernetSwitchPort - public class EthernetSwitchPort : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - public static string CreatedClassName = "Msvm_EthernetSwitchPort"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public EthernetSwitchPort() { - this.InitializeObject(null, null, null); - } - - public EthernetSwitchPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(null, new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); - } - - public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); - } - - public EthernetSwitchPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public EthernetSwitchPort(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public EthernetSwitchPort(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public EthernetSwitchPort(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsActiveMaximumTransmissionUnitNull { - get { - if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong ActiveMaximumTransmissionUnit { - get { - if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["ActiveMaximumTransmissionUnit"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AdditionalAvailability { - get { - return ((ushort[])(curObj["AdditionalAvailability"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutoSenseNull { - get { - if ((curObj["AutoSense"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutoSense { - get { - if ((curObj["AutoSense"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutoSense"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAvailabilityNull { - get { - if ((curObj["Availability"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort Availability { - get { - if ((curObj["Availability"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["Availability"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] Capabilities { - get { - return ((ushort[])(curObj["Capabilities"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] CapabilityDescriptions { - get { - return ((string[])(curObj["CapabilityDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string DeviceID { - get { - return ((string)(curObj["DeviceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] EnabledCapabilities { - get { - return ((ushort[])(curObj["EnabledCapabilities"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsErrorClearedNull { - get { - if ((curObj["ErrorCleared"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool ErrorCleared { - get { - if ((curObj["ErrorCleared"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["ErrorCleared"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ErrorDescription { - get { - return ((string)(curObj["ErrorDescription"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsFullDuplexNull { - get { - if ((curObj["FullDuplex"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool FullDuplex { - get { - if ((curObj["FullDuplex"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["FullDuplex"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] IdentifyingDescriptions { - get { - return ((string[])(curObj["IdentifyingDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsIOVOffloadUsageNull { - get { - if ((curObj["IOVOffloadUsage"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The current I/O virtualization (IOV) offload usage on this port. The usage is the" + - "amount of IOV resources in use on the port.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint IOVOffloadUsage { - get { - if ((curObj["IOVOffloadUsage"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["IOVOffloadUsage"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLastErrorCodeNull { - get { - if ((curObj["LastErrorCode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint LastErrorCode { - get { - if ((curObj["LastErrorCode"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["LastErrorCode"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLinkTechnologyNull { - get { - if ((curObj["LinkTechnology"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort LinkTechnology { - get { - if ((curObj["LinkTechnology"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["LinkTechnology"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxDataSizeNull { - get { - if ((curObj["MaxDataSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint MaxDataSize { - get { - if ((curObj["MaxDataSize"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["MaxDataSize"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxQuiesceTimeNull { - get { - if ((curObj["MaxQuiesceTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxQuiesceTime { - get { - if ((curObj["MaxQuiesceTime"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxQuiesceTime"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxSpeedNull { - get { - if ((curObj["MaxSpeed"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxSpeed { - get { - if ((curObj["MaxSpeed"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxSpeed"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] NetworkAddresses { - get { - return ((string[])(curObj["NetworkAddresses"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherEnabledCapabilities { - get { - return ((string[])(curObj["OtherEnabledCapabilities"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherIdentifyingInfo { - get { - return ((string[])(curObj["OtherIdentifyingInfo"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherLinkTechnology { - get { - return ((string)(curObj["OtherLinkTechnology"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherNetworkPortType { - get { - return ((string)(curObj["OtherNetworkPortType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherPortType { - get { - return ((string)(curObj["OtherPortType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PermanentAddress { - get { - return ((string)(curObj["PermanentAddress"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPortNumberNull { - get { - if ((curObj["PortNumber"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PortNumber { - get { - if ((curObj["PortNumber"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PortNumber"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPortTypeNull { - get { - if ((curObj["PortType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PortType { - get { - if ((curObj["PortType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PortType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] PowerManagementCapabilities { - get { - return ((ushort[])(curObj["PowerManagementCapabilities"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPowerManagementSupportedNull { - get { - if ((curObj["PowerManagementSupported"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool PowerManagementSupported { - get { - if ((curObj["PowerManagementSupported"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["PowerManagementSupported"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPowerOnHoursNull { - get { - if ((curObj["PowerOnHours"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong PowerOnHours { - get { - if ((curObj["PowerOnHours"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["PowerOnHours"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedSpeedNull { - get { - if ((curObj["RequestedSpeed"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong RequestedSpeed { - get { - if ((curObj["RequestedSpeed"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["RequestedSpeed"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSpeedNull { - get { - if ((curObj["Speed"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Speed { - get { - if ((curObj["Speed"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Speed"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStatusInfoNull { - get { - if ((curObj["StatusInfo"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort StatusInfo { - get { - if ((curObj["StatusInfo"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["StatusInfo"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSupportedMaximumTransmissionUnitNull { - get { - if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong SupportedMaximumTransmissionUnit { - get { - if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["SupportedMaximumTransmissionUnit"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemCreationClassName { - get { - return ((string)(curObj["SystemCreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemName { - get { - return ((string)(curObj["SystemName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTotalPowerOnHoursNull { - get { - if ((curObj["TotalPowerOnHours"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong TotalPowerOnHours { - get { - if ((curObj["TotalPowerOnHours"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["TotalPowerOnHours"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsUsageRestrictionNull { - get { - if ((curObj["UsageRestriction"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort UsageRestriction { - get { - if ((curObj["UsageRestriction"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["UsageRestriction"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVMQOffloadUsageNull { - get { - if ((curObj["VMQOffloadUsage"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The current VMQ offloading usage on this port. The usage is the amount of VMQ res" + - "ources in use on the port.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint VMQOffloadUsage { - get { - if ((curObj["VMQOffloadUsage"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["VMQOffloadUsage"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeActiveMaximumTransmissionUnit() { - if ((this.IsActiveMaximumTransmissionUnitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutoSense() { - if ((this.IsAutoSenseNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAvailability() { - if ((this.IsAvailabilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeErrorCleared() { - if ((this.IsErrorClearedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeFullDuplex() { - if ((this.IsFullDuplexNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeIOVOffloadUsage() { - if ((this.IsIOVOffloadUsageNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLastErrorCode() { - if ((this.IsLastErrorCodeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLinkTechnology() { - if ((this.IsLinkTechnologyNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxDataSize() { - if ((this.IsMaxDataSizeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxQuiesceTime() { - if ((this.IsMaxQuiesceTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxSpeed() { - if ((this.IsMaxSpeedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePortNumber() { - if ((this.IsPortNumberNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePortType() { - if ((this.IsPortTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePowerManagementSupported() { - if ((this.IsPowerManagementSupportedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePowerOnHours() { - if ((this.IsPowerOnHoursNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedSpeed() { - if ((this.IsRequestedSpeedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeSpeed() { - if ((this.IsSpeedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStatusInfo() { - if ((this.IsStatusInfoNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeSupportedMaximumTransmissionUnit() { - if ((this.IsSupportedMaximumTransmissionUnitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTotalPowerOnHours() { - if ((this.IsTotalPowerOnHoursNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeUsageRestriction() { - if ((this.IsUsageRestrictionNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVMQOffloadUsage() { - if ((this.IsVMQOffloadUsageNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPort"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static EthernetSwitchPortCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static EthernetSwitchPortCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static EthernetSwitchPortCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static EthernetSwitchPortCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_EthernetSwitchPort"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new EthernetSwitchPortCollection(clsObject.GetInstances(enumOptions)); - } - - public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetSwitchPort", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new EthernetSwitchPortCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static EthernetSwitchPort CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new EthernetSwitchPort(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint EnableDevice(bool Enabled) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice"); - inParams["Enabled"] = ((bool)(Enabled)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint OnlineDevice(bool Online) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice"); - inParams["Online"] = ((bool)(Online)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint QuiesceDevice(bool Quiesce) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice"); - inParams["Quiesce"] = ((bool)(Quiesce)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint Reset() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RestoreProperties() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint SaveProperties() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint SetPowerState(ushort PowerState, System.DateTime Time) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); - inParams["PowerState"] = ((ushort)(PowerState)); - inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class EthernetSwitchPortCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public EthernetSwitchPortCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new EthernetSwitchPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new EthernetSwitchPortEnumerator(privColObj.GetEnumerator()); - } - - public class EthernetSwitchPortEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public EthernetSwitchPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new EthernetSwitchPort(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_EthernetSwitchPort + public class EthernetSwitchPort : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + public static string CreatedClassName = "Msvm_EthernetSwitchPort"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public EthernetSwitchPort() { + this.InitializeObject(null, null, null); + } + + public EthernetSwitchPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(null, new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); + } + + public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); + } + + public EthernetSwitchPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public EthernetSwitchPort(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public EthernetSwitchPort(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public EthernetSwitchPort(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsActiveMaximumTransmissionUnitNull { + get { + if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong ActiveMaximumTransmissionUnit { + get { + if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["ActiveMaximumTransmissionUnit"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AdditionalAvailability { + get { + return ((ushort[])(curObj["AdditionalAvailability"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutoSenseNull { + get { + if ((curObj["AutoSense"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutoSense { + get { + if ((curObj["AutoSense"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutoSense"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAvailabilityNull { + get { + if ((curObj["Availability"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort Availability { + get { + if ((curObj["Availability"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["Availability"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] Capabilities { + get { + return ((ushort[])(curObj["Capabilities"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] CapabilityDescriptions { + get { + return ((string[])(curObj["CapabilityDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string DeviceID { + get { + return ((string)(curObj["DeviceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] EnabledCapabilities { + get { + return ((ushort[])(curObj["EnabledCapabilities"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsErrorClearedNull { + get { + if ((curObj["ErrorCleared"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool ErrorCleared { + get { + if ((curObj["ErrorCleared"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["ErrorCleared"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ErrorDescription { + get { + return ((string)(curObj["ErrorDescription"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsFullDuplexNull { + get { + if ((curObj["FullDuplex"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool FullDuplex { + get { + if ((curObj["FullDuplex"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["FullDuplex"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] IdentifyingDescriptions { + get { + return ((string[])(curObj["IdentifyingDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsIOVOffloadUsageNull { + get { + if ((curObj["IOVOffloadUsage"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The current I/O virtualization (IOV) offload usage on this port. The usage is the" + + "amount of IOV resources in use on the port.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint IOVOffloadUsage { + get { + if ((curObj["IOVOffloadUsage"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["IOVOffloadUsage"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastErrorCodeNull { + get { + if ((curObj["LastErrorCode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint LastErrorCode { + get { + if ((curObj["LastErrorCode"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["LastErrorCode"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLinkTechnologyNull { + get { + if ((curObj["LinkTechnology"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort LinkTechnology { + get { + if ((curObj["LinkTechnology"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["LinkTechnology"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxDataSizeNull { + get { + if ((curObj["MaxDataSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint MaxDataSize { + get { + if ((curObj["MaxDataSize"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["MaxDataSize"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxQuiesceTimeNull { + get { + if ((curObj["MaxQuiesceTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxQuiesceTime { + get { + if ((curObj["MaxQuiesceTime"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxQuiesceTime"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxSpeedNull { + get { + if ((curObj["MaxSpeed"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxSpeed { + get { + if ((curObj["MaxSpeed"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxSpeed"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] NetworkAddresses { + get { + return ((string[])(curObj["NetworkAddresses"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherEnabledCapabilities { + get { + return ((string[])(curObj["OtherEnabledCapabilities"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherIdentifyingInfo { + get { + return ((string[])(curObj["OtherIdentifyingInfo"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherLinkTechnology { + get { + return ((string)(curObj["OtherLinkTechnology"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherNetworkPortType { + get { + return ((string)(curObj["OtherNetworkPortType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherPortType { + get { + return ((string)(curObj["OtherPortType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PermanentAddress { + get { + return ((string)(curObj["PermanentAddress"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPortNumberNull { + get { + if ((curObj["PortNumber"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PortNumber { + get { + if ((curObj["PortNumber"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PortNumber"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPortTypeNull { + get { + if ((curObj["PortType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PortType { + get { + if ((curObj["PortType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PortType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] PowerManagementCapabilities { + get { + return ((ushort[])(curObj["PowerManagementCapabilities"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPowerManagementSupportedNull { + get { + if ((curObj["PowerManagementSupported"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool PowerManagementSupported { + get { + if ((curObj["PowerManagementSupported"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["PowerManagementSupported"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPowerOnHoursNull { + get { + if ((curObj["PowerOnHours"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong PowerOnHours { + get { + if ((curObj["PowerOnHours"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["PowerOnHours"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedSpeedNull { + get { + if ((curObj["RequestedSpeed"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong RequestedSpeed { + get { + if ((curObj["RequestedSpeed"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["RequestedSpeed"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSpeedNull { + get { + if ((curObj["Speed"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Speed { + get { + if ((curObj["Speed"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Speed"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStatusInfoNull { + get { + if ((curObj["StatusInfo"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort StatusInfo { + get { + if ((curObj["StatusInfo"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["StatusInfo"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSupportedMaximumTransmissionUnitNull { + get { + if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong SupportedMaximumTransmissionUnit { + get { + if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["SupportedMaximumTransmissionUnit"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemCreationClassName { + get { + return ((string)(curObj["SystemCreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemName { + get { + return ((string)(curObj["SystemName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTotalPowerOnHoursNull { + get { + if ((curObj["TotalPowerOnHours"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong TotalPowerOnHours { + get { + if ((curObj["TotalPowerOnHours"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["TotalPowerOnHours"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsUsageRestrictionNull { + get { + if ((curObj["UsageRestriction"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort UsageRestriction { + get { + if ((curObj["UsageRestriction"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["UsageRestriction"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVMQOffloadUsageNull { + get { + if ((curObj["VMQOffloadUsage"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The current VMQ offloading usage on this port. The usage is the amount of VMQ " + + "resources in use on the port.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint VMQOffloadUsage { + get { + if ((curObj["VMQOffloadUsage"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["VMQOffloadUsage"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeActiveMaximumTransmissionUnit() { + if ((this.IsActiveMaximumTransmissionUnitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutoSense() { + if ((this.IsAutoSenseNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAvailability() { + if ((this.IsAvailabilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeErrorCleared() { + if ((this.IsErrorClearedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeFullDuplex() { + if ((this.IsFullDuplexNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeIOVOffloadUsage() { + if ((this.IsIOVOffloadUsageNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLastErrorCode() { + if ((this.IsLastErrorCodeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLinkTechnology() { + if ((this.IsLinkTechnologyNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxDataSize() { + if ((this.IsMaxDataSizeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxQuiesceTime() { + if ((this.IsMaxQuiesceTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxSpeed() { + if ((this.IsMaxSpeedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePortNumber() { + if ((this.IsPortNumberNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePortType() { + if ((this.IsPortTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePowerManagementSupported() { + if ((this.IsPowerManagementSupportedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePowerOnHours() { + if ((this.IsPowerOnHoursNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedSpeed() { + if ((this.IsRequestedSpeedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeSpeed() { + if ((this.IsSpeedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStatusInfo() { + if ((this.IsStatusInfoNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeSupportedMaximumTransmissionUnit() { + if ((this.IsSupportedMaximumTransmissionUnitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTotalPowerOnHours() { + if ((this.IsTotalPowerOnHoursNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeUsageRestriction() { + if ((this.IsUsageRestrictionNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVMQOffloadUsage() { + if ((this.IsVMQOffloadUsageNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPort"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static EthernetSwitchPortCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static EthernetSwitchPortCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static EthernetSwitchPortCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static EthernetSwitchPortCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_EthernetSwitchPort"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new EthernetSwitchPortCollection(clsObject.GetInstances(enumOptions)); + } + + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetSwitchPort", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new EthernetSwitchPortCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static EthernetSwitchPort CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new EthernetSwitchPort(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint EnableDevice(bool Enabled) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice"); + inParams["Enabled"] = ((bool)(Enabled)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint OnlineDevice(bool Online) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice"); + inParams["Online"] = ((bool)(Online)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint QuiesceDevice(bool Quiesce) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice"); + inParams["Quiesce"] = ((bool)(Quiesce)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint Reset() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RestoreProperties() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint SaveProperties() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint SetPowerState(ushort PowerState, System.DateTime Time) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); + inParams["PowerState"] = ((ushort)(PowerState)); + inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class EthernetSwitchPortCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public EthernetSwitchPortCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new EthernetSwitchPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new EthernetSwitchPortEnumerator(privColObj.GetEnumerator()); + } + + public class EthernetSwitchPortEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public EthernetSwitchPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new EthernetSwitchPort(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 5418bec7f98..24cc7dbf41e 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 @@ -1,1022 +1,1022 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public EthernetSwitchPortVlanSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAccessVlanIdNull { - get { - if ((curObj["AccessVlanId"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The vlan ID in access mode.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort AccessVlanId { - get { - if ((curObj["AccessVlanId"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["AccessVlanId"])); - } - set { - curObj["AccessVlanId"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsNativeVlanIdNull { - get { - if ((curObj["NativeVlanId"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The vlan ID in trunk mode.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort NativeVlanId { - get { - if ((curObj["NativeVlanId"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["NativeVlanId"])); - } - set { - curObj["NativeVlanId"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperationModeNull { - get { - if ((curObj["OperationMode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The vlan operation modes.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public OperationModeValues OperationMode { - get { - if ((curObj["OperationMode"] == null)) { - return ((OperationModeValues)(System.Convert.ToInt32(0))); - } - return ((OperationModeValues)(System.Convert.ToInt32(curObj["OperationMode"]))); - } - set { - if ((OperationModeValues.NULL_ENUM_VALUE == value)) { - curObj["OperationMode"] = null; - } - else { - curObj["OperationMode"] = value; - } - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryVlanIdNull { - get { - if ((curObj["PrimaryVlanId"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The primary vlan ID in private mode.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryVlanId { - get { - if ((curObj["PrimaryVlanId"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryVlanId"])); - } - set { - curObj["PrimaryVlanId"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The prune vlan ID bitmap in trunk mode.")] - public ushort[] PruneVlanIdArray { - get { - return ((ushort[])(curObj["PruneVlanIdArray"])); - } - set { - curObj["PruneVlanIdArray"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPvlanModeNull { - get { - if ((curObj["PvlanMode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The private vlan modes.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public PvlanModeValues PvlanMode { - get { - if ((curObj["PvlanMode"] == null)) { - return ((PvlanModeValues)(System.Convert.ToInt32(0))); - } - return ((PvlanModeValues)(System.Convert.ToInt32(curObj["PvlanMode"]))); - } - set { - if ((PvlanModeValues.NULL_ENUM_VALUE == value)) { - curObj["PvlanMode"] = null; - } - else { - curObj["PvlanMode"] = value; - } - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSecondaryVlanIdNull { - get { - if ((curObj["SecondaryVlanId"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The secondary vlan ID in private mode.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort SecondaryVlanId { - get { - if ((curObj["SecondaryVlanId"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["SecondaryVlanId"])); - } - set { - curObj["SecondaryVlanId"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The secondary vlan ID bitmap in private mode.")] - public ushort[] SecondaryVlanIdArray { - get { - return ((ushort[])(curObj["SecondaryVlanIdArray"])); - } - set { - curObj["SecondaryVlanIdArray"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The trunk vlan ID bitmap in trunk mode.")] - public ushort[] TrunkVlanIdArray { - get { - return ((ushort[])(curObj["TrunkVlanIdArray"])); - } - set { - curObj["TrunkVlanIdArray"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAccessVlanId() { - if ((this.IsAccessVlanIdNull == false)) { - return true; - } - return false; - } - - private void ResetAccessVlanId() { - curObj["AccessVlanId"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeNativeVlanId() { - if ((this.IsNativeVlanIdNull == false)) { - return true; - } - return false; - } - - private void ResetNativeVlanId() { - curObj["NativeVlanId"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeOperationMode() { - if ((this.IsOperationModeNull == false)) { - return true; - } - return false; - } - - private void ResetOperationMode() { - curObj["OperationMode"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializePrimaryVlanId() { - if ((this.IsPrimaryVlanIdNull == false)) { - return true; - } - return false; - } - - private void ResetPrimaryVlanId() { - curObj["PrimaryVlanId"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetPruneVlanIdArray() { - curObj["PruneVlanIdArray"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializePvlanMode() { - if ((this.IsPvlanModeNull == false)) { - return true; - } - return false; - } - - private void ResetPvlanMode() { - curObj["PvlanMode"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeSecondaryVlanId() { - if ((this.IsSecondaryVlanIdNull == false)) { - return true; - } - return false; - } - - private void ResetSecondaryVlanId() { - curObj["SecondaryVlanId"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetSecondaryVlanIdArray() { - curObj["SecondaryVlanIdArray"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetTrunkVlanIdArray() { - curObj["TrunkVlanIdArray"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPortVlanSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static EthernetSwitchPortVlanSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_EthernetSwitchPortVlanSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new EthernetSwitchPortVlanSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetSwitchPortVlanSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new EthernetSwitchPortVlanSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static EthernetSwitchPortVlanSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new EthernetSwitchPortVlanSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public enum OperationModeValues { - - Access = 1, - - Trunk = 2, - - Private = 3, - - NULL_ENUM_VALUE = 0, - } - - public enum PvlanModeValues { - - Isolated = 1, - - Community = 2, - - Promiscuous = 3, - - NULL_ENUM_VALUE = 0, - } - - // Enumerator implementation for enumerating instances of the class. - public class EthernetSwitchPortVlanSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public EthernetSwitchPortVlanSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new EthernetSwitchPortVlanSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class EthernetSwitchPortVlanSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public EthernetSwitchPortVlanSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public EthernetSwitchPortVlanSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAccessVlanIdNull { + get { + if ((curObj["AccessVlanId"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The vlan ID in access mode.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort AccessVlanId { + get { + if ((curObj["AccessVlanId"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["AccessVlanId"])); + } + set { + curObj["AccessVlanId"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsNativeVlanIdNull { + get { + if ((curObj["NativeVlanId"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The vlan ID in trunk mode.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort NativeVlanId { + get { + if ((curObj["NativeVlanId"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["NativeVlanId"])); + } + set { + curObj["NativeVlanId"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperationModeNull { + get { + if ((curObj["OperationMode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The vlan operation modes.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public OperationModeValues OperationMode { + get { + if ((curObj["OperationMode"] == null)) { + return ((OperationModeValues)(System.Convert.ToInt32(0))); + } + return ((OperationModeValues)(System.Convert.ToInt32(curObj["OperationMode"]))); + } + set { + if ((OperationModeValues.NULL_ENUM_VALUE == value)) { + curObj["OperationMode"] = null; + } + else { + curObj["OperationMode"] = value; + } + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryVlanIdNull { + get { + if ((curObj["PrimaryVlanId"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The primary vlan ID in private mode.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryVlanId { + get { + if ((curObj["PrimaryVlanId"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryVlanId"])); + } + set { + curObj["PrimaryVlanId"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The prune vlan ID bitmap in trunk mode.")] + public ushort[] PruneVlanIdArray { + get { + return ((ushort[])(curObj["PruneVlanIdArray"])); + } + set { + curObj["PruneVlanIdArray"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPvlanModeNull { + get { + if ((curObj["PvlanMode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The private vlan modes.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public PvlanModeValues PvlanMode { + get { + if ((curObj["PvlanMode"] == null)) { + return ((PvlanModeValues)(System.Convert.ToInt32(0))); + } + return ((PvlanModeValues)(System.Convert.ToInt32(curObj["PvlanMode"]))); + } + set { + if ((PvlanModeValues.NULL_ENUM_VALUE == value)) { + curObj["PvlanMode"] = null; + } + else { + curObj["PvlanMode"] = value; + } + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSecondaryVlanIdNull { + get { + if ((curObj["SecondaryVlanId"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The secondary vlan ID in private mode.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort SecondaryVlanId { + get { + if ((curObj["SecondaryVlanId"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["SecondaryVlanId"])); + } + set { + curObj["SecondaryVlanId"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The secondary vlan ID bitmap in private mode.")] + public ushort[] SecondaryVlanIdArray { + get { + return ((ushort[])(curObj["SecondaryVlanIdArray"])); + } + set { + curObj["SecondaryVlanIdArray"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The trunk vlan ID bitmap in trunk mode.")] + public ushort[] TrunkVlanIdArray { + get { + return ((ushort[])(curObj["TrunkVlanIdArray"])); + } + set { + curObj["TrunkVlanIdArray"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAccessVlanId() { + if ((this.IsAccessVlanIdNull == false)) { + return true; + } + return false; + } + + private void ResetAccessVlanId() { + curObj["AccessVlanId"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeNativeVlanId() { + if ((this.IsNativeVlanIdNull == false)) { + return true; + } + return false; + } + + private void ResetNativeVlanId() { + curObj["NativeVlanId"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeOperationMode() { + if ((this.IsOperationModeNull == false)) { + return true; + } + return false; + } + + private void ResetOperationMode() { + curObj["OperationMode"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializePrimaryVlanId() { + if ((this.IsPrimaryVlanIdNull == false)) { + return true; + } + return false; + } + + private void ResetPrimaryVlanId() { + curObj["PrimaryVlanId"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetPruneVlanIdArray() { + curObj["PruneVlanIdArray"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializePvlanMode() { + if ((this.IsPvlanModeNull == false)) { + return true; + } + return false; + } + + private void ResetPvlanMode() { + curObj["PvlanMode"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeSecondaryVlanId() { + if ((this.IsSecondaryVlanIdNull == false)) { + return true; + } + return false; + } + + private void ResetSecondaryVlanId() { + curObj["SecondaryVlanId"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetSecondaryVlanIdArray() { + curObj["SecondaryVlanIdArray"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetTrunkVlanIdArray() { + curObj["TrunkVlanIdArray"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPortVlanSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static EthernetSwitchPortVlanSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_EthernetSwitchPortVlanSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new EthernetSwitchPortVlanSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetSwitchPortVlanSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new EthernetSwitchPortVlanSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static EthernetSwitchPortVlanSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new EthernetSwitchPortVlanSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public enum OperationModeValues { + + Access = 1, + + Trunk = 2, + + Private = 3, + + NULL_ENUM_VALUE = 0, + } + + public enum PvlanModeValues { + + Isolated = 1, + + Community = 2, + + Promiscuous = 3, + + NULL_ENUM_VALUE = 0, + } + + // Enumerator implementation for enumerating instances of the class. + public class EthernetSwitchPortVlanSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public EthernetSwitchPortVlanSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new EthernetSwitchPortVlanSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class EthernetSwitchPortVlanSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public EthernetSwitchPortVlanSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 c5138852547..801aa9e7dd7 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 @@ -1,2087 +1,2086 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_ExternalEthernetPort - public class ExternalEthernetPort : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - private static string CreatedClassName = "Msvm_ExternalEthernetPort"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public ExternalEthernetPort() { - this.InitializeObject(null, null, null); - } - - public ExternalEthernetPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(null, new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); - } - - public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); - } - - public ExternalEthernetPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public ExternalEthernetPort(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public ExternalEthernetPort(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public ExternalEthernetPort(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsActiveMaximumTransmissionUnitNull { - get { - if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong ActiveMaximumTransmissionUnit { - get { - if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["ActiveMaximumTransmissionUnit"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AdditionalAvailability { - get { - return ((ushort[])(curObj["AdditionalAvailability"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutoSenseNull { - get { - if ((curObj["AutoSense"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutoSense { - get { - if ((curObj["AutoSense"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutoSense"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAvailabilityNull { - get { - if ((curObj["Availability"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort Availability { - get { - if ((curObj["Availability"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["Availability"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] Capabilities { - get { - return ((ushort[])(curObj["Capabilities"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] CapabilityDescriptions { - get { - return ((string[])(curObj["CapabilityDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string DeviceID { - get { - return ((string)(curObj["DeviceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] EnabledCapabilities { - get { - return ((ushort[])(curObj["EnabledCapabilities"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsErrorClearedNull { - get { - if ((curObj["ErrorCleared"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool ErrorCleared { - get { - if ((curObj["ErrorCleared"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["ErrorCleared"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ErrorDescription { - get { - return ((string)(curObj["ErrorDescription"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsFullDuplexNull { - get { - if ((curObj["FullDuplex"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool FullDuplex { - get { - if ((curObj["FullDuplex"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["FullDuplex"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] IdentifyingDescriptions { - get { - return ((string[])(curObj["IdentifyingDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsIsBoundNull { - get { - if ((curObj["IsBound"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("If this property is true, then this Ethernet port can be connected to the switche" + - "s and thus can provide connectivity to virtual machine. If this property is fals" + - "e, then this Ethernet is not being used by the virtual machine networking archit" + - "ecture.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool IsBound { - get { - if ((curObj["IsBound"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["IsBound"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLastErrorCodeNull { - get { - if ((curObj["LastErrorCode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint LastErrorCode { - get { - if ((curObj["LastErrorCode"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["LastErrorCode"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLinkTechnologyNull { - get { - if ((curObj["LinkTechnology"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort LinkTechnology { - get { - if ((curObj["LinkTechnology"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["LinkTechnology"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxDataSizeNull { - get { - if ((curObj["MaxDataSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint MaxDataSize { - get { - if ((curObj["MaxDataSize"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["MaxDataSize"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxQuiesceTimeNull { - get { - if ((curObj["MaxQuiesceTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxQuiesceTime { - get { - if ((curObj["MaxQuiesceTime"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxQuiesceTime"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxSpeedNull { - get { - if ((curObj["MaxSpeed"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxSpeed { - get { - if ((curObj["MaxSpeed"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxSpeed"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] NetworkAddresses { - get { - return ((string[])(curObj["NetworkAddresses"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherEnabledCapabilities { - get { - return ((string[])(curObj["OtherEnabledCapabilities"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherIdentifyingInfo { - get { - return ((string[])(curObj["OtherIdentifyingInfo"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherLinkTechnology { - get { - return ((string)(curObj["OtherLinkTechnology"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherNetworkPortType { - get { - return ((string)(curObj["OtherNetworkPortType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherPortType { - get { - return ((string)(curObj["OtherPortType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PermanentAddress { - get { - return ((string)(curObj["PermanentAddress"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPortNumberNull { - get { - if ((curObj["PortNumber"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PortNumber { - get { - if ((curObj["PortNumber"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PortNumber"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPortTypeNull { - get { - if ((curObj["PortType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PortType { - get { - if ((curObj["PortType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PortType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] PowerManagementCapabilities { - get { - return ((ushort[])(curObj["PowerManagementCapabilities"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPowerManagementSupportedNull { - get { - if ((curObj["PowerManagementSupported"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool PowerManagementSupported { - get { - if ((curObj["PowerManagementSupported"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["PowerManagementSupported"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPowerOnHoursNull { - get { - if ((curObj["PowerOnHours"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong PowerOnHours { - get { - if ((curObj["PowerOnHours"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["PowerOnHours"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedSpeedNull { - get { - if ((curObj["RequestedSpeed"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong RequestedSpeed { - get { - if ((curObj["RequestedSpeed"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["RequestedSpeed"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSpeedNull { - get { - if ((curObj["Speed"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Speed { - get { - if ((curObj["Speed"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Speed"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStatusInfoNull { - get { - if ((curObj["StatusInfo"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort StatusInfo { - get { - if ((curObj["StatusInfo"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["StatusInfo"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSupportedMaximumTransmissionUnitNull { - get { - if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong SupportedMaximumTransmissionUnit { - get { - if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["SupportedMaximumTransmissionUnit"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemCreationClassName { - get { - return ((string)(curObj["SystemCreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemName { - get { - return ((string)(curObj["SystemName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTotalPowerOnHoursNull { - get { - if ((curObj["TotalPowerOnHours"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong TotalPowerOnHours { - get { - if ((curObj["TotalPowerOnHours"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["TotalPowerOnHours"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsUsageRestrictionNull { - get { - if ((curObj["UsageRestriction"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort UsageRestriction { - get { - if ((curObj["UsageRestriction"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["UsageRestriction"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeActiveMaximumTransmissionUnit() { - if ((this.IsActiveMaximumTransmissionUnitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutoSense() { - if ((this.IsAutoSenseNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAvailability() { - if ((this.IsAvailabilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeErrorCleared() { - if ((this.IsErrorClearedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeFullDuplex() { - if ((this.IsFullDuplexNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeIsBound() { - if ((this.IsIsBoundNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLastErrorCode() { - if ((this.IsLastErrorCodeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLinkTechnology() { - if ((this.IsLinkTechnologyNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxDataSize() { - if ((this.IsMaxDataSizeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxQuiesceTime() { - if ((this.IsMaxQuiesceTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxSpeed() { - if ((this.IsMaxSpeedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePortNumber() { - if ((this.IsPortNumberNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePortType() { - if ((this.IsPortTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePowerManagementSupported() { - if ((this.IsPowerManagementSupportedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePowerOnHours() { - if ((this.IsPowerOnHoursNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedSpeed() { - if ((this.IsRequestedSpeedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeSpeed() { - if ((this.IsSpeedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStatusInfo() { - if ((this.IsStatusInfoNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeSupportedMaximumTransmissionUnit() { - if ((this.IsSupportedMaximumTransmissionUnitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTotalPowerOnHours() { - if ((this.IsTotalPowerOnHoursNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeUsageRestriction() { - if ((this.IsUsageRestrictionNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_ExternalEthernetPort"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static ExternalEthernetPortCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static ExternalEthernetPortCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static ExternalEthernetPortCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static ExternalEthernetPortCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_ExternalEthernetPort"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new ExternalEthernetPortCollection(clsObject.GetInstances(enumOptions)); - } - - public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ExternalEthernetPort", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new ExternalEthernetPortCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static ExternalEthernetPort CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new ExternalEthernetPort(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint EnableDevice(bool Enabled) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice"); - inParams["Enabled"] = ((bool)(Enabled)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint OnlineDevice(bool Online) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice"); - inParams["Online"] = ((bool)(Online)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint QuiesceDevice(bool Quiesce) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice"); - inParams["Quiesce"] = ((bool)(Quiesce)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint Reset() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RestoreProperties() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint SaveProperties() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint SetPowerState(ushort PowerState, System.DateTime Time) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); - inParams["PowerState"] = ((ushort)(PowerState)); - inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class ExternalEthernetPortCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public ExternalEthernetPortCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new ExternalEthernetPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new ExternalEthernetPortEnumerator(privColObj.GetEnumerator()); - } - - public class ExternalEthernetPortEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public ExternalEthernetPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new ExternalEthernetPort(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_ExternalEthernetPort + public class ExternalEthernetPort : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + private static string CreatedClassName = "Msvm_ExternalEthernetPort"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public ExternalEthernetPort() { + this.InitializeObject(null, null, null); + } + + public ExternalEthernetPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(null, new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); + } + + public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); + } + + public ExternalEthernetPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public ExternalEthernetPort(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public ExternalEthernetPort(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public ExternalEthernetPort(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsActiveMaximumTransmissionUnitNull { + get { + if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong ActiveMaximumTransmissionUnit { + get { + if ((curObj["ActiveMaximumTransmissionUnit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["ActiveMaximumTransmissionUnit"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AdditionalAvailability { + get { + return ((ushort[])(curObj["AdditionalAvailability"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutoSenseNull { + get { + if ((curObj["AutoSense"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutoSense { + get { + if ((curObj["AutoSense"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutoSense"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAvailabilityNull { + get { + if ((curObj["Availability"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort Availability { + get { + if ((curObj["Availability"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["Availability"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] Capabilities { + get { + return ((ushort[])(curObj["Capabilities"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] CapabilityDescriptions { + get { + return ((string[])(curObj["CapabilityDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string DeviceID { + get { + return ((string)(curObj["DeviceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] EnabledCapabilities { + get { + return ((ushort[])(curObj["EnabledCapabilities"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsErrorClearedNull { + get { + if ((curObj["ErrorCleared"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool ErrorCleared { + get { + if ((curObj["ErrorCleared"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["ErrorCleared"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ErrorDescription { + get { + return ((string)(curObj["ErrorDescription"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsFullDuplexNull { + get { + if ((curObj["FullDuplex"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool FullDuplex { + get { + if ((curObj["FullDuplex"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["FullDuplex"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] IdentifyingDescriptions { + get { + return ((string[])(curObj["IdentifyingDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsIsBoundNull { + get { + if ((curObj["IsBound"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("If this property is true, then this Ethernet port can be connected to the switches" + + " and thus can provide connectivity to virtual machine. If this property is false" + + ", then this Ethernet is not being used by the virtual machine networking architecture.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool IsBound { + get { + if ((curObj["IsBound"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["IsBound"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastErrorCodeNull { + get { + if ((curObj["LastErrorCode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint LastErrorCode { + get { + if ((curObj["LastErrorCode"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["LastErrorCode"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLinkTechnologyNull { + get { + if ((curObj["LinkTechnology"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort LinkTechnology { + get { + if ((curObj["LinkTechnology"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["LinkTechnology"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxDataSizeNull { + get { + if ((curObj["MaxDataSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint MaxDataSize { + get { + if ((curObj["MaxDataSize"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["MaxDataSize"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxQuiesceTimeNull { + get { + if ((curObj["MaxQuiesceTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxQuiesceTime { + get { + if ((curObj["MaxQuiesceTime"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxQuiesceTime"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxSpeedNull { + get { + if ((curObj["MaxSpeed"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxSpeed { + get { + if ((curObj["MaxSpeed"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxSpeed"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] NetworkAddresses { + get { + return ((string[])(curObj["NetworkAddresses"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherEnabledCapabilities { + get { + return ((string[])(curObj["OtherEnabledCapabilities"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherIdentifyingInfo { + get { + return ((string[])(curObj["OtherIdentifyingInfo"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherLinkTechnology { + get { + return ((string)(curObj["OtherLinkTechnology"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherNetworkPortType { + get { + return ((string)(curObj["OtherNetworkPortType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherPortType { + get { + return ((string)(curObj["OtherPortType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PermanentAddress { + get { + return ((string)(curObj["PermanentAddress"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPortNumberNull { + get { + if ((curObj["PortNumber"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PortNumber { + get { + if ((curObj["PortNumber"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PortNumber"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPortTypeNull { + get { + if ((curObj["PortType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PortType { + get { + if ((curObj["PortType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PortType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] PowerManagementCapabilities { + get { + return ((ushort[])(curObj["PowerManagementCapabilities"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPowerManagementSupportedNull { + get { + if ((curObj["PowerManagementSupported"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool PowerManagementSupported { + get { + if ((curObj["PowerManagementSupported"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["PowerManagementSupported"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPowerOnHoursNull { + get { + if ((curObj["PowerOnHours"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong PowerOnHours { + get { + if ((curObj["PowerOnHours"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["PowerOnHours"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedSpeedNull { + get { + if ((curObj["RequestedSpeed"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong RequestedSpeed { + get { + if ((curObj["RequestedSpeed"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["RequestedSpeed"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSpeedNull { + get { + if ((curObj["Speed"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Speed { + get { + if ((curObj["Speed"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Speed"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStatusInfoNull { + get { + if ((curObj["StatusInfo"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort StatusInfo { + get { + if ((curObj["StatusInfo"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["StatusInfo"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSupportedMaximumTransmissionUnitNull { + get { + if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong SupportedMaximumTransmissionUnit { + get { + if ((curObj["SupportedMaximumTransmissionUnit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["SupportedMaximumTransmissionUnit"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemCreationClassName { + get { + return ((string)(curObj["SystemCreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemName { + get { + return ((string)(curObj["SystemName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTotalPowerOnHoursNull { + get { + if ((curObj["TotalPowerOnHours"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong TotalPowerOnHours { + get { + if ((curObj["TotalPowerOnHours"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["TotalPowerOnHours"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsUsageRestrictionNull { + get { + if ((curObj["UsageRestriction"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort UsageRestriction { + get { + if ((curObj["UsageRestriction"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["UsageRestriction"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeActiveMaximumTransmissionUnit() { + if ((this.IsActiveMaximumTransmissionUnitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutoSense() { + if ((this.IsAutoSenseNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAvailability() { + if ((this.IsAvailabilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeErrorCleared() { + if ((this.IsErrorClearedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeFullDuplex() { + if ((this.IsFullDuplexNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeIsBound() { + if ((this.IsIsBoundNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLastErrorCode() { + if ((this.IsLastErrorCodeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLinkTechnology() { + if ((this.IsLinkTechnologyNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxDataSize() { + if ((this.IsMaxDataSizeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxQuiesceTime() { + if ((this.IsMaxQuiesceTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxSpeed() { + if ((this.IsMaxSpeedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePortNumber() { + if ((this.IsPortNumberNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePortType() { + if ((this.IsPortTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePowerManagementSupported() { + if ((this.IsPowerManagementSupportedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePowerOnHours() { + if ((this.IsPowerOnHoursNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedSpeed() { + if ((this.IsRequestedSpeedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeSpeed() { + if ((this.IsSpeedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStatusInfo() { + if ((this.IsStatusInfoNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeSupportedMaximumTransmissionUnit() { + if ((this.IsSupportedMaximumTransmissionUnitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTotalPowerOnHours() { + if ((this.IsTotalPowerOnHoursNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeUsageRestriction() { + if ((this.IsUsageRestrictionNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_ExternalEthernetPort"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static ExternalEthernetPortCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static ExternalEthernetPortCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static ExternalEthernetPortCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static ExternalEthernetPortCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_ExternalEthernetPort"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new ExternalEthernetPortCollection(clsObject.GetInstances(enumOptions)); + } + + public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ExternalEthernetPort", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new ExternalEthernetPortCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static ExternalEthernetPort CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new ExternalEthernetPort(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint EnableDevice(bool Enabled) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice"); + inParams["Enabled"] = ((bool)(Enabled)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint OnlineDevice(bool Online) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice"); + inParams["Online"] = ((bool)(Online)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint QuiesceDevice(bool Quiesce) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice"); + inParams["Quiesce"] = ((bool)(Quiesce)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint Reset() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RestoreProperties() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint SaveProperties() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint SetPowerState(ushort PowerState, System.DateTime Time) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); + inParams["PowerState"] = ((ushort)(PowerState)); + inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class ExternalEthernetPortCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public ExternalEthernetPortCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new ExternalEthernetPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new ExternalEthernetPortEnumerator(privColObj.GetEnumerator()); + } + + public class ExternalEthernetPortEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public ExternalEthernetPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new ExternalEthernetPort(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 ff27854e8d5..ba96348416e 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 @@ -1,1525 +1,1525 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_ImageManagementService - public class ImageManagementService : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - private static string CreatedClassName = "Msvm_ImageManagementService"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public ImageManagementService() { - this.InitializeObject(null, null, null); - } - - public ImageManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(null, new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public ImageManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public ImageManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public ImageManagementService(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public ImageManagementService(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public ImageManagementService(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerContact { - get { - return ((string)(curObj["PrimaryOwnerContact"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerName { - get { - return ((string)(curObj["PrimaryOwnerName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStartedNull { - get { - if ((curObj["Started"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool Started { - get { - if ((curObj["Started"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["Started"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string StartMode { - get { - return ((string)(curObj["StartMode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemCreationClassName { - get { - return ((string)(curObj["SystemCreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemName { - get { - return ((string)(curObj["SystemName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStarted() { - if ((this.IsStartedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_ImageManagementService"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static ImageManagementServiceCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static ImageManagementServiceCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static ImageManagementServiceCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static ImageManagementServiceCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_ImageManagementService"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new ImageManagementServiceCollection(clsObject.GetInstances(enumOptions)); - } - - public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ImageManagementService", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new ImageManagementServiceCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static ImageManagementService CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new ImageManagementService(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint AttachVirtualHardDisk(bool AssignDriveLetter, string Path, bool ReadOnly, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("AttachVirtualHardDisk"); - inParams["AssignDriveLetter"] = ((bool)(AssignDriveLetter)); - inParams["Path"] = ((string)(Path)); - inParams["ReadOnly"] = ((bool)(ReadOnly)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AttachVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint CompactVirtualHardDisk(ushort Mode, string Path, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("CompactVirtualHardDisk"); - inParams["Mode"] = ((ushort)(Mode)); - inParams["Path"] = ((string)(Path)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CompactVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ConvertVirtualHardDisk(string SourcePath, string VirtualDiskSettingData, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ConvertVirtualHardDisk"); - inParams["SourcePath"] = ((string)(SourcePath)); - inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ConvertVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint CreateVirtualFloppyDisk(string Path, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualFloppyDisk"); - inParams["Path"] = ((string)(Path)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualFloppyDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint CreateVirtualHardDisk(string VirtualDiskSettingData, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualHardDisk"); - inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GetVirtualHardDiskSettingData(string Path, out System.Management.ManagementPath Job, out string SettingData) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualHardDiskSettingData"); - inParams["Path"] = ((string)(Path)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualHardDiskSettingData", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - SettingData = System.Convert.ToString(outParams.Properties["SettingData"].Value); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - SettingData = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GetVirtualHardDiskState(string Path, out System.Management.ManagementPath Job, out string State) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualHardDiskState"); - inParams["Path"] = ((string)(Path)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualHardDiskState", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - State = System.Convert.ToString(outParams.Properties["State"].Value); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - State = null; - return System.Convert.ToUInt32(0); - } - } - - public uint MergeVirtualHardDisk(string DestinationPath, string SourcePath, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("MergeVirtualHardDisk"); - inParams["DestinationPath"] = ((string)(DestinationPath)); - inParams["SourcePath"] = ((string)(SourcePath)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("MergeVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ResizeVirtualHardDisk(ulong MaxInternalSize, string Path, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ResizeVirtualHardDisk"); - inParams["MaxInternalSize"] = ((ulong)(MaxInternalSize)); - inParams["Path"] = ((string)(Path)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ResizeVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint SetParentVirtualHardDisk(string ChildPath, bool IgnoreIDMismatch, string LeafPath, string ParentPath, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetParentVirtualHardDisk"); - inParams["ChildPath"] = ((string)(ChildPath)); - inParams["IgnoreIDMismatch"] = ((bool)(IgnoreIDMismatch)); - inParams["LeafPath"] = ((string)(LeafPath)); - inParams["ParentPath"] = ((string)(ParentPath)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetParentVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint SetVirtualHardDiskSettingData(string VirtualDiskSettingData, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetVirtualHardDiskSettingData"); - inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetVirtualHardDiskSettingData", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint StartService() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint StopService() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint ValidateVirtualHardDisk(string Path, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ValidateVirtualHardDisk"); - inParams["Path"] = ((string)(Path)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ValidateVirtualHardDisk", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class ImageManagementServiceCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public ImageManagementServiceCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new ImageManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new ImageManagementServiceEnumerator(privColObj.GetEnumerator()); - } - - public class ImageManagementServiceEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public ImageManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new ImageManagementService(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_ImageManagementService + public class ImageManagementService : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + private static string CreatedClassName = "Msvm_ImageManagementService"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public ImageManagementService() { + this.InitializeObject(null, null, null); + } + + public ImageManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(null, new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public ImageManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public ImageManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public ImageManagementService(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public ImageManagementService(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public ImageManagementService(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerContact { + get { + return ((string)(curObj["PrimaryOwnerContact"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerName { + get { + return ((string)(curObj["PrimaryOwnerName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStartedNull { + get { + if ((curObj["Started"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool Started { + get { + if ((curObj["Started"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["Started"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string StartMode { + get { + return ((string)(curObj["StartMode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemCreationClassName { + get { + return ((string)(curObj["SystemCreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemName { + get { + return ((string)(curObj["SystemName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStarted() { + if ((this.IsStartedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_ImageManagementService"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static ImageManagementServiceCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static ImageManagementServiceCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static ImageManagementServiceCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static ImageManagementServiceCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_ImageManagementService"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new ImageManagementServiceCollection(clsObject.GetInstances(enumOptions)); + } + + public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ImageManagementService", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new ImageManagementServiceCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static ImageManagementService CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new ImageManagementService(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint AttachVirtualHardDisk(bool AssignDriveLetter, string Path, bool ReadOnly, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("AttachVirtualHardDisk"); + inParams["AssignDriveLetter"] = ((bool)(AssignDriveLetter)); + inParams["Path"] = ((string)(Path)); + inParams["ReadOnly"] = ((bool)(ReadOnly)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AttachVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint CompactVirtualHardDisk(ushort Mode, string Path, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("CompactVirtualHardDisk"); + inParams["Mode"] = ((ushort)(Mode)); + inParams["Path"] = ((string)(Path)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CompactVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ConvertVirtualHardDisk(string SourcePath, string VirtualDiskSettingData, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ConvertVirtualHardDisk"); + inParams["SourcePath"] = ((string)(SourcePath)); + inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ConvertVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint CreateVirtualFloppyDisk(string Path, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualFloppyDisk"); + inParams["Path"] = ((string)(Path)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualFloppyDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint CreateVirtualHardDisk(string VirtualDiskSettingData, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualHardDisk"); + inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GetVirtualHardDiskSettingData(string Path, out System.Management.ManagementPath Job, out string SettingData) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualHardDiskSettingData"); + inParams["Path"] = ((string)(Path)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualHardDiskSettingData", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + SettingData = System.Convert.ToString(outParams.Properties["SettingData"].Value); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + SettingData = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GetVirtualHardDiskState(string Path, out System.Management.ManagementPath Job, out string State) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualHardDiskState"); + inParams["Path"] = ((string)(Path)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualHardDiskState", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + State = System.Convert.ToString(outParams.Properties["State"].Value); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + State = null; + return System.Convert.ToUInt32(0); + } + } + + public uint MergeVirtualHardDisk(string DestinationPath, string SourcePath, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("MergeVirtualHardDisk"); + inParams["DestinationPath"] = ((string)(DestinationPath)); + inParams["SourcePath"] = ((string)(SourcePath)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("MergeVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ResizeVirtualHardDisk(ulong MaxInternalSize, string Path, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ResizeVirtualHardDisk"); + inParams["MaxInternalSize"] = ((ulong)(MaxInternalSize)); + inParams["Path"] = ((string)(Path)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ResizeVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint SetParentVirtualHardDisk(string ChildPath, bool IgnoreIDMismatch, string LeafPath, string ParentPath, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetParentVirtualHardDisk"); + inParams["ChildPath"] = ((string)(ChildPath)); + inParams["IgnoreIDMismatch"] = ((bool)(IgnoreIDMismatch)); + inParams["LeafPath"] = ((string)(LeafPath)); + inParams["ParentPath"] = ((string)(ParentPath)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetParentVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint SetVirtualHardDiskSettingData(string VirtualDiskSettingData, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetVirtualHardDiskSettingData"); + inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetVirtualHardDiskSettingData", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint StartService() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint StopService() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint ValidateVirtualHardDisk(string Path, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ValidateVirtualHardDisk"); + inParams["Path"] = ((string)(Path)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ValidateVirtualHardDisk", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class ImageManagementServiceCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public ImageManagementServiceCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new ImageManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new ImageManagementServiceEnumerator(privColObj.GetEnumerator()); + } + + public class ImageManagementServiceEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public ImageManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new ImageManagementService(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 d9f6c5667a6..aaf02d6beaf 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 @@ -1,1615 +1,1615 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 -{ - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_KvpExchangeComponent - public class KvpExchangeComponent : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - private static string CreatedClassName = "Msvm_KvpExchangeComponent"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public KvpExchangeComponent() { - this.InitializeObject(null, null, null); - } - - public KvpExchangeComponent(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(null, new System.Management.ManagementPath(KvpExchangeComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); - } - - public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(KvpExchangeComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); - } - - public KvpExchangeComponent(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public KvpExchangeComponent(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public KvpExchangeComponent(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public KvpExchangeComponent(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AdditionalAvailability { - get { - return ((ushort[])(curObj["AdditionalAvailability"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAvailabilityNull { - get { - if ((curObj["Availability"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort Availability { - get { - if ((curObj["Availability"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["Availability"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string DeviceID { - get { - return ((string)(curObj["DeviceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsErrorClearedNull { - get { - if ((curObj["ErrorCleared"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool ErrorCleared { - get { - if ((curObj["ErrorCleared"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["ErrorCleared"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ErrorDescription { - get { - return ((string)(curObj["ErrorDescription"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"An array of embedded Msvm_KvpExchangeDataItem instances which contain the set of key-value pairs that components running within the guest operating system have pushed up to be available for access by external clients. This array will not contain any intrinsic items that are pushed by the integration component directly.")] - public string[] GuestExchangeItems { - get { - return ((string[])(curObj["GuestExchangeItems"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"An array of embedded Msvm_KvpExchangeDataItem instances which contain the set of key-value pairs that the guest operating system has pushed up to be available for access by external clients. This array will not contain any data items pushed by other components running within the guest operating system.")] - public string[] GuestIntrinsicExchangeItems { - get { - return ((string[])(curObj["GuestIntrinsicExchangeItems"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] IdentifyingDescriptions { - get { - return ((string[])(curObj["IdentifyingDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLastErrorCodeNull { - get { - if ((curObj["LastErrorCode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint LastErrorCode { - get { - if ((curObj["LastErrorCode"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["LastErrorCode"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxQuiesceTimeNull { - get { - if ((curObj["MaxQuiesceTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxQuiesceTime { - get { - if ((curObj["MaxQuiesceTime"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxQuiesceTime"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherIdentifyingInfo { - get { - return ((string[])(curObj["OtherIdentifyingInfo"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] PowerManagementCapabilities { - get { - return ((ushort[])(curObj["PowerManagementCapabilities"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPowerManagementSupportedNull { - get { - if ((curObj["PowerManagementSupported"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool PowerManagementSupported { - get { - if ((curObj["PowerManagementSupported"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["PowerManagementSupported"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPowerOnHoursNull { - get { - if ((curObj["PowerOnHours"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong PowerOnHours { - get { - if ((curObj["PowerOnHours"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["PowerOnHours"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStatusInfoNull { - get { - if ((curObj["StatusInfo"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort StatusInfo { - get { - if ((curObj["StatusInfo"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["StatusInfo"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemCreationClassName { - get { - return ((string)(curObj["SystemCreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemName { - get { - return ((string)(curObj["SystemName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTotalPowerOnHoursNull { - get { - if ((curObj["TotalPowerOnHours"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong TotalPowerOnHours { - get { - if ((curObj["TotalPowerOnHours"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["TotalPowerOnHours"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAvailability() { - if ((this.IsAvailabilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeErrorCleared() { - if ((this.IsErrorClearedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLastErrorCode() { - if ((this.IsLastErrorCodeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxQuiesceTime() { - if ((this.IsMaxQuiesceTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePowerManagementSupported() { - if ((this.IsPowerManagementSupportedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePowerOnHours() { - if ((this.IsPowerOnHoursNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStatusInfo() { - if ((this.IsStatusInfoNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTotalPowerOnHours() { - if ((this.IsTotalPowerOnHoursNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_KvpExchangeComponent"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static KvpExchangeComponentCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static KvpExchangeComponentCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static KvpExchangeComponentCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static KvpExchangeComponentCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_KvpExchangeComponent"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new KvpExchangeComponentCollection(clsObject.GetInstances(enumOptions)); - } - - public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_KvpExchangeComponent", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new KvpExchangeComponentCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static KvpExchangeComponent CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new KvpExchangeComponent(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint EnableDevice(bool Enabled) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice"); - inParams["Enabled"] = ((bool)(Enabled)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint OnlineDevice(bool Online) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice"); - inParams["Online"] = ((bool)(Online)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint QuiesceDevice(bool Quiesce) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice"); - inParams["Quiesce"] = ((bool)(Quiesce)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint Reset() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RestoreProperties() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint SaveProperties() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint SetPowerState(ushort PowerState, System.DateTime Time) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); - inParams["PowerState"] = ((ushort)(PowerState)); - inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class KvpExchangeComponentCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public KvpExchangeComponentCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new KvpExchangeComponent(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new KvpExchangeComponentEnumerator(privColObj.GetEnumerator()); - } - - public class KvpExchangeComponentEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public KvpExchangeComponentEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new KvpExchangeComponent(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 +{ + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_KvpExchangeComponent + public class KvpExchangeComponent : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + private static string CreatedClassName = "Msvm_KvpExchangeComponent"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public KvpExchangeComponent() { + this.InitializeObject(null, null, null); + } + + public KvpExchangeComponent(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(null, new System.Management.ManagementPath(KvpExchangeComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); + } + + public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(KvpExchangeComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); + } + + public KvpExchangeComponent(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public KvpExchangeComponent(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public KvpExchangeComponent(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public KvpExchangeComponent(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AdditionalAvailability { + get { + return ((ushort[])(curObj["AdditionalAvailability"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAvailabilityNull { + get { + if ((curObj["Availability"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort Availability { + get { + if ((curObj["Availability"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["Availability"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string DeviceID { + get { + return ((string)(curObj["DeviceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsErrorClearedNull { + get { + if ((curObj["ErrorCleared"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool ErrorCleared { + get { + if ((curObj["ErrorCleared"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["ErrorCleared"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ErrorDescription { + get { + return ((string)(curObj["ErrorDescription"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"An array of embedded Msvm_KvpExchangeDataItem instances which contain the set of key-value pairs that components running within the guest operating system have pushed up to be available for access by external clients. This array will not contain any intrinsic items that are pushed by the integration component directly.")] + public string[] GuestExchangeItems { + get { + return ((string[])(curObj["GuestExchangeItems"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"An array of embedded Msvm_KvpExchangeDataItem instances which contain the set of key-value pairs that the guest operating system has pushed up to be available for access by external clients. This array will not contain any data items pushed by other components running within the guest operating system.")] + public string[] GuestIntrinsicExchangeItems { + get { + return ((string[])(curObj["GuestIntrinsicExchangeItems"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] IdentifyingDescriptions { + get { + return ((string[])(curObj["IdentifyingDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastErrorCodeNull { + get { + if ((curObj["LastErrorCode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint LastErrorCode { + get { + if ((curObj["LastErrorCode"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["LastErrorCode"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxQuiesceTimeNull { + get { + if ((curObj["MaxQuiesceTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxQuiesceTime { + get { + if ((curObj["MaxQuiesceTime"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxQuiesceTime"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherIdentifyingInfo { + get { + return ((string[])(curObj["OtherIdentifyingInfo"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] PowerManagementCapabilities { + get { + return ((ushort[])(curObj["PowerManagementCapabilities"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPowerManagementSupportedNull { + get { + if ((curObj["PowerManagementSupported"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool PowerManagementSupported { + get { + if ((curObj["PowerManagementSupported"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["PowerManagementSupported"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPowerOnHoursNull { + get { + if ((curObj["PowerOnHours"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong PowerOnHours { + get { + if ((curObj["PowerOnHours"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["PowerOnHours"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStatusInfoNull { + get { + if ((curObj["StatusInfo"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort StatusInfo { + get { + if ((curObj["StatusInfo"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["StatusInfo"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemCreationClassName { + get { + return ((string)(curObj["SystemCreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemName { + get { + return ((string)(curObj["SystemName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTotalPowerOnHoursNull { + get { + if ((curObj["TotalPowerOnHours"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong TotalPowerOnHours { + get { + if ((curObj["TotalPowerOnHours"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["TotalPowerOnHours"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAvailability() { + if ((this.IsAvailabilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeErrorCleared() { + if ((this.IsErrorClearedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLastErrorCode() { + if ((this.IsLastErrorCodeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxQuiesceTime() { + if ((this.IsMaxQuiesceTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePowerManagementSupported() { + if ((this.IsPowerManagementSupportedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePowerOnHours() { + if ((this.IsPowerOnHoursNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStatusInfo() { + if ((this.IsStatusInfoNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTotalPowerOnHours() { + if ((this.IsTotalPowerOnHoursNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_KvpExchangeComponent"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static KvpExchangeComponentCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static KvpExchangeComponentCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static KvpExchangeComponentCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static KvpExchangeComponentCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_KvpExchangeComponent"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new KvpExchangeComponentCollection(clsObject.GetInstances(enumOptions)); + } + + public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_KvpExchangeComponent", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new KvpExchangeComponentCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static KvpExchangeComponent CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new KvpExchangeComponent(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint EnableDevice(bool Enabled) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice"); + inParams["Enabled"] = ((bool)(Enabled)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint OnlineDevice(bool Online) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice"); + inParams["Online"] = ((bool)(Online)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint QuiesceDevice(bool Quiesce) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice"); + inParams["Quiesce"] = ((bool)(Quiesce)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint Reset() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RestoreProperties() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint SaveProperties() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint SetPowerState(ushort PowerState, System.DateTime Time) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); + inParams["PowerState"] = ((ushort)(PowerState)); + inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class KvpExchangeComponentCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public KvpExchangeComponentCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new KvpExchangeComponent(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new KvpExchangeComponentEnumerator(privColObj.GetEnumerator()); + } + + public class KvpExchangeComponentEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public KvpExchangeComponentEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new KvpExchangeComponent(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 0832e3c9228..de15266595e 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 @@ -15,1040 +15,1040 @@ // specific language governing permissions and limitations // under the License. -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 -{ - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public KvpExchangeComponentSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Address { - get { - return ((string)(curObj["Address"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AddressOnParent { - get { - return ((string)(curObj["AddressOnParent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AllocationUnits { - get { - return ((string)(curObj["AllocationUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticAllocationNull { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticAllocation { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticAllocation"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticDeallocationNull { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticDeallocation { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticDeallocation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Connection { - get { - return ((string[])(curObj["Connection"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConsumerVisibilityNull { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ConsumerVisibility { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ConsumerVisibility"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 +{ + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public KvpExchangeComponentSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Address { + get { + return ((string)(curObj["Address"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AddressOnParent { + get { + return ((string)(curObj["AddressOnParent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AllocationUnits { + get { + return ((string)(curObj["AllocationUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticAllocationNull { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticAllocation { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticAllocation"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticDeallocationNull { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticDeallocation { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticDeallocation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Connection { + get { + return ((string[])(curObj["Connection"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConsumerVisibilityNull { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ConsumerVisibility { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ConsumerVisibility"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"The enabled and disabled states of an element. Valid values are 2 (enabled) and 3 (disabled). The default value is 2 (enabled). -This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("An array of Msvm_KvpExchangeDataItem instances.\nThis is a read-only property, but" + - " it can be changed using the AddKvpItems, ModifyKvpItems, and RemoveKvpItems met" + - "hods of the Msvm_VirtualSystemManagementService class.")] - public string[] HostExchangeItems { - get { - return ((string[])(curObj["HostExchangeItems"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"An array of Msvm_KvpExchangeDataItem instances containing the key/value pairs that are stored in the configuration file but not exchanged with the guest OS. This allows applications to store VM-specific data that does not need to be visible to the guest OS. The items are formatted the same as the items in the HostExchangeItems property except the Source property of the Msvm_KvpExchangeDataItem instance is set to 4. Each configuration file is limited to 128 key/value pairs, where each value field is allowed to be up to 16 KB in size and the key field is allowed to be up to512 bytes.")] - public string[] HostOnlyItems { - get { - return ((string[])(curObj["HostOnlyItems"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] HostResource { - get { - return ((string[])(curObj["HostResource"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitNull { - get { - if ((curObj["Limit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Limit { - get { - if ((curObj["Limit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Limit"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMappingBehaviorNull { - get { - if ((curObj["MappingBehavior"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort MappingBehavior { - get { - if ((curObj["MappingBehavior"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["MappingBehavior"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherResourceType { - get { - return ((string)(curObj["OtherResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PoolID { - get { - return ((string)(curObj["PoolID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReservationNull { - get { - if ((curObj["Reservation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Reservation { - get { - if ((curObj["Reservation"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Reservation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ResourceSubType { - get { - return ((string)(curObj["ResourceSubType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResourceTypeNull { - get { - if ((curObj["ResourceType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResourceType { - get { - if ((curObj["ResourceType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResourceType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualQuantityNull { - get { - if ((curObj["VirtualQuantity"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualQuantity { - get { - if ((curObj["VirtualQuantity"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualQuantity"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualQuantityUnits { - get { - return ((string)(curObj["VirtualQuantityUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsWeightNull { - get { - if ((curObj["Weight"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Weight { - get { - if ((curObj["Weight"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Weight"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAutomaticAllocation() { - if ((this.IsAutomaticAllocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticDeallocation() { - if ((this.IsAutomaticDeallocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConsumerVisibility() { - if ((this.IsConsumerVisibilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimit() { - if ((this.IsLimitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMappingBehavior() { - if ((this.IsMappingBehaviorNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReservation() { - if ((this.IsReservationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResourceType() { - if ((this.IsResourceTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualQuantity() { - if ((this.IsVirtualQuantityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeWeight() { - if ((this.IsWeightNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_KvpExchangeComponentSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static KvpExchangeComponentSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static KvpExchangeComponentSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static KvpExchangeComponentSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static KvpExchangeComponentSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_KvpExchangeComponentSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new KvpExchangeComponentSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_KvpExchangeComponentSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new KvpExchangeComponentSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static KvpExchangeComponentSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new KvpExchangeComponentSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class KvpExchangeComponentSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public KvpExchangeComponentSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new KvpExchangeComponentSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new KvpExchangeComponentSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class KvpExchangeComponentSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public KvpExchangeComponentSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new KvpExchangeComponentSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("An array of Msvm_KvpExchangeDataItem instances.\nThis is a read-only property, but" + + " it can be changed using the AddKvpItems, ModifyKvpItems, and RemoveKvpItems met" + + "hods of the Msvm_VirtualSystemManagementService class.")] + public string[] HostExchangeItems { + get { + return ((string[])(curObj["HostExchangeItems"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"An array of Msvm_KvpExchangeDataItem instances containing the key/value pairs that are stored in the configuration file but not exchanged with the guest OS. This allows applications to store VM-specific data that does not need to be visible to the guest OS. The items are formatted the same as the items in the HostExchangeItems property except the Source property of the Msvm_KvpExchangeDataItem instance is set to 4. Each configuration file is limited to 128 key/value pairs, where each value field is allowed to be up to 16 KB in size and the key field is allowed to be up to512 bytes.")] + public string[] HostOnlyItems { + get { + return ((string[])(curObj["HostOnlyItems"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] HostResource { + get { + return ((string[])(curObj["HostResource"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitNull { + get { + if ((curObj["Limit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Limit { + get { + if ((curObj["Limit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Limit"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMappingBehaviorNull { + get { + if ((curObj["MappingBehavior"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort MappingBehavior { + get { + if ((curObj["MappingBehavior"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["MappingBehavior"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherResourceType { + get { + return ((string)(curObj["OtherResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PoolID { + get { + return ((string)(curObj["PoolID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReservationNull { + get { + if ((curObj["Reservation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Reservation { + get { + if ((curObj["Reservation"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Reservation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ResourceSubType { + get { + return ((string)(curObj["ResourceSubType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResourceTypeNull { + get { + if ((curObj["ResourceType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResourceType { + get { + if ((curObj["ResourceType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResourceType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualQuantityNull { + get { + if ((curObj["VirtualQuantity"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualQuantity { + get { + if ((curObj["VirtualQuantity"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualQuantity"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualQuantityUnits { + get { + return ((string)(curObj["VirtualQuantityUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsWeightNull { + get { + if ((curObj["Weight"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Weight { + get { + if ((curObj["Weight"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Weight"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAutomaticAllocation() { + if ((this.IsAutomaticAllocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticDeallocation() { + if ((this.IsAutomaticDeallocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConsumerVisibility() { + if ((this.IsConsumerVisibilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimit() { + if ((this.IsLimitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMappingBehavior() { + if ((this.IsMappingBehaviorNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReservation() { + if ((this.IsReservationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResourceType() { + if ((this.IsResourceTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualQuantity() { + if ((this.IsVirtualQuantityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeWeight() { + if ((this.IsWeightNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_KvpExchangeComponentSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static KvpExchangeComponentSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static KvpExchangeComponentSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static KvpExchangeComponentSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static KvpExchangeComponentSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_KvpExchangeComponentSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new KvpExchangeComponentSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_KvpExchangeComponentSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new KvpExchangeComponentSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static KvpExchangeComponentSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new KvpExchangeComponentSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class KvpExchangeComponentSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public KvpExchangeComponentSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new KvpExchangeComponentSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new KvpExchangeComponentSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class KvpExchangeComponentSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public KvpExchangeComponentSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new KvpExchangeComponentSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 bf5eaae8e7c..ffc1e9888ac 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 @@ -1,670 +1,670 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 -{ - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public KvpExchangeDataItem(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Data { - get { - return ((string)(curObj["Data"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSourceNull { - get { - if ((curObj["Source"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort Source { - get { - if ((curObj["Source"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["Source"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeSource() { - if ((this.IsSourceNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath() { - string strPath = "ROOT\\virtualization\\v2:Msvm_KvpExchangeDataItem"; - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static KvpExchangeDataItemCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static KvpExchangeDataItemCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static KvpExchangeDataItemCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static KvpExchangeDataItemCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_KvpExchangeDataItem"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new KvpExchangeDataItemCollection(clsObject.GetInstances(enumOptions)); - } - - public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_KvpExchangeDataItem", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new KvpExchangeDataItemCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static KvpExchangeDataItem CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new KvpExchangeDataItem(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class KvpExchangeDataItemCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public KvpExchangeDataItemCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new KvpExchangeDataItem(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new KvpExchangeDataItemEnumerator(privColObj.GetEnumerator()); - } - - public class KvpExchangeDataItemEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public KvpExchangeDataItemEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new KvpExchangeDataItem(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 +{ + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public KvpExchangeDataItem(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Data { + get { + return ((string)(curObj["Data"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSourceNull { + get { + if ((curObj["Source"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort Source { + get { + if ((curObj["Source"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["Source"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeSource() { + if ((this.IsSourceNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath() { + string strPath = "ROOT\\virtualization\\v2:Msvm_KvpExchangeDataItem"; + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static KvpExchangeDataItemCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static KvpExchangeDataItemCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static KvpExchangeDataItemCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static KvpExchangeDataItemCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_KvpExchangeDataItem"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new KvpExchangeDataItemCollection(clsObject.GetInstances(enumOptions)); + } + + public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_KvpExchangeDataItem", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new KvpExchangeDataItemCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static KvpExchangeDataItem CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new KvpExchangeDataItem(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class KvpExchangeDataItemCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public KvpExchangeDataItemCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new KvpExchangeDataItem(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new KvpExchangeDataItemEnumerator(privColObj.GetEnumerator()); + } + + public class KvpExchangeDataItemEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public KvpExchangeDataItemEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new KvpExchangeDataItem(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 453f528d497..ee8563aadc5 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 @@ -1,1422 +1,1422 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_LANEndpoint - public class LANEndpoint : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - public static string CreatedClassName = "Msvm_LANEndpoint"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public LANEndpoint() { - this.InitializeObject(null, null, null); - } - - public LANEndpoint(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(null, new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public LANEndpoint(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public LANEndpoint(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public LANEndpoint(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public LANEndpoint(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public LANEndpoint(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] AliasAddresses { - get { - return ((string[])(curObj["AliasAddresses"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConnectedNull { - get { - if ((curObj["Connected"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("This property is set to TRUE if the LAN endpoint is connected to a switch port.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool Connected { - get { - if ((curObj["Connected"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["Connected"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] GroupAddresses { - get { - return ((string[])(curObj["GroupAddresses"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string LANID { - get { - return ((string)(curObj["LANID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLANTypeNull { - get { - if ((curObj["LANType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort LANType { - get { - if ((curObj["LANType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["LANType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string MACAddress { - get { - return ((string)(curObj["MACAddress"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxDataSizeNull { - get { - if ((curObj["MaxDataSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint MaxDataSize { - get { - if ((curObj["MaxDataSize"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["MaxDataSize"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string NameFormat { - get { - return ((string)(curObj["NameFormat"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherLANType { - get { - return ((string)(curObj["OtherLANType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherTypeDescription { - get { - return ((string)(curObj["OtherTypeDescription"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsProtocolIFTypeNull { - get { - if ((curObj["ProtocolIFType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ProtocolIFType { - get { - if ((curObj["ProtocolIFType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ProtocolIFType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsProtocolTypeNull { - get { - if ((curObj["ProtocolType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ProtocolType { - get { - if ((curObj["ProtocolType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ProtocolType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemCreationClassName { - get { - return ((string)(curObj["SystemCreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemName { - get { - return ((string)(curObj["SystemName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConnected() { - if ((this.IsConnectedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLANType() { - if ((this.IsLANTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxDataSize() { - if ((this.IsMaxDataSizeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeProtocolIFType() { - if ((this.IsProtocolIFTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeProtocolType() { - if ((this.IsProtocolTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_LANEndpoint"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static LANEndpointCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static LANEndpointCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static LANEndpointCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static LANEndpointCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_LANEndpoint"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new LANEndpointCollection(clsObject.GetInstances(enumOptions)); - } - - public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_LANEndpoint", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new LANEndpointCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static LANEndpoint CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new LANEndpoint(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class LANEndpointCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public LANEndpointCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new LANEndpoint(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new LANEndpointEnumerator(privColObj.GetEnumerator()); - } - - public class LANEndpointEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public LANEndpointEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new LANEndpoint(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_LANEndpoint + public class LANEndpoint : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + public static string CreatedClassName = "Msvm_LANEndpoint"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public LANEndpoint() { + this.InitializeObject(null, null, null); + } + + public LANEndpoint(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(null, new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public LANEndpoint(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public LANEndpoint(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public LANEndpoint(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public LANEndpoint(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public LANEndpoint(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] AliasAddresses { + get { + return ((string[])(curObj["AliasAddresses"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConnectedNull { + get { + if ((curObj["Connected"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("This property is set to TRUE if the LAN endpoint is connected to a switch port.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool Connected { + get { + if ((curObj["Connected"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["Connected"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] GroupAddresses { + get { + return ((string[])(curObj["GroupAddresses"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string LANID { + get { + return ((string)(curObj["LANID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLANTypeNull { + get { + if ((curObj["LANType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort LANType { + get { + if ((curObj["LANType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["LANType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string MACAddress { + get { + return ((string)(curObj["MACAddress"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxDataSizeNull { + get { + if ((curObj["MaxDataSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint MaxDataSize { + get { + if ((curObj["MaxDataSize"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["MaxDataSize"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string NameFormat { + get { + return ((string)(curObj["NameFormat"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherLANType { + get { + return ((string)(curObj["OtherLANType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherTypeDescription { + get { + return ((string)(curObj["OtherTypeDescription"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsProtocolIFTypeNull { + get { + if ((curObj["ProtocolIFType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ProtocolIFType { + get { + if ((curObj["ProtocolIFType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ProtocolIFType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsProtocolTypeNull { + get { + if ((curObj["ProtocolType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ProtocolType { + get { + if ((curObj["ProtocolType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ProtocolType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemCreationClassName { + get { + return ((string)(curObj["SystemCreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemName { + get { + return ((string)(curObj["SystemName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConnected() { + if ((this.IsConnectedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLANType() { + if ((this.IsLANTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxDataSize() { + if ((this.IsMaxDataSizeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeProtocolIFType() { + if ((this.IsProtocolIFTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeProtocolType() { + if ((this.IsProtocolTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_LANEndpoint"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static LANEndpointCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static LANEndpointCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static LANEndpointCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static LANEndpointCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_LANEndpoint"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new LANEndpointCollection(clsObject.GetInstances(enumOptions)); + } + + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_LANEndpoint", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new LANEndpointCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static LANEndpoint CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new LANEndpoint(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class LANEndpointCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public LANEndpointCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new LANEndpoint(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new LANEndpointEnumerator(privColObj.GetEnumerator()); + } + + public class LANEndpointEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public LANEndpointEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new LANEndpoint(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 f57655ff8e8..d6cda05931d 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 @@ -1,1163 +1,1163 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public MemorySettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Address { - get { - return ((string)(curObj["Address"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AddressOnParent { - get { - return ((string)(curObj["AddressOnParent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AllocationUnits { - get { - return ((string)(curObj["AllocationUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticAllocationNull { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticAllocation { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticAllocation"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticDeallocationNull { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticDeallocation { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticDeallocation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Connection { - get { - return ((string[])(curObj["Connection"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConsumerVisibilityNull { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ConsumerVisibility { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ConsumerVisibility"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDynamicMemoryEnabledNull { - get { - if ((curObj["DynamicMemoryEnabled"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates if dynamic memory is enabled.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool DynamicMemoryEnabled { - get { - if ((curObj["DynamicMemoryEnabled"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["DynamicMemoryEnabled"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] HostResource { - get { - return ((string[])(curObj["HostResource"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsIsVirtualizedNull { - get { - if ((curObj["IsVirtualized"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"Indicates whether this device is virtualized or passed through, possibly using partitioning. When set to False, the underlying or host resource is utilized. At least one item shall be present in the DeviceID property. When set to True, the resource is virtualized and may not map directly to an underlying/host resource. Some implementations may support specific assignment for virtualized resources, in which case the host resource(s) are exposed using the DeviceID property. This property is always set to True.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool IsVirtualized { - get { - if ((curObj["IsVirtualized"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["IsVirtualized"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitNull { - get { - if ((curObj["Limit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Limit { - get { - if ((curObj["Limit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Limit"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMappingBehaviorNull { - get { - if ((curObj["MappingBehavior"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort MappingBehavior { - get { - if ((curObj["MappingBehavior"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["MappingBehavior"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxMemoryBlocksPerNumaNodeNull { - get { - if ((curObj["MaxMemoryBlocksPerNumaNode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum amount of memory that can be observed within the VM as belonging to a" + - " single NUMA node.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxMemoryBlocksPerNumaNode { - get { - if ((curObj["MaxMemoryBlocksPerNumaNode"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxMemoryBlocksPerNumaNode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherResourceType { - get { - return ((string)(curObj["OtherResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PoolID { - get { - return ((string)(curObj["PoolID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReservationNull { - get { - if ((curObj["Reservation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Reservation { - get { - if ((curObj["Reservation"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Reservation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ResourceSubType { - get { - return ((string)(curObj["ResourceSubType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResourceTypeNull { - get { - if ((curObj["ResourceType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResourceType { - get { - if ((curObj["ResourceType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResourceType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSwapFilesInUseNull { - get { - if ((curObj["SwapFilesInUse"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates if smart paging is active.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool SwapFilesInUse { - get { - if ((curObj["SwapFilesInUse"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["SwapFilesInUse"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTargetMemoryBufferNull { - get { - if ((curObj["TargetMemoryBuffer"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint TargetMemoryBuffer { - get { - if ((curObj["TargetMemoryBuffer"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["TargetMemoryBuffer"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualQuantityNull { - get { - if ((curObj["VirtualQuantity"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualQuantity { - get { - if ((curObj["VirtualQuantity"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualQuantity"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualQuantityUnits { - get { - return ((string)(curObj["VirtualQuantityUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsWeightNull { - get { - if ((curObj["Weight"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Weight { - get { - if ((curObj["Weight"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Weight"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAutomaticAllocation() { - if ((this.IsAutomaticAllocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticDeallocation() { - if ((this.IsAutomaticDeallocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConsumerVisibility() { - if ((this.IsConsumerVisibilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDynamicMemoryEnabled() { - if ((this.IsDynamicMemoryEnabledNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeIsVirtualized() { - if ((this.IsIsVirtualizedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimit() { - if ((this.IsLimitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMappingBehavior() { - if ((this.IsMappingBehaviorNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxMemoryBlocksPerNumaNode() { - if ((this.IsMaxMemoryBlocksPerNumaNodeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReservation() { - if ((this.IsReservationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResourceType() { - if ((this.IsResourceTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeSwapFilesInUse() { - if ((this.IsSwapFilesInUseNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTargetMemoryBuffer() { - if ((this.IsTargetMemoryBufferNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualQuantity() { - if ((this.IsVirtualQuantityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeWeight() { - if ((this.IsWeightNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_MemorySettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static MemorySettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static MemorySettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static MemorySettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static MemorySettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_MemorySettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new MemorySettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_MemorySettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new MemorySettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static MemorySettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new MemorySettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class MemorySettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public MemorySettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new MemorySettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new MemorySettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class MemorySettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public MemorySettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new MemorySettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public MemorySettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Address { + get { + return ((string)(curObj["Address"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AddressOnParent { + get { + return ((string)(curObj["AddressOnParent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AllocationUnits { + get { + return ((string)(curObj["AllocationUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticAllocationNull { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticAllocation { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticAllocation"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticDeallocationNull { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticDeallocation { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticDeallocation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Connection { + get { + return ((string[])(curObj["Connection"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConsumerVisibilityNull { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ConsumerVisibility { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ConsumerVisibility"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDynamicMemoryEnabledNull { + get { + if ((curObj["DynamicMemoryEnabled"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates if dynamic memory is enabled.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool DynamicMemoryEnabled { + get { + if ((curObj["DynamicMemoryEnabled"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["DynamicMemoryEnabled"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] HostResource { + get { + return ((string[])(curObj["HostResource"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsIsVirtualizedNull { + get { + if ((curObj["IsVirtualized"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"Indicates whether this device is virtualized or passed through, possibly using partitioning. When set to False, the underlying or host resource is utilized. At least one item shall be present in the DeviceID property. When set to True, the resource is virtualized and may not map directly to an underlying/host resource. Some implementations may support specific assignment for virtualized resources, in which case the host resource(s) are exposed using the DeviceID property. This property is always set to True.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool IsVirtualized { + get { + if ((curObj["IsVirtualized"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["IsVirtualized"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitNull { + get { + if ((curObj["Limit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Limit { + get { + if ((curObj["Limit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Limit"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMappingBehaviorNull { + get { + if ((curObj["MappingBehavior"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort MappingBehavior { + get { + if ((curObj["MappingBehavior"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["MappingBehavior"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxMemoryBlocksPerNumaNodeNull { + get { + if ((curObj["MaxMemoryBlocksPerNumaNode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum amount of memory that can be observed within the VM as belonging to a" + + " single NUMA node.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxMemoryBlocksPerNumaNode { + get { + if ((curObj["MaxMemoryBlocksPerNumaNode"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxMemoryBlocksPerNumaNode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherResourceType { + get { + return ((string)(curObj["OtherResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PoolID { + get { + return ((string)(curObj["PoolID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReservationNull { + get { + if ((curObj["Reservation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Reservation { + get { + if ((curObj["Reservation"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Reservation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ResourceSubType { + get { + return ((string)(curObj["ResourceSubType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResourceTypeNull { + get { + if ((curObj["ResourceType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResourceType { + get { + if ((curObj["ResourceType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResourceType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSwapFilesInUseNull { + get { + if ((curObj["SwapFilesInUse"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates if smart paging is active.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool SwapFilesInUse { + get { + if ((curObj["SwapFilesInUse"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["SwapFilesInUse"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTargetMemoryBufferNull { + get { + if ((curObj["TargetMemoryBuffer"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint TargetMemoryBuffer { + get { + if ((curObj["TargetMemoryBuffer"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["TargetMemoryBuffer"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualQuantityNull { + get { + if ((curObj["VirtualQuantity"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualQuantity { + get { + if ((curObj["VirtualQuantity"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualQuantity"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualQuantityUnits { + get { + return ((string)(curObj["VirtualQuantityUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsWeightNull { + get { + if ((curObj["Weight"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Weight { + get { + if ((curObj["Weight"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Weight"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAutomaticAllocation() { + if ((this.IsAutomaticAllocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticDeallocation() { + if ((this.IsAutomaticDeallocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConsumerVisibility() { + if ((this.IsConsumerVisibilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDynamicMemoryEnabled() { + if ((this.IsDynamicMemoryEnabledNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeIsVirtualized() { + if ((this.IsIsVirtualizedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimit() { + if ((this.IsLimitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMappingBehavior() { + if ((this.IsMappingBehaviorNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxMemoryBlocksPerNumaNode() { + if ((this.IsMaxMemoryBlocksPerNumaNodeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReservation() { + if ((this.IsReservationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResourceType() { + if ((this.IsResourceTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeSwapFilesInUse() { + if ((this.IsSwapFilesInUseNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTargetMemoryBuffer() { + if ((this.IsTargetMemoryBufferNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualQuantity() { + if ((this.IsVirtualQuantityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeWeight() { + if ((this.IsWeightNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_MemorySettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static MemorySettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static MemorySettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static MemorySettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static MemorySettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_MemorySettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new MemorySettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_MemorySettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new MemorySettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static MemorySettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new MemorySettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class MemorySettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public MemorySettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new MemorySettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new MemorySettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class MemorySettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public MemorySettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new MemorySettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 0962e7e6f91..f26a1f168c9 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 @@ -1,1134 +1,1134 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public ProcessorSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Address { - get { - return ((string)(curObj["Address"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AddressOnParent { - get { - return ((string)(curObj["AddressOnParent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AllocationUnits { - get { - return ((string)(curObj["AllocationUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticAllocationNull { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticAllocation { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticAllocation"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticDeallocationNull { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticDeallocation { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticDeallocation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Connection { - get { - return ((string[])(curObj["Connection"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConsumerVisibilityNull { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ConsumerVisibility { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ConsumerVisibility"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] HostResource { - get { - return ((string[])(curObj["HostResource"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitNull { - get { - if ((curObj["Limit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Limit { - get { - if ((curObj["Limit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Limit"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitCPUIDNull { - get { - if ((curObj["LimitCPUID"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates whether the virtual machine should lower the CPU identifier. Some older" + - " operating systems may require you to limit processor functionality in this way " + - "in order to run.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool LimitCPUID { - get { - if ((curObj["LimitCPUID"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["LimitCPUID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitProcessorFeaturesNull { - get { - if ((curObj["LimitProcessorFeatures"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"Indicates whether the VM should limit the CPU features exposed to the operating system. Limiting the processor features enables the VM to be migrated to different host computer systems with different processors. Migrating VMs between computers with processors from different vendors is not supported.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool LimitProcessorFeatures { - get { - if ((curObj["LimitProcessorFeatures"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["LimitProcessorFeatures"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMappingBehaviorNull { - get { - if ((curObj["MappingBehavior"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort MappingBehavior { - get { - if ((curObj["MappingBehavior"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["MappingBehavior"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxNumaNodesPerSocketNull { - get { - if ((curObj["MaxNumaNodesPerSocket"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum number of NUMA nodes that can be observed within the VM as belonging " + - "to a single processor socket.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxNumaNodesPerSocket { - get { - if ((curObj["MaxNumaNodesPerSocket"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxNumaNodesPerSocket"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxProcessorsPerNumaNodeNull { - get { - if ((curObj["MaxProcessorsPerNumaNode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum number of virtual processors that can be observed within the VM as be" + - "longing to a single virtual NUMA node.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxProcessorsPerNumaNode { - get { - if ((curObj["MaxProcessorsPerNumaNode"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxProcessorsPerNumaNode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherResourceType { - get { - return ((string)(curObj["OtherResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PoolID { - get { - return ((string)(curObj["PoolID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReservationNull { - get { - if ((curObj["Reservation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Reservation { - get { - if ((curObj["Reservation"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Reservation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ResourceSubType { - get { - return ((string)(curObj["ResourceSubType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResourceTypeNull { - get { - if ((curObj["ResourceType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResourceType { - get { - if ((curObj["ResourceType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResourceType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualQuantityNull { - get { - if ((curObj["VirtualQuantity"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualQuantity { - get { - if ((curObj["VirtualQuantity"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualQuantity"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualQuantityUnits { - get { - return ((string)(curObj["VirtualQuantityUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsWeightNull { - get { - if ((curObj["Weight"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Weight { - get { - if ((curObj["Weight"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Weight"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAutomaticAllocation() { - if ((this.IsAutomaticAllocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticDeallocation() { - if ((this.IsAutomaticDeallocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConsumerVisibility() { - if ((this.IsConsumerVisibilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimit() { - if ((this.IsLimitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimitCPUID() { - if ((this.IsLimitCPUIDNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimitProcessorFeatures() { - if ((this.IsLimitProcessorFeaturesNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMappingBehavior() { - if ((this.IsMappingBehaviorNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxNumaNodesPerSocket() { - if ((this.IsMaxNumaNodesPerSocketNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxProcessorsPerNumaNode() { - if ((this.IsMaxProcessorsPerNumaNodeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReservation() { - if ((this.IsReservationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResourceType() { - if ((this.IsResourceTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualQuantity() { - if ((this.IsVirtualQuantityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeWeight() { - if ((this.IsWeightNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_ProcessorSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static ProcessorSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static ProcessorSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static ProcessorSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static ProcessorSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_ProcessorSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new ProcessorSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ProcessorSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new ProcessorSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static ProcessorSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new ProcessorSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class ProcessorSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public ProcessorSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new ProcessorSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new ProcessorSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class ProcessorSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public ProcessorSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new ProcessorSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public ProcessorSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Address { + get { + return ((string)(curObj["Address"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AddressOnParent { + get { + return ((string)(curObj["AddressOnParent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AllocationUnits { + get { + return ((string)(curObj["AllocationUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticAllocationNull { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticAllocation { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticAllocation"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticDeallocationNull { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticDeallocation { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticDeallocation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Connection { + get { + return ((string[])(curObj["Connection"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConsumerVisibilityNull { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ConsumerVisibility { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ConsumerVisibility"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] HostResource { + get { + return ((string[])(curObj["HostResource"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitNull { + get { + if ((curObj["Limit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Limit { + get { + if ((curObj["Limit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Limit"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitCPUIDNull { + get { + if ((curObj["LimitCPUID"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates whether the virtual machine should lower the CPU identifier. Some older" + + " operating systems may require you to limit processor functionality in this way " + + "in order to run.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool LimitCPUID { + get { + if ((curObj["LimitCPUID"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["LimitCPUID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitProcessorFeaturesNull { + get { + if ((curObj["LimitProcessorFeatures"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"Indicates whether the VM should limit the CPU features exposed to the operating system. Limiting the processor features enables the VM to be migrated to different host computer systems with different processors. Migrating VMs between computers with processors from different vendors is not supported.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool LimitProcessorFeatures { + get { + if ((curObj["LimitProcessorFeatures"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["LimitProcessorFeatures"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMappingBehaviorNull { + get { + if ((curObj["MappingBehavior"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort MappingBehavior { + get { + if ((curObj["MappingBehavior"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["MappingBehavior"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxNumaNodesPerSocketNull { + get { + if ((curObj["MaxNumaNodesPerSocket"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum number of NUMA nodes that can be observed within the VM as belonging " + + "to a single processor socket.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxNumaNodesPerSocket { + get { + if ((curObj["MaxNumaNodesPerSocket"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxNumaNodesPerSocket"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxProcessorsPerNumaNodeNull { + get { + if ((curObj["MaxProcessorsPerNumaNode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum number of virtual processors that can be observed within the VM as be" + + "longing to a single virtual NUMA node.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxProcessorsPerNumaNode { + get { + if ((curObj["MaxProcessorsPerNumaNode"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxProcessorsPerNumaNode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherResourceType { + get { + return ((string)(curObj["OtherResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PoolID { + get { + return ((string)(curObj["PoolID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReservationNull { + get { + if ((curObj["Reservation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Reservation { + get { + if ((curObj["Reservation"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Reservation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ResourceSubType { + get { + return ((string)(curObj["ResourceSubType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResourceTypeNull { + get { + if ((curObj["ResourceType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResourceType { + get { + if ((curObj["ResourceType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResourceType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualQuantityNull { + get { + if ((curObj["VirtualQuantity"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualQuantity { + get { + if ((curObj["VirtualQuantity"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualQuantity"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualQuantityUnits { + get { + return ((string)(curObj["VirtualQuantityUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsWeightNull { + get { + if ((curObj["Weight"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Weight { + get { + if ((curObj["Weight"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Weight"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAutomaticAllocation() { + if ((this.IsAutomaticAllocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticDeallocation() { + if ((this.IsAutomaticDeallocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConsumerVisibility() { + if ((this.IsConsumerVisibilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimit() { + if ((this.IsLimitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimitCPUID() { + if ((this.IsLimitCPUIDNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimitProcessorFeatures() { + if ((this.IsLimitProcessorFeaturesNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMappingBehavior() { + if ((this.IsMappingBehaviorNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxNumaNodesPerSocket() { + if ((this.IsMaxNumaNodesPerSocketNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxProcessorsPerNumaNode() { + if ((this.IsMaxProcessorsPerNumaNodeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReservation() { + if ((this.IsReservationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResourceType() { + if ((this.IsResourceTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualQuantity() { + if ((this.IsVirtualQuantityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeWeight() { + if ((this.IsWeightNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_ProcessorSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static ProcessorSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static ProcessorSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static ProcessorSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static ProcessorSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_ProcessorSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new ProcessorSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ProcessorSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new ProcessorSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static ProcessorSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new ProcessorSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class ProcessorSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public ProcessorSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new ProcessorSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new ProcessorSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class ProcessorSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public ProcessorSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new ProcessorSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 de4ce9320fb..18483c71893 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 @@ -1,1010 +1,1010 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 -{ - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public ResourceAllocationSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Address { - get { - return ((string)(curObj["Address"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AddressOnParent { - get { - return ((string)(curObj["AddressOnParent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AllocationUnits { - get { - return ((string)(curObj["AllocationUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticAllocationNull { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticAllocation { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticAllocation"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticDeallocationNull { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticDeallocation { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticDeallocation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Connection { - get { - return ((string[])(curObj["Connection"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConsumerVisibilityNull { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ConsumerVisibility { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ConsumerVisibility"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] HostResource { - get { - return ((string[])(curObj["HostResource"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitNull { - get { - if ((curObj["Limit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Limit { - get { - if ((curObj["Limit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Limit"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMappingBehaviorNull { - get { - if ((curObj["MappingBehavior"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort MappingBehavior { - get { - if ((curObj["MappingBehavior"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["MappingBehavior"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherResourceType { - get { - return ((string)(curObj["OtherResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PoolID { - get { - return ((string)(curObj["PoolID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReservationNull { - get { - if ((curObj["Reservation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Reservation { - get { - if ((curObj["Reservation"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Reservation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ResourceSubType { - get { - return ((string)(curObj["ResourceSubType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResourceTypeNull { - get { - if ((curObj["ResourceType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResourceType { - get { - if ((curObj["ResourceType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResourceType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualQuantityNull { - get { - if ((curObj["VirtualQuantity"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualQuantity { - get { - if ((curObj["VirtualQuantity"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualQuantity"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualQuantityUnits { - get { - return ((string)(curObj["VirtualQuantityUnits"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. These values are only used if the ResourceType property is set to 6 (Parallel SCSI HBA) and the ResourceSubType property is set to ""Microsoft Synthetic SCSI Controller"". This property is set to ""GUID"". -This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class. -Windows Server 2008: The VirtualSystemIdentifiers property is not supported until Windows Server 2008 R2.")] - public string[] VirtualSystemIdentifiers { - get { - return ((string[])(curObj["VirtualSystemIdentifiers"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsWeightNull { - get { - if ((curObj["Weight"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Weight { - get { - if ((curObj["Weight"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Weight"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAutomaticAllocation() { - if ((this.IsAutomaticAllocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticDeallocation() { - if ((this.IsAutomaticDeallocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConsumerVisibility() { - if ((this.IsConsumerVisibilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimit() { - if ((this.IsLimitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMappingBehavior() { - if ((this.IsMappingBehaviorNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReservation() { - if ((this.IsReservationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResourceType() { - if ((this.IsResourceTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualQuantity() { - if ((this.IsVirtualQuantityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeWeight() { - if ((this.IsWeightNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_ResourceAllocationSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static ResourceAllocationSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static ResourceAllocationSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static ResourceAllocationSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static ResourceAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_ResourceAllocationSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new ResourceAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ResourceAllocationSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new ResourceAllocationSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static ResourceAllocationSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new ResourceAllocationSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class ResourceAllocationSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public ResourceAllocationSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new ResourceAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new ResourceAllocationSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class ResourceAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public ResourceAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new ResourceAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 +{ + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public ResourceAllocationSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Address { + get { + return ((string)(curObj["Address"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AddressOnParent { + get { + return ((string)(curObj["AddressOnParent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AllocationUnits { + get { + return ((string)(curObj["AllocationUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticAllocationNull { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticAllocation { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticAllocation"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticDeallocationNull { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticDeallocation { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticDeallocation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Connection { + get { + return ((string[])(curObj["Connection"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConsumerVisibilityNull { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ConsumerVisibility { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ConsumerVisibility"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] HostResource { + get { + return ((string[])(curObj["HostResource"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitNull { + get { + if ((curObj["Limit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Limit { + get { + if ((curObj["Limit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Limit"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMappingBehaviorNull { + get { + if ((curObj["MappingBehavior"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort MappingBehavior { + get { + if ((curObj["MappingBehavior"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["MappingBehavior"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherResourceType { + get { + return ((string)(curObj["OtherResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PoolID { + get { + return ((string)(curObj["PoolID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReservationNull { + get { + if ((curObj["Reservation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Reservation { + get { + if ((curObj["Reservation"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Reservation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ResourceSubType { + get { + return ((string)(curObj["ResourceSubType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResourceTypeNull { + get { + if ((curObj["ResourceType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResourceType { + get { + if ((curObj["ResourceType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResourceType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualQuantityNull { + get { + if ((curObj["VirtualQuantity"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualQuantity { + get { + if ((curObj["VirtualQuantity"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualQuantity"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualQuantityUnits { + get { + return ((string)(curObj["VirtualQuantityUnits"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. These values are only used if the ResourceType property is set to 6 (Parallel SCSI HBA) and the ResourceSubType property is set to ""Microsoft Synthetic SCSI Controller"". This property is set to ""GUID"". +This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class. +Windows Server 2008: The VirtualSystemIdentifiers property is not supported until Windows Server 2008 R2.")] + public string[] VirtualSystemIdentifiers { + get { + return ((string[])(curObj["VirtualSystemIdentifiers"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsWeightNull { + get { + if ((curObj["Weight"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Weight { + get { + if ((curObj["Weight"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Weight"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAutomaticAllocation() { + if ((this.IsAutomaticAllocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticDeallocation() { + if ((this.IsAutomaticDeallocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConsumerVisibility() { + if ((this.IsConsumerVisibilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimit() { + if ((this.IsLimitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMappingBehavior() { + if ((this.IsMappingBehaviorNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReservation() { + if ((this.IsReservationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResourceType() { + if ((this.IsResourceTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualQuantity() { + if ((this.IsVirtualQuantityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeWeight() { + if ((this.IsWeightNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_ResourceAllocationSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static ResourceAllocationSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static ResourceAllocationSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static ResourceAllocationSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static ResourceAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_ResourceAllocationSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new ResourceAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ResourceAllocationSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new ResourceAllocationSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static ResourceAllocationSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new ResourceAllocationSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class ResourceAllocationSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public ResourceAllocationSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new ResourceAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new ResourceAllocationSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class ResourceAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public ResourceAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new ResourceAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 45f6b06ae4a..b24d2cfcc26 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 @@ -1,1214 +1,1214 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public StorageAllocationSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAccessNull { - get { - if ((curObj["Access"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort Access { - get { - if ((curObj["Access"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["Access"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Address { - get { - return ((string)(curObj["Address"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AddressOnParent { - get { - return ((string)(curObj["AddressOnParent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AllocationUnits { - get { - return ((string)(curObj["AllocationUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticAllocationNull { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticAllocation { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticAllocation"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticDeallocationNull { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticDeallocation { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticDeallocation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Connection { - get { - return ((string[])(curObj["Connection"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConsumerVisibilityNull { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ConsumerVisibility { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ConsumerVisibility"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string HostExtentName { - get { - return ((string)(curObj["HostExtentName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHostExtentNameFormatNull { - get { - if ((curObj["HostExtentNameFormat"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HostExtentNameFormat { - get { - if ((curObj["HostExtentNameFormat"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HostExtentNameFormat"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHostExtentNameNamespaceNull { - get { - if ((curObj["HostExtentNameNamespace"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HostExtentNameNamespace { - get { - if ((curObj["HostExtentNameNamespace"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HostExtentNameNamespace"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHostExtentStartingAddressNull { - get { - if ((curObj["HostExtentStartingAddress"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong HostExtentStartingAddress { - get { - if ((curObj["HostExtentStartingAddress"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["HostExtentStartingAddress"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] HostResource { - get { - return ((string[])(curObj["HostResource"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHostResourceBlockSizeNull { - get { - if ((curObj["HostResourceBlockSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong HostResourceBlockSize { - get { - if ((curObj["HostResourceBlockSize"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["HostResourceBlockSize"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitNull { - get { - if ((curObj["Limit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Limit { - get { - if ((curObj["Limit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Limit"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMappingBehaviorNull { - get { - if ((curObj["MappingBehavior"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort MappingBehavior { - get { - if ((curObj["MappingBehavior"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["MappingBehavior"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherHostExtentNameFormat { - get { - return ((string)(curObj["OtherHostExtentNameFormat"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherHostExtentNameNamespace { - get { - return ((string)(curObj["OtherHostExtentNameNamespace"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherResourceType { - get { - return ((string)(curObj["OtherResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PoolID { - get { - return ((string)(curObj["PoolID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReservationNull { - get { - if ((curObj["Reservation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Reservation { - get { - if ((curObj["Reservation"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Reservation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ResourceSubType { - get { - return ((string)(curObj["ResourceSubType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResourceTypeNull { - get { - if ((curObj["ResourceType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResourceType { - get { - if ((curObj["ResourceType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResourceType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualQuantityNull { - get { - if ((curObj["VirtualQuantity"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualQuantity { - get { - if ((curObj["VirtualQuantity"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualQuantity"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualQuantityUnits { - get { - return ((string)(curObj["VirtualQuantityUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualResourceBlockSizeNull { - get { - if ((curObj["VirtualResourceBlockSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualResourceBlockSize { - get { - if ((curObj["VirtualResourceBlockSize"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualResourceBlockSize"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsWeightNull { - get { - if ((curObj["Weight"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Weight { - get { - if ((curObj["Weight"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Weight"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAccess() { - if ((this.IsAccessNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticAllocation() { - if ((this.IsAutomaticAllocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticDeallocation() { - if ((this.IsAutomaticDeallocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConsumerVisibility() { - if ((this.IsConsumerVisibilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHostExtentNameFormat() { - if ((this.IsHostExtentNameFormatNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHostExtentNameNamespace() { - if ((this.IsHostExtentNameNamespaceNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHostExtentStartingAddress() { - if ((this.IsHostExtentStartingAddressNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHostResourceBlockSize() { - if ((this.IsHostResourceBlockSizeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimit() { - if ((this.IsLimitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMappingBehavior() { - if ((this.IsMappingBehaviorNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReservation() { - if ((this.IsReservationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResourceType() { - if ((this.IsResourceTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualQuantity() { - if ((this.IsVirtualQuantityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualResourceBlockSize() { - if ((this.IsVirtualResourceBlockSizeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeWeight() { - if ((this.IsWeightNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_StorageAllocationSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static StorageAllocationSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static StorageAllocationSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static StorageAllocationSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static StorageAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_StorageAllocationSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new StorageAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_StorageAllocationSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new StorageAllocationSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static StorageAllocationSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new StorageAllocationSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class StorageAllocationSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public StorageAllocationSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new StorageAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new StorageAllocationSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class StorageAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public StorageAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new StorageAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public StorageAllocationSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAccessNull { + get { + if ((curObj["Access"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort Access { + get { + if ((curObj["Access"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["Access"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Address { + get { + return ((string)(curObj["Address"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AddressOnParent { + get { + return ((string)(curObj["AddressOnParent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AllocationUnits { + get { + return ((string)(curObj["AllocationUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticAllocationNull { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticAllocation { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticAllocation"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticDeallocationNull { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticDeallocation { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticDeallocation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Connection { + get { + return ((string[])(curObj["Connection"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConsumerVisibilityNull { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ConsumerVisibility { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ConsumerVisibility"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string HostExtentName { + get { + return ((string)(curObj["HostExtentName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHostExtentNameFormatNull { + get { + if ((curObj["HostExtentNameFormat"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HostExtentNameFormat { + get { + if ((curObj["HostExtentNameFormat"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HostExtentNameFormat"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHostExtentNameNamespaceNull { + get { + if ((curObj["HostExtentNameNamespace"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HostExtentNameNamespace { + get { + if ((curObj["HostExtentNameNamespace"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HostExtentNameNamespace"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHostExtentStartingAddressNull { + get { + if ((curObj["HostExtentStartingAddress"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong HostExtentStartingAddress { + get { + if ((curObj["HostExtentStartingAddress"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["HostExtentStartingAddress"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] HostResource { + get { + return ((string[])(curObj["HostResource"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHostResourceBlockSizeNull { + get { + if ((curObj["HostResourceBlockSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong HostResourceBlockSize { + get { + if ((curObj["HostResourceBlockSize"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["HostResourceBlockSize"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitNull { + get { + if ((curObj["Limit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Limit { + get { + if ((curObj["Limit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Limit"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMappingBehaviorNull { + get { + if ((curObj["MappingBehavior"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort MappingBehavior { + get { + if ((curObj["MappingBehavior"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["MappingBehavior"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherHostExtentNameFormat { + get { + return ((string)(curObj["OtherHostExtentNameFormat"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherHostExtentNameNamespace { + get { + return ((string)(curObj["OtherHostExtentNameNamespace"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherResourceType { + get { + return ((string)(curObj["OtherResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PoolID { + get { + return ((string)(curObj["PoolID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReservationNull { + get { + if ((curObj["Reservation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Reservation { + get { + if ((curObj["Reservation"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Reservation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ResourceSubType { + get { + return ((string)(curObj["ResourceSubType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResourceTypeNull { + get { + if ((curObj["ResourceType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResourceType { + get { + if ((curObj["ResourceType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResourceType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualQuantityNull { + get { + if ((curObj["VirtualQuantity"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualQuantity { + get { + if ((curObj["VirtualQuantity"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualQuantity"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualQuantityUnits { + get { + return ((string)(curObj["VirtualQuantityUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualResourceBlockSizeNull { + get { + if ((curObj["VirtualResourceBlockSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualResourceBlockSize { + get { + if ((curObj["VirtualResourceBlockSize"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualResourceBlockSize"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsWeightNull { + get { + if ((curObj["Weight"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Weight { + get { + if ((curObj["Weight"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Weight"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAccess() { + if ((this.IsAccessNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticAllocation() { + if ((this.IsAutomaticAllocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticDeallocation() { + if ((this.IsAutomaticDeallocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConsumerVisibility() { + if ((this.IsConsumerVisibilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHostExtentNameFormat() { + if ((this.IsHostExtentNameFormatNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHostExtentNameNamespace() { + if ((this.IsHostExtentNameNamespaceNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHostExtentStartingAddress() { + if ((this.IsHostExtentStartingAddressNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHostResourceBlockSize() { + if ((this.IsHostResourceBlockSizeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimit() { + if ((this.IsLimitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMappingBehavior() { + if ((this.IsMappingBehaviorNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReservation() { + if ((this.IsReservationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResourceType() { + if ((this.IsResourceTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualQuantity() { + if ((this.IsVirtualQuantityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualResourceBlockSize() { + if ((this.IsVirtualResourceBlockSizeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeWeight() { + if ((this.IsWeightNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_StorageAllocationSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static StorageAllocationSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static StorageAllocationSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static StorageAllocationSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static StorageAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_StorageAllocationSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new StorageAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_StorageAllocationSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new StorageAllocationSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static StorageAllocationSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new StorageAllocationSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class StorageAllocationSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public StorageAllocationSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new StorageAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new StorageAllocationSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class StorageAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public StorageAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new StorageAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 604005be2ff..343f4122eb0 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 @@ -1,1537 +1,1537 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public SummaryInformation(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The identifier of the physical graphics processing unit (GPU) allocated to this v" + - "irtual machine (VM). This property only applies to VMs that use RemoteFX.")] - public string AllocatedGPU { - get { - return ((string)(curObj["AllocatedGPU"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsApplicationHealthNull { - get { - if ((curObj["ApplicationHealth"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"The current application health status for the virtual system. This property may be one of the following values: ""OK""; ""Application Critical""; ""Disabled"".For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ApplicationHealthValues ApplicationHealth { - get { - if ((curObj["ApplicationHealth"] == null)) { - return ((ApplicationHealthValues)(System.Convert.ToInt32(0))); - } - return ((ApplicationHealthValues)(System.Convert.ToInt32(curObj["ApplicationHealth"]))); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("An array of Msvm_ConcreteJob instances representing any asynchronous operations r" + - "elated to the virtual system which are currently executing. This property is not" + - " valid for instances of Msvm_SummaryInformation representing a virtual system sn" + - "apshot.")] - public System.Management.ManagementBaseObject[] AsynchronousTasks { - get { - return ((System.Management.ManagementBaseObject[])(curObj["AsynchronousTasks"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAvailableMemoryBufferNull { - get { - if ((curObj["AvailableMemoryBuffer"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The available memory buffer percentage in the virtual system.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public int AvailableMemoryBuffer { - get { - if ((curObj["AvailableMemoryBuffer"] == null)) { - return System.Convert.ToInt32(0); - } - return ((int)(curObj["AvailableMemoryBuffer"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCreationTimeNull { - get { - if ((curObj["CreationTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The time at which the virtual system or snapshot was created.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime CreationTime { - get { - if ((curObj["CreationTime"] != null)) { - return ToDateTime(((string)(curObj["CreationTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The friendly name for the virtual system or snapshot.")] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The current state of the virtual system or snapshot.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The name of the guest operating system, if available. If this information is not " + - "available, the value of this property is NULL. This property is not valid for in" + - "stances of Msvm_SummaryInformation representing a virtual system snapshot.")] - public string GuestOperatingSystem { - get { - return ((string)(curObj["GuestOperatingSystem"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The current health state for the virtual system. This property is not valid for i" + - "nstances of Msvm_SummaryInformation representing a virtual system snapshot.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHeartbeatNull { - get { - if ((curObj["Heartbeat"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"The current heartbeat status for the virtual system. This property may be one of the following values: ""OK""; ""Error""; ""No Contact""; or ""Lost Communication"". For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort Heartbeat { - get { - if ((curObj["Heartbeat"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["Heartbeat"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsIntegrationServicesVersionStateNull { - get { - if ((curObj["IntegrationServicesVersionState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Whether or not the integration services installed in the virtual machine are up t" + - "o date")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public IntegrationServicesVersionStateValues IntegrationServicesVersionState { - get { - if ((curObj["IntegrationServicesVersionState"] == null)) { - return ((IntegrationServicesVersionStateValues)(System.Convert.ToInt32(3))); - } - return ((IntegrationServicesVersionStateValues)(System.Convert.ToInt32(curObj["IntegrationServicesVersionState"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMemoryAvailableNull { - get { - if ((curObj["MemoryAvailable"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The memory available percentage in the virtual system.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public int MemoryAvailable { - get { - if ((curObj["MemoryAvailable"] == null)) { - return System.Convert.ToInt32(0); - } - return ((int)(curObj["MemoryAvailable"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMemorySpansPhysicalNumaNodesNull { - get { - if ((curObj["MemorySpansPhysicalNumaNodes"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates whether or not the memory of the one or more of the virtual non-uniform" + - " memory access (NUMA) nodes of the virtual machine spans multiple physical NUMA " + - "nodes of the hosting computer system.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool MemorySpansPhysicalNumaNodes { - get { - if ((curObj["MemorySpansPhysicalNumaNodes"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["MemorySpansPhysicalNumaNodes"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMemoryUsageNull { - get { - if ((curObj["MemoryUsage"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The current memory usage of the virtual system. This property is not valid for in" + - "stances of Msvm_SummaryInformation representing a virtual system snapshot.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MemoryUsage { - get { - if ((curObj["MemoryUsage"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MemoryUsage"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The unique name for the virtual system or snapshot.")] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The notes associated with the virtual system or snapshot.")] - public string Notes { - get { - return ((string)(curObj["Notes"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsNumberOfProcessorsNull { - get { - if ((curObj["NumberOfProcessors"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The total number of virtual processors allocated to the virtual system or snapsho" + - "t.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort NumberOfProcessors { - get { - if ((curObj["NumberOfProcessors"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["NumberOfProcessors"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The current status of the element.")] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("A string that describes the enabled or disabled state of the element when the Ena" + - "bledState property is set to 1 (\"Other\"). This property must be set to null when" + - " EnabledState is any value other than 1.")] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsProcessorLoadNull { - get { - if ((curObj["ProcessorLoad"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The current processor usage of the virtual system. This property is not valid for" + - " instances of Msvm_SummaryInformation representing a virtual system snapshot.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ProcessorLoad { - get { - if ((curObj["ProcessorLoad"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ProcessorLoad"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("An array of the previous 100 samples of the processor usage for the virtual syste" + - "m. This property is not valid for instances of Msvm_SummaryInformation represent" + - "ing a virtual system snapshot.")] - public ushort[] ProcessorLoadHistory { - get { - return ((ushort[])(curObj["ProcessorLoadHistory"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReplicationHealthNull { - get { - if ((curObj["ReplicationHealth"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Replication health for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ReplicationHealthValues ReplicationHealth { - get { - if ((curObj["ReplicationHealth"] == null)) { - return ((ReplicationHealthValues)(System.Convert.ToInt32(4))); - } - return ((ReplicationHealthValues)(System.Convert.ToInt32(curObj["ReplicationHealth"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReplicationModeNull { - get { - if ((curObj["ReplicationMode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Identifies replication type for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ReplicationModeValues ReplicationMode { - get { - if ((curObj["ReplicationMode"] == null)) { - return ((ReplicationModeValues)(System.Convert.ToInt32(4))); - } - return ((ReplicationModeValues)(System.Convert.ToInt32(curObj["ReplicationMode"]))); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReplicationStateNull { - get { - if ((curObj["ReplicationState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Replication state for the virtual machine.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ReplicationStateValues ReplicationState { - get { - if ((curObj["ReplicationState"] == null)) { - return ((ReplicationStateValues)(System.Convert.ToInt32(12))); - } - return ((ReplicationStateValues)(System.Convert.ToInt32(curObj["ReplicationState"]))); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("An array of Msvm_VirtualSystemSettingData instances representing the snapshots fo" + - "r the virtual system. This property is not valid for instances of Msvm_SummaryIn" + - "formation representing a virtual system snapshot.")] - public System.Management.ManagementBaseObject[] Snapshots { - get { - return ((System.Management.ManagementBaseObject[])(curObj["Snapshots"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Strings that describe the various OperationalStatus array values.")] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsSwapFilesInUseNull { - get { - if ((curObj["SwapFilesInUse"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indecates if smart paging is active.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool SwapFilesInUse { - get { - if ((curObj["SwapFilesInUse"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["SwapFilesInUse"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Reference to the CIM_ComputerSystem instance representing the test replica virtua" + - "l system for the virtual machine. This property is not valid for instances of Ms" + - "vm_SummaryInformation representing a virtual system snapshot.")] - public System.Management.ManagementPath TestReplicaSystem { - get { - if ((curObj["TestReplicaSystem"] != null)) { - return new System.Management.ManagementPath(curObj["TestReplicaSystem"].ToString()); - } - return null; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("An array containing a small, thumbnail-sized image of the desktop for the virtual" + - " system or snapshot in RGB565 format.")] - public byte[] ThumbnailImage { - get { - return ((byte[])(curObj["ThumbnailImage"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsUpTimeNull { - get { - if ((curObj["UpTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The amount of time since the virtual system was last booted. This property is not" + - " valid for instances of Msvm_SummaryInformation representing a virtual system sn" + - "apshot.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong UpTime { - get { - if ((curObj["UpTime"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["UpTime"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeApplicationHealth() { - if ((this.IsApplicationHealthNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAvailableMemoryBuffer() { - if ((this.IsAvailableMemoryBufferNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeCreationTime() { - if ((this.IsCreationTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHeartbeat() { - if ((this.IsHeartbeatNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeIntegrationServicesVersionState() { - if ((this.IsIntegrationServicesVersionStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMemoryAvailable() { - if ((this.IsMemoryAvailableNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMemorySpansPhysicalNumaNodes() { - if ((this.IsMemorySpansPhysicalNumaNodesNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMemoryUsage() { - if ((this.IsMemoryUsageNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeNumberOfProcessors() { - if ((this.IsNumberOfProcessorsNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeProcessorLoad() { - if ((this.IsProcessorLoadNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReplicationHealth() { - if ((this.IsReplicationHealthNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReplicationMode() { - if ((this.IsReplicationModeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReplicationState() { - if ((this.IsReplicationStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeSwapFilesInUse() { - if ((this.IsSwapFilesInUseNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeUpTime() { - if ((this.IsUpTimeNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath() { - string strPath = "ROOT\\virtualization\\v2:Msvm_SummaryInformation"; - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static SummaryInformationCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static SummaryInformationCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static SummaryInformationCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static SummaryInformationCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_SummaryInformation"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new SummaryInformationCollection(clsObject.GetInstances(enumOptions)); - } - - public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SummaryInformation", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new SummaryInformationCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static SummaryInformation CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new SummaryInformation(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public enum ApplicationHealthValues { - - OK = 2, - - Application_Critical = 32782, - - Disabled = 32896, - - NULL_ENUM_VALUE = 0, - } - - public enum IntegrationServicesVersionStateValues { - - Unknown0 = 0, - - UpToDate = 1, - - Mismatch = 2, - - NULL_ENUM_VALUE = 3, - } - - public enum ReplicationHealthValues { - - Not_applicable = 0, - - Ok = 1, - - Warning = 2, - - Critical = 3, - - NULL_ENUM_VALUE = 4, - } - - public enum ReplicationModeValues { - - None = 0, - - Primary = 1, - - Recovery = 2, - - Test_Replica = 3, - - NULL_ENUM_VALUE = 4, - } - - public enum ReplicationStateValues { - - Disabled = 0, - - Ready_for_replication = 1, - - Waiting_to_complete_initial_replication = 2, - - Replicating = 3, - - Synced_replication_complete = 4, - - Recovered = 5, - - Committed = 6, - - Suspended = 7, - - Critical = 8, - - Waiting_to_start_resynchronization = 9, - - Resynchronizing = 10, - - Resynchronization_suspended = 11, - - NULL_ENUM_VALUE = 12, - } - - // Enumerator implementation for enumerating instances of the class. - public class SummaryInformationCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public SummaryInformationCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new SummaryInformation(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new SummaryInformationEnumerator(privColObj.GetEnumerator()); - } - - public class SummaryInformationEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public SummaryInformationEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new SummaryInformation(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public SummaryInformation(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The identifier of the physical graphics processing unit (GPU) allocated to this v" + + "irtual machine (VM). This property only applies to VMs that use RemoteFX.")] + public string AllocatedGPU { + get { + return ((string)(curObj["AllocatedGPU"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsApplicationHealthNull { + get { + if ((curObj["ApplicationHealth"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"The current application health status for the virtual system. This property may be one of the following values: ""OK""; ""Application Critical""; ""Disabled"".For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ApplicationHealthValues ApplicationHealth { + get { + if ((curObj["ApplicationHealth"] == null)) { + return ((ApplicationHealthValues)(System.Convert.ToInt32(0))); + } + return ((ApplicationHealthValues)(System.Convert.ToInt32(curObj["ApplicationHealth"]))); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("An array of Msvm_ConcreteJob instances representing any asynchronous operations r" + + "elated to the virtual system which are currently executing. This property is not" + + " valid for instances of Msvm_SummaryInformation representing a virtual system sn" + + "apshot.")] + public System.Management.ManagementBaseObject[] AsynchronousTasks { + get { + return ((System.Management.ManagementBaseObject[])(curObj["AsynchronousTasks"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAvailableMemoryBufferNull { + get { + if ((curObj["AvailableMemoryBuffer"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The available memory buffer percentage in the virtual system.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public int AvailableMemoryBuffer { + get { + if ((curObj["AvailableMemoryBuffer"] == null)) { + return System.Convert.ToInt32(0); + } + return ((int)(curObj["AvailableMemoryBuffer"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCreationTimeNull { + get { + if ((curObj["CreationTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The time at which the virtual system or snapshot was created.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime CreationTime { + get { + if ((curObj["CreationTime"] != null)) { + return ToDateTime(((string)(curObj["CreationTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The friendly name for the virtual system or snapshot.")] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The current state of the virtual system or snapshot.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The name of the guest operating system, if available. If this information is not " + + "available, the value of this property is NULL. This property is not valid for in" + + "stances of Msvm_SummaryInformation representing a virtual system snapshot.")] + public string GuestOperatingSystem { + get { + return ((string)(curObj["GuestOperatingSystem"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The current health state for the virtual system. This property is not valid for i" + + "nstances of Msvm_SummaryInformation representing a virtual system snapshot.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHeartbeatNull { + get { + if ((curObj["Heartbeat"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"The current heartbeat status for the virtual system. This property may be one of the following values: ""OK""; ""Error""; ""No Contact""; or ""Lost Communication"". For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort Heartbeat { + get { + if ((curObj["Heartbeat"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["Heartbeat"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsIntegrationServicesVersionStateNull { + get { + if ((curObj["IntegrationServicesVersionState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Whether or not the integration services installed in the virtual machine are up t" + + "o date")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public IntegrationServicesVersionStateValues IntegrationServicesVersionState { + get { + if ((curObj["IntegrationServicesVersionState"] == null)) { + return ((IntegrationServicesVersionStateValues)(System.Convert.ToInt32(3))); + } + return ((IntegrationServicesVersionStateValues)(System.Convert.ToInt32(curObj["IntegrationServicesVersionState"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMemoryAvailableNull { + get { + if ((curObj["MemoryAvailable"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The memory available percentage in the virtual system.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public int MemoryAvailable { + get { + if ((curObj["MemoryAvailable"] == null)) { + return System.Convert.ToInt32(0); + } + return ((int)(curObj["MemoryAvailable"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMemorySpansPhysicalNumaNodesNull { + get { + if ((curObj["MemorySpansPhysicalNumaNodes"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates whether or not the memory of the one or more of the virtual non-uniform" + + " memory access (NUMA) nodes of the virtual machine spans multiple physical NUMA " + + "nodes of the hosting computer system.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool MemorySpansPhysicalNumaNodes { + get { + if ((curObj["MemorySpansPhysicalNumaNodes"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["MemorySpansPhysicalNumaNodes"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMemoryUsageNull { + get { + if ((curObj["MemoryUsage"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The current memory usage of the virtual system. This property is not valid for in" + + "stances of Msvm_SummaryInformation representing a virtual system snapshot.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MemoryUsage { + get { + if ((curObj["MemoryUsage"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MemoryUsage"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The unique name for the virtual system or snapshot.")] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The notes associated with the virtual system or snapshot.")] + public string Notes { + get { + return ((string)(curObj["Notes"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsNumberOfProcessorsNull { + get { + if ((curObj["NumberOfProcessors"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The total number of virtual processors allocated to the virtual system or snapsho" + + "t.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort NumberOfProcessors { + get { + if ((curObj["NumberOfProcessors"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["NumberOfProcessors"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The current status of the element.")] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("A string that describes the enabled or disabled state of the element when the Ena" + + "bledState property is set to 1 (\"Other\"). This property must be set to null when" + + " EnabledState is any value other than 1.")] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsProcessorLoadNull { + get { + if ((curObj["ProcessorLoad"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The current processor usage of the virtual system. This property is not valid for" + + " instances of Msvm_SummaryInformation representing a virtual system snapshot.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ProcessorLoad { + get { + if ((curObj["ProcessorLoad"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ProcessorLoad"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("An array of the previous 100 samples of the processor usage for the virtual syste" + + "m. This property is not valid for instances of Msvm_SummaryInformation represent" + + "ing a virtual system snapshot.")] + public ushort[] ProcessorLoadHistory { + get { + return ((ushort[])(curObj["ProcessorLoadHistory"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReplicationHealthNull { + get { + if ((curObj["ReplicationHealth"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Replication health for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ReplicationHealthValues ReplicationHealth { + get { + if ((curObj["ReplicationHealth"] == null)) { + return ((ReplicationHealthValues)(System.Convert.ToInt32(4))); + } + return ((ReplicationHealthValues)(System.Convert.ToInt32(curObj["ReplicationHealth"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReplicationModeNull { + get { + if ((curObj["ReplicationMode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Identifies replication type for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ReplicationModeValues ReplicationMode { + get { + if ((curObj["ReplicationMode"] == null)) { + return ((ReplicationModeValues)(System.Convert.ToInt32(4))); + } + return ((ReplicationModeValues)(System.Convert.ToInt32(curObj["ReplicationMode"]))); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReplicationStateNull { + get { + if ((curObj["ReplicationState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Replication state for the virtual machine.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ReplicationStateValues ReplicationState { + get { + if ((curObj["ReplicationState"] == null)) { + return ((ReplicationStateValues)(System.Convert.ToInt32(12))); + } + return ((ReplicationStateValues)(System.Convert.ToInt32(curObj["ReplicationState"]))); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("An array of Msvm_VirtualSystemSettingData instances representing the snapshots fo" + + "r the virtual system. This property is not valid for instances of Msvm_SummaryIn" + + "formation representing a virtual system snapshot.")] + public System.Management.ManagementBaseObject[] Snapshots { + get { + return ((System.Management.ManagementBaseObject[])(curObj["Snapshots"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Strings that describe the various OperationalStatus array values.")] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsSwapFilesInUseNull { + get { + if ((curObj["SwapFilesInUse"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indecates if smart paging is active.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool SwapFilesInUse { + get { + if ((curObj["SwapFilesInUse"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["SwapFilesInUse"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Reference to the CIM_ComputerSystem instance representing the test replica virtua" + + "l system for the virtual machine. This property is not valid for instances of Ms" + + "vm_SummaryInformation representing a virtual system snapshot.")] + public System.Management.ManagementPath TestReplicaSystem { + get { + if ((curObj["TestReplicaSystem"] != null)) { + return new System.Management.ManagementPath(curObj["TestReplicaSystem"].ToString()); + } + return null; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("An array containing a small, thumbnail-sized image of the desktop for the virtual" + + " system or snapshot in RGB565 format.")] + public byte[] ThumbnailImage { + get { + return ((byte[])(curObj["ThumbnailImage"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsUpTimeNull { + get { + if ((curObj["UpTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The amount of time since the virtual system was last booted. This property is not" + + " valid for instances of Msvm_SummaryInformation representing a virtual system sn" + + "apshot.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong UpTime { + get { + if ((curObj["UpTime"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["UpTime"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeApplicationHealth() { + if ((this.IsApplicationHealthNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAvailableMemoryBuffer() { + if ((this.IsAvailableMemoryBufferNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeCreationTime() { + if ((this.IsCreationTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHeartbeat() { + if ((this.IsHeartbeatNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeIntegrationServicesVersionState() { + if ((this.IsIntegrationServicesVersionStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMemoryAvailable() { + if ((this.IsMemoryAvailableNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMemorySpansPhysicalNumaNodes() { + if ((this.IsMemorySpansPhysicalNumaNodesNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMemoryUsage() { + if ((this.IsMemoryUsageNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeNumberOfProcessors() { + if ((this.IsNumberOfProcessorsNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeProcessorLoad() { + if ((this.IsProcessorLoadNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReplicationHealth() { + if ((this.IsReplicationHealthNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReplicationMode() { + if ((this.IsReplicationModeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReplicationState() { + if ((this.IsReplicationStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeSwapFilesInUse() { + if ((this.IsSwapFilesInUseNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeUpTime() { + if ((this.IsUpTimeNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath() { + string strPath = "ROOT\\virtualization\\v2:Msvm_SummaryInformation"; + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static SummaryInformationCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static SummaryInformationCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static SummaryInformationCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static SummaryInformationCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_SummaryInformation"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new SummaryInformationCollection(clsObject.GetInstances(enumOptions)); + } + + public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SummaryInformation", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new SummaryInformationCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static SummaryInformation CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new SummaryInformation(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public enum ApplicationHealthValues { + + OK = 2, + + Application_Critical = 32782, + + Disabled = 32896, + + NULL_ENUM_VALUE = 0, + } + + public enum IntegrationServicesVersionStateValues { + + Unknown0 = 0, + + UpToDate = 1, + + Mismatch = 2, + + NULL_ENUM_VALUE = 3, + } + + public enum ReplicationHealthValues { + + Not_applicable = 0, + + Ok = 1, + + Warning = 2, + + Critical = 3, + + NULL_ENUM_VALUE = 4, + } + + public enum ReplicationModeValues { + + None = 0, + + Primary = 1, + + Recovery = 2, + + Test_Replica = 3, + + NULL_ENUM_VALUE = 4, + } + + public enum ReplicationStateValues { + + Disabled = 0, + + Ready_for_replication = 1, + + Waiting_to_complete_initial_replication = 2, + + Replicating = 3, + + Synced_replication_complete = 4, + + Recovered = 5, + + Committed = 6, + + Suspended = 7, + + Critical = 8, + + Waiting_to_start_resynchronization = 9, + + Resynchronizing = 10, + + Resynchronization_suspended = 11, + + NULL_ENUM_VALUE = 12, + } + + // Enumerator implementation for enumerating instances of the class. + public class SummaryInformationCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public SummaryInformationCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new SummaryInformation(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new SummaryInformationEnumerator(privColObj.GetEnumerator()); + } + + public class SummaryInformationEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public SummaryInformationEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new SummaryInformation(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 86be3a9d62a..8759568d6c3 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 @@ -15,1069 +15,1069 @@ // specific language governing permissions and limitations // under the License. -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public SyntheticEthernetPortSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Address { - get { - return ((string)(curObj["Address"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AddressOnParent { - get { - return ((string)(curObj["AddressOnParent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AllocationUnits { - get { - return ((string)(curObj["AllocationUnits"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticAllocationNull { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticAllocation { - get { - if ((curObj["AutomaticAllocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticAllocation"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticDeallocationNull { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AutomaticDeallocation { - get { - if ((curObj["AutomaticDeallocation"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AutomaticDeallocation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Connection { - get { - return ((string[])(curObj["Connection"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsConsumerVisibilityNull { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ConsumerVisibility { - get { - if ((curObj["ConsumerVisibility"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ConsumerVisibility"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDesiredVLANEndpointModeNull { - get { - if ((curObj["DesiredVLANEndpointMode"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DesiredVLANEndpointMode { - get { - if ((curObj["DesiredVLANEndpointMode"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DesiredVLANEndpointMode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] HostResource { - get { - return ((string[])(curObj["HostResource"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLimitNull { - get { - if ((curObj["Limit"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Limit { - get { - if ((curObj["Limit"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Limit"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMappingBehaviorNull { - get { - if ((curObj["MappingBehavior"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort MappingBehavior { - get { - if ((curObj["MappingBehavior"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["MappingBehavior"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEndpointMode { - get { - return ((string)(curObj["OtherEndpointMode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherResourceType { - get { - return ((string)(curObj["OtherResourceType"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PoolID { - get { - return ((string)(curObj["PoolID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsReservationNull { - get { - if ((curObj["Reservation"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong Reservation { - get { - if ((curObj["Reservation"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["Reservation"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ResourceSubType { - get { - return ((string)(curObj["ResourceSubType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResourceTypeNull { - get { - if ((curObj["ResourceType"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResourceType { - get { - if ((curObj["ResourceType"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResourceType"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStaticMacAddressNull { - get { - if ((curObj["StaticMacAddress"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates a static MAC address.\nThis is a read-only property, but it can be chang" + - "ed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManage" + - "mentService class.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool StaticMacAddress { - get { - if ((curObj["StaticMacAddress"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["StaticMacAddress"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualQuantityNull { - get { - if ((curObj["VirtualQuantity"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong VirtualQuantity { - get { - if ((curObj["VirtualQuantity"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["VirtualQuantity"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualQuantityUnits { - get { - return ((string)(curObj["VirtualQuantityUnits"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public SyntheticEthernetPortSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Address { + get { + return ((string)(curObj["Address"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AddressOnParent { + get { + return ((string)(curObj["AddressOnParent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string AllocationUnits { + get { + return ((string)(curObj["AllocationUnits"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticAllocationNull { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticAllocation { + get { + if ((curObj["AutomaticAllocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticAllocation"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticDeallocationNull { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AutomaticDeallocation { + get { + if ((curObj["AutomaticDeallocation"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AutomaticDeallocation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Connection { + get { + return ((string[])(curObj["Connection"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsConsumerVisibilityNull { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ConsumerVisibility { + get { + if ((curObj["ConsumerVisibility"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ConsumerVisibility"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDesiredVLANEndpointModeNull { + get { + if ((curObj["DesiredVLANEndpointMode"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DesiredVLANEndpointMode { + get { + if ((curObj["DesiredVLANEndpointMode"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DesiredVLANEndpointMode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] HostResource { + get { + return ((string[])(curObj["HostResource"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLimitNull { + get { + if ((curObj["Limit"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Limit { + get { + if ((curObj["Limit"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Limit"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMappingBehaviorNull { + get { + if ((curObj["MappingBehavior"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort MappingBehavior { + get { + if ((curObj["MappingBehavior"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["MappingBehavior"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEndpointMode { + get { + return ((string)(curObj["OtherEndpointMode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherResourceType { + get { + return ((string)(curObj["OtherResourceType"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PoolID { + get { + return ((string)(curObj["PoolID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsReservationNull { + get { + if ((curObj["Reservation"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong Reservation { + get { + if ((curObj["Reservation"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["Reservation"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ResourceSubType { + get { + return ((string)(curObj["ResourceSubType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResourceTypeNull { + get { + if ((curObj["ResourceType"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResourceType { + get { + if ((curObj["ResourceType"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResourceType"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStaticMacAddressNull { + get { + if ((curObj["StaticMacAddress"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates a static MAC address.\nThis is a read-only property, but it can be chang" + + "ed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManage" + + "mentService class.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool StaticMacAddress { + get { + if ((curObj["StaticMacAddress"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["StaticMacAddress"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualQuantityNull { + get { + if ((curObj["VirtualQuantity"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong VirtualQuantity { + get { + if ((curObj["VirtualQuantity"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["VirtualQuantity"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualQuantityUnits { + get { + return ((string)(curObj["VirtualQuantityUnits"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. The indexes and values per index are defined on a per resource basis (that is, for each enumerated ResourceType value). This property is set to ""GUID"". -This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the sd class.")] - public string[] VirtualSystemIdentifiers { - get { - return ((string[])(curObj["VirtualSystemIdentifiers"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsWeightNull { - get { - if ((curObj["Weight"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint Weight { - get { - if ((curObj["Weight"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["Weight"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeAutomaticAllocation() { - if ((this.IsAutomaticAllocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticDeallocation() { - if ((this.IsAutomaticDeallocationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeConsumerVisibility() { - if ((this.IsConsumerVisibilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDesiredVLANEndpointMode() { - if ((this.IsDesiredVLANEndpointModeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeLimit() { - if ((this.IsLimitNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMappingBehavior() { - if ((this.IsMappingBehaviorNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeReservation() { - if ((this.IsReservationNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResourceType() { - if ((this.IsResourceTypeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStaticMacAddress() { - if ((this.IsStaticMacAddressNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualQuantity() { - if ((this.IsVirtualQuantityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeWeight() { - if ((this.IsWeightNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_SyntheticEthernetPortSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static SyntheticEthernetPortSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static SyntheticEthernetPortSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_SyntheticEthernetPortSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new SyntheticEthernetPortSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SyntheticEthernetPortSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new SyntheticEthernetPortSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static SyntheticEthernetPortSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new SyntheticEthernetPortSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class SyntheticEthernetPortSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public SyntheticEthernetPortSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new SyntheticEthernetPortSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class SyntheticEthernetPortSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public SyntheticEthernetPortSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the sd class.")] + public string[] VirtualSystemIdentifiers { + get { + return ((string[])(curObj["VirtualSystemIdentifiers"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsWeightNull { + get { + if ((curObj["Weight"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint Weight { + get { + if ((curObj["Weight"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["Weight"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeAutomaticAllocation() { + if ((this.IsAutomaticAllocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticDeallocation() { + if ((this.IsAutomaticDeallocationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeConsumerVisibility() { + if ((this.IsConsumerVisibilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDesiredVLANEndpointMode() { + if ((this.IsDesiredVLANEndpointModeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeLimit() { + if ((this.IsLimitNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMappingBehavior() { + if ((this.IsMappingBehaviorNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeReservation() { + if ((this.IsReservationNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResourceType() { + if ((this.IsResourceTypeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStaticMacAddress() { + if ((this.IsStaticMacAddressNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualQuantity() { + if ((this.IsVirtualQuantityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeWeight() { + if ((this.IsWeightNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_SyntheticEthernetPortSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static SyntheticEthernetPortSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static SyntheticEthernetPortSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_SyntheticEthernetPortSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new SyntheticEthernetPortSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SyntheticEthernetPortSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new SyntheticEthernetPortSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static SyntheticEthernetPortSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new SyntheticEthernetPortSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class SyntheticEthernetPortSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public SyntheticEthernetPortSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new SyntheticEthernetPortSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class SyntheticEthernetPortSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public SyntheticEthernetPortSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 6ab4069bbe8..28ab749e828 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 @@ -1,1386 +1,1386 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitch - public class VirtualEthernetSwitch : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - public static string CreatedClassName = "Msvm_VirtualEthernetSwitch"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public VirtualEthernetSwitch() { - this.InitializeObject(null, null, null); - } - - public VirtualEthernetSwitch(string keyCreationClassName, string keyName) { - this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null); - } - - public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null); - } - - public VirtualEthernetSwitch(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public VirtualEthernetSwitch(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public VirtualEthernetSwitch(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public VirtualEthernetSwitch(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] Dedicated { - get { - return ((ushort[])(curObj["Dedicated"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] IdentifyingDescriptions { - get { - return ((string[])(curObj["IdentifyingDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxIOVOffloadsNull { - get { - if ((curObj["MaxIOVOffloads"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum number of SR-IOV Virtual Function offloads available on this switch.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint MaxIOVOffloads { - get { - if ((curObj["MaxIOVOffloads"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["MaxIOVOffloads"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxVMQOffloadsNull { - get { - if ((curObj["MaxVMQOffloads"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum number of VMQ offloads allowed for a port on this switch.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint MaxVMQOffloads { - get { - if ((curObj["MaxVMQOffloads"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["MaxVMQOffloads"])); - } - set { - curObj["MaxVMQOffloads"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string NameFormat { - get { - return ((string)(curObj["NameFormat"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherDedicatedDescriptions { - get { - return ((string[])(curObj["OtherDedicatedDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] OtherIdentifyingInfo { - get { - return ((string[])(curObj["OtherIdentifyingInfo"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] PowerManagementCapabilities { - get { - return ((ushort[])(curObj["PowerManagementCapabilities"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerContact { - get { - return ((string)(curObj["PrimaryOwnerContact"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerName { - get { - return ((string)(curObj["PrimaryOwnerName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsResetCapabilityNull { - get { - if ((curObj["ResetCapability"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort ResetCapability { - get { - if ((curObj["ResetCapability"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["ResetCapability"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Roles { - get { - return ((string[])(curObj["Roles"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxIOVOffloads() { - if ((this.IsMaxIOVOffloadsNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeMaxVMQOffloads() { - if ((this.IsMaxVMQOffloadsNull == false)) { - return true; - } - return false; - } - - private void ResetMaxVMQOffloads() { - curObj["MaxVMQOffloads"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeResetCapability() { - if ((this.IsResetCapabilityNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitch"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static VirtualEthernetSwitchCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static VirtualEthernetSwitchCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static VirtualEthernetSwitchCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static VirtualEthernetSwitchCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_VirtualEthernetSwitch"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new VirtualEthernetSwitchCollection(clsObject.GetInstances(enumOptions)); - } - - public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualEthernetSwitch", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new VirtualEthernetSwitchCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static VirtualEthernetSwitch CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new VirtualEthernetSwitch(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint SetPowerState(uint PowerState, System.DateTime Time) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); - inParams["PowerState"] = ((uint)(PowerState)); - inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class VirtualEthernetSwitchCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public VirtualEthernetSwitchCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new VirtualEthernetSwitch(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new VirtualEthernetSwitchEnumerator(privColObj.GetEnumerator()); - } - - public class VirtualEthernetSwitchEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public VirtualEthernetSwitchEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new VirtualEthernetSwitch(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitch + public class VirtualEthernetSwitch : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + public static string CreatedClassName = "Msvm_VirtualEthernetSwitch"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public VirtualEthernetSwitch() { + this.InitializeObject(null, null, null); + } + + public VirtualEthernetSwitch(string keyCreationClassName, string keyName) { + this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null); + } + + public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null); + } + + public VirtualEthernetSwitch(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public VirtualEthernetSwitch(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public VirtualEthernetSwitch(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public VirtualEthernetSwitch(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] Dedicated { + get { + return ((ushort[])(curObj["Dedicated"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] IdentifyingDescriptions { + get { + return ((string[])(curObj["IdentifyingDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxIOVOffloadsNull { + get { + if ((curObj["MaxIOVOffloads"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum number of SR-IOV Virtual Function offloads available on this switch.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint MaxIOVOffloads { + get { + if ((curObj["MaxIOVOffloads"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["MaxIOVOffloads"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxVMQOffloadsNull { + get { + if ((curObj["MaxVMQOffloads"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum number of VMQ offloads allowed for a port on this switch.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint MaxVMQOffloads { + get { + if ((curObj["MaxVMQOffloads"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["MaxVMQOffloads"])); + } + set { + curObj["MaxVMQOffloads"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string NameFormat { + get { + return ((string)(curObj["NameFormat"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherDedicatedDescriptions { + get { + return ((string[])(curObj["OtherDedicatedDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] OtherIdentifyingInfo { + get { + return ((string[])(curObj["OtherIdentifyingInfo"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] PowerManagementCapabilities { + get { + return ((ushort[])(curObj["PowerManagementCapabilities"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerContact { + get { + return ((string)(curObj["PrimaryOwnerContact"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerName { + get { + return ((string)(curObj["PrimaryOwnerName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsResetCapabilityNull { + get { + if ((curObj["ResetCapability"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort ResetCapability { + get { + if ((curObj["ResetCapability"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["ResetCapability"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Roles { + get { + return ((string[])(curObj["Roles"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxIOVOffloads() { + if ((this.IsMaxIOVOffloadsNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeMaxVMQOffloads() { + if ((this.IsMaxVMQOffloadsNull == false)) { + return true; + } + return false; + } + + private void ResetMaxVMQOffloads() { + curObj["MaxVMQOffloads"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeResetCapability() { + if ((this.IsResetCapabilityNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitch"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static VirtualEthernetSwitchCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static VirtualEthernetSwitchCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static VirtualEthernetSwitchCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static VirtualEthernetSwitchCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_VirtualEthernetSwitch"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new VirtualEthernetSwitchCollection(clsObject.GetInstances(enumOptions)); + } + + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualEthernetSwitch", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new VirtualEthernetSwitchCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static VirtualEthernetSwitch CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new VirtualEthernetSwitch(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint SetPowerState(uint PowerState, System.DateTime Time) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState"); + inParams["PowerState"] = ((uint)(PowerState)); + inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class VirtualEthernetSwitchCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public VirtualEthernetSwitchCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new VirtualEthernetSwitch(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new VirtualEthernetSwitchEnumerator(privColObj.GetEnumerator()); + } + + public class VirtualEthernetSwitchEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public VirtualEthernetSwitchEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new VirtualEthernetSwitch(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 ee167a7cd81..31166815945 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 @@ -1,1515 +1,1515 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitchManagementService - public class VirtualEthernetSwitchManagementService : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - private static string CreatedClassName = "Msvm_VirtualEthernetSwitchManagementService"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public VirtualEthernetSwitchManagementService() { - this.InitializeObject(null, null, null); - } - - public VirtualEthernetSwitchManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public VirtualEthernetSwitchManagementService(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public VirtualEthernetSwitchManagementService(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerContact { - get { - return ((string)(curObj["PrimaryOwnerContact"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerName { - get { - return ((string)(curObj["PrimaryOwnerName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStartedNull { - get { - if ((curObj["Started"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool Started { - get { - if ((curObj["Started"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["Started"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string StartMode { - get { - return ((string)(curObj["StartMode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemCreationClassName { - get { - return ((string)(curObj["SystemCreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemName { - get { - return ((string)(curObj["SystemName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStarted() { - if ((this.IsStartedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitchManagementService"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static VirtualEthernetSwitchManagementServiceCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_VirtualEthernetSwitchManagementService"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new VirtualEthernetSwitchManagementServiceCollection(clsObject.GetInstances(enumOptions)); - } - - public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualEthernetSwitchManagementService", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new VirtualEthernetSwitchManagementServiceCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static VirtualEthernetSwitchManagementService CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new VirtualEthernetSwitchManagementService(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint AddFeatureSettings(System.Management.ManagementPath AffectedConfiguration, string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("AddFeatureSettings"); - inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; - inParams["FeatureSettings"] = ((string[])(FeatureSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFeatureSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - ResultingFeatureSettings = null; - if ((outParams.Properties["ResultingFeatureSettings"] != null)) { - int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingFeatureSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingFeatureSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint AddResourceSettings(System.Management.ManagementPath AffectedConfiguration, string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("AddResourceSettings"); - inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; - inParams["ResourceSettings"] = ((string[])(ResourceSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddResourceSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - ResultingResourceSettings = null; - if ((outParams.Properties["ResultingResourceSettings"] != null)) { - int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingResourceSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingResourceSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint DefineSystem(System.Management.ManagementPath ReferenceConfiguration, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("DefineSystem"); - inParams["ReferenceConfiguration"] = ((System.Management.ManagementPath)(ReferenceConfiguration)).Path; - inParams["ResourceSettings"] = ((string[])(ResourceSettings)); - inParams["SystemSettings"] = ((string)(SystemSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DefineSystem", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - ResultingSystem = null; - if ((outParams.Properties["ResultingSystem"] != null)) { - ResultingSystem = new System.Management.ManagementPath(outParams.Properties["ResultingSystem"].ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingSystem = null; - return System.Convert.ToUInt32(0); - } - } - - public uint DestroySystem(System.Management.ManagementPath AffectedSystem, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("DestroySystem"); - inParams["AffectedSystem"] = ((System.Management.ManagementPath)(AffectedSystem)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DestroySystem", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifyFeatureSettings(string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifyFeatureSettings"); - inParams["FeatureSettings"] = ((string[])(FeatureSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyFeatureSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - ResultingFeatureSettings = null; - if ((outParams.Properties["ResultingFeatureSettings"] != null)) { - int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingFeatureSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingFeatureSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifyResourceSettings(string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifyResourceSettings"); - inParams["ResourceSettings"] = ((string[])(ResourceSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyResourceSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - ResultingResourceSettings = null; - if ((outParams.Properties["ResultingResourceSettings"] != null)) { - int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingResourceSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingResourceSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifySystemSettings(string SystemSettings, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifySystemSettings"); - inParams["SystemSettings"] = ((string)(SystemSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifySystemSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RemoveFeatureSettings(System.Management.ManagementPath[] FeatureSettings, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFeatureSettings"); - if ((FeatureSettings != null)) { - int len = ((System.Array)(FeatureSettings)).Length; - string[] arrProp = new string[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(FeatureSettings)).GetValue(iCounter))).Path; - } - inParams["FeatureSettings"] = arrProp; - } - else { - inParams["FeatureSettings"] = null; - } - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFeatureSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RemoveResourceSettings(System.Management.ManagementPath[] ResourceSettings, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RemoveResourceSettings"); - if ((ResourceSettings != null)) { - int len = ((System.Array)(ResourceSettings)).Length; - string[] arrProp = new string[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(ResourceSettings)).GetValue(iCounter))).Path; - } - inParams["ResourceSettings"] = arrProp; - } - else { - inParams["ResourceSettings"] = null; - } - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveResourceSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) - { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { - Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint StartService() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint StopService() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class VirtualEthernetSwitchManagementServiceCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public VirtualEthernetSwitchManagementServiceCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new VirtualEthernetSwitchManagementServiceEnumerator(privColObj.GetEnumerator()); - } - - public class VirtualEthernetSwitchManagementServiceEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public VirtualEthernetSwitchManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitchManagementService + public class VirtualEthernetSwitchManagementService : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + private static string CreatedClassName = "Msvm_VirtualEthernetSwitchManagementService"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public VirtualEthernetSwitchManagementService() { + this.InitializeObject(null, null, null); + } + + public VirtualEthernetSwitchManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public VirtualEthernetSwitchManagementService(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public VirtualEthernetSwitchManagementService(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerContact { + get { + return ((string)(curObj["PrimaryOwnerContact"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerName { + get { + return ((string)(curObj["PrimaryOwnerName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStartedNull { + get { + if ((curObj["Started"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool Started { + get { + if ((curObj["Started"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["Started"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string StartMode { + get { + return ((string)(curObj["StartMode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemCreationClassName { + get { + return ((string)(curObj["SystemCreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemName { + get { + return ((string)(curObj["SystemName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStarted() { + if ((this.IsStartedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitchManagementService"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static VirtualEthernetSwitchManagementServiceCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_VirtualEthernetSwitchManagementService"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new VirtualEthernetSwitchManagementServiceCollection(clsObject.GetInstances(enumOptions)); + } + + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualEthernetSwitchManagementService", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new VirtualEthernetSwitchManagementServiceCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static VirtualEthernetSwitchManagementService CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new VirtualEthernetSwitchManagementService(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint AddFeatureSettings(System.Management.ManagementPath AffectedConfiguration, string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("AddFeatureSettings"); + inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; + inParams["FeatureSettings"] = ((string[])(FeatureSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFeatureSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + ResultingFeatureSettings = null; + if ((outParams.Properties["ResultingFeatureSettings"] != null)) { + int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingFeatureSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingFeatureSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint AddResourceSettings(System.Management.ManagementPath AffectedConfiguration, string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("AddResourceSettings"); + inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; + inParams["ResourceSettings"] = ((string[])(ResourceSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddResourceSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + ResultingResourceSettings = null; + if ((outParams.Properties["ResultingResourceSettings"] != null)) { + int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingResourceSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingResourceSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint DefineSystem(System.Management.ManagementPath ReferenceConfiguration, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("DefineSystem"); + inParams["ReferenceConfiguration"] = ((System.Management.ManagementPath)(ReferenceConfiguration)).Path; + inParams["ResourceSettings"] = ((string[])(ResourceSettings)); + inParams["SystemSettings"] = ((string)(SystemSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DefineSystem", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + ResultingSystem = null; + if ((outParams.Properties["ResultingSystem"] != null)) { + ResultingSystem = new System.Management.ManagementPath(outParams.Properties["ResultingSystem"].ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingSystem = null; + return System.Convert.ToUInt32(0); + } + } + + public uint DestroySystem(System.Management.ManagementPath AffectedSystem, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("DestroySystem"); + inParams["AffectedSystem"] = ((System.Management.ManagementPath)(AffectedSystem)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DestroySystem", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifyFeatureSettings(string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifyFeatureSettings"); + inParams["FeatureSettings"] = ((string[])(FeatureSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyFeatureSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + ResultingFeatureSettings = null; + if ((outParams.Properties["ResultingFeatureSettings"] != null)) { + int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingFeatureSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingFeatureSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifyResourceSettings(string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifyResourceSettings"); + inParams["ResourceSettings"] = ((string[])(ResourceSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyResourceSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + ResultingResourceSettings = null; + if ((outParams.Properties["ResultingResourceSettings"] != null)) { + int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingResourceSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingResourceSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifySystemSettings(string SystemSettings, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifySystemSettings"); + inParams["SystemSettings"] = ((string)(SystemSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifySystemSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RemoveFeatureSettings(System.Management.ManagementPath[] FeatureSettings, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFeatureSettings"); + if ((FeatureSettings != null)) { + int len = ((System.Array)(FeatureSettings)).Length; + string[] arrProp = new string[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(FeatureSettings)).GetValue(iCounter))).Path; + } + inParams["FeatureSettings"] = arrProp; + } + else { + inParams["FeatureSettings"] = null; + } + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFeatureSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RemoveResourceSettings(System.Management.ManagementPath[] ResourceSettings, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RemoveResourceSettings"); + if ((ResourceSettings != null)) { + int len = ((System.Array)(ResourceSettings)).Length; + string[] arrProp = new string[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(ResourceSettings)).GetValue(iCounter))).Path; + } + inParams["ResourceSettings"] = arrProp; + } + else { + inParams["ResourceSettings"] = null; + } + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveResourceSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) + { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) { + Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint StartService() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint StopService() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class VirtualEthernetSwitchManagementServiceCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public VirtualEthernetSwitchManagementServiceCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new VirtualEthernetSwitchManagementServiceEnumerator(privColObj.GetEnumerator()); + } + + public class VirtualEthernetSwitchManagementServiceEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public VirtualEthernetSwitchManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 94851c54cc7..9f1a738e4eb 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 @@ -1,1051 +1,1051 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public VirtualHardDiskSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsBlockSizeNull { - get { - if ((curObj["BlockSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The block size used by the virtual hard disk")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint BlockSize { - get { - if ((curObj["BlockSize"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["BlockSize"])); - } - set { - curObj["BlockSize"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - set { - curObj["Caption"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - set { - curObj["Description"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - set { - curObj["ElementName"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsFormatNull { - get { - if ((curObj["Format"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The format for the virtual hard disk.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public FormatValues Format { - get { - if ((curObj["Format"] == null)) { - return ((FormatValues)(System.Convert.ToInt32(0))); - } - return ((FormatValues)(System.Convert.ToInt32(curObj["Format"]))); - } - set { - if ((FormatValues.NULL_ENUM_VALUE == value)) { - curObj["Format"] = null; - } - else { - curObj["Format"] = value; - } - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - set { - curObj["InstanceID"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsLogicalSectorSizeNull { - get { - if ((curObj["LogicalSectorSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The logical sector size used by the virtual hard disk")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint LogicalSectorSize { - get { - if ((curObj["LogicalSectorSize"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["LogicalSectorSize"])); - } - set { - curObj["LogicalSectorSize"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsMaxInternalSizeNull { - get { - if ((curObj["MaxInternalSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum size of the virtual hard disk as viewable by the virtual machine, in " + - "bytes. The specified size will be rounded up to the next largest multiple of the" + - " sector size.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ulong MaxInternalSize { - get { - if ((curObj["MaxInternalSize"] == null)) { - return System.Convert.ToUInt64(0); - } - return ((ulong)(curObj["MaxInternalSize"])); - } - set { - curObj["MaxInternalSize"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The parent of the virtual hard disk. If the virtual hard disk does not have a par" + - "ent, then this field is empty.")] - public string ParentPath { - get { - return ((string)(curObj["ParentPath"])); - } - set { - curObj["ParentPath"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The path of the virtual hard disk.")] - public string Path0 { - get { - return ((string)(curObj["Path"])); - } - set { - curObj["Path"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPhysicalSectorSizeNull { - get { - if ((curObj["PhysicalSectorSize"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The physical sector size used by the virtual hard disk")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint PhysicalSectorSize { - get { - if ((curObj["PhysicalSectorSize"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["PhysicalSectorSize"])); - } - set { - curObj["PhysicalSectorSize"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTypeNull { - get { - if ((curObj["Type"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The type of virtual hard disk.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public TypeValues Type { - get { - if ((curObj["Type"] == null)) { - return ((TypeValues)(System.Convert.ToInt32(0))); - } - return ((TypeValues)(System.Convert.ToInt32(curObj["Type"]))); - } - set { - if ((TypeValues.NULL_ENUM_VALUE == value)) { - curObj["Type"] = null; - } - else { - curObj["Type"] = value; - } - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeBlockSize() { - if ((this.IsBlockSizeNull == false)) { - return true; - } - return false; - } - - private void ResetBlockSize() { - curObj["BlockSize"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetCaption() { - curObj["Caption"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetDescription() { - curObj["Description"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetElementName() { - curObj["ElementName"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeFormat() { - if ((this.IsFormatNull == false)) { - return true; - } - return false; - } - - private void ResetFormat() { - curObj["Format"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeLogicalSectorSize() { - if ((this.IsLogicalSectorSizeNull == false)) { - return true; - } - return false; - } - - private void ResetLogicalSectorSize() { - curObj["LogicalSectorSize"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeMaxInternalSize() { - if ((this.IsMaxInternalSizeNull == false)) { - return true; - } - return false; - } - - private void ResetMaxInternalSize() { - curObj["MaxInternalSize"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetParentPath() { - curObj["ParentPath"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetPath0() { - curObj["Path"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializePhysicalSectorSize() { - if ((this.IsPhysicalSectorSizeNull == false)) { - return true; - } - return false; - } - - private void ResetPhysicalSectorSize() { - curObj["PhysicalSectorSize"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeType() { - if ((this.IsTypeNull == false)) { - return true; - } - return false; - } - - private void ResetType() { - curObj["Type"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualHardDiskSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static VirtualHardDiskSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static VirtualHardDiskSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static VirtualHardDiskSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static VirtualHardDiskSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_VirtualHardDiskSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new VirtualHardDiskSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualHardDiskSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new VirtualHardDiskSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static VirtualHardDiskSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new VirtualHardDiskSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public enum FormatValues { - - VHD = 2, - - VHDX = 3, - - NULL_ENUM_VALUE = 0, - } - - public enum TypeValues { - - Fixed = 2, - - Dynamic = 3, - - Differencing = 4, - - NULL_ENUM_VALUE = 0, - } - - // Enumerator implementation for enumerating instances of the class. - public class VirtualHardDiskSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public VirtualHardDiskSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new VirtualHardDiskSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new VirtualHardDiskSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class VirtualHardDiskSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public VirtualHardDiskSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new VirtualHardDiskSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public VirtualHardDiskSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsBlockSizeNull { + get { + if ((curObj["BlockSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The block size used by the virtual hard disk")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint BlockSize { + get { + if ((curObj["BlockSize"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["BlockSize"])); + } + set { + curObj["BlockSize"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + set { + curObj["Caption"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + set { + curObj["Description"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + set { + curObj["ElementName"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsFormatNull { + get { + if ((curObj["Format"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The format for the virtual hard disk.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public FormatValues Format { + get { + if ((curObj["Format"] == null)) { + return ((FormatValues)(System.Convert.ToInt32(0))); + } + return ((FormatValues)(System.Convert.ToInt32(curObj["Format"]))); + } + set { + if ((FormatValues.NULL_ENUM_VALUE == value)) { + curObj["Format"] = null; + } + else { + curObj["Format"] = value; + } + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + set { + curObj["InstanceID"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLogicalSectorSizeNull { + get { + if ((curObj["LogicalSectorSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The logical sector size used by the virtual hard disk")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint LogicalSectorSize { + get { + if ((curObj["LogicalSectorSize"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["LogicalSectorSize"])); + } + set { + curObj["LogicalSectorSize"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsMaxInternalSizeNull { + get { + if ((curObj["MaxInternalSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum size of the virtual hard disk as viewable by the virtual machine, in " + + "bytes. The specified size will be rounded up to the next largest multiple of the" + + " sector size.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ulong MaxInternalSize { + get { + if ((curObj["MaxInternalSize"] == null)) { + return System.Convert.ToUInt64(0); + } + return ((ulong)(curObj["MaxInternalSize"])); + } + set { + curObj["MaxInternalSize"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The parent of the virtual hard disk. If the virtual hard disk does not have a par" + + "ent, then this field is empty.")] + public string ParentPath { + get { + return ((string)(curObj["ParentPath"])); + } + set { + curObj["ParentPath"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The path of the virtual hard disk.")] + public string Path0 { + get { + return ((string)(curObj["Path"])); + } + set { + curObj["Path"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPhysicalSectorSizeNull { + get { + if ((curObj["PhysicalSectorSize"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The physical sector size used by the virtual hard disk")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint PhysicalSectorSize { + get { + if ((curObj["PhysicalSectorSize"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["PhysicalSectorSize"])); + } + set { + curObj["PhysicalSectorSize"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTypeNull { + get { + if ((curObj["Type"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The type of virtual hard disk.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public TypeValues Type { + get { + if ((curObj["Type"] == null)) { + return ((TypeValues)(System.Convert.ToInt32(0))); + } + return ((TypeValues)(System.Convert.ToInt32(curObj["Type"]))); + } + set { + if ((TypeValues.NULL_ENUM_VALUE == value)) { + curObj["Type"] = null; + } + else { + curObj["Type"] = value; + } + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeBlockSize() { + if ((this.IsBlockSizeNull == false)) { + return true; + } + return false; + } + + private void ResetBlockSize() { + curObj["BlockSize"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetCaption() { + curObj["Caption"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetDescription() { + curObj["Description"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetElementName() { + curObj["ElementName"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeFormat() { + if ((this.IsFormatNull == false)) { + return true; + } + return false; + } + + private void ResetFormat() { + curObj["Format"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeLogicalSectorSize() { + if ((this.IsLogicalSectorSizeNull == false)) { + return true; + } + return false; + } + + private void ResetLogicalSectorSize() { + curObj["LogicalSectorSize"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeMaxInternalSize() { + if ((this.IsMaxInternalSizeNull == false)) { + return true; + } + return false; + } + + private void ResetMaxInternalSize() { + curObj["MaxInternalSize"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetParentPath() { + curObj["ParentPath"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetPath0() { + curObj["Path"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializePhysicalSectorSize() { + if ((this.IsPhysicalSectorSizeNull == false)) { + return true; + } + return false; + } + + private void ResetPhysicalSectorSize() { + curObj["PhysicalSectorSize"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeType() { + if ((this.IsTypeNull == false)) { + return true; + } + return false; + } + + private void ResetType() { + curObj["Type"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualHardDiskSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static VirtualHardDiskSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static VirtualHardDiskSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static VirtualHardDiskSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static VirtualHardDiskSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_VirtualHardDiskSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new VirtualHardDiskSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualHardDiskSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new VirtualHardDiskSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static VirtualHardDiskSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new VirtualHardDiskSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public enum FormatValues { + + VHD = 2, + + VHDX = 3, + + NULL_ENUM_VALUE = 0, + } + + public enum TypeValues { + + Fixed = 2, + + Dynamic = 3, + + Differencing = 4, + + NULL_ENUM_VALUE = 0, + } + + // Enumerator implementation for enumerating instances of the class. + public class VirtualHardDiskSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public VirtualHardDiskSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new VirtualHardDiskSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new VirtualHardDiskSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class VirtualHardDiskSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public VirtualHardDiskSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new VirtualHardDiskSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 124cda26ca1..0aca9977e44 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 @@ -1,1916 +1,1916 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 -{ - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_VirtualSystemManagementService - public class VirtualSystemManagementService : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - private static string CreatedClassName = "Msvm_VirtualSystemManagementService"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public VirtualSystemManagementService() { - this.InitializeObject(null, null, null); - } - - public VirtualSystemManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); - } - - public VirtualSystemManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public VirtualSystemManagementService(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public VirtualSystemManagementService(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public VirtualSystemManagementService(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] AvailableRequestedStates { - get { - return ((ushort[])(curObj["AvailableRequestedStates"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCommunicationStatusNull { - get { - if ((curObj["CommunicationStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort CommunicationStatus { - get { - if ((curObj["CommunicationStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["CommunicationStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string CreationClassName { - get { - return ((string)(curObj["CreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDetailedStatusNull { - get { - if ((curObj["DetailedStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort DetailedStatus { - get { - if ((curObj["DetailedStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["DetailedStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledDefaultNull { - get { - if ((curObj["EnabledDefault"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledDefault { - get { - if ((curObj["EnabledDefault"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledDefault"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEnabledStateNull { - get { - if ((curObj["EnabledState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort EnabledState { - get { - if ((curObj["EnabledState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["EnabledState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHealthStateNull { - get { - if ((curObj["HealthState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort HealthState { - get { - if ((curObj["HealthState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["HealthState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsInstallDateNull { - get { - if ((curObj["InstallDate"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime InstallDate { - get { - if ((curObj["InstallDate"] != null)) { - return ToDateTime(((string)(curObj["InstallDate"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Name { - get { - return ((string)(curObj["Name"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsOperatingStatusNull { - get { - if ((curObj["OperatingStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort OperatingStatus { - get { - if ((curObj["OperatingStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["OperatingStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ushort[] OperationalStatus { - get { - return ((ushort[])(curObj["OperationalStatus"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OtherEnabledState { - get { - return ((string)(curObj["OtherEnabledState"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerContact { - get { - return ((string)(curObj["PrimaryOwnerContact"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string PrimaryOwnerName { - get { - return ((string)(curObj["PrimaryOwnerName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsPrimaryStatusNull { - get { - if ((curObj["PrimaryStatus"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort PrimaryStatus { - get { - if ((curObj["PrimaryStatus"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["PrimaryStatus"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsRequestedStateNull { - get { - if ((curObj["RequestedState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort RequestedState { - get { - if ((curObj["RequestedState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["RequestedState"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsStartedNull { - get { - if ((curObj["Started"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool Started { - get { - if ((curObj["Started"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["Started"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string StartMode { - get { - return ((string)(curObj["StartMode"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Status { - get { - return ((string)(curObj["Status"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] StatusDescriptions { - get { - return ((string[])(curObj["StatusDescriptions"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemCreationClassName { - get { - return ((string)(curObj["SystemCreationClassName"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SystemName { - get { - return ((string)(curObj["SystemName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTimeOfLastStateChangeNull { - get { - if ((curObj["TimeOfLastStateChange"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime TimeOfLastStateChange { - get { - if ((curObj["TimeOfLastStateChange"] != null)) { - return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsTransitioningToStateNull { - get { - if ((curObj["TransitioningToState"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort TransitioningToState { - get { - if ((curObj["TransitioningToState"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["TransitioningToState"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeCommunicationStatus() { - if ((this.IsCommunicationStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDetailedStatus() { - if ((this.IsDetailedStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledDefault() { - if ((this.IsEnabledDefaultNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeEnabledState() { - if ((this.IsEnabledStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeHealthState() { - if ((this.IsHealthStateNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeInstallDate() { - if ((this.IsInstallDateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeOperatingStatus() { - if ((this.IsOperatingStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializePrimaryStatus() { - if ((this.IsPrimaryStatusNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeRequestedState() { - if ((this.IsRequestedStateNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeStarted() { - if ((this.IsStartedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTimeOfLastStateChange() { - if ((this.IsTimeOfLastStateChangeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeTransitioningToState() { - if ((this.IsTransitioningToStateNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { - string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemManagementService"; - strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); - strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static VirtualSystemManagementServiceCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static VirtualSystemManagementServiceCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static VirtualSystemManagementServiceCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static VirtualSystemManagementServiceCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_VirtualSystemManagementService"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new VirtualSystemManagementServiceCollection(clsObject.GetInstances(enumOptions)); - } - - public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementService", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new VirtualSystemManagementServiceCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static VirtualSystemManagementService CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new VirtualSystemManagementService(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public uint AddFeatureSettings(System.Management.ManagementPath AffectedConfiguration, string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("AddFeatureSettings"); - inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; - inParams["FeatureSettings"] = ((string[])(FeatureSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFeatureSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - ResultingFeatureSettings = null; - if ((outParams.Properties["ResultingFeatureSettings"] != null && outParams.Properties["ResultingFeatureSettings"].Value != null)) - { - int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingFeatureSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingFeatureSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint AddFibreChannelChap(string[] FcPortSettings, byte SecretEncoding, byte[] SharedSecret) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("AddFibreChannelChap"); - inParams["FcPortSettings"] = ((string[])(FcPortSettings)); - inParams["SecretEncoding"] = ((byte)(SecretEncoding)); - inParams["SharedSecret"] = ((byte[])(SharedSecret)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFibreChannelChap", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint AddKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("AddKvpItems"); - inParams["DataItems"] = ((string[])(DataItems)); - inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddKvpItems", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint AddResourceSettings(System.Management.ManagementPath AffectedConfiguration, string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("AddResourceSettings"); - inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; - inParams["ResourceSettings"] = ((string[])(ResourceSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddResourceSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - ResultingResourceSettings = null; - if ((outParams.Properties["ResultingResourceSettings"] != null && outParams.Properties["ResultingResourceSettings"].Value != null)) - { - int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingResourceSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingResourceSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint DefineSystem(string ReferenceConfigurationPath, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("DefineSystem"); - inParams["ReferenceConfiguration"] = ReferenceConfigurationPath; - inParams["ResourceSettings"] = ResourceSettings; - inParams["SystemSettings"] = SystemSettings; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DefineSystem", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - ResultingSystem = null; - if ((outParams.Properties["ResultingSystem"] != null && outParams.Properties["ResultingSystem"].Value != null)) - { - ResultingSystem = new System.Management.ManagementPath((string)outParams.Properties["ResultingSystem"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingSystem = null; - return System.Convert.ToUInt32(0); - } - } - - public uint DestroySystem(System.Management.ManagementPath AffectedSystem, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("DestroySystem"); - inParams["AffectedSystem"] = ((System.Management.ManagementPath)(AffectedSystem)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DestroySystem", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ExportSystemDefinition(System.Management.ManagementPath ComputerSystem, string ExportDirectory, string ExportSettingData, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ExportSystemDefinition"); - inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path; - inParams["ExportDirectory"] = ((string)(ExportDirectory)); - inParams["ExportSettingData"] = ((string)(ExportSettingData)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ExportSystemDefinition", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint FormatError(string[] Errors, out string ErrorMessage) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("FormatError"); - inParams["Errors"] = ((string[])(Errors)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("FormatError", inParams, null); - ErrorMessage = System.Convert.ToString(outParams.Properties["ErrorMessage"].Value); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - ErrorMessage = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GenerateWwpn(uint NumberOfWwpns, out string[] GeneratedWwpn) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("GenerateWwpn"); - inParams["NumberOfWwpns"] = ((uint)(NumberOfWwpns)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GenerateWwpn", inParams, null); - GeneratedWwpn = ((string[])(outParams.Properties["GeneratedWwpn"].Value)); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - GeneratedWwpn = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GetCurrentWwpnFromGenerator(out string CurrentWwpn) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetCurrentWwpnFromGenerator", inParams, null); - CurrentWwpn = System.Convert.ToString(outParams.Properties["CurrentWwpn"].Value); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - CurrentWwpn = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GetDefinitionFileSummaryInformation(string[] DefinitionFiles, out System.Management.ManagementBaseObject[] SummaryInformation) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("GetDefinitionFileSummaryInformation"); - inParams["DefinitionFiles"] = ((string[])(DefinitionFiles)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetDefinitionFileSummaryInformation", inParams, null); - SummaryInformation = ((System.Management.ManagementBaseObject[])(outParams.Properties["SummaryInformation"].Value)); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - SummaryInformation = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GetSizeOfSystemFiles(System.Management.ManagementPath Vssd, out ulong Size) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("GetSizeOfSystemFiles"); - inParams["Vssd"] = ((System.Management.ManagementPath)(Vssd)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetSizeOfSystemFiles", inParams, null); - Size = System.Convert.ToUInt64(outParams.Properties["Size"].Value); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Size = System.Convert.ToUInt64(0); - return System.Convert.ToUInt32(0); - } - } - - public uint GetSummaryInformation(uint[] RequestedInformation, System.Management.ManagementPath[] SettingData, out System.Management.ManagementBaseObject[] SummaryInformation) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("GetSummaryInformation"); - inParams["RequestedInformation"] = ((uint[])(RequestedInformation)); - if ((SettingData != null)) { - int len = ((System.Array)(SettingData)).Length; - string[] arrProp = new string[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(SettingData)).GetValue(iCounter))).Path; - } - inParams["SettingData"] = arrProp; - } - else { - inParams["SettingData"] = null; - } - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetSummaryInformation", inParams, null); - SummaryInformation = ((System.Management.ManagementBaseObject[])(outParams.Properties["SummaryInformation"].Value)); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - SummaryInformation = null; - return System.Convert.ToUInt32(0); - } - } - - public uint GetVirtualSystemThumbnailImage(ushort HeightPixels, System.Management.ManagementPath TargetSystem, ushort WidthPixels, out byte[] ImageData) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualSystemThumbnailImage"); - inParams["HeightPixels"] = ((ushort)(HeightPixels)); - inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; - inParams["WidthPixels"] = ((ushort)(WidthPixels)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualSystemThumbnailImage", inParams, null); - ImageData = ((byte[])(outParams.Properties["ImageData"].Value)); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - ImageData = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ImportSnapshotDefinitions(System.Management.ManagementPath PlannedSystem, string SnapshotFolder, out System.Management.ManagementPath[] ImportedSnapshots, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ImportSnapshotDefinitions"); - inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path; - inParams["SnapshotFolder"] = ((string)(SnapshotFolder)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSnapshotDefinitions", inParams, null); - ImportedSnapshots = null; - if ((outParams.Properties["ImportedSnapshots"] != null && outParams.Properties["ImportedSnapshots"].Value != null)) - { - int len = ((System.Array)(outParams.Properties["ImportedSnapshots"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ImportedSnapshots"].Value)).GetValue(iCounter).ToString()); - } - ImportedSnapshots = arrToRet; - } - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - ImportedSnapshots = null; - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ImportSystemDefinition(bool GenerateNewSystemIdentifier, string SnapshotFolder, string SystemDefinitionFile, out System.Management.ManagementPath ImportedSystem, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ImportSystemDefinition"); - inParams["GenerateNewSystemIdentifier"] = ((bool)(GenerateNewSystemIdentifier)); - inParams["SnapshotFolder"] = ((string)(SnapshotFolder)); - inParams["SystemDefinitionFile"] = ((string)(SystemDefinitionFile)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSystemDefinition", inParams, null); - ImportedSystem = null; - if ((outParams.Properties["ImportedSystem"] != null && outParams.Properties["ImportedSystem"].Value != null)) - { - ImportedSystem = new System.Management.ManagementPath(outParams.Properties["ImportedSystem"].ToString()); - } - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - ImportedSystem = null; - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifyDiskMergeSettings(string SettingData, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifyDiskMergeSettings"); - inParams["SettingData"] = ((string)(SettingData)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyDiskMergeSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifyFeatureSettings(string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifyFeatureSettings"); - inParams["FeatureSettings"] = ((string[])(FeatureSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyFeatureSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - ResultingFeatureSettings = null; - if ((outParams.Properties["ResultingFeatureSettings"] != null && outParams.Properties["ResultingFeatureSettings"].Value != null)) - { - int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingFeatureSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingFeatureSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifyKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifyKvpItems"); - inParams["DataItems"] = ((string[])(DataItems)); - inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyKvpItems", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifyResourceSettings(string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifyResourceSettings"); - inParams["ResourceSettings"] = ((string[])(ResourceSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyResourceSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - ResultingResourceSettings = null; - if ((outParams.Properties["ResultingResourceSettings"] != null && outParams.Properties["ResultingResourceSettings"].Value != null)) - { - int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; - System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); - } - ResultingResourceSettings = arrToRet; - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingResourceSettings = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifyServiceSettings(string SettingData, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifyServiceSettings"); - inParams["SettingData"] = ((string)(SettingData)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyServiceSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint ModifySystemSettings(string SystemSettings, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ModifySystemSettings"); - inParams["SystemSettings"] = ((string)(SystemSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifySystemSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RealizePlannedSystem(System.Management.ManagementPath PlannedSystem, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RealizePlannedSystem"); - inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RealizePlannedSystem", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - ResultingSystem = null; - if ((outParams.Properties["ResultingSystem"] != null)) { - ResultingSystem = new System.Management.ManagementPath(outParams.Properties["ResultingSystem"].ToString()); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - ResultingSystem = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RemoveFeatureSettings(System.Management.ManagementPath[] FeatureSettings, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFeatureSettings"); - if ((FeatureSettings != null)) { - int len = ((System.Array)(FeatureSettings)).Length; - string[] arrProp = new string[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(FeatureSettings)).GetValue(iCounter))).Path; - } - inParams["FeatureSettings"] = arrProp; - } - else { - inParams["FeatureSettings"] = null; - } - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFeatureSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RemoveFibreChannelChap(string[] FcPortSettings) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFibreChannelChap"); - inParams["FcPortSettings"] = ((string[])(FcPortSettings)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFibreChannelChap", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint RemoveKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RemoveKvpItems"); - inParams["DataItems"] = ((string[])(DataItems)); - inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveKvpItems", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RemoveResourceSettings(System.Management.ManagementPath[] ResourceSettings, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RemoveResourceSettings"); - if ((ResourceSettings != null)) { - int len = ((System.Array)(ResourceSettings)).Length; - string[] arrProp = new string[len]; - for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { - arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(ResourceSettings)).GetValue(iCounter))).Path; - } - inParams["ResourceSettings"] = arrProp; - } - else { - inParams["ResourceSettings"] = null; - } - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveResourceSettings", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); - inParams["RequestedState"] = ((ushort)(RequestedState)); - inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint SetGuestNetworkAdapterConfiguration(System.Management.ManagementPath ComputerSystem, string[] NetworkConfiguration, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("SetGuestNetworkAdapterConfiguration"); - inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path; - inParams["NetworkConfiguration"] = ((string[])(NetworkConfiguration)); - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetGuestNetworkAdapterConfiguration", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - public uint StartService() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint StopService() { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null); - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - return System.Convert.ToUInt32(0); - } - } - - public uint ValidatePlannedSystem(System.Management.ManagementPath PlannedSystem, out System.Management.ManagementPath Job) { - if ((isEmbedded == false)) { - System.Management.ManagementBaseObject inParams = null; - inParams = PrivateLateBoundObject.GetMethodParameters("ValidatePlannedSystem"); - inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path; - System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ValidatePlannedSystem", inParams, null); - Job = null; - if ((outParams.Properties["Job"] != null)) - { - Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); - } - return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); - } - else { - Job = null; - return System.Convert.ToUInt32(0); - } - } - - // Enumerator implementation for enumerating instances of the class. - public class VirtualSystemManagementServiceCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public VirtualSystemManagementServiceCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new VirtualSystemManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new VirtualSystemManagementServiceEnumerator(privColObj.GetEnumerator()); - } - - public class VirtualSystemManagementServiceEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public VirtualSystemManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new VirtualSystemManagementService(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 +{ + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_VirtualSystemManagementService + public class VirtualSystemManagementService : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + private static string CreatedClassName = "Msvm_VirtualSystemManagementService"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public VirtualSystemManagementService() { + this.InitializeObject(null, null, null); + } + + public VirtualSystemManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); + } + + public VirtualSystemManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public VirtualSystemManagementService(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public VirtualSystemManagementService(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public VirtualSystemManagementService(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] AvailableRequestedStates { + get { + return ((ushort[])(curObj["AvailableRequestedStates"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCommunicationStatusNull { + get { + if ((curObj["CommunicationStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort CommunicationStatus { + get { + if ((curObj["CommunicationStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["CommunicationStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string CreationClassName { + get { + return ((string)(curObj["CreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDetailedStatusNull { + get { + if ((curObj["DetailedStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort DetailedStatus { + get { + if ((curObj["DetailedStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["DetailedStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledDefaultNull { + get { + if ((curObj["EnabledDefault"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledDefault { + get { + if ((curObj["EnabledDefault"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledDefault"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsEnabledStateNull { + get { + if ((curObj["EnabledState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort EnabledState { + get { + if ((curObj["EnabledState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["EnabledState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHealthStateNull { + get { + if ((curObj["HealthState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort HealthState { + get { + if ((curObj["HealthState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["HealthState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsInstallDateNull { + get { + if ((curObj["InstallDate"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime InstallDate { + get { + if ((curObj["InstallDate"] != null)) { + return ToDateTime(((string)(curObj["InstallDate"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Name { + get { + return ((string)(curObj["Name"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsOperatingStatusNull { + get { + if ((curObj["OperatingStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort OperatingStatus { + get { + if ((curObj["OperatingStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["OperatingStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ushort[] OperationalStatus { + get { + return ((ushort[])(curObj["OperationalStatus"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OtherEnabledState { + get { + return ((string)(curObj["OtherEnabledState"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerContact { + get { + return ((string)(curObj["PrimaryOwnerContact"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string PrimaryOwnerName { + get { + return ((string)(curObj["PrimaryOwnerName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsPrimaryStatusNull { + get { + if ((curObj["PrimaryStatus"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort PrimaryStatus { + get { + if ((curObj["PrimaryStatus"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["PrimaryStatus"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsRequestedStateNull { + get { + if ((curObj["RequestedState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort RequestedState { + get { + if ((curObj["RequestedState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["RequestedState"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsStartedNull { + get { + if ((curObj["Started"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool Started { + get { + if ((curObj["Started"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["Started"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string StartMode { + get { + return ((string)(curObj["StartMode"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Status { + get { + return ((string)(curObj["Status"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] StatusDescriptions { + get { + return ((string[])(curObj["StatusDescriptions"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemCreationClassName { + get { + return ((string)(curObj["SystemCreationClassName"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SystemName { + get { + return ((string)(curObj["SystemName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTimeOfLastStateChangeNull { + get { + if ((curObj["TimeOfLastStateChange"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime TimeOfLastStateChange { + get { + if ((curObj["TimeOfLastStateChange"] != null)) { + return ToDateTime(((string)(curObj["TimeOfLastStateChange"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsTransitioningToStateNull { + get { + if ((curObj["TransitioningToState"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort TransitioningToState { + get { + if ((curObj["TransitioningToState"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["TransitioningToState"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeCommunicationStatus() { + if ((this.IsCommunicationStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDetailedStatus() { + if ((this.IsDetailedStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledDefault() { + if ((this.IsEnabledDefaultNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeEnabledState() { + if ((this.IsEnabledStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeHealthState() { + if ((this.IsHealthStateNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeInstallDate() { + if ((this.IsInstallDateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeOperatingStatus() { + if ((this.IsOperatingStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializePrimaryStatus() { + if ((this.IsPrimaryStatusNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeRequestedState() { + if ((this.IsRequestedStateNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeStarted() { + if ((this.IsStartedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTimeOfLastStateChange() { + if ((this.IsTimeOfLastStateChangeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeTransitioningToState() { + if ((this.IsTransitioningToStateNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { + string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemManagementService"; + strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\"")))); + strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static VirtualSystemManagementServiceCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static VirtualSystemManagementServiceCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static VirtualSystemManagementServiceCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static VirtualSystemManagementServiceCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_VirtualSystemManagementService"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new VirtualSystemManagementServiceCollection(clsObject.GetInstances(enumOptions)); + } + + public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementService", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new VirtualSystemManagementServiceCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static VirtualSystemManagementService CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new VirtualSystemManagementService(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public uint AddFeatureSettings(System.Management.ManagementPath AffectedConfiguration, string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("AddFeatureSettings"); + inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; + inParams["FeatureSettings"] = ((string[])(FeatureSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFeatureSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + ResultingFeatureSettings = null; + if ((outParams.Properties["ResultingFeatureSettings"] != null && outParams.Properties["ResultingFeatureSettings"].Value != null)) + { + int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingFeatureSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingFeatureSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint AddFibreChannelChap(string[] FcPortSettings, byte SecretEncoding, byte[] SharedSecret) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("AddFibreChannelChap"); + inParams["FcPortSettings"] = ((string[])(FcPortSettings)); + inParams["SecretEncoding"] = ((byte)(SecretEncoding)); + inParams["SharedSecret"] = ((byte[])(SharedSecret)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFibreChannelChap", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint AddKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("AddKvpItems"); + inParams["DataItems"] = ((string[])(DataItems)); + inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddKvpItems", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint AddResourceSettings(System.Management.ManagementPath AffectedConfiguration, string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("AddResourceSettings"); + inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path; + inParams["ResourceSettings"] = ((string[])(ResourceSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddResourceSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + ResultingResourceSettings = null; + if ((outParams.Properties["ResultingResourceSettings"] != null && outParams.Properties["ResultingResourceSettings"].Value != null)) + { + int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingResourceSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingResourceSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint DefineSystem(string ReferenceConfigurationPath, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("DefineSystem"); + inParams["ReferenceConfiguration"] = ReferenceConfigurationPath; + inParams["ResourceSettings"] = ResourceSettings; + inParams["SystemSettings"] = SystemSettings; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DefineSystem", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + ResultingSystem = null; + if ((outParams.Properties["ResultingSystem"] != null && outParams.Properties["ResultingSystem"].Value != null)) + { + ResultingSystem = new System.Management.ManagementPath((string)outParams.Properties["ResultingSystem"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingSystem = null; + return System.Convert.ToUInt32(0); + } + } + + public uint DestroySystem(System.Management.ManagementPath AffectedSystem, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("DestroySystem"); + inParams["AffectedSystem"] = ((System.Management.ManagementPath)(AffectedSystem)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DestroySystem", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ExportSystemDefinition(System.Management.ManagementPath ComputerSystem, string ExportDirectory, string ExportSettingData, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ExportSystemDefinition"); + inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path; + inParams["ExportDirectory"] = ((string)(ExportDirectory)); + inParams["ExportSettingData"] = ((string)(ExportSettingData)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ExportSystemDefinition", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint FormatError(string[] Errors, out string ErrorMessage) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("FormatError"); + inParams["Errors"] = ((string[])(Errors)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("FormatError", inParams, null); + ErrorMessage = System.Convert.ToString(outParams.Properties["ErrorMessage"].Value); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + ErrorMessage = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GenerateWwpn(uint NumberOfWwpns, out string[] GeneratedWwpn) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("GenerateWwpn"); + inParams["NumberOfWwpns"] = ((uint)(NumberOfWwpns)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GenerateWwpn", inParams, null); + GeneratedWwpn = ((string[])(outParams.Properties["GeneratedWwpn"].Value)); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + GeneratedWwpn = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GetCurrentWwpnFromGenerator(out string CurrentWwpn) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetCurrentWwpnFromGenerator", inParams, null); + CurrentWwpn = System.Convert.ToString(outParams.Properties["CurrentWwpn"].Value); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + CurrentWwpn = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GetDefinitionFileSummaryInformation(string[] DefinitionFiles, out System.Management.ManagementBaseObject[] SummaryInformation) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("GetDefinitionFileSummaryInformation"); + inParams["DefinitionFiles"] = ((string[])(DefinitionFiles)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetDefinitionFileSummaryInformation", inParams, null); + SummaryInformation = ((System.Management.ManagementBaseObject[])(outParams.Properties["SummaryInformation"].Value)); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + SummaryInformation = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GetSizeOfSystemFiles(System.Management.ManagementPath Vssd, out ulong Size) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("GetSizeOfSystemFiles"); + inParams["Vssd"] = ((System.Management.ManagementPath)(Vssd)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetSizeOfSystemFiles", inParams, null); + Size = System.Convert.ToUInt64(outParams.Properties["Size"].Value); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Size = System.Convert.ToUInt64(0); + return System.Convert.ToUInt32(0); + } + } + + public uint GetSummaryInformation(uint[] RequestedInformation, System.Management.ManagementPath[] SettingData, out System.Management.ManagementBaseObject[] SummaryInformation) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("GetSummaryInformation"); + inParams["RequestedInformation"] = ((uint[])(RequestedInformation)); + if ((SettingData != null)) { + int len = ((System.Array)(SettingData)).Length; + string[] arrProp = new string[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(SettingData)).GetValue(iCounter))).Path; + } + inParams["SettingData"] = arrProp; + } + else { + inParams["SettingData"] = null; + } + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetSummaryInformation", inParams, null); + SummaryInformation = ((System.Management.ManagementBaseObject[])(outParams.Properties["SummaryInformation"].Value)); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + SummaryInformation = null; + return System.Convert.ToUInt32(0); + } + } + + public uint GetVirtualSystemThumbnailImage(ushort HeightPixels, System.Management.ManagementPath TargetSystem, ushort WidthPixels, out byte[] ImageData) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualSystemThumbnailImage"); + inParams["HeightPixels"] = ((ushort)(HeightPixels)); + inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; + inParams["WidthPixels"] = ((ushort)(WidthPixels)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualSystemThumbnailImage", inParams, null); + ImageData = ((byte[])(outParams.Properties["ImageData"].Value)); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + ImageData = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ImportSnapshotDefinitions(System.Management.ManagementPath PlannedSystem, string SnapshotFolder, out System.Management.ManagementPath[] ImportedSnapshots, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ImportSnapshotDefinitions"); + inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path; + inParams["SnapshotFolder"] = ((string)(SnapshotFolder)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSnapshotDefinitions", inParams, null); + ImportedSnapshots = null; + if ((outParams.Properties["ImportedSnapshots"] != null && outParams.Properties["ImportedSnapshots"].Value != null)) + { + int len = ((System.Array)(outParams.Properties["ImportedSnapshots"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ImportedSnapshots"].Value)).GetValue(iCounter).ToString()); + } + ImportedSnapshots = arrToRet; + } + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + ImportedSnapshots = null; + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ImportSystemDefinition(bool GenerateNewSystemIdentifier, string SnapshotFolder, string SystemDefinitionFile, out System.Management.ManagementPath ImportedSystem, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ImportSystemDefinition"); + inParams["GenerateNewSystemIdentifier"] = ((bool)(GenerateNewSystemIdentifier)); + inParams["SnapshotFolder"] = ((string)(SnapshotFolder)); + inParams["SystemDefinitionFile"] = ((string)(SystemDefinitionFile)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSystemDefinition", inParams, null); + ImportedSystem = null; + if ((outParams.Properties["ImportedSystem"] != null && outParams.Properties["ImportedSystem"].Value != null)) + { + ImportedSystem = new System.Management.ManagementPath(outParams.Properties["ImportedSystem"].ToString()); + } + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + ImportedSystem = null; + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifyDiskMergeSettings(string SettingData, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifyDiskMergeSettings"); + inParams["SettingData"] = ((string)(SettingData)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyDiskMergeSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifyFeatureSettings(string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifyFeatureSettings"); + inParams["FeatureSettings"] = ((string[])(FeatureSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyFeatureSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + ResultingFeatureSettings = null; + if ((outParams.Properties["ResultingFeatureSettings"] != null && outParams.Properties["ResultingFeatureSettings"].Value != null)) + { + int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingFeatureSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingFeatureSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifyKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifyKvpItems"); + inParams["DataItems"] = ((string[])(DataItems)); + inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyKvpItems", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifyResourceSettings(string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifyResourceSettings"); + inParams["ResourceSettings"] = ((string[])(ResourceSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyResourceSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + ResultingResourceSettings = null; + if ((outParams.Properties["ResultingResourceSettings"] != null && outParams.Properties["ResultingResourceSettings"].Value != null)) + { + int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length; + System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString()); + } + ResultingResourceSettings = arrToRet; + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingResourceSettings = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifyServiceSettings(string SettingData, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifyServiceSettings"); + inParams["SettingData"] = ((string)(SettingData)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyServiceSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint ModifySystemSettings(string SystemSettings, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ModifySystemSettings"); + inParams["SystemSettings"] = ((string)(SystemSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifySystemSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RealizePlannedSystem(System.Management.ManagementPath PlannedSystem, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RealizePlannedSystem"); + inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RealizePlannedSystem", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + ResultingSystem = null; + if ((outParams.Properties["ResultingSystem"] != null)) { + ResultingSystem = new System.Management.ManagementPath(outParams.Properties["ResultingSystem"].ToString()); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + ResultingSystem = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RemoveFeatureSettings(System.Management.ManagementPath[] FeatureSettings, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFeatureSettings"); + if ((FeatureSettings != null)) { + int len = ((System.Array)(FeatureSettings)).Length; + string[] arrProp = new string[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(FeatureSettings)).GetValue(iCounter))).Path; + } + inParams["FeatureSettings"] = arrProp; + } + else { + inParams["FeatureSettings"] = null; + } + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFeatureSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RemoveFibreChannelChap(string[] FcPortSettings) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFibreChannelChap"); + inParams["FcPortSettings"] = ((string[])(FcPortSettings)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFibreChannelChap", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint RemoveKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RemoveKvpItems"); + inParams["DataItems"] = ((string[])(DataItems)); + inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveKvpItems", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RemoveResourceSettings(System.Management.ManagementPath[] ResourceSettings, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RemoveResourceSettings"); + if ((ResourceSettings != null)) { + int len = ((System.Array)(ResourceSettings)).Length; + string[] arrProp = new string[len]; + for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) { + arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(ResourceSettings)).GetValue(iCounter))).Path; + } + inParams["ResourceSettings"] = arrProp; + } + else { + inParams["ResourceSettings"] = null; + } + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveResourceSettings", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange"); + inParams["RequestedState"] = ((ushort)(RequestedState)); + inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod))); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint SetGuestNetworkAdapterConfiguration(System.Management.ManagementPath ComputerSystem, string[] NetworkConfiguration, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("SetGuestNetworkAdapterConfiguration"); + inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path; + inParams["NetworkConfiguration"] = ((string[])(NetworkConfiguration)); + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetGuestNetworkAdapterConfiguration", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + public uint StartService() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint StopService() { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null); + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + return System.Convert.ToUInt32(0); + } + } + + public uint ValidatePlannedSystem(System.Management.ManagementPath PlannedSystem, out System.Management.ManagementPath Job) { + if ((isEmbedded == false)) { + System.Management.ManagementBaseObject inParams = null; + inParams = PrivateLateBoundObject.GetMethodParameters("ValidatePlannedSystem"); + inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path; + System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ValidatePlannedSystem", inParams, null); + Job = null; + if ((outParams.Properties["Job"] != null)) + { + Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value); + } + return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value); + } + else { + Job = null; + return System.Convert.ToUInt32(0); + } + } + + // Enumerator implementation for enumerating instances of the class. + public class VirtualSystemManagementServiceCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public VirtualSystemManagementServiceCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new VirtualSystemManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new VirtualSystemManagementServiceEnumerator(privColObj.GetEnumerator()); + } + + public class VirtualSystemManagementServiceEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public VirtualSystemManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new VirtualSystemManagementService(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 98f0eff6383..7347df9b095 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs @@ -1,809 +1,809 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 -{ - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public VirtualSystemManagementServiceSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"Used by OEMs to allow BIOS-locked Windows operating systems to run in the virtual machine. This string must be exactly 32 characters in length. -This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] - public string BiosLockString { - get { - return ((string)(curObj["BiosLockString"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The WorldWideNodeName address for dynamically generated WorldWideName addresses u" + - "sed for Synthetic HBAs.\nThis is a read-only property, but it can be changed usin" + - "g the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService cl" + - "ass.")] - public string CurrentWWNNAddress { - get { - return ((string)(curObj["CurrentWWNNAddress"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The default external data root. By default, \"root\\ProgramData\\Microsoft\\Windows\\V" + - "irtualization\".\nThis is a read-only property, but it can be changed using the Mo" + - "difyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] - public string DefaultExternalDataRoot { - get { - return ((string)(curObj["DefaultExternalDataRoot"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The default virtual hard disk path. By default, \"root\\Users\\Public\\Documents\\Virt" + - "ual Hard Disks\".\nThis is a read-only property, but it can be changed using the M" + - "odifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] - public string DefaultVirtualHardDiskPath { - get { - return ((string)(curObj["DefaultVirtualHardDiskPath"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsHbaLunTimeoutNull { - get { - if ((curObj["HbaLunTimeout"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"This property describes the amount of time that the Synthetic FC virtual device will wait for a LUN to appear before starting a virtual machine. -This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint HbaLunTimeout { - get { - if ((curObj["HbaLunTimeout"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["HbaLunTimeout"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum MAC address for dynamically generated MAC addresses.\nThis is a read-o" + - "nly property, but it can be changed using the ModifyServiceSettings method of th" + - "e Msvm_VirtualSystemManagementService class.")] - public string MaximumMacAddress { - get { - return ((string)(curObj["MaximumMacAddress"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The maximum WorldWidePortName address for dynamically generated WorldWideName add" + - "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" + - "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" + - "rvice class.")] - public string MaximumWWPNAddress { - get { - return ((string)(curObj["MaximumWWPNAddress"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The minimum MAC address for dynamically generated MAC addresses.\nThis is a read-o" + - "nly property, but it can be changed using the ModifyServiceSettings method of th" + - "e Msvm_VirtualSystemManagementService class.")] - public string MinimumMacAddress { - get { - return ((string)(curObj["MinimumMacAddress"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The minimum WorldWidePortName address for dynamically generated WorldWideName add" + - "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" + - "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" + - "rvice class.")] - public string MinimumWWPNAddress { - get { - return ((string)(curObj["MinimumWWPNAddress"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsNumaSpanningEnabledNull { - get { - if ((curObj["NumaSpanningEnabled"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Reserved for future use.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool NumaSpanningEnabled { - get { - if ((curObj["NumaSpanningEnabled"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["NumaSpanningEnabled"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Controls memory allocation for the VMs on non-uniform memory access (NUMA) system" + - "s.\nThis is a read-only property, but it can be changed using the ModifyServiceSe" + - "ttings method of the Msvm_VirtualSystemManagementService class.")] - public string PrimaryOwnerContact { - get { - return ((string)(curObj["PrimaryOwnerContact"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"Describes how the primary system owner can be reached (for example, phone number or e-mail address). By default, empty. This name may not exceed 256 characters in length. -This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] - public string PrimaryOwnerName { - get { - return ((string)(curObj["PrimaryOwnerName"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private bool ShouldSerializeHbaLunTimeout() { - if ((this.IsHbaLunTimeoutNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeNumaSpanningEnabled() { - if ((this.IsNumaSpanningEnabledNull == false)) { - return true; - } - return false; - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemManagementServiceSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static VirtualSystemManagementServiceSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_VirtualSystemManagementServiceSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new VirtualSystemManagementServiceSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementServiceSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new VirtualSystemManagementServiceSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static VirtualSystemManagementServiceSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new VirtualSystemManagementServiceSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - // Enumerator implementation for enumerating instances of the class. - public class VirtualSystemManagementServiceSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public VirtualSystemManagementServiceSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new VirtualSystemManagementServiceSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class VirtualSystemManagementServiceSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public VirtualSystemManagementServiceSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 +{ + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public VirtualSystemManagementServiceSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"Used by OEMs to allow BIOS-locked Windows operating systems to run in the virtual machine. This string must be exactly 32 characters in length. +This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] + public string BiosLockString { + get { + return ((string)(curObj["BiosLockString"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The WorldWideNodeName address for dynamically generated WorldWideName addresses u" + + "sed for Synthetic HBAs.\nThis is a read-only property, but it can be changed usin" + + "g the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService cl" + + "ass.")] + public string CurrentWWNNAddress { + get { + return ((string)(curObj["CurrentWWNNAddress"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The default external data root. By default, \"root\\ProgramData\\Microsoft\\Windows\\V" + + "irtualization\".\nThis is a read-only property, but it can be changed using the Mo" + + "difyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] + public string DefaultExternalDataRoot { + get { + return ((string)(curObj["DefaultExternalDataRoot"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The default virtual hard disk path. By default, \"root\\Users\\Public\\Documents\\Virt" + + "ual Hard Disks\".\nThis is a read-only property, but it can be changed using the M" + + "odifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] + public string DefaultVirtualHardDiskPath { + get { + return ((string)(curObj["DefaultVirtualHardDiskPath"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsHbaLunTimeoutNull { + get { + if ((curObj["HbaLunTimeout"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"This property describes the amount of time that the Synthetic FC virtual device will wait for a LUN to appear before starting a virtual machine. +This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint HbaLunTimeout { + get { + if ((curObj["HbaLunTimeout"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["HbaLunTimeout"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum MAC address for dynamically generated MAC addresses.\nThis is a read-o" + + "nly property, but it can be changed using the ModifyServiceSettings method of th" + + "e Msvm_VirtualSystemManagementService class.")] + public string MaximumMacAddress { + get { + return ((string)(curObj["MaximumMacAddress"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The maximum WorldWidePortName address for dynamically generated WorldWideName add" + + "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" + + "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" + + "rvice class.")] + public string MaximumWWPNAddress { + get { + return ((string)(curObj["MaximumWWPNAddress"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The minimum MAC address for dynamically generated MAC addresses.\nThis is a read-o" + + "nly property, but it can be changed using the ModifyServiceSettings method of th" + + "e Msvm_VirtualSystemManagementService class.")] + public string MinimumMacAddress { + get { + return ((string)(curObj["MinimumMacAddress"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The minimum WorldWidePortName address for dynamically generated WorldWideName add" + + "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" + + "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" + + "rvice class.")] + public string MinimumWWPNAddress { + get { + return ((string)(curObj["MinimumWWPNAddress"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsNumaSpanningEnabledNull { + get { + if ((curObj["NumaSpanningEnabled"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Reserved for future use.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool NumaSpanningEnabled { + get { + if ((curObj["NumaSpanningEnabled"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["NumaSpanningEnabled"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Controls memory allocation for the VMs on non-uniform memory access (NUMA) system" + + "s.\nThis is a read-only property, but it can be changed using the ModifyServiceSe" + + "ttings method of the Msvm_VirtualSystemManagementService class.")] + public string PrimaryOwnerContact { + get { + return ((string)(curObj["PrimaryOwnerContact"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description(@"Describes how the primary system owner can be reached (for example, phone number or e-mail address). By default, empty. This name may not exceed 256 characters in length. +This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")] + public string PrimaryOwnerName { + get { + return ((string)(curObj["PrimaryOwnerName"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private bool ShouldSerializeHbaLunTimeout() { + if ((this.IsHbaLunTimeoutNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeNumaSpanningEnabled() { + if ((this.IsNumaSpanningEnabledNull == false)) { + return true; + } + return false; + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemManagementServiceSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static VirtualSystemManagementServiceSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_VirtualSystemManagementServiceSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new VirtualSystemManagementServiceSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementServiceSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new VirtualSystemManagementServiceSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static VirtualSystemManagementServiceSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new VirtualSystemManagementServiceSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + // Enumerator implementation for enumerating instances of the class. + public class VirtualSystemManagementServiceSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public VirtualSystemManagementServiceSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new VirtualSystemManagementServiceSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class VirtualSystemManagementServiceSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public VirtualSystemManagementServiceSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} 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 85babfee2eb..1dab7d0f811 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 @@ -15,517 +15,517 @@ // specific language governing permissions and limitations // under the License. -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { - using System; - using System.ComponentModel; - using System.Management; - using System.Collections; - using System.Globalization; - using System.ComponentModel.Design.Serialization; - using System.Reflection; - - - // Functions ShouldSerialize 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. - // An Early Bound class generated for the WMI class.Msvm_VirtualSystemSettingData - public class VirtualSystemSettingData : System.ComponentModel.Component { - - // Private property to hold the WMI namespace in which the class resides. - private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - - // Private property to hold the name of WMI class which created this class. - public static string CreatedClassName = "Msvm_VirtualSystemSettingData"; - - // Private member variable to hold the ManagementScope which is used by the various methods. - private static System.Management.ManagementScope statMgmtScope = null; - - private ManagementSystemProperties PrivateSystemProperties; - - // Underlying lateBound WMI object. - private System.Management.ManagementObject PrivateLateBoundObject; - - // Member variable to store the 'automatic commit' behavior for the class. - private bool AutoCommitProp; - - // Private variable to hold the embedded property representing the instance. - private System.Management.ManagementBaseObject embeddedObj; - - // The current WMI object used - private System.Management.ManagementBaseObject curObj; - - // Flag to indicate if the instance is an embedded object. - private bool isEmbedded; - - // Below are different overloads of constructors to initialize an instance of the class with a WMI object. - public VirtualSystemSettingData() { - this.InitializeObject(null, null, null); - } - - public VirtualSystemSettingData(string keyInstanceID) { - this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemSettingData.ConstructPath(keyInstanceID)), null); - } - - public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { - this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemSettingData.ConstructPath(keyInstanceID)), null); - } - - public VirtualSystemSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(null, path, getOptions); - } - - public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { - this.InitializeObject(mgmtScope, path, null); - } - - public VirtualSystemSettingData(System.Management.ManagementPath path) { - this.InitializeObject(null, path, null); - } - - public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - this.InitializeObject(mgmtScope, path, getOptions); - } - - public VirtualSystemSettingData(System.Management.ManagementObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - PrivateLateBoundObject = theObject; - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - public VirtualSystemSettingData(System.Management.ManagementBaseObject theObject) { - Initialize(); - if ((CheckIfProperClass(theObject) == true)) { - embeddedObj = theObject; - PrivateSystemProperties = new ManagementSystemProperties(theObject); - curObj = embeddedObj; - isEmbedded = true; - } - else { - throw new System.ArgumentException("Class name does not match."); - } - } - - // Property returns the namespace of the WMI class. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string OriginatingNamespace { - get { - return "ROOT\\virtualization\\v2"; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ManagementClassName { - get { - string strRet = CreatedClassName; - if ((curObj != null)) { - if ((curObj.ClassPath != null)) { - strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) - || (strRet == string.Empty))) { - strRet = CreatedClassName; - } - } - } - return strRet; - } - } - - // Property pointing to an embedded object to get System properties of the WMI object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ManagementSystemProperties SystemProperties { - get { - return PrivateSystemProperties; - } - } - - // Property returning the underlying lateBound object. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementBaseObject LateBoundObject { - get { - return curObj; - } - } - - // ManagementScope of the object. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public System.Management.ManagementScope Scope { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Scope; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Scope = value; - } - } - } - - // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool AutoCommit { - get { - return AutoCommitProp; - } - set { - AutoCommitProp = value; - } - } - - // The ManagementPath of the underlying WMI object. - [Browsable(true)] - public System.Management.ManagementPath Path { - get { - if ((isEmbedded == false)) { - return PrivateLateBoundObject.Path; - } - else { - return null; - } - } - set { - if ((isEmbedded == false)) { - if ((CheckIfProperClass(null, value, null) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - PrivateLateBoundObject.Path = value; - } - } - } - - // Public static scope property which is used by the various methods. - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public static System.Management.ManagementScope StaticScope { - get { - return statMgmtScope; - } - set { - statMgmtScope = value; - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { + using System; + using System.ComponentModel; + using System.Management; + using System.Collections; + using System.Globalization; + using System.ComponentModel.Design.Serialization; + using System.Reflection; + + + // Functions ShouldSerialize 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. + // An Early Bound class generated for the WMI class.Msvm_VirtualSystemSettingData + public class VirtualSystemSettingData : System.ComponentModel.Component { + + // Private property to hold the WMI namespace in which the class resides. + private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; + + // Private property to hold the name of WMI class which created this class. + public static string CreatedClassName = "Msvm_VirtualSystemSettingData"; + + // Private member variable to hold the ManagementScope which is used by the various methods. + private static System.Management.ManagementScope statMgmtScope = null; + + private ManagementSystemProperties PrivateSystemProperties; + + // Underlying lateBound WMI object. + private System.Management.ManagementObject PrivateLateBoundObject; + + // Member variable to store the 'automatic commit' behavior for the class. + private bool AutoCommitProp; + + // Private variable to hold the embedded property representing the instance. + private System.Management.ManagementBaseObject embeddedObj; + + // The current WMI object used + private System.Management.ManagementBaseObject curObj; + + // Flag to indicate if the instance is an embedded object. + private bool isEmbedded; + + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. + public VirtualSystemSettingData() { + this.InitializeObject(null, null, null); + } + + public VirtualSystemSettingData(string keyInstanceID) { + this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemSettingData.ConstructPath(keyInstanceID)), null); + } + + public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { + this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemSettingData.ConstructPath(keyInstanceID)), null); + } + + public VirtualSystemSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(null, path, getOptions); + } + + public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { + this.InitializeObject(mgmtScope, path, null); + } + + public VirtualSystemSettingData(System.Management.ManagementPath path) { + this.InitializeObject(null, path, null); + } + + public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + this.InitializeObject(mgmtScope, path, getOptions); + } + + public VirtualSystemSettingData(System.Management.ManagementObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + PrivateLateBoundObject = theObject; + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + public VirtualSystemSettingData(System.Management.ManagementBaseObject theObject) { + Initialize(); + if ((CheckIfProperClass(theObject) == true)) { + embeddedObj = theObject; + PrivateSystemProperties = new ManagementSystemProperties(theObject); + curObj = embeddedObj; + isEmbedded = true; + } + else { + throw new System.ArgumentException("Class name does not match."); + } + } + + // Property returns the namespace of the WMI class. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string OriginatingNamespace { + get { + return "ROOT\\virtualization\\v2"; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ManagementClassName { + get { + string strRet = CreatedClassName; + if ((curObj != null)) { + if ((curObj.ClassPath != null)) { + strRet = ((string)(curObj["__CLASS"])); + if (((strRet == null) + || (strRet == string.Empty))) { + strRet = CreatedClassName; + } + } + } + return strRet; + } + } + + // Property pointing to an embedded object to get System properties of the WMI object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ManagementSystemProperties SystemProperties { + get { + return PrivateSystemProperties; + } + } + + // Property returning the underlying lateBound object. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementBaseObject LateBoundObject { + get { + return curObj; + } + } + + // ManagementScope of the object. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public System.Management.ManagementScope Scope { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Scope; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Scope = value; + } + } + } + + // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property). + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AutoCommit { + get { + return AutoCommitProp; + } + set { + AutoCommitProp = value; + } + } + + // The ManagementPath of the underlying WMI object. + [Browsable(true)] + public System.Management.ManagementPath Path { + get { + if ((isEmbedded == false)) { + return PrivateLateBoundObject.Path; + } + else { + return null; + } + } + set { + if ((isEmbedded == false)) { + if ((CheckIfProperClass(null, value, null) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + PrivateLateBoundObject.Path = value; + } + } + } + + // Public static scope property which is used by the various methods. + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public static System.Management.ManagementScope StaticScope { + get { + return statMgmtScope; + } + set { + statMgmtScope = value; + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"Any additional information provided to the recovery action. The meaning of this property is defined by the action in AutomaticRecoveryAction. If AutomaticRecoveryAction is 0 (""None"") or 1 (""Restart""), this value is NULL. If AutomaticRecoveryAction is 2 (""Revert to Snapshot""), this is the object path to a snapshot that should be applied on failure of the virtual machine worker process. -This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")] - public string AdditionalRecoveryInformation { - get { - return ((string)(curObj["AdditionalRecoveryInformation"])); - } - set { - curObj["AdditionalRecoveryInformation"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAllowFullSCSICommandSetNull { - get { - if ((curObj["AllowFullSCSICommandSet"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")] + public string AdditionalRecoveryInformation { + get { + return ((string)(curObj["AdditionalRecoveryInformation"])); + } + set { + curObj["AdditionalRecoveryInformation"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAllowFullSCSICommandSetNull { + get { + if ((curObj["AllowFullSCSICommandSet"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"Indicates whether SCSI commands from the guest operating system are passed to pass-through disks. If TRUE, SCSI commands emitted by the guest operating system to pass-through disks are not filtered.It is recommended that SCSI filtering remains enabled for production deployments. This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class. -Windows Server 2008: The AllowFullSCSICommandSet property is not supported.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AllowFullSCSICommandSet { - get { - if ((curObj["AllowFullSCSICommandSet"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AllowFullSCSICommandSet"])); - } - set { - curObj["AllowFullSCSICommandSet"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAllowReducedFcRedundancyNull { - get { - if ((curObj["AllowReducedFcRedundancy"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +Windows Server 2008: The AllowFullSCSICommandSet property is not supported.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AllowFullSCSICommandSet { + get { + if ((curObj["AllowFullSCSICommandSet"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AllowFullSCSICommandSet"])); + } + set { + curObj["AllowFullSCSICommandSet"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAllowReducedFcRedundancyNull { + get { + if ((curObj["AllowReducedFcRedundancy"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"Indicates whether live migration of a virtual machine that is configured with a virtual FC adapter is allowed to a destination machine, without doing any checks for the existence of paths to the storage devices on the destination The default value of this property is FALSE. If set to TRUE, the VM can be live migrated to a target machine which may have no or reduced paths to the target FC devices. The guest operating system may lose connectivity to storage and may behave in an unpredictable manner. - This property should be cleared after a live migration")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool AllowReducedFcRedundancy { - get { - if ((curObj["AllowReducedFcRedundancy"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["AllowReducedFcRedundancy"])); - } - set { - curObj["AllowReducedFcRedundancy"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticRecoveryActionNull { - get { - if ((curObj["AutomaticRecoveryAction"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort AutomaticRecoveryAction { - get { - if ((curObj["AutomaticRecoveryAction"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["AutomaticRecoveryAction"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticShutdownActionNull { - get { - if ((curObj["AutomaticShutdownAction"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort AutomaticShutdownAction { - get { - if ((curObj["AutomaticShutdownAction"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["AutomaticShutdownAction"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticStartupActionNull { - get { - if ((curObj["AutomaticStartupAction"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort AutomaticStartupAction { - get { - if ((curObj["AutomaticStartupAction"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["AutomaticStartupAction"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticStartupActionDelayNull { - get { - if ((curObj["AutomaticStartupActionDelay"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime AutomaticStartupActionDelay { - get { - if ((curObj["AutomaticStartupActionDelay"] != null)) { - return ToDateTime(((string)(curObj["AutomaticStartupActionDelay"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsAutomaticStartupActionSequenceNumberNull { - get { - if ((curObj["AutomaticStartupActionSequenceNumber"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public ushort AutomaticStartupActionSequenceNumber { - get { - if ((curObj["AutomaticStartupActionSequenceNumber"] == null)) { - return System.Convert.ToUInt16(0); - } - return ((ushort)(curObj["AutomaticStartupActionSequenceNumber"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The serial number of the base board for the virtual computer system.\nThis is a re" + - "ad-only property, but it can be changed using the ModifyVirtualSystem method of " + - "the Msvm_VirtualSystemManagementService class.")] - public string BaseBoardSerialNumber { - get { - return ((string)(curObj["BaseBoardSerialNumber"])); - } - set { - curObj["BaseBoardSerialNumber"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The globally-unique identifier for the BIOS of the virtual computer system.\nThis " + - "is a read-only property, but it can be changed using the ModifyVirtualSystem met" + - "hod of the Msvm_VirtualSystemManagementService class.")] - public string BIOSGUID { - get { - return ((string)(curObj["BIOSGUID"])); - } - set { - curObj["BIOSGUID"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsBIOSNumLockNull { - get { - if ((curObj["BIOSNumLock"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + This property should be cleared after a live migration")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool AllowReducedFcRedundancy { + get { + if ((curObj["AllowReducedFcRedundancy"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["AllowReducedFcRedundancy"])); + } + set { + curObj["AllowReducedFcRedundancy"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticRecoveryActionNull { + get { + if ((curObj["AutomaticRecoveryAction"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort AutomaticRecoveryAction { + get { + if ((curObj["AutomaticRecoveryAction"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["AutomaticRecoveryAction"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticShutdownActionNull { + get { + if ((curObj["AutomaticShutdownAction"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort AutomaticShutdownAction { + get { + if ((curObj["AutomaticShutdownAction"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["AutomaticShutdownAction"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticStartupActionNull { + get { + if ((curObj["AutomaticStartupAction"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort AutomaticStartupAction { + get { + if ((curObj["AutomaticStartupAction"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["AutomaticStartupAction"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticStartupActionDelayNull { + get { + if ((curObj["AutomaticStartupActionDelay"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime AutomaticStartupActionDelay { + get { + if ((curObj["AutomaticStartupActionDelay"] != null)) { + return ToDateTime(((string)(curObj["AutomaticStartupActionDelay"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsAutomaticStartupActionSequenceNumberNull { + get { + if ((curObj["AutomaticStartupActionSequenceNumber"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public ushort AutomaticStartupActionSequenceNumber { + get { + if ((curObj["AutomaticStartupActionSequenceNumber"] == null)) { + return System.Convert.ToUInt16(0); + } + return ((ushort)(curObj["AutomaticStartupActionSequenceNumber"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The serial number of the base board for the virtual computer system.\nThis is a re" + + "ad-only property, but it can be changed using the ModifyVirtualSystem method of " + + "the Msvm_VirtualSystemManagementService class.")] + public string BaseBoardSerialNumber { + get { + return ((string)(curObj["BaseBoardSerialNumber"])); + } + set { + curObj["BaseBoardSerialNumber"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The globally-unique identifier for the BIOS of the virtual computer system.\nThis " + + "is a read-only property, but it can be changed using the ModifyVirtualSystem met" + + "hod of the Msvm_VirtualSystemManagementService class.")] + public string BIOSGUID { + get { + return ((string)(curObj["BIOSGUID"])); + } + set { + curObj["BIOSGUID"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsBIOSNumLockNull { + get { + if ((curObj["BIOSNumLock"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"This property is set to TRUE if the num lock key is set to on by the BIOS, FALSE if the num lock key is set to off by the BIOS. -This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool BIOSNumLock { - get { - if ((curObj["BIOSNumLock"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["BIOSNumLock"])); - } - set { - curObj["BIOSNumLock"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The serial number of the BIOS for the virtual computer system.\nThis is a read-onl" + - "y property, but it can be changed using the ModifyVirtualSystem method of the Ms" + - "vm_VirtualSystemManagementService class.")] - public string BIOSSerialNumber { - get { - return ((string)(curObj["BIOSSerialNumber"])); - } - set { - curObj["BIOSSerialNumber"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool BIOSNumLock { + get { + if ((curObj["BIOSNumLock"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["BIOSNumLock"])); + } + set { + curObj["BIOSNumLock"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The serial number of the BIOS for the virtual computer system.\nThis is a read-onl" + + "y property, but it can be changed using the ModifyVirtualSystem method of the Ms" + + "vm_VirtualSystemManagementService class.")] + public string BIOSSerialNumber { + get { + return ((string)(curObj["BIOSSerialNumber"])); + } + set { + curObj["BIOSSerialNumber"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"The boot order set within the BIOS of the virtual computer system. This property is an array of values, max length 4, where each value indicates a device to boot from. The virtual computer system will first attempt to boot from the device indicated by the first value within the array. If that device does not contain a boot sector, the virtual computer system will attempt to boot from the next device specified by the BootOrder property and so on. If no device specified within the BootOrder contains a boot sector the virtual computer system will fail to boot. The default value for a virtual computer system is [0, 1, 2, 3, 4]. Value definitions: 0 (Floppy): The virtual computer system will attempt to boot from the floppy disk within the floppy drive. @@ -534,1157 +534,1157 @@ Value definitions: 3 (PXE Boot): The virtual computer system will attempt to PXE boot from the network. 4 (SCSI Hard Drive): The virtual computer system will attempt to boot from the first hard drive found attached to a SCSI controller with a boot sector. 5-65535: Reserved -This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")] - public ushort[] BootOrder { - get { - return ((ushort[])(curObj["BootOrder"])); - } - set { - curObj["BootOrder"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Caption { - get { - return ((string)(curObj["Caption"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The asset tag of the chassis for the virtual computer system.\nThis is a read-only" + - " property, but it can be changed using the ModifyVirtualSystem method of the Msv" + - "m_VirtualSystemManagementService class.")] - public string ChassisAssetTag { - get { - return ((string)(curObj["ChassisAssetTag"])); - } - set { - curObj["ChassisAssetTag"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The serial number of the chassis for the virtual computer system.\nThis is a read-" + - "only property, but it can be changed using the ModifyVirtualSystem method of the" + - " Msvm_VirtualSystemManagementService class.")] - public string ChassisSerialNumber { - get { - return ((string)(curObj["ChassisSerialNumber"])); - } - set { - curObj["ChassisSerialNumber"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ConfigurationDataRoot { - get { - return ((string)(curObj["ConfigurationDataRoot"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ConfigurationFile { - get { - return ((string)(curObj["ConfigurationFile"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ConfigurationID { - get { - return ((string)(curObj["ConfigurationID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsCreationTimeNull { - get { - if ((curObj["CreationTime"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [TypeConverter(typeof(WMIValueTypeConverter))] - public System.DateTime CreationTime { - get { - if ((curObj["CreationTime"] != null)) { - return ToDateTime(((string)(curObj["CreationTime"]))); - } - else { - return System.DateTime.MinValue; - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDebugChannelIdNull { - get { - if ((curObj["DebugChannelId"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The channel identifier used to debug the virtual system using the VUD unified deb" + - "ugger.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint DebugChannelId { - get { - if ((curObj["DebugChannelId"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["DebugChannelId"])); - } - set { - curObj["DebugChannelId"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDebugPortNull { - get { - if ((curObj["DebugPort"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The tcpip port used to debug the virtual system using synthetic debugging.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public uint DebugPort { - get { - if ((curObj["DebugPort"] == null)) { - return System.Convert.ToUInt32(0); - } - return ((uint)(curObj["DebugPort"])); - } - set { - curObj["DebugPort"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDebugPortEnabledNull { - get { - if ((curObj["DebugPortEnabled"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Whether the virtual system is using synthetic debugging.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public DebugPortEnabledValues DebugPortEnabled { - get { - if ((curObj["DebugPortEnabled"] == null)) { - return ((DebugPortEnabledValues)(System.Convert.ToInt32(3))); - } - return ((DebugPortEnabledValues)(System.Convert.ToInt32(curObj["DebugPortEnabled"]))); - } - set { - if ((DebugPortEnabledValues.NULL_ENUM_VALUE == value)) { - curObj["DebugPortEnabled"] = null; - } - else { - curObj["DebugPortEnabled"] = value; - } - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string Description { - get { - return ((string)(curObj["Description"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string ElementName { - get { - return ((string)(curObj["ElementName"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsIncrementalBackupEnabledNull { - get { - if ((curObj["IncrementalBackupEnabled"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("Indicates whether the Hyper-V VSS writer supports taking incremental backup of th" + - "is Virtual machine.\nThis is a read-write property.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool IncrementalBackupEnabled { - get { - if ((curObj["IncrementalBackupEnabled"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["IncrementalBackupEnabled"])); - } - set { - curObj["IncrementalBackupEnabled"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string InstanceID { - get { - return ((string)(curObj["InstanceID"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsIsSavedNull { - get { - if ((curObj["IsSaved"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")] + public ushort[] BootOrder { + get { + return ((ushort[])(curObj["BootOrder"])); + } + set { + curObj["BootOrder"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Caption { + get { + return ((string)(curObj["Caption"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The asset tag of the chassis for the virtual computer system.\nThis is a read-only" + + " property, but it can be changed using the ModifyVirtualSystem method of the Msv" + + "m_VirtualSystemManagementService class.")] + public string ChassisAssetTag { + get { + return ((string)(curObj["ChassisAssetTag"])); + } + set { + curObj["ChassisAssetTag"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The serial number of the chassis for the virtual computer system.\nThis is a read-" + + "only property, but it can be changed using the ModifyVirtualSystem method of the" + + " Msvm_VirtualSystemManagementService class.")] + public string ChassisSerialNumber { + get { + return ((string)(curObj["ChassisSerialNumber"])); + } + set { + curObj["ChassisSerialNumber"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ConfigurationDataRoot { + get { + return ((string)(curObj["ConfigurationDataRoot"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ConfigurationFile { + get { + return ((string)(curObj["ConfigurationFile"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ConfigurationID { + get { + return ((string)(curObj["ConfigurationID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsCreationTimeNull { + get { + if ((curObj["CreationTime"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [TypeConverter(typeof(WMIValueTypeConverter))] + public System.DateTime CreationTime { + get { + if ((curObj["CreationTime"] != null)) { + return ToDateTime(((string)(curObj["CreationTime"]))); + } + else { + return System.DateTime.MinValue; + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDebugChannelIdNull { + get { + if ((curObj["DebugChannelId"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The channel identifier used to debug the virtual system using the VUD unified deb" + + "ugger.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint DebugChannelId { + get { + if ((curObj["DebugChannelId"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["DebugChannelId"])); + } + set { + curObj["DebugChannelId"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDebugPortNull { + get { + if ((curObj["DebugPort"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The tcpip port used to debug the virtual system using synthetic debugging.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public uint DebugPort { + get { + if ((curObj["DebugPort"] == null)) { + return System.Convert.ToUInt32(0); + } + return ((uint)(curObj["DebugPort"])); + } + set { + curObj["DebugPort"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsDebugPortEnabledNull { + get { + if ((curObj["DebugPortEnabled"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Whether the virtual system is using synthetic debugging.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public DebugPortEnabledValues DebugPortEnabled { + get { + if ((curObj["DebugPortEnabled"] == null)) { + return ((DebugPortEnabledValues)(System.Convert.ToInt32(3))); + } + return ((DebugPortEnabledValues)(System.Convert.ToInt32(curObj["DebugPortEnabled"]))); + } + set { + if ((DebugPortEnabledValues.NULL_ENUM_VALUE == value)) { + curObj["DebugPortEnabled"] = null; + } + else { + curObj["DebugPortEnabled"] = value; + } + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Description { + get { + return ((string)(curObj["Description"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string ElementName { + get { + return ((string)(curObj["ElementName"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsIncrementalBackupEnabledNull { + get { + if ((curObj["IncrementalBackupEnabled"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("Indicates whether the Hyper-V VSS writer supports taking incremental backup of th" + + "is Virtual machine.\nThis is a read-write property.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool IncrementalBackupEnabled { + get { + if ((curObj["IncrementalBackupEnabled"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["IncrementalBackupEnabled"])); + } + set { + curObj["IncrementalBackupEnabled"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string InstanceID { + get { + return ((string)(curObj["InstanceID"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsIsSavedNull { + get { + if ((curObj["IsSaved"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"This property is set to TRUE if the configuration has a reference to a saved state file, FALSE if not. Note that this does not indicate the presence of such a file, only that the configuration specifies one. -This is a read-only property, it cannot be changed.")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool IsSaved { - get { - if ((curObj["IsSaved"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["IsSaved"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string LogDataRoot { - get { - return ((string)(curObj["LogDataRoot"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string[] Notes { - get { - return ((string[])(curObj["Notes"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The object path for the snapshot Msvm_VirtualSystemSettingData from which this ob" + - "ject is based. This property will be NULL if this object is not based off a snap" + - "shot.")] - public string Parent { - get { - return ((string)(curObj["Parent"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string RecoveryFile { - get { - return ((string)(curObj["RecoveryFile"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SnapshotDataRoot { - get { - return ((string)(curObj["SnapshotDataRoot"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SuspendDataRoot { - get { - return ((string)(curObj["SuspendDataRoot"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SwapFileDataRoot { - get { - return ((string)(curObj["SwapFileDataRoot"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The version of the virtual system in a format of \"major.minor\", for example \"2.0\"" + - ".\nWindows Server 2008: The Version property is not supported.")] - public string Version { - get { - return ((string)(curObj["Version"])); - } - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsVirtualNumaEnabledNull { - get { - if ((curObj["VirtualNumaEnabled"] == null)) { - return true; - } - else { - return false; - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] +This is a read-only property, it cannot be changed.")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool IsSaved { + get { + if ((curObj["IsSaved"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["IsSaved"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string LogDataRoot { + get { + return ((string)(curObj["LogDataRoot"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string[] Notes { + get { + return ((string[])(curObj["Notes"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The object path for the snapshot Msvm_VirtualSystemSettingData from which this ob" + + "ject is based. This property will be NULL if this object is not based off a snap" + + "shot.")] + public string Parent { + get { + return ((string)(curObj["Parent"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string RecoveryFile { + get { + return ((string)(curObj["RecoveryFile"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SnapshotDataRoot { + get { + return ((string)(curObj["SnapshotDataRoot"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SuspendDataRoot { + get { + return ((string)(curObj["SuspendDataRoot"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string SwapFileDataRoot { + get { + return ((string)(curObj["SwapFileDataRoot"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The version of the virtual system in a format of \"major.minor\", for example \"2.0\"" + + ".\nWindows Server 2008: The Version property is not supported.")] + public string Version { + get { + return ((string)(curObj["Version"])); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsVirtualNumaEnabledNull { + get { + if ((curObj["VirtualNumaEnabled"] == null)) { + return true; + } + else { + return false; + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"Indicates whether virtual non-uniform memory access (NUMA) nodes are projected into the virtual machine. If FALSE, the virtual machine will have a single node. If TRUE, the number of virtual NUMA nodes projected into the virtual machine is determined from the values of the Msvm_ProcessorSettingData.MaxProcessorsPerNumaNode and Msvm_MemorySettingData.MaxMemoryBlocksPerNumaNode properties. -")] - [TypeConverter(typeof(WMIValueTypeConverter))] - public bool VirtualNumaEnabled { - get { - if ((curObj["VirtualNumaEnabled"] == null)) { - return System.Convert.ToBoolean(0); - } - return ((bool)(curObj["VirtualNumaEnabled"])); - } - set { - curObj["VirtualNumaEnabled"] = value; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description("The name of the CIM_ComputerSystem to which this setting data belongs")] - public string VirtualSystemIdentifier { - get { - return ((string)(curObj["VirtualSystemIdentifier"])); - } - } - - [Browsable(true)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string VirtualSystemType { - get { - return ((string)(curObj["VirtualSystemType"])); - } - } - - private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) - && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); - } - } - - private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) - && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { - return true; - } - else { - System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); - if ((parentClasses != null)) { - int count = 0; - for (count = 0; (count < parentClasses.Length); count = (count + 1)) { - if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { - return true; - } - } - } - } - return false; - } - - private void ResetAdditionalRecoveryInformation() { - curObj["AdditionalRecoveryInformation"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeAllowFullSCSICommandSet() { - if ((this.IsAllowFullSCSICommandSetNull == false)) { - return true; - } - return false; - } - - private void ResetAllowFullSCSICommandSet() { - curObj["AllowFullSCSICommandSet"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeAllowReducedFcRedundancy() { - if ((this.IsAllowReducedFcRedundancyNull == false)) { - return true; - } - return false; - } - - private void ResetAllowReducedFcRedundancy() { - curObj["AllowReducedFcRedundancy"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeAutomaticRecoveryAction() { - if ((this.IsAutomaticRecoveryActionNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticShutdownAction() { - if ((this.IsAutomaticShutdownActionNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticStartupAction() { - if ((this.IsAutomaticStartupActionNull == false)) { - return true; - } - return false; - } - - // Converts a given datetime in DMTF format to System.DateTime object. - static System.DateTime ToDateTime(string dmtfDate) { - System.DateTime initializer = System.DateTime.MinValue; - int year = initializer.Year; - int month = initializer.Month; - int day = initializer.Day; - int hour = initializer.Hour; - int minute = initializer.Minute; - int second = initializer.Second; - long ticks = 0; - string dmtf = dmtfDate; - System.DateTime datetime = System.DateTime.MinValue; - string tempString = string.Empty; - if ((dmtf == null)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length == 0)) { - throw new System.ArgumentOutOfRangeException(); - } - if ((dmtf.Length != 25)) { - throw new System.ArgumentOutOfRangeException(); - } - try { - tempString = dmtf.Substring(0, 4); - if (("****" != tempString)) { - year = int.Parse(tempString); - } - tempString = dmtf.Substring(4, 2); - if (("**" != tempString)) { - month = int.Parse(tempString); - } - tempString = dmtf.Substring(6, 2); - if (("**" != tempString)) { - day = int.Parse(tempString); - } - tempString = dmtf.Substring(8, 2); - if (("**" != tempString)) { - hour = int.Parse(tempString); - } - tempString = dmtf.Substring(10, 2); - if (("**" != tempString)) { - minute = int.Parse(tempString); - } - tempString = dmtf.Substring(12, 2); - if (("**" != tempString)) { - second = int.Parse(tempString); - } - tempString = dmtf.Substring(15, 6); - if (("******" != tempString)) { - ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); - } - if (((((((((year < 0) - || (month < 0)) - || (day < 0)) - || (hour < 0)) - || (minute < 0)) - || (minute < 0)) - || (second < 0)) - || (ticks < 0))) { - throw new System.ArgumentOutOfRangeException(); - } - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - datetime = new System.DateTime(year, month, day, hour, minute, second, 0); - datetime = datetime.AddTicks(ticks); - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); - int UTCOffset = 0; - int OffsetToBeAdjusted = 0; - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - tempString = dmtf.Substring(22, 3); - if ((tempString != "******")) { - tempString = dmtf.Substring(21, 4); - try { - UTCOffset = int.Parse(tempString); - } - catch (System.Exception e) { - throw new System.ArgumentOutOfRangeException(null, e.Message); - } - OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); - datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); - } - return datetime; - } - - // Converts a given System.DateTime object to DMTF datetime format. - static string ToDmtfDateTime(System.DateTime date) { - string utcString = string.Empty; - System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); - long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); - if ((System.Math.Abs(OffsetMins) > 999)) { - date = date.ToUniversalTime(); - utcString = "+000"; - } - else { - if ((tickOffset.Ticks >= 0)) { - utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); - } - else { - string strTemp = ((long)(OffsetMins)).ToString(); - utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); - } - } - string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, "."); - System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((long)((((date.Ticks - dtTemp.Ticks) - * 1000) - / System.TimeSpan.TicksPerMillisecond))); - string strMicrosec = ((long)(microsec)).ToString(); - if ((strMicrosec.Length > 6)) { - strMicrosec = strMicrosec.Substring(0, 6); - } - dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); - dmtfDateTime = string.Concat(dmtfDateTime, utcString); - return dmtfDateTime; - } - - private bool ShouldSerializeAutomaticStartupActionDelay() { - if ((this.IsAutomaticStartupActionDelayNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeAutomaticStartupActionSequenceNumber() { - if ((this.IsAutomaticStartupActionSequenceNumberNull == false)) { - return true; - } - return false; - } - - private void ResetBaseBoardSerialNumber() { - curObj["BaseBoardSerialNumber"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetBIOSGUID() { - curObj["BIOSGUID"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeBIOSNumLock() { - if ((this.IsBIOSNumLockNull == false)) { - return true; - } - return false; - } - - private void ResetBIOSNumLock() { - curObj["BIOSNumLock"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetBIOSSerialNumber() { - curObj["BIOSSerialNumber"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetBootOrder() { - curObj["BootOrder"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetChassisAssetTag() { - curObj["ChassisAssetTag"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private void ResetChassisSerialNumber() { - curObj["ChassisSerialNumber"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeCreationTime() { - if ((this.IsCreationTimeNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeDebugChannelId() { - if ((this.IsDebugChannelIdNull == false)) { - return true; - } - return false; - } - - private void ResetDebugChannelId() { - curObj["DebugChannelId"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeDebugPort() { - if ((this.IsDebugPortNull == false)) { - return true; - } - return false; - } - - private void ResetDebugPort() { - curObj["DebugPort"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeDebugPortEnabled() { - if ((this.IsDebugPortEnabledNull == false)) { - return true; - } - return false; - } - - private void ResetDebugPortEnabled() { - curObj["DebugPortEnabled"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeIncrementalBackupEnabled() { - if ((this.IsIncrementalBackupEnabledNull == false)) { - return true; - } - return false; - } - - private void ResetIncrementalBackupEnabled() { - curObj["IncrementalBackupEnabled"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - private bool ShouldSerializeIsSaved() { - if ((this.IsIsSavedNull == false)) { - return true; - } - return false; - } - - private bool ShouldSerializeVirtualNumaEnabled() { - if ((this.IsVirtualNumaEnabledNull == false)) { - return true; - } - return false; - } - - private void ResetVirtualNumaEnabled() { - curObj["VirtualNumaEnabled"] = null; - if (((isEmbedded == false) - && (AutoCommitProp == true))) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject() { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(); - } - } - - [Browsable(true)] - public void CommitObject(System.Management.PutOptions putOptions) { - if ((isEmbedded == false)) { - PrivateLateBoundObject.Put(putOptions); - } - } - - private void Initialize() { - AutoCommitProp = true; - isEmbedded = false; - } - - private static string ConstructPath(string keyInstanceID) { - string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemSettingData"; - strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); - return strPath; - } - - private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { - Initialize(); - if ((path != null)) { - if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { - throw new System.ArgumentException("Class name does not match."); - } - } - PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); - PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); - curObj = PrivateLateBoundObject; - } - - // Different overloads of GetInstances() help in enumerating instances of the WMI class. - public static VirtualSystemSettingDataCollection GetInstances() { - return GetInstances(null, null, null); - } - - public static VirtualSystemSettingDataCollection GetInstances(string condition) { - return GetInstances(null, condition, null); - } - - public static VirtualSystemSettingDataCollection GetInstances(string[] selectedProperties) { - return GetInstances(null, null, selectedProperties); - } - - public static VirtualSystemSettingDataCollection GetInstances(string condition, string[] selectedProperties) { - return GetInstances(null, condition, selectedProperties); - } - - public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); - pathObj.ClassName = "Msvm_VirtualSystemSettingData"; - pathObj.NamespacePath = "root\\virtualization\\v2"; - System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); - if ((enumOptions == null)) { - enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - } - return new VirtualSystemSettingDataCollection(clsObject.GetInstances(enumOptions)); - } - - public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { - return GetInstances(mgmtScope, condition, null); - } - - public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { - return GetInstances(mgmtScope, null, selectedProperties); - } - - public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { - if ((mgmtScope == null)) { - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; - } - else { - mgmtScope = statMgmtScope; - } - } - System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemSettingData", condition, selectedProperties)); - System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); - enumOptions.EnsureLocatable = true; - ObjectSearcher.Options = enumOptions; - return new VirtualSystemSettingDataCollection(ObjectSearcher.Get()); - } - - [Browsable(true)] - public static VirtualSystemSettingData CreateInstance() { - System.Management.ManagementScope mgmtScope = null; - if ((statMgmtScope == null)) { - mgmtScope = new System.Management.ManagementScope(); - mgmtScope.Path.NamespacePath = CreatedWmiNamespace; - } - else { - mgmtScope = statMgmtScope; - } - System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); - System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); - return new VirtualSystemSettingData(tmpMgmtClass.CreateInstance()); - } - - [Browsable(true)] - public void Delete() { - PrivateLateBoundObject.Delete(); - } - - public enum DebugPortEnabledValues { - - Val__Off = 0, - - On = 1, - - OnAutoAssigned = 2, - - NULL_ENUM_VALUE = 3, - } - - // Enumerator implementation for enumerating instances of the class. - public class VirtualSystemSettingDataCollection : object, ICollection { - - private ManagementObjectCollection privColObj; - - public VirtualSystemSettingDataCollection(ManagementObjectCollection objCollection) { - privColObj = objCollection; - } - - public virtual int Count { - get { - return privColObj.Count; - } - } - - public virtual bool IsSynchronized { - get { - return privColObj.IsSynchronized; - } - } - - public virtual object SyncRoot { - get { - return this; - } - } - - public virtual void CopyTo(System.Array array, int index) { - privColObj.CopyTo(array, index); - int nCtr; - for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { - array.SetValue(new VirtualSystemSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); - } - } - - public virtual System.Collections.IEnumerator GetEnumerator() { - return new VirtualSystemSettingDataEnumerator(privColObj.GetEnumerator()); - } - - public class VirtualSystemSettingDataEnumerator : object, System.Collections.IEnumerator { - - private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - - public VirtualSystemSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { - privObjEnum = objEnum; - } - - public virtual object Current { - get { - return new VirtualSystemSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); - } - } - - public virtual bool MoveNext() { - return privObjEnum.MoveNext(); - } - - public virtual void Reset() { - privObjEnum.Reset(); - } - } - } - - // TypeConverter to handle null values for ValueType properties - public class WMIValueTypeConverter : TypeConverter { - - private TypeConverter baseConverter; - - private System.Type baseType; - - public WMIValueTypeConverter(System.Type inBaseType) { - baseConverter = TypeDescriptor.GetConverter(inBaseType); - baseType = inBaseType; - } - - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { - return baseConverter.CanConvertFrom(context, srcType); - } - - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { - return baseConverter.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - return baseConverter.ConvertFrom(context, culture, value); - } - - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { - return baseConverter.CreateInstance(context, dictionary); - } - - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetCreateInstanceSupported(context); - } - - public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { - return baseConverter.GetProperties(context, value, attributeVar); - } - - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetPropertiesSupported(context); - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValues(context); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesExclusive(context); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { - return baseConverter.GetStandardValuesSupported(context); - } - - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { - if ((baseType.BaseType == typeof(System.Enum))) { - if ((value.GetType() == destinationType)) { - return value; - } - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return "NULL_ENUM_VALUE" ; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((baseType == typeof(bool)) - && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - if (((context != null) - && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { - return ""; - } - return baseConverter.ConvertTo(context, culture, value, destinationType); - } - } - - // Embedded class to represent WMI system Properties. - [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] - public class ManagementSystemProperties { - - private System.Management.ManagementBaseObject PrivateLateBoundObject; - - public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { - PrivateLateBoundObject = ManagedObject; - } - - [Browsable(true)] - public int GENUS { - get { - return ((int)(PrivateLateBoundObject["__GENUS"])); - } - } - - [Browsable(true)] - public string CLASS { - get { - return ((string)(PrivateLateBoundObject["__CLASS"])); - } - } - - [Browsable(true)] - public string SUPERCLASS { - get { - return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); - } - } - - [Browsable(true)] - public string DYNASTY { - get { - return ((string)(PrivateLateBoundObject["__DYNASTY"])); - } - } - - [Browsable(true)] - public string RELPATH { - get { - return ((string)(PrivateLateBoundObject["__RELPATH"])); - } - } - - [Browsable(true)] - public int PROPERTY_COUNT { - get { - return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); - } - } - - [Browsable(true)] - public string[] DERIVATION { - get { - return ((string[])(PrivateLateBoundObject["__DERIVATION"])); - } - } - - [Browsable(true)] - public string SERVER { - get { - return ((string)(PrivateLateBoundObject["__SERVER"])); - } - } - - [Browsable(true)] - public string NAMESPACE { - get { - return ((string)(PrivateLateBoundObject["__NAMESPACE"])); - } - } - - [Browsable(true)] - public string PATH { - get { - return ((string)(PrivateLateBoundObject["__PATH"])); - } - } - } - } -} +")] + [TypeConverter(typeof(WMIValueTypeConverter))] + public bool VirtualNumaEnabled { + get { + if ((curObj["VirtualNumaEnabled"] == null)) { + return System.Convert.ToBoolean(0); + } + return ((bool)(curObj["VirtualNumaEnabled"])); + } + set { + curObj["VirtualNumaEnabled"] = value; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Description("The name of the CIM_ComputerSystem to which this setting data belongs")] + public string VirtualSystemIdentifier { + get { + return ((string)(curObj["VirtualSystemIdentifier"])); + } + } + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string VirtualSystemType { + get { + return ((string)(curObj["VirtualSystemType"])); + } + } + + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { + if (((path != null) + && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); + } + } + + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { + if (((theObj != null) + && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { + return true; + } + else { + System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"])); + if ((parentClasses != null)) { + int count = 0; + for (count = 0; (count < parentClasses.Length); count = (count + 1)) { + if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) { + return true; + } + } + } + } + return false; + } + + private void ResetAdditionalRecoveryInformation() { + curObj["AdditionalRecoveryInformation"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeAllowFullSCSICommandSet() { + if ((this.IsAllowFullSCSICommandSetNull == false)) { + return true; + } + return false; + } + + private void ResetAllowFullSCSICommandSet() { + curObj["AllowFullSCSICommandSet"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeAllowReducedFcRedundancy() { + if ((this.IsAllowReducedFcRedundancyNull == false)) { + return true; + } + return false; + } + + private void ResetAllowReducedFcRedundancy() { + curObj["AllowReducedFcRedundancy"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeAutomaticRecoveryAction() { + if ((this.IsAutomaticRecoveryActionNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticShutdownAction() { + if ((this.IsAutomaticShutdownActionNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticStartupAction() { + if ((this.IsAutomaticStartupActionNull == false)) { + return true; + } + return false; + } + + // Converts a given datetime in DMTF format to System.DateTime object. + static System.DateTime ToDateTime(string dmtfDate) { + System.DateTime initializer = System.DateTime.MinValue; + int year = initializer.Year; + int month = initializer.Month; + int day = initializer.Day; + int hour = initializer.Hour; + int minute = initializer.Minute; + int second = initializer.Second; + long ticks = 0; + string dmtf = dmtfDate; + System.DateTime datetime = System.DateTime.MinValue; + string tempString = string.Empty; + if ((dmtf == null)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length == 0)) { + throw new System.ArgumentOutOfRangeException(); + } + if ((dmtf.Length != 25)) { + throw new System.ArgumentOutOfRangeException(); + } + try { + tempString = dmtf.Substring(0, 4); + if (("****" != tempString)) { + year = int.Parse(tempString); + } + tempString = dmtf.Substring(4, 2); + if (("**" != tempString)) { + month = int.Parse(tempString); + } + tempString = dmtf.Substring(6, 2); + if (("**" != tempString)) { + day = int.Parse(tempString); + } + tempString = dmtf.Substring(8, 2); + if (("**" != tempString)) { + hour = int.Parse(tempString); + } + tempString = dmtf.Substring(10, 2); + if (("**" != tempString)) { + minute = int.Parse(tempString); + } + tempString = dmtf.Substring(12, 2); + if (("**" != tempString)) { + second = int.Parse(tempString); + } + tempString = dmtf.Substring(15, 6); + if (("******" != tempString)) { + ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000)))); + } + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) + || (ticks < 0))) { + throw new System.ArgumentOutOfRangeException(); + } + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + datetime = new System.DateTime(year, month, day, hour, minute, second, 0); + datetime = datetime.AddTicks(ticks); + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime); + int UTCOffset = 0; + int OffsetToBeAdjusted = 0; + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + tempString = dmtf.Substring(22, 3); + if ((tempString != "******")) { + tempString = dmtf.Substring(21, 4); + try { + UTCOffset = int.Parse(tempString); + } + catch (System.Exception e) { + throw new System.ArgumentOutOfRangeException(null, e.Message); + } + OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset))); + datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted))); + } + return datetime; + } + + // Converts a given System.DateTime object to DMTF datetime format. + static string ToDmtfDateTime(System.DateTime date) { + string utcString = string.Empty; + System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date); + long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))); + if ((System.Math.Abs(OffsetMins) > 999)) { + date = date.ToUniversalTime(); + utcString = "+000"; + } + else { + if ((tickOffset.Ticks >= 0)) { + utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0')); + } + else { + string strTemp = ((long)(OffsetMins)).ToString(); + utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0')); + } + } + string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0'); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, "."); + System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) + / System.TimeSpan.TicksPerMillisecond))); + string strMicrosec = ((long)(microsec)).ToString(); + if ((strMicrosec.Length > 6)) { + strMicrosec = strMicrosec.Substring(0, 6); + } + dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0')); + dmtfDateTime = string.Concat(dmtfDateTime, utcString); + return dmtfDateTime; + } + + private bool ShouldSerializeAutomaticStartupActionDelay() { + if ((this.IsAutomaticStartupActionDelayNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeAutomaticStartupActionSequenceNumber() { + if ((this.IsAutomaticStartupActionSequenceNumberNull == false)) { + return true; + } + return false; + } + + private void ResetBaseBoardSerialNumber() { + curObj["BaseBoardSerialNumber"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetBIOSGUID() { + curObj["BIOSGUID"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeBIOSNumLock() { + if ((this.IsBIOSNumLockNull == false)) { + return true; + } + return false; + } + + private void ResetBIOSNumLock() { + curObj["BIOSNumLock"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetBIOSSerialNumber() { + curObj["BIOSSerialNumber"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetBootOrder() { + curObj["BootOrder"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetChassisAssetTag() { + curObj["ChassisAssetTag"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private void ResetChassisSerialNumber() { + curObj["ChassisSerialNumber"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeCreationTime() { + if ((this.IsCreationTimeNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeDebugChannelId() { + if ((this.IsDebugChannelIdNull == false)) { + return true; + } + return false; + } + + private void ResetDebugChannelId() { + curObj["DebugChannelId"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeDebugPort() { + if ((this.IsDebugPortNull == false)) { + return true; + } + return false; + } + + private void ResetDebugPort() { + curObj["DebugPort"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeDebugPortEnabled() { + if ((this.IsDebugPortEnabledNull == false)) { + return true; + } + return false; + } + + private void ResetDebugPortEnabled() { + curObj["DebugPortEnabled"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeIncrementalBackupEnabled() { + if ((this.IsIncrementalBackupEnabledNull == false)) { + return true; + } + return false; + } + + private void ResetIncrementalBackupEnabled() { + curObj["IncrementalBackupEnabled"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + private bool ShouldSerializeIsSaved() { + if ((this.IsIsSavedNull == false)) { + return true; + } + return false; + } + + private bool ShouldSerializeVirtualNumaEnabled() { + if ((this.IsVirtualNumaEnabledNull == false)) { + return true; + } + return false; + } + + private void ResetVirtualNumaEnabled() { + curObj["VirtualNumaEnabled"] = null; + if (((isEmbedded == false) + && (AutoCommitProp == true))) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject() { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(); + } + } + + [Browsable(true)] + public void CommitObject(System.Management.PutOptions putOptions) { + if ((isEmbedded == false)) { + PrivateLateBoundObject.Put(putOptions); + } + } + + private void Initialize() { + AutoCommitProp = true; + isEmbedded = false; + } + + private static string ConstructPath(string keyInstanceID) { + string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemSettingData"; + strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); + return strPath; + } + + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { + Initialize(); + if ((path != null)) { + if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) { + throw new System.ArgumentException("Class name does not match."); + } + } + PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions); + PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); + curObj = PrivateLateBoundObject; + } + + // Different overloads of GetInstances() help in enumerating instances of the WMI class. + public static VirtualSystemSettingDataCollection GetInstances() { + return GetInstances(null, null, null); + } + + public static VirtualSystemSettingDataCollection GetInstances(string condition) { + return GetInstances(null, condition, null); + } + + public static VirtualSystemSettingDataCollection GetInstances(string[] selectedProperties) { + return GetInstances(null, null, selectedProperties); + } + + public static VirtualSystemSettingDataCollection GetInstances(string condition, string[] selectedProperties) { + return GetInstances(null, condition, selectedProperties); + } + + public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementPath pathObj = new System.Management.ManagementPath(); + pathObj.ClassName = "Msvm_VirtualSystemSettingData"; + pathObj.NamespacePath = "root\\virtualization\\v2"; + System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null); + if ((enumOptions == null)) { + enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + } + return new VirtualSystemSettingDataCollection(clsObject.GetInstances(enumOptions)); + } + + public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { + return GetInstances(mgmtScope, condition, null); + } + + public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { + return GetInstances(mgmtScope, null, selectedProperties); + } + + public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { + if ((mgmtScope == null)) { + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = "root\\virtualization\\v2"; + } + else { + mgmtScope = statMgmtScope; + } + } + System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemSettingData", condition, selectedProperties)); + System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions(); + enumOptions.EnsureLocatable = true; + ObjectSearcher.Options = enumOptions; + return new VirtualSystemSettingDataCollection(ObjectSearcher.Get()); + } + + [Browsable(true)] + public static VirtualSystemSettingData CreateInstance() { + System.Management.ManagementScope mgmtScope = null; + if ((statMgmtScope == null)) { + mgmtScope = new System.Management.ManagementScope(); + mgmtScope.Path.NamespacePath = CreatedWmiNamespace; + } + else { + mgmtScope = statMgmtScope; + } + System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName); + System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); + return new VirtualSystemSettingData(tmpMgmtClass.CreateInstance()); + } + + [Browsable(true)] + public void Delete() { + PrivateLateBoundObject.Delete(); + } + + public enum DebugPortEnabledValues { + + Val__Off = 0, + + On = 1, + + OnAutoAssigned = 2, + + NULL_ENUM_VALUE = 3, + } + + // Enumerator implementation for enumerating instances of the class. + public class VirtualSystemSettingDataCollection : object, ICollection { + + private ManagementObjectCollection privColObj; + + public VirtualSystemSettingDataCollection(ManagementObjectCollection objCollection) { + privColObj = objCollection; + } + + public virtual int Count { + get { + return privColObj.Count; + } + } + + public virtual bool IsSynchronized { + get { + return privColObj.IsSynchronized; + } + } + + public virtual object SyncRoot { + get { + return this; + } + } + + public virtual void CopyTo(System.Array array, int index) { + privColObj.CopyTo(array, index); + int nCtr; + for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) { + array.SetValue(new VirtualSystemSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); + } + } + + public virtual System.Collections.IEnumerator GetEnumerator() { + return new VirtualSystemSettingDataEnumerator(privColObj.GetEnumerator()); + } + + public class VirtualSystemSettingDataEnumerator : object, System.Collections.IEnumerator { + + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; + + public VirtualSystemSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { + privObjEnum = objEnum; + } + + public virtual object Current { + get { + return new VirtualSystemSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); + } + } + + public virtual bool MoveNext() { + return privObjEnum.MoveNext(); + } + + public virtual void Reset() { + privObjEnum.Reset(); + } + } + } + + // TypeConverter to handle null values for ValueType properties + public class WMIValueTypeConverter : TypeConverter { + + private TypeConverter baseConverter; + + private System.Type baseType; + + public WMIValueTypeConverter(System.Type inBaseType) { + baseConverter = TypeDescriptor.GetConverter(inBaseType); + baseType = inBaseType; + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { + return baseConverter.CanConvertFrom(context, srcType); + } + + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { + return baseConverter.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { + return baseConverter.ConvertFrom(context, culture, value); + } + + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { + return baseConverter.CreateInstance(context, dictionary); + } + + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetCreateInstanceSupported(context); + } + + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { + return baseConverter.GetProperties(context, value, attributeVar); + } + + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetPropertiesSupported(context); + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValues(context); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesExclusive(context); + } + + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { + return baseConverter.GetStandardValuesSupported(context); + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { + if ((baseType.BaseType == typeof(System.Enum))) { + if ((value.GetType() == destinationType)) { + return value; + } + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return "NULL_ENUM_VALUE" ; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((baseType == typeof(bool)) + && (baseType.BaseType == typeof(System.ValueType)))) { + if ((((value == null) + && (context != null)) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + if (((context != null) + && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { + return ""; + } + return baseConverter.ConvertTo(context, culture, value, destinationType); + } + } + + // Embedded class to represent WMI system Properties. + [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] + public class ManagementSystemProperties { + + private System.Management.ManagementBaseObject PrivateLateBoundObject; + + public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) { + PrivateLateBoundObject = ManagedObject; + } + + [Browsable(true)] + public int GENUS { + get { + return ((int)(PrivateLateBoundObject["__GENUS"])); + } + } + + [Browsable(true)] + public string CLASS { + get { + return ((string)(PrivateLateBoundObject["__CLASS"])); + } + } + + [Browsable(true)] + public string SUPERCLASS { + get { + return ((string)(PrivateLateBoundObject["__SUPERCLASS"])); + } + } + + [Browsable(true)] + public string DYNASTY { + get { + return ((string)(PrivateLateBoundObject["__DYNASTY"])); + } + } + + [Browsable(true)] + public string RELPATH { + get { + return ((string)(PrivateLateBoundObject["__RELPATH"])); + } + } + + [Browsable(true)] + public int PROPERTY_COUNT { + get { + return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"])); + } + } + + [Browsable(true)] + public string[] DERIVATION { + get { + return ((string[])(PrivateLateBoundObject["__DERIVATION"])); + } + } + + [Browsable(true)] + public string SERVER { + get { + return ((string)(PrivateLateBoundObject["__SERVER"])); + } + } + + [Browsable(true)] + public string NAMESPACE { + get { + return ((string)(PrivateLateBoundObject["__NAMESPACE"])); + } + } + + [Browsable(true)] + public string PATH { + get { + return ((string)(PrivateLateBoundObject["__PATH"])); + } + } + } + } +} diff --git a/plugins/hypervisors/hyperv/buildagent.sh b/plugins/hypervisors/hyperv/buildagent.sh index e5bff6e3153..536ba437ffc 100755 --- a/plugins/hypervisors/hyperv/buildagent.sh +++ b/plugins/hypervisors/hyperv/buildagent.sh @@ -1,20 +1,22 @@ #!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at + +# 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 +# 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. +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + export EnableNuGetPackageRestore=true wget http://nuget.org/nuget.exe mv nuget.exe ./DotNet/ServerResource/.nuget/NuGet.exe diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml index 83157ce4c65..c67943ab243 100644 --- a/plugins/hypervisors/hyperv/pom.xml +++ b/plugins/hypervisors/hyperv/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/hyperv/src/main/java/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java b/plugins/hypervisors/hyperv/src/main/java/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java index 0e189d05000..55944a08242 100644 --- a/plugins/hypervisors/hyperv/src/main/java/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java +++ b/plugins/hypervisors/hyperv/src/main/java/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java @@ -155,6 +155,7 @@ public class HypervStorageMotionStrategy implements DataMotionStrategy { volumeVO.setPath(volumeTo.getPath()); volumeVO.setPodId(pool.getPodId()); volumeVO.setPoolId(pool.getId()); + volumeVO.setPoolType(pool.getPoolType()); volumeVO.setLastPoolId(oldPoolId); // For SMB, pool credentials are also stored in the uri query string. We trim the query string // part here to make sure the credentials do not get stored in the db unencrypted. diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml index ab25aa0ccc9..a7c5461e798 100644 --- a/plugins/hypervisors/kvm/pom.xml +++ b/plugins/hypervisors/kvm/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.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 a86efeb8a1f..0c97e93b64b 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 @@ -69,6 +69,7 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import com.cloud.agent.api.to.VirtualMachineMetadataTO; import org.apache.cloudstack.api.ApiConstants.IoDriverPolicy; import org.apache.cloudstack.command.CommandInfo; import org.apache.cloudstack.command.ReconcileCommandService; @@ -199,6 +200,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogAction; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogModel; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.MetadataDef; import com.cloud.hypervisor.kvm.resource.rolling.maintenance.RollingMaintenanceAgentExecutor; import com.cloud.hypervisor.kvm.resource.rolling.maintenance.RollingMaintenanceExecutor; import com.cloud.hypervisor.kvm.resource.rolling.maintenance.RollingMaintenanceServiceExecutor; @@ -882,6 +884,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv protected StorageSubsystemCommandHandler storageHandler; private boolean convertInstanceVerboseMode = false; + private String[] convertInstanceEnv = null; protected boolean dpdkSupport = false; protected String dpdkOvsPath; protected String directDownloadTemporaryDownloadPath; @@ -946,6 +949,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return convertInstanceVerboseMode; } + public String[] getConvertInstanceEnv() { + return convertInstanceEnv; + } + /** * Defines resource's public and private network interface according to what is configured in agent.properties. */ @@ -1146,6 +1153,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv convertInstanceVerboseMode = BooleanUtils.isTrue(AgentPropertiesFileHandler.getPropertyValue(AgentProperties.VIRTV2V_VERBOSE_ENABLED)); + String convertEnvTmpDir = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.CONVERT_ENV_TMPDIR); + String convertEnvVirtv2vTmpDir = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.CONVERT_ENV_VIRTV2V_TMPDIR); + + setConvertInstanceEnv(convertEnvTmpDir, convertEnvVirtv2vTmpDir); + pool = (String)params.get("pool"); if (pool == null) { pool = "/root"; @@ -1422,6 +1434,22 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return true; } + private void setConvertInstanceEnv(String convertEnvTmpDir, String convertEnvVirtv2vTmpDir) { + if (StringUtils.isAllBlank(convertEnvTmpDir, convertEnvVirtv2vTmpDir)) { + return; + } + if (StringUtils.isNotBlank(convertEnvTmpDir) && StringUtils.isNotBlank(convertEnvVirtv2vTmpDir)) { + convertInstanceEnv = new String[2]; + convertInstanceEnv[0] = String.format("%s=%s", "TMPDIR", convertEnvTmpDir); + convertInstanceEnv[1] = String.format("%s=%s", "VIRT_V2V_TMPDIR", convertEnvVirtv2vTmpDir); + } else { + convertInstanceEnv = new String[1]; + String key = StringUtils.isNotBlank(convertEnvTmpDir) ? "TMPDIR" : "VIRT_V2V_TMPDIR"; + String value = StringUtils.isNotBlank(convertEnvTmpDir) ? convertEnvTmpDir : convertEnvVirtv2vTmpDir; + convertInstanceEnv[0] = String.format("%s=%s", key, value); + } + } + /** * Parses a string containing whitespace-separated CPU feature names and converts it into a list. * @@ -2985,9 +3013,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv vm.addComp(createClockDef(vmTO)); vm.addComp(createDevicesDef(vmTO, guest, vcpus, isUefiEnabled)); + MetadataDef metaDef; + if ((metaDef = createMetadataDef(vmTO)) != null) { + vm.addComp(metaDef); + } + addExtraConfigsToVM(vmTO, vm, extraConfig); } + protected MetadataDef createMetadataDef(VirtualMachineTO vmTO) { + VirtualMachineMetadataTO metadata = vmTO.getMetadata(); + return (metadata != null) ? new MetadataDef(metadata) : null; + } + /** * Adds extra configuration to User VM Domain XML before starting. */ @@ -3255,25 +3293,25 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv setGuestLoader(bootMode, SECURE, guest, GuestDef.GUEST_LOADER_SECURE); setGuestLoader(bootMode, LEGACY, guest, GuestDef.GUEST_LOADER_LEGACY); - if (isUefiPropertieNotNull(GuestDef.GUEST_NVRAM_PATH)) { + if (isUefiPropertyNotNull(GuestDef.GUEST_NVRAM_PATH)) { guest.setNvram(uefiProperties.getProperty(GuestDef.GUEST_NVRAM_PATH)); } - if (isSecureBoot && isUefiPropertieNotNull(GuestDef.GUEST_NVRAM_TEMPLATE_SECURE) && SECURE.equalsIgnoreCase(bootMode)) { + if (isSecureBoot && isUefiPropertyNotNull(GuestDef.GUEST_NVRAM_TEMPLATE_SECURE) && SECURE.equalsIgnoreCase(bootMode)) { guest.setNvramTemplate(uefiProperties.getProperty(GuestDef.GUEST_NVRAM_TEMPLATE_SECURE)); - } else if (isUefiPropertieNotNull(GuestDef.GUEST_NVRAM_TEMPLATE_LEGACY)) { + } else if (isUefiPropertyNotNull(GuestDef.GUEST_NVRAM_TEMPLATE_LEGACY)) { guest.setNvramTemplate(uefiProperties.getProperty(GuestDef.GUEST_NVRAM_TEMPLATE_LEGACY)); } } - private void setGuestLoader(String bootMode, String mode, GuestDef guest, String propertie) { - if (isUefiPropertieNotNull(propertie) && mode.equalsIgnoreCase(bootMode)) { - guest.setLoader(uefiProperties.getProperty(propertie)); + private void setGuestLoader(String bootMode, String mode, GuestDef guest, String property) { + if (isUefiPropertyNotNull(property) && mode.equalsIgnoreCase(bootMode)) { + guest.setLoader(uefiProperties.getProperty(property)); } } - private boolean isUefiPropertieNotNull(String propertie) { - return uefiProperties.getProperty(propertie) != null; + private boolean isUefiPropertyNotNull(String property) { + return uefiProperties.getProperty(property) != null; } public boolean isGuestAarch64() { 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 46a5024bf15..211395513d5 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 @@ -17,6 +17,10 @@ package com.cloud.hypervisor.kvm.resource; import java.io.File; +import java.io.StringWriter; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -29,9 +33,25 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import com.cloud.agent.api.to.VirtualMachineMetadataTO; + import com.cloud.agent.properties.AgentProperties; import com.cloud.agent.properties.AgentPropertiesFileHandler; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME; public class LibvirtVMDef { protected static Logger LOGGER = LogManager.getLogger(LibvirtVMDef.class); @@ -46,6 +66,157 @@ public class LibvirtVMDef { private final Map components = new HashMap(); private static final int NUMBER_OF_IOTHREADS = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.IOTHREADS); + public static class MetadataDef { + private VirtualMachineMetadataTO metaTO; + + public MetadataDef(VirtualMachineMetadataTO data) { + metaTO = data; + } + + public VirtualMachineMetadataTO getMetadata() { + return metaTO; + } + + @Override + public String toString() { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true); + Document doc = null; + try { + doc = docFactory.newDocumentBuilder().newDocument(); + } catch (ParserConfigurationException e) { + LOGGER.warn("Could not create a new DOM XML document. The metadata will not be included in the libvirt domain XML: {}", e.getMessage()); + return ""; + } + Element metadata = doc.createElement("metadata"); // + Element instance = doc.createElementNS("http://cloudstack.apache.org/instance", "cloudstack:instance"); // + + Element zone = doc.createElement("cloudstack:zone"); + zone.setAttribute("uuid", metaTO.getZoneUuid()); + zone.setTextContent(metaTO.getZoneName()); + instance.appendChild(zone); + + Element pod = doc.createElement("cloudstack:pod"); + pod.setAttribute("uuid", metaTO.getPodUuid()); + pod.setTextContent(metaTO.getPodName()); + instance.appendChild(pod); + + Element cluster = doc.createElement("cloudstack:cluster"); + cluster.setAttribute("uuid", metaTO.getClusterUuid()); + cluster.setTextContent(metaTO.getClusterName()); + instance.appendChild(cluster); + + Element instanceName = doc.createElement("cloudstack:name"); + instanceName.setTextContent(metaTO.getName()); + instance.appendChild(instanceName); + + Element instanceInternalName = doc.createElement("cloudstack:internal_name"); + instanceInternalName.setTextContent(metaTO.getInternalName()); + instance.appendChild(instanceInternalName); + + Element instanceDisplayName = doc.createElement("cloudstack:display_name"); + instanceDisplayName.setTextContent(metaTO.getDisplayName()); + instance.appendChild(instanceDisplayName); + + Element instanceUuid = doc.createElement("cloudstack:uuid"); + instanceUuid.setTextContent(metaTO.getInstanceUuid()); + instance.appendChild(instanceUuid); + + Element serviceOffering = doc.createElement("cloudstack:service_offering"); // + + Element computeOfferingName = doc.createElement("cloudstack:name"); + computeOfferingName.setTextContent(metaTO.getserviceOfferingName()); + serviceOffering.appendChild(computeOfferingName); + + Element cpu = doc.createElement("cloudstack:cpu"); + cpu.setTextContent(metaTO.getCpuCores().toString()); + serviceOffering.appendChild(cpu); + + Element memory = doc.createElement("cloudstack:memory"); + memory.setTextContent(metaTO.getMemory().toString()); + serviceOffering.appendChild(memory); + + Element hostTags = doc.createElement("cloudstack:host_tags"); + List tags = metaTO.getserviceOfferingHostTags(); + if (tags != null) { + for (String i : metaTO.getserviceOfferingHostTags()) { + Element tag = doc.createElement("cloudstack:tag"); + tag.setTextContent(i); + hostTags.appendChild(tag); + } + } + serviceOffering.appendChild(hostTags); + + instance.appendChild(serviceOffering); // + + Element creationTime = doc.createElement("cloudstack:created_at"); + creationTime.setTextContent( + LocalDateTime.ofInstant(Instant.ofEpochSecond(metaTO.getCreated()), ZoneOffset.UTC).format(ISO_LOCAL_DATE_TIME) + ); + instance.appendChild(creationTime); + + Element startedTime = doc.createElement("cloudstack:started_at"); + startedTime.setTextContent( + LocalDateTime.ofInstant(Instant.ofEpochSecond(metaTO.getStarted()), ZoneOffset.UTC).format(ISO_LOCAL_DATE_TIME) + ); + instance.appendChild(startedTime); + + Element owner = doc.createElement("cloudstack:owner"); // + + Element domain = doc.createElement("cloudstack:domain"); + domain.setAttribute("uuid", metaTO.getOwnerDomainUuid()); + domain.setTextContent(metaTO.getOwnerDomainName()); + owner.appendChild(domain); + + Element account = doc.createElement("cloudstack:account"); + account.setAttribute("uuid", metaTO.getOwnerAccountUuid()); + account.setTextContent(metaTO.getOwnerAccountName()); + owner.appendChild(account); + + Element project = doc.createElement("cloudstack:project"); + project.setAttribute("uuid", metaTO.getOwnerProjectUuid()); + project.setTextContent(metaTO.getOwnerProjectName()); + owner.appendChild(project); + + instance.appendChild(owner); // + + Element resourceTags = doc.createElement("cloudstack:resource_tags"); // + for (Map.Entry entry : metaTO.getResourceTags().entrySet()) { + Element tag = doc.createElement("cloudstack:resource_tag"); // + tag.setAttribute("key", entry.getKey()); + tag.setTextContent(entry.getValue()); + resourceTags.appendChild(tag); // + } + instance.appendChild(resourceTags); // + + metadata.appendChild(instance); // + doc.appendChild(metadata); // + + Transformer transformer = null; + try { + transformer = TransformerFactory.newInstance().newTransformer(); + } catch (TransformerConfigurationException e) { + LOGGER.warn("Could not create an XML transformer. The metadata will not be included in the libvirt domain XML: {}", e.getMessage()); + return ""; + } + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + DOMSource domSource = new DOMSource(doc); + StringWriter writer = new StringWriter(); + StreamResult result = new StreamResult(writer); + try { + transformer.transform(domSource, result); + } catch (TransformerException e) { + LOGGER.warn("Could not generate metadata XML. The metadata will not be included in the libvirt domain XML: {}", e.getMessage()); + return ""; + } + + return writer.toString(); + } + } + public static class GuestDef { enum GuestType { KVM, XEN, EXE, LXC @@ -707,7 +878,7 @@ public class LibvirtVMDef { } public enum DiskCacheMode { - NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough"); + NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough"), HYPERVISOR_DEFAULT("default"); String _diskCacheMode; DiskCacheMode(String cacheMode) { @@ -2163,34 +2334,6 @@ public class LibvirtVMDef { } } - public class MetadataDef { - Map customNodes = new HashMap<>(); - - public T getMetadataNode(Class fieldClass) { - T field = (T) customNodes.get(fieldClass.getName()); - if (field == null) { - try { - field = fieldClass.newInstance(); - customNodes.put(field.getClass().getName(), field); - } catch (InstantiationException | IllegalAccessException e) { - LOGGER.debug("No default constructor available in class " + fieldClass.getName() + ", ignoring exception", e); - } - } - return field; - } - - @Override - public String toString() { - StringBuilder fsBuilder = new StringBuilder(); - fsBuilder.append("\n"); - for (Object field : customNodes.values()) { - fsBuilder.append(field.toString()); - } - fsBuilder.append("\n"); - return fsBuilder.toString(); - } - } - public static class RngDef { enum RngModel { VIRTIO("virtio"); @@ -2493,15 +2636,6 @@ public class LibvirtVMDef { return null; } - public MetadataDef getMetaData() { - MetadataDef o = (MetadataDef) components.get(MetadataDef.class.toString()); - if (o == null) { - o = new MetadataDef(); - addComp(o); - } - return o; - } - @Override public String toString() { StringBuilder vmBuilder = new StringBuilder(); @@ -2513,6 +2647,7 @@ public class LibvirtVMDef { if (_desc != null) { vmBuilder.append("" + _desc + "\n"); } + for (Object o : components.values()) { vmBuilder.append(o.toString()); } 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 abc408f20f6..93895349a6e 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 @@ -20,6 +20,7 @@ package com.cloud.hypervisor.kvm.resource.wrapper; import java.net.URLEncoder; import java.nio.charset.Charset; +import java.util.Arrays; import java.util.List; import java.util.UUID; @@ -57,11 +58,13 @@ public class LibvirtConvertInstanceCommandWrapper extends CommandWrapper 1) { @@ -210,17 +215,18 @@ public class LibvirtConvertInstanceCommandWrapper extends CommandWrapper separatedArgs = Arrays.asList(extraParams.split(" ")); + int i = 0; + while (i < separatedArgs.size()) { + String current = separatedArgs.get(i); + String next = (i + 1) < separatedArgs.size() ? separatedArgs.get(i + 1) : null; + if (next == null || next.startsWith("-")) { + script.add(current); + i = i + 1; + } else { + script.add(current, next); + i = i + 2; + } + } + } + protected String encodeUsername(String username) { return URLEncoder.encode(username, Charset.defaultCharset()); } 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 index 0eec15cf733..5602da15679 100644 --- 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 @@ -67,6 +67,7 @@ public class LibvirtImportConvertedInstanceCommandWrapper extends CommandWrapper List destinationStoragePools = cmd.getDestinationStoragePools(); DataStoreTO conversionTemporaryLocation = cmd.getConversionTemporaryLocation(); final String temporaryConvertUuid = cmd.getTemporaryConvertUuid(); + final boolean forceConvertToPool = cmd.isForceConvertToPool(); final KVMStoragePoolManager storagePoolMgr = serverResource.getStoragePoolMgr(); KVMStoragePool temporaryStoragePool = getTemporaryStoragePool(conversionTemporaryLocation, storagePoolMgr); @@ -80,13 +81,18 @@ public class LibvirtImportConvertedInstanceCommandWrapper extends CommandWrapper getTemporaryDisksWithPrefixFromTemporaryPool(temporaryStoragePool, temporaryConvertPath, temporaryConvertUuid) : getTemporaryDisksFromParsedXml(temporaryStoragePool, xmlParser, convertedBasePath); - List destinationDisks = moveTemporaryDisksToDestination(temporaryDisks, - destinationStoragePools, storagePoolMgr); - - cleanupDisksAndDomainFromTemporaryLocation(temporaryDisks, temporaryStoragePool, temporaryConvertUuid); + List disks = null; + if (forceConvertToPool) { + // Force flag to use the conversion path, no need to move disks + disks = temporaryDisks; + } else { + disks = moveTemporaryDisksToDestination(temporaryDisks, + destinationStoragePools, storagePoolMgr); + cleanupDisksAndDomainFromTemporaryLocation(temporaryDisks, temporaryStoragePool, temporaryConvertUuid); + } UnmanagedInstanceTO convertedInstanceTO = getConvertedUnmanagedInstance(temporaryConvertUuid, - destinationDisks, xmlParser); + disks, xmlParser); return new ImportConvertedInstanceAnswer(cmd, convertedInstanceTO); } catch (Exception e) { String error = String.format("Error converting instance %s from %s, due to: %s", 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 0bb621af171..7b56ba47db0 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 @@ -364,16 +364,7 @@ public class KVMStorageProcessor implements StorageProcessor { final TemplateObjectTO newTemplate = new TemplateObjectTO(); newTemplate.setPath(primaryVol.getName()); newTemplate.setSize(primaryVol.getSize()); - - if(List.of( - StoragePoolType.RBD, - StoragePoolType.PowerFlex, - StoragePoolType.Linstor, - StoragePoolType.FiberChannel).contains(primaryPool.getType())) { - newTemplate.setFormat(ImageFormat.RAW); - } else { - newTemplate.setFormat(ImageFormat.QCOW2); - } + newTemplate.setFormat(getFormat(primaryPool.getType())); data = newTemplate; } else if (destData.getObjectType() == DataObjectType.VOLUME) { final VolumeObjectTO volumeObjectTO = new VolumeObjectTO(); @@ -2990,7 +2981,7 @@ public class KVMStorageProcessor implements StorageProcessor { final VolumeObjectTO srcVol = (VolumeObjectTO)srcData; final VolumeObjectTO destVol = (VolumeObjectTO)destData; final ImageFormat srcFormat = srcVol.getFormat(); - final ImageFormat destFormat = destVol.getFormat(); + ImageFormat destFormat = destVol.getFormat(); final DataStoreTO srcStore = srcData.getDataStore(); final DataStoreTO destStore = destData.getDataStore(); final PrimaryDataStoreTO srcPrimaryStore = (PrimaryDataStoreTO)srcStore; @@ -3025,33 +3016,35 @@ public class KVMStorageProcessor implements StorageProcessor { volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString())); volume.setDispName(srcVol.getName()); volume.setVmName(srcVol.getVmName()); - - String destVolumeName = null; + KVMPhysicalDisk newVolume; + String destVolumeName; + destPool = storagePoolMgr.getStoragePool(destPrimaryStore.getPoolType(), destPrimaryStore.getUuid()); if (destPrimaryStore.isManaged()) { if (!storagePoolMgr.connectPhysicalDisk(destPrimaryStore.getPoolType(), destPrimaryStore.getUuid(), destVolumePath, destPrimaryStore.getDetails())) { logger.warn("Failed to connect dest volume {}, in storage pool {}", destVol, destPrimaryStore); } destVolumeName = derivePath(destPrimaryStore, destData, destPrimaryStore.getDetails()); } else { + PhysicalDiskFormat destPoolDefaultFormat = destPool.getDefaultFormat(); + destFormat = getFormat(destPoolDefaultFormat); final String volumeName = UUID.randomUUID().toString(); destVolumeName = volumeName + "." + destFormat.getFileExtension(); // Update path in the command for reconciliation - if (destData.getPath() == null) { + if (StringUtils.isBlank(destVolumePath)) { ((VolumeObjectTO) destData).setPath(destVolumeName); } } - destPool = storagePoolMgr.getStoragePool(destPrimaryStore.getPoolType(), destPrimaryStore.getUuid()); try { Volume.Type volumeType = srcVol.getVolumeType(); resource.createOrUpdateLogFileForCommand(cmd, Command.State.PROCESSING_IN_BACKEND); if (srcVol.getPassphrase() != null && (Volume.Type.ROOT.equals(volumeType) || Volume.Type.DATADISK.equals(volumeType))) { volume.setQemuEncryptFormat(QemuObject.EncryptFormat.LUKS); - storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, destPool, cmd.getWaitInMillSeconds(), srcVol.getPassphrase(), destVol.getPassphrase(), srcVol.getProvisioningType()); + newVolume = storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, destPool, cmd.getWaitInMillSeconds(), srcVol.getPassphrase(), destVol.getPassphrase(), srcVol.getProvisioningType()); } else { - storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, destPool, cmd.getWaitInMillSeconds()); + newVolume = storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, destPool, cmd.getWaitInMillSeconds()); } resource.createOrUpdateLogFileForCommand(cmd, Command.State.COMPLETED); } catch (Exception e) { // Any exceptions while copying the disk, should send failed answer with the error message @@ -3071,9 +3064,13 @@ public class KVMStorageProcessor implements StorageProcessor { } final VolumeObjectTO newVol = new VolumeObjectTO(); - String path = destPrimaryStore.isManaged() ? destVolumeName : destVolumePath + File.separator + destVolumeName; + String path = destVolumeName; + if (!destPrimaryStore.isManaged() && StringUtils.isNotBlank(destVolumePath)) { + path = destVolumePath + File.separator + destVolumeName; + } newVol.setPath(path); - newVol.setFormat(destFormat); + ImageFormat newVolumeFormat = getFormat(newVolume.getFormat()); + newVol.setFormat(newVolumeFormat); newVol.setEncryptFormat(destVol.getEncryptFormat()); return new CopyCmdAnswer(newVol); } catch (final CloudRuntimeException e) { @@ -3085,6 +3082,26 @@ public class KVMStorageProcessor implements StorageProcessor { } } + private Storage.ImageFormat getFormat(PhysicalDiskFormat format) { + if (format == null) { + return null; + } + + return ImageFormat.valueOf(format.toString().toUpperCase()); + } + + private Storage.ImageFormat getFormat(StoragePoolType poolType) { + if(List.of( + StoragePoolType.RBD, + StoragePoolType.PowerFlex, + StoragePoolType.Linstor, + StoragePoolType.FiberChannel).contains(poolType)) { + return ImageFormat.RAW; + } else { + return ImageFormat.QCOW2; + } + } + /** * True if location exists */ 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 d5119ea55b7..87544cfaa9d 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 @@ -79,6 +79,7 @@ import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StorageLayer; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; +import com.cloud.utils.storage.TemplateDownloaderUtil; public class LibvirtStorageAdaptor implements StorageAdaptor { protected Logger logger = LogManager.getLogger(getClass()); @@ -172,37 +173,11 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { return null; } - /** - * Checks if downloaded template is extractable - * @return true if it should be extracted, false if not - */ - 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"); - } - - /** - * Return extract command to execute given downloaded file - * @param downloadedTemplateFile - * @param templateUuid - */ - public static String getExtractCommandForDownloadedFile(String downloadedTemplateFile, String templateUuid) { - if (downloadedTemplateFile.endsWith(".zip")) { - return "unzip -p " + downloadedTemplateFile + " | cat > " + templateUuid; - } else if (downloadedTemplateFile.endsWith(".bz2")) { - return "bunzip2 -c " + downloadedTemplateFile + " > " + templateUuid; - } else if (downloadedTemplateFile.endsWith(".gz")) { - return "gunzip -c " + downloadedTemplateFile + " > " + templateUuid; - } else { - throw new CloudRuntimeException("Unable to extract template " + downloadedTemplateFile); - } - } - /** * Extract downloaded template into installPath, remove compressed file */ public static void extractDownloadedTemplate(String downloadedTemplateFile, KVMStoragePool destPool, String destinationFile) { - String extractCommand = getExtractCommandForDownloadedFile(downloadedTemplateFile, destinationFile); + String extractCommand = TemplateDownloaderUtil.getExtractCommandForDownloadedFile(downloadedTemplateFile, destinationFile); Script.runSimpleBashScript(extractCommand); Script.runSimpleBashScript("rm -f " + downloadedTemplateFile); } @@ -221,7 +196,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { if (destPool.getType() == StoragePoolType.NetworkFilesystem || destPool.getType() == StoragePoolType.Filesystem || destPool.getType() == StoragePoolType.SharedMountPoint) { - if (!Storage.ImageFormat.ISO.equals(format) && isTemplateExtractable(templateFilePath)) { + if (!Storage.ImageFormat.ISO.equals(format) && TemplateDownloaderUtil.isTemplateExtractable(templateFilePath)) { extractDownloadedTemplate(templateFilePath, destPool, destinationFile); } else { Script.runSimpleBashScript("mv " + templateFilePath + " " + destinationFile); @@ -1116,7 +1091,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { // make room for encryption header on raw format, use LUKS if (format == PhysicalDiskFormat.RAW) { - destFile.setSize(destFile.getSize() - (16<<20)); + destFile.setSize(destFile.getSize() - (16 << 20)); destFile.setFormat(PhysicalDiskFormat.LUKS); } @@ -1593,7 +1568,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { String sourcePath = disk.getPath(); KVMPhysicalDisk newDisk; - logger.debug("copyPhysicalDisk: disk size:" + toHumanReadableSize(disk.getSize()) + ", virtualsize:" + toHumanReadableSize(disk.getVirtualSize())+" format:"+disk.getFormat()); + logger.debug("copyPhysicalDisk: disk size:{}, virtualsize:{} format:{}", toHumanReadableSize(disk.getSize()), toHumanReadableSize(disk.getVirtualSize()), disk.getFormat()); if (destPool.getType() != StoragePoolType.RBD) { if (disk.getFormat() == PhysicalDiskFormat.TAR) { newDisk = destPool.createPhysicalDisk(name, PhysicalDiskFormat.DIR, Storage.ProvisioningType.THIN, disk.getVirtualSize(), null); @@ -1714,7 +1689,11 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { */ srcFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(srcPool, sourcePath)); srcFile.setFormat(sourceFormat); - destFile = new QemuImgFile(destPath); + if (destPool.getType() == StoragePoolType.RBD) { + destFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool, destPath)); + } else { + destFile = new QemuImgFile(destPath); + } destFile.setFormat(destFormat); try { 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 7ba29ffc26e..514e412559c 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 @@ -423,24 +423,6 @@ public abstract class MultipathSCSIAdapterBase implements StorageAdaptor { throw new UnsupportedOperationException("Unimplemented method 'createPhysicalDisk'"); } - boolean isTemplateExtractable(String templatePath) { - ScriptResult result = runScript("file", 5000L, templatePath, "| awk -F' ' '{print $2}'"); - String type = result.getResult(); - return type.equalsIgnoreCase("bzip2") || type.equalsIgnoreCase("gzip") || type.equalsIgnoreCase("zip"); - } - - String getExtractCommandForDownloadedFile(String downloadedTemplateFile, String templateFile) { - if (downloadedTemplateFile.endsWith(".zip")) { - return "unzip -p " + downloadedTemplateFile + " | cat > " + templateFile; - } else if (downloadedTemplateFile.endsWith(".bz2")) { - return "bunzip2 -c " + downloadedTemplateFile + " > " + templateFile; - } else if (downloadedTemplateFile.endsWith(".gz")) { - return "gunzip -c " + downloadedTemplateFile + " > " + templateFile; - } else { - throw new CloudRuntimeException("Unable to extract template " + downloadedTemplateFile); - } - } - boolean waitForDiskToBecomeAvailable(AddressInfo address, KVMStoragePool pool, long waitTimeInSec) { LOGGER.debug("Waiting for the volume with id: " + address.getPath() + " of the storage pool: " + pool.getUuid() + " to become available for " + waitTimeInSec + " secs"); 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 efa8024a34b..e336e0e5a54 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 @@ -53,6 +53,8 @@ import com.cloud.utils.Ternary; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; +import com.cloud.utils.storage.TemplateDownloaderUtil; + import org.apache.commons.lang3.StringUtils; public class ScaleIOStorageAdaptor implements StorageAdaptor { @@ -572,10 +574,10 @@ public class ScaleIOStorageAdaptor implements StorageAdaptor { throw new CloudRuntimeException("Failed to find the disk: " + destTemplatePath + " of the storage pool: " + destPool.getUuid()); } - if (isTemplateExtractable(templateFilePath)) { + if (TemplateDownloaderUtil.isTemplateExtractable(templateFilePath)) { srcTemplateFilePath = sourceFile.getParent() + "/" + UUID.randomUUID().toString(); logger.debug("Extract the downloaded template " + templateFilePath + " to " + srcTemplateFilePath); - String extractCommand = getExtractCommandForDownloadedFile(templateFilePath, srcTemplateFilePath); + String extractCommand = TemplateDownloaderUtil.getExtractCommandForDownloadedFile(templateFilePath, srcTemplateFilePath); Script.runSimpleBashScript(extractCommand); Script.runSimpleBashScript("rm -f " + templateFilePath); } @@ -611,23 +613,6 @@ public class ScaleIOStorageAdaptor implements StorageAdaptor { return destDisk; } - private boolean isTemplateExtractable(String templatePath) { - String type = Script.runSimpleBashScript("file " + templatePath + " | awk -F' ' '{print $2}'"); - return type.equalsIgnoreCase("bzip2") || type.equalsIgnoreCase("gzip") || type.equalsIgnoreCase("zip"); - } - - private String getExtractCommandForDownloadedFile(String downloadedTemplateFile, String templateFile) { - if (downloadedTemplateFile.endsWith(".zip")) { - return "unzip -p " + downloadedTemplateFile + " | cat > " + templateFile; - } else if (downloadedTemplateFile.endsWith(".bz2")) { - return "bunzip2 -c " + downloadedTemplateFile + " > " + templateFile; - } else if (downloadedTemplateFile.endsWith(".gz")) { - return "gunzip -c " + downloadedTemplateFile + " > " + templateFile; - } else { - throw new CloudRuntimeException("Unable to extract template " + downloadedTemplateFile); - } - } - public void resizeQcow2ToVolume(String volumePath, QemuImageOptions options, List objects, Integer timeout) throws QemuImgException, LibvirtException { long rawSizeBytes = getPhysicalDiskSize(volumePath); long usableSizeBytes = getUsableBytesFromRawBytes(rawSizeBytes); 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 b369cf25f3d..4d55ac2bc73 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 @@ -128,6 +128,7 @@ public class LibvirtConvertInstanceCommandWrapperTest { Mockito.when(cmd.getWait()).thenReturn(14400); Mockito.when(cmd.getConversionTemporaryLocation()).thenReturn(secondaryDataStore); Mockito.when(cmd.getCheckConversionSupport()).thenReturn(checkConversionSupport); + Mockito.when(cmd.getOriginalVMName()).thenReturn(vmName); return cmd; } @@ -166,8 +167,26 @@ public class LibvirtConvertInstanceCommandWrapperTest { Answer answer = convertInstanceCommandWrapper.execute(cmd, libvirtComputingResourceMock); Assert.assertFalse(answer.getResult()); - Mockito.verify(convertInstanceCommandWrapper).performInstanceConversion(Mockito.anyString(), - Mockito.anyString(), Mockito.anyString(), Mockito.anyLong(), Mockito.anyBoolean()); + Mockito.verify(convertInstanceCommandWrapper).performInstanceConversion(Mockito.anyString(), Mockito.anyString(), + Mockito.anyString(), Mockito.anyString(), Mockito.anyLong(), Mockito.anyBoolean(), Mockito.nullable(String.class), Mockito.any(LibvirtComputingResource.class)); } } + + @Test + public void testAddExtraParamsToScriptSameKeysAndValues() { + Script script = Mockito.mock(Script.class); + String extraParams = "--mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254"; + convertInstanceCommandWrapper.addExtraParamsToScript(extraParams, script); + Mockito.verify(script).add("--mac", "00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254"); + } + + @Test + public void testAddExtraParamsToScriptDifferentArgs() { + Script script = Mockito.mock(Script.class); + String extraParams = "--mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254 -x -v"; + convertInstanceCommandWrapper.addExtraParamsToScript(extraParams, script); + Mockito.verify(script).add("--mac", "00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254"); + Mockito.verify(script).add("-x"); + Mockito.verify(script).add("-v"); + } } diff --git a/plugins/hypervisors/ovm/pom.xml b/plugins/hypervisors/ovm/pom.xml index 46dd6ef498d..d29f9afa73a 100644 --- a/plugins/hypervisors/ovm/pom.xml +++ b/plugins/hypervisors/ovm/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/object/Test.java b/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/object/Test.java index cd1b14eeaa1..32960a9616c 100644 --- a/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/object/Test.java +++ b/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/object/Test.java @@ -23,37 +23,6 @@ import java.util.Map; public class Test { public static void main(final String[] args) { try { - /*Connection c = new Connection("192.168.105.155", "oracle", "password"); - Utils util = new UtilsImpl(c); - Storage storage = new StorageImpl(c); - String[] res = util.listDir("/etc", 1); - for (String s : res) { - System.out.println(s); - } - - - Pool pool = new PoolImpl(c); - - //pool.registerServer("192.168.105.155", Pool.ServerType.SITE); - //pool.registerServer("192.168.105.155", Pool.ServerType.UTILITY); - //pool.registerServer("192.168.105.155", Pool.ServerType.XEN); - System.out.println("Is:" + pool.isServerRegistered()); - System.out.println(pool.getServerConfig()); - System.out.println(pool.getServerXmInfo()); - System.out.println(pool.getHostInfo()); - System.out.println(pool.getAgentVersion()); - String[] srs = storage.listSr(); - for (int i=0; i spaceInfo = storage.getSrSpaceInfo("192.168.110.232:/export/frank/nfs"); - System.out.println("Total:" + spaceInfo.first()); - System.out.println("Free:" + spaceInfo.second());*/ final OvmVm.Details vm = new OvmVm.Details(); vm.cpuNum = 1; vm.memory = 512; @@ -80,23 +49,7 @@ public class Test { vm.vifs.add(vif); vm.vifs.add(vif); vm.vifs.add(vif); - //System.out.println(vm.toJson()); final Connection c = new Connection("192.168.189.12", "oracle", "password"); - //System.out.println(Coder.toJson(OvmHost.getDetails(c))); - - /* This is not being used at the moment. - * Coverity issue: 1012179 - */ - - //OvmHost.Details d = new GsonBuilder().create().fromJson(txt, OvmHost.Details.class); - //OvmHost.Details d = Coder.fromJson(txt, OvmHost.Details.class); - //OvmHost.Details d = OvmHost.getDetails(c); - //System.out.println(Coder.toJson(d)); - // OvmStoragePool.Details pool = new OvmStoragePool.Details(); - // pool.path = "192.168.110.232:/export/frank/ovs"; - // pool.type = OvmStoragePool.NFS; - // pool.uuid = "123"; - // System.out.println(pool.toJson()); String cmd = null; System.out.println(args.length); @@ -119,15 +72,10 @@ public class Test { System.out.println(d.toJson()); if (cmd.equalsIgnoreCase("create")) { - // String s = - // "{\"cpuNum\":1,\"memory\":512,\"rootDisk\":{\"type\":\"w\",\"path\":\"/var/ovs/mount/60D0985974CA425AAF5D01A1F161CC8B/running_pool/36_systemvm/System.img\"},\"disks\":[],\"vifs\":[{\"mac\":\"00:16:3E:5C:B1:D1\",\"bridge\":\"xenbr0\",\"type\":\"netfront\"}],\"name\":\"MyTest\",\"uuid\":\"1-2-3-4-5\"}"; OvmVm.create(c, d); - // c.call("OvmVm.echo", new Object[]{s}); } else if (cmd.equalsIgnoreCase("reboot")) { final Map res = OvmVm.reboot(c, "MyTest"); System.out.println(res.get("vncPort")); - //OvmVm.stop(c, "MyTest"); - //OvmVm.create(c, d); } else if (cmd.equalsIgnoreCase("stop")) { OvmVm.stop(c, "MyTest"); } else if (cmd.equalsIgnoreCase("details")) { @@ -166,12 +114,6 @@ public class Test { l.add("4b4d8951-f0b6-36c5-b4f3-a82ff2611c65"); System.out.println(Coder.toJson(l)); - // Map res = OvmHost.getPerformanceStats(c, "xenbr0"); - // System.out.println(res.toString()); - // String stxt = "{\"vifs\": [{\"bridge\": \"xenbr0\", \"mac\": \"00:16:3E:5C:B1:D1\", \"type\": \"netfront\"}], \"powerState\": \"RUNNING\", \"disks\": [], \"cpuNum\": 1, \"memory\": 536870912, \"rootDisk\": {\"path\": \"/var/ovs/mount/60D0985974CA425AAF5D01A1F161CC8B/running_pool/MyTest/System.img\", \"type\": \"w\"}}"; - // OvmVm.Details ddd = Coder.fromJson(stxt, OvmVm.Details.class); - // System.out.println(ddd.vifs.size()); - // System.out.println(ddd.rootDisk.path); } catch (final Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/plugins/hypervisors/ovm3/pom.xml b/plugins/hypervisors/ovm3/pom.xml index ea591c89126..4214ee8a71b 100644 --- a/plugins/hypervisors/ovm3/pom.xml +++ b/plugins/hypervisors/ovm3/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/ovm3/src/test/resources/scripts/socat.sh b/plugins/hypervisors/ovm3/src/test/resources/scripts/socat.sh index e37ba47cfa9..6072bb64644 100755 --- a/plugins/hypervisors/ovm3/src/test/resources/scripts/socat.sh +++ b/plugins/hypervisors/ovm3/src/test/resources/scripts/socat.sh @@ -1,19 +1,21 @@ -#Licensed to the Apache Software Foundation (ASF) under one -#or more contributor license agreements. See the NOTICE file -#distributed with this work for additional information -#regarding copyright ownership. The ASF licenses this file -#to you under the Apache License, Version 2.0 (the -#"License"); you may not use this file except in compliance -#with the License. You may obtain a copy of the License at +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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. +# 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. CERT="/etc/ovs-agent/cert" socat OPENSSL-LISTEN:8899,reuseaddr,fork,verify=0,key=$CERT/key.pem,cert=$CERT/certificate.pem TCP:localhost:8898 & diff --git a/plugins/hypervisors/ovm3/src/test/resources/scripts/tail.sh b/plugins/hypervisors/ovm3/src/test/resources/scripts/tail.sh index 2665c44e143..458f3ec74ba 100755 --- a/plugins/hypervisors/ovm3/src/test/resources/scripts/tail.sh +++ b/plugins/hypervisors/ovm3/src/test/resources/scripts/tail.sh @@ -1,19 +1,21 @@ -#Licensed to the Apache Software Foundation (ASF) under one -#or more contributor license agreements. See the NOTICE file -#distributed with this work for additional information -#regarding copyright ownership. The ASF licenses this file -#to you under the Apache License, Version 2.0 (the -#"License"); you may not use this file except in compliance -#with the License. You may obtain a copy of the License at +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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. +# 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. cd /var/log tail -f ovm-consoled.log devmon.log messages ovs-agent.log ovmwatch.log diff --git a/plugins/hypervisors/simulator/pom.xml b/plugins/hypervisors/simulator/pom.xml index 87d692e5b29..8ef011fa971 100644 --- a/plugins/hypervisors/simulator/pom.xml +++ b/plugins/hypervisors/simulator/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml cloud-plugin-hypervisor-simulator diff --git a/plugins/hypervisors/simulator/src/main/java/com/cloud/resource/SimulatorStorageProcessor.java b/plugins/hypervisors/simulator/src/main/java/com/cloud/resource/SimulatorStorageProcessor.java index 3614154f334..e19b0fa01c3 100644 --- a/plugins/hypervisors/simulator/src/main/java/com/cloud/resource/SimulatorStorageProcessor.java +++ b/plugins/hypervisors/simulator/src/main/java/com/cloud/resource/SimulatorStorageProcessor.java @@ -270,7 +270,11 @@ public class SimulatorStorageProcessor implements StorageProcessor { @Override public Answer copyVolumeFromPrimaryToPrimary(CopyCommand cmd) { - return null; + VolumeObjectTO volume = new VolumeObjectTO(); + volume.setPath(UUID.randomUUID().toString()); + volume.setSize(100); + volume.setFormat(Storage.ImageFormat.RAW); + return new CopyCmdAnswer(volume); } @Override diff --git a/plugins/hypervisors/ucs/pom.xml b/plugins/hypervisors/ucs/pom.xml index fd287cd3c7f..67bde3b6429 100644 --- a/plugins/hypervisors/ucs/pom.xml +++ b/plugins/hypervisors/ucs/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml cloud-plugin-hypervisor-ucs diff --git a/plugins/hypervisors/vmware/pom.xml b/plugins/hypervisors/vmware/pom.xml index 445822085de..7637cb7db6d 100644 --- a/plugins/hypervisors/vmware/pom.xml +++ b/plugins/hypervisors/vmware/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java index 88df637b0dd..1a8d9f7b59e 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java @@ -61,6 +61,7 @@ import org.apache.cloudstack.utils.volume.VirtualMachineDiskInfo; import org.apache.cloudstack.vm.UnmanagedInstanceTO; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import com.cloud.agent.api.BackupSnapshotCommand; @@ -694,7 +695,12 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co updateTemplateRef(templateId, poolId, templatePath, templateSize); return templateId; } else { - return volumeVO.getTemplateId(); + Long templateId = volumeVO.getTemplateId(); + if (templateId == null && volumeVO.getInstanceId() != null) { + VMInstanceVO vmInstanceVO = vmDao.findByIdIncludingRemoved(volumeVO.getInstanceId()); + return vmInstanceVO.getTemplateId(); + } + return templateId; } } } @@ -1393,6 +1399,9 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co String datacenter = params.get(VmDetailConstants.VMWARE_DATACENTER_NAME); String username = params.get(VmDetailConstants.VMWARE_VCENTER_USERNAME); String password = params.get(VmDetailConstants.VMWARE_VCENTER_PASSWORD); + Integer requestedCpuNumber = params.containsKey(VmDetailConstants.CPU_NUMBER) ? Integer.parseInt(params.get(VmDetailConstants.CPU_NUMBER)) : null; + Integer requestedCpuSpeed = params.containsKey(VmDetailConstants.CPU_SPEED) ? Integer.parseInt(params.get(VmDetailConstants.CPU_SPEED)) : null; + Integer requestedMemory = params.containsKey(VmDetailConstants.MEMORY) ? Integer.parseInt(params.get(VmDetailConstants.MEMORY)) : null; try { VmwareContext context = connectToVcenter(vcenter, username, password); @@ -1404,6 +1413,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co throw new CloudRuntimeException(err); } + checkSourceVmResourcesAgainstSelectedOfferingResources(vmMo, requestedCpuNumber, requestedCpuSpeed, requestedMemory); VirtualMachinePowerState sourceVmPowerState = vmMo.getPowerState(); if (sourceVmPowerState == VirtualMachinePowerState.POWERED_OFF) { @@ -1444,6 +1454,29 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co } } + protected void checkSourceVmResourcesAgainstSelectedOfferingResources(VirtualMachineMO vmMo, Integer requestedCpuNumber, Integer requestedCpuSpeed, Integer requestedMemory) throws Exception { + if (ObjectUtils.allNull(requestedCpuNumber, requestedCpuSpeed, requestedMemory)) { + return; + } + VirtualMachineConfigSummary configSummary = vmMo.getConfigSummary(); + if (configSummary != null) { + compareSourceVmResourceAgainstRequested(configSummary.getNumCpu(), requestedCpuNumber, "CPU number"); + compareSourceVmResourceAgainstRequested(configSummary.getCpuReservation(), requestedCpuSpeed, "CPU speed"); + compareSourceVmResourceAgainstRequested(configSummary.getMemorySizeMB(), requestedMemory, "Memory"); + } + } + + protected void compareSourceVmResourceAgainstRequested(Integer actualResource, Integer requestedResource, String resourceName) throws Exception { + if (ObjectUtils.anyNull(actualResource, requestedResource)) { + return; + } + if (requestedResource < actualResource) { + String err = String.format("The requested %s (%d) is less than the source VM %s (%d)", resourceName, requestedResource, resourceName, actualResource); + logger.error(err); + throw new CloudRuntimeException(err); + } + } + private boolean isWindowsVm(VirtualMachineMO vmMo) throws Exception { UnmanagedInstanceTO sourceInstance = VmwareHelper.getUnmanagedInstance(vmMo.getRunningHost(), vmMo); return sourceInstance.getOperatingSystem().toLowerCase().contains("windows"); diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java index d2c71c4ee01..49f10970e7c 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java @@ -65,15 +65,6 @@ public class VmwareCleanupMaid { _vmName = vmName; } -// @Override -// public int cleanup(CheckPointManager checkPointMgr) { -// -// // save a check-point in case we crash at current run so that we won't lose it -// _checkPoint = checkPointMgr.pushCheckPoint(new VmwareCleanupMaid(_vCenterAddress, _dcMorValue, _vmName)); -// addLeftOverVM(this); -// return 0; -// } - public String getCleanupProcedure() { return null; } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index c841706557d..8d2ccfd6375 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -4712,7 +4712,7 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes vmMo.mountToolsInstaller(); logger.debug(String.format("Successfully re-mounted vmware tools installer for :[%s].", cmd.getVmName())); } catch (Exception e) { - logger.error(String.format("Unabled to re-mount vmware tools installer for: [%s].", cmd.getVmName()), e); + logger.error(String.format("Unable to re-mount vmware tools installer for: [%s].", cmd.getVmName()), e); } } } @@ -7171,7 +7171,7 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes if (s_serviceContext.get() != null) { context = s_serviceContext.get(); String poolKey = VmwareContextPool.composePoolKey(_vCenterAddress, _username); - // Before re-using the thread local context, ensure it corresponds to the right vCenter API session and that it is valid to make calls. + // Before reusing the thread local context, ensure it corresponds to the right vCenter API session and that it is valid to make calls. if (context.getPoolKey().equals(poolKey)) { if (context.validate()) { if (logger.isTraceEnabled()) { diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java index beac489acdb..73d63f04c5f 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java @@ -66,9 +66,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase { @DB - //public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, ServerResource resource, String vsmName) { - public - CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, String vCenterIpaddr, String vCenterDcName) { + public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, String vCenterIpaddr, String vCenterDcName) { // In this function, we associate this VSM with each host // in the clusterId specified. @@ -154,28 +152,6 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase { // into each host's resource. Also, we first configure each resource's // entries in the database to contain this VSM information before the injection. - //for (HostVO host : hosts) { - // Create a host details VO object and write it out for this hostid. - //Long hostid = new Long(vsmId); - //DetailVO vsmDetail = new DetailVO(host.getId(), "vsmId", hostid.toString()); - //Transaction tx = Transaction.currentTxn(); - //try { - //tx.start(); - //_hostDetailDao.persist(vsmDetail); - //tx.commit(); - //} catch (Exception e) { - //tx.rollback(); - //throw new CloudRuntimeException(e.getMessage()); - //} - //} - // Reconfigure the resource. - //Map hostDetails = new HashMap(); - //hostDetails.put(ApiConstants.ID, vsmId); - //hostDetails.put(ApiConstants.IP_ADDRESS, ipaddress); - //hostDetails.put(ApiConstants.USERNAME, username); - //hostDetails.put(ApiConstants.PASSWORD, password); - //_agentMrg.send(host.getId(), ) - return VSMObj; } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java index 8b87911d375..f3bfe532117 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java @@ -998,11 +998,11 @@ public class VmwareStorageProcessor implements StorageProcessor { long wait, String nfsVersion) throws Exception { String volumeFolder; String volumeName; - String sufix = ".ova"; + String suffix = ".ova"; int index = srcVolumePath.lastIndexOf(File.separator); - if (srcVolumePath.endsWith(sufix)) { + if (srcVolumePath.endsWith(suffix)) { volumeFolder = srcVolumePath.substring(0, index); - volumeName = srcVolumePath.substring(index + 1).replace(sufix, ""); + volumeName = srcVolumePath.substring(index + 1).replace(suffix, ""); } else { volumeFolder = srcVolumePath; volumeName = srcVolumePath.substring(index + 1); @@ -3787,16 +3787,16 @@ public class VmwareStorageProcessor implements StorageProcessor { } DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs); - boolean isDatastoreStoragePolicyComplaint = primaryDsMo.isDatastoreStoragePolicyComplaint(storagePolicyId); + boolean isDatastoreStoragePolicyCompliant = primaryDsMo.isDatastoreStoragePolicyCompliant(storagePolicyId); - String failedMessage = String.format("DataStore %s is not compliance with storage policy id %s", primaryStorageNameLabel, storagePolicyId); - if (!isDatastoreStoragePolicyComplaint) - return new Answer(cmd, isDatastoreStoragePolicyComplaint, failedMessage); + String failedMessage = String.format("DataStore %s is not compliant with storage policy id %s", primaryStorageNameLabel, storagePolicyId); + if (!isDatastoreStoragePolicyCompliant) + return new Answer(cmd, isDatastoreStoragePolicyCompliant, failedMessage); else - return new Answer(cmd, isDatastoreStoragePolicyComplaint, null); + return new Answer(cmd, isDatastoreStoragePolicyCompliant, null); } catch (Throwable e) { hostService.createLogMessageException(e, cmd); - String details = String.format("Exception while checking if datastore [%s] is storage policy [%s] compliance due to: [%s]", primaryStorageNameLabel, storagePolicyId, VmwareHelper.getExceptionMessage(e)); + String details = String.format("Exception while checking if datastore [%s] is storage policy [%s] compliant due to: [%s]", primaryStorageNameLabel, storagePolicyId, VmwareHelper.getExceptionMessage(e)); return new Answer(cmd, false, details); } } diff --git a/plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java b/plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java index b0cacf60a17..d2d319ed9d0 100644 --- a/plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java +++ b/plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java @@ -433,6 +433,7 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy { volumeVO.setFolder(pool.getPath()); volumeVO.setPodId(pool.getPodId()); volumeVO.setPoolId(pool.getId()); + volumeVO.setPoolType(pool.getPoolType()); volDao.update(volume.getId(), volumeVO); updated = true; break; diff --git a/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VMwareGuruTest.java b/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VMwareGuruTest.java index 6e96330ac58..270f61fcbbe 100644 --- a/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VMwareGuruTest.java +++ b/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VMwareGuruTest.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.vmware.vim25.VirtualMachineConfigSummary; import org.apache.cloudstack.storage.NfsMountManager; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; @@ -626,4 +627,24 @@ public class VMwareGuruTest { boolean result = vMwareGuru.removeVMTemplateOutOfBand(dataStore, templateDir); assertTrue(result); } + + @Test(expected = CloudRuntimeException.class) + public void testCheckSourceVmResourcesAgainstSelectedOfferingResourcesInsufficientMemory() throws Exception { + VirtualMachineMO virtualMachineMO = Mockito.mock(VirtualMachineMO.class); + VirtualMachineConfigSummary configSummary = Mockito.mock(VirtualMachineConfigSummary.class); + Mockito.when(virtualMachineMO.getConfigSummary()).thenReturn(configSummary); + Mockito.when(configSummary.getNumCpu()).thenReturn(1); + Mockito.when(configSummary.getMemorySizeMB()).thenReturn(2048); + vMwareGuru.checkSourceVmResourcesAgainstSelectedOfferingResources(virtualMachineMO, 1, 500, 1024); + } + + @Test + public void testCheckSourceVmResourcesAgainstSelectedOfferingResourcesGreaterOffering() throws Exception { + VirtualMachineMO virtualMachineMO = Mockito.mock(VirtualMachineMO.class); + VirtualMachineConfigSummary configSummary = Mockito.mock(VirtualMachineConfigSummary.class); + Mockito.when(virtualMachineMO.getConfigSummary()).thenReturn(configSummary); + Mockito.when(configSummary.getNumCpu()).thenReturn(1); + Mockito.when(configSummary.getMemorySizeMB()).thenReturn(1024); + vMwareGuru.checkSourceVmResourcesAgainstSelectedOfferingResources(virtualMachineMO, 2, 1500, 2048); + } } diff --git a/plugins/hypervisors/xenserver/pom.xml b/plugins/hypervisors/xenserver/pom.xml index 11861b3aeeb..4d7ebf69db2 100644 --- a/plugins/hypervisors/xenserver/pom.xml +++ b/plugins/hypervisors/xenserver/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index 4658b0eb4e5..d904e9a975b 100644 --- a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -2908,7 +2908,7 @@ public abstract class CitrixResourceBase extends ServerResourceBase implements S * within a XenServer that's under CloudStack control. * * - Native Networks: these are networks that are untagged on the XenServer - * and are used to crate VLAN networks on. These are created by the user and + * and are used to create VLAN networks on. These are created by the user and * is assumed to be one per cluster. - VLAN Networks: these are dynamically * created by CloudStack and can have problems with duplicated names. - * LinkLocal Networks: these are dynamically created by CloudStack and can @@ -3773,7 +3773,7 @@ public abstract class CitrixResourceBase extends ServerResourceBase implements S Host host = pbd.getHost(conn); if (!isRefNull(host) && StringUtils.equals(host.getUuid(conn), _host.getUuid())) { if (!pbd.getCurrentlyAttached(conn)) { - logger.debug(String.format("PBD [%s] of local SR [%s] was unplugged, pluggin it now", pbd.getUuid(conn), srRec.uuid)); + logger.debug(String.format("PBD [%s] of local SR [%s] was unplugged, plugging it in now", pbd.getUuid(conn), srRec.uuid)); pbd.plug(conn); } logger.debug("Scanning local SR: " + srRec.uuid); diff --git a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java index 3ecbafc0926..c03b419fcdc 100644 --- a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java +++ b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java @@ -220,7 +220,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor { srUuid = sr.getUuid(conn); Set pbDs = sr.getPBDs(conn); for (PBD pbd : pbDs) { - logger.debug(String.format("Unpluging PBD [%s] of SR [%s] as it is not working properly.", pbd.getUuid(conn), srUuid)); + logger.debug(String.format("Unplugging PBD [%s] of SR [%s] as it is not working properly.", pbd.getUuid(conn), srUuid)); unplugPbd(conn, pbd); } logger.debug(String.format("Forgetting SR [%s] as it is not working properly.", srUuid)); @@ -239,7 +239,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor { pbdUuid = pbd.getUuid(conn); pbd.unplug(conn); } catch (XenAPIException | XmlRpcException e) { - throw new CloudRuntimeException(String.format("Exception while unpluging PBD [%s].", pbdUuid)); + throw new CloudRuntimeException(String.format("Exception while unplugging PBD [%s].", pbdUuid)); } } diff --git a/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixRequestWrapperTest.java b/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixRequestWrapperTest.java index d464a266493..b9504b6648a 100755 --- a/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixRequestWrapperTest.java +++ b/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixRequestWrapperTest.java @@ -576,37 +576,6 @@ public class CitrixRequestWrapperTest { fail(e.getMessage()); } - // try { - // PowerMockito.mockStatic(Host.class); - // //BDDMockito.given(Host.getByUuid(conn, - // xsHost.getUuid())).willReturn(host); - // PowerMockito.when(Host.getByUuid(conn, - // xsHost.getUuid())).thenReturn(host); - // PowerMockito.verifyStatic(times(1)); - // } catch (final BadServerResponse e) { - // fail(e.getMessage()); - // } catch (final XenAPIException e) { - // fail(e.getMessage()); - // } catch (final XmlRpcException e) { - // fail(e.getMessage()); - // } - // - // PowerMockito.mockStatic(Types.class); - // PowerMockito.when(Types.toHostRecord(spiedMap)).thenReturn(hr); - // PowerMockito.verifyStatic(times(1)); - // - // try { - // PowerMockito.mockStatic(Host.Record.class); - // when(host.getRecord(conn)).thenReturn(hr); - // verify(host, times(1)).getRecord(conn); - // } catch (final BadServerResponse e) { - // fail(e.getMessage()); - // } catch (final XenAPIException e) { - // fail(e.getMessage()); - // } catch (final XmlRpcException e) { - // fail(e.getMessage()); - // } - final Answer answer = wrapper.execute(maintainCommand, citrixResourceBase); assertFalse(answer.getResult()); diff --git a/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java b/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java index 4b2dd1ac3ec..d5e794d2899 100644 --- a/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java +++ b/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java @@ -462,17 +462,6 @@ public class XenServer610WrapperTest { verify(xenServer610Resource, times(1)).getConnection(); - // try { - // verify(xenServer610Resource, times(1)).waitForTask(conn, task, 1000, timeout); - // verify(xenServer610Resource, times(1)).checkForSuccess(conn, task); - // } catch (final XenAPIException e) { - // fail(e.getMessage()); - // } catch (final XmlRpcException e) { - // fail(e.getMessage()); - // } catch (final TimeoutException e) { - // fail(e.getMessage()); - // } - assertFalse(answer.getResult()); } diff --git a/plugins/integrations/cloudian/pom.xml b/plugins/integrations/cloudian/pom.xml index bebf04f21a8..1c806acec7a 100644 --- a/plugins/integrations/cloudian/pom.xml +++ b/plugins/integrations/cloudian/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/integrations/kubernetes-service/pom.xml b/plugins/integrations/kubernetes-service/pom.xml index 4ea372343a3..6b5cec95aab 100644 --- a/plugins/integrations/kubernetes-service/pom.xml +++ b/plugins/integrations/kubernetes-service/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java index c46b0c00fa1..213657db073 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java @@ -96,7 +96,16 @@ import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd; import org.apache.cloudstack.api.command.user.network.DeleteNetworkACLCmd; import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd; import org.apache.cloudstack.api.command.user.network.ListNetworksCmd; +import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotCmd; +import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotCmd; +import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd; import org.apache.cloudstack.api.command.user.vm.ListVMsCmd; +import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd; +import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd; +import org.apache.cloudstack.api.command.user.volume.DeleteVolumeCmd; +import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd; +import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd; +import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd; import org.apache.cloudstack.api.response.KubernetesClusterConfigResponse; import org.apache.cloudstack.api.response.KubernetesClusterResponse; import org.apache.cloudstack.api.response.KubernetesUserVmResponse; @@ -118,6 +127,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Level; import com.cloud.api.ApiDBUtils; +import com.cloud.api.ApiResponseHelper; import com.cloud.api.query.dao.NetworkOfferingJoinDao; import com.cloud.api.query.dao.TemplateJoinDao; import com.cloud.api.query.dao.UserVmJoinDao; @@ -135,7 +145,6 @@ import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DedicatedResourceDao; import com.cloud.deploy.DeployDestination; -import com.cloud.domain.Domain; import com.cloud.event.ActionEvent; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; @@ -252,7 +261,16 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne private static final List> PROJECT_KUBERNETES_ACCOUNT_ROLE_ALLOWED_APIS = Arrays.asList( QueryAsyncJobResultCmd.class, ListVMsCmd.class, + ListVolumesCmd.class, + CreateVolumeCmd.class, + DeleteVolumeCmd.class, + AttachVolumeCmd.class, + DetachVolumeCmd.class, + ResizeVolumeCmd.class, ListNetworksCmd.class, + CreateSnapshotCmd.class, + ListSnapshotsCmd.class, + DeleteSnapshotCmd.class, ListPublicIpAddressesCmd.class, AssociateIPAddrCmd.class, DisassociateIPAddrCmd.class, @@ -538,7 +556,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne if (cksIso == null) { return systemVMPreferredArchitecture; } - String cksIsoArchName = cksIso.getArch().name(); + String cksIsoArchName = cksIso.getArch().getType(); return cksIsoArchName.equals(systemVMPreferredArchitecture) ? systemVMPreferredArchitecture : cksIsoArchName; } @@ -789,6 +807,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne VMTemplateVO template = ApiDBUtils.findTemplateById(kubernetesCluster.getTemplateId()); if (template != null) { response.setTemplateId(template.getUuid()); + response.setTemplateName(template.getName()); } ServiceOfferingVO offering = serviceOfferingDao.findByIdIncludingRemoved(kubernetesCluster.getServiceOfferingId()); if (offering != null) { @@ -814,18 +833,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne response.setKubernetesVersionId(version.getUuid()); response.setKubernetesVersionName(version.getName()); } - Account account = ApiDBUtils.findAccountById(kubernetesCluster.getAccountId()); - if (account.getType() == Account.Type.PROJECT) { - Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId()); - response.setProjectId(project.getUuid()); - response.setProjectName(project.getName()); - } else { - response.setAccountName(account.getAccountName()); - } - Domain domain = ApiDBUtils.findDomainById(kubernetesCluster.getDomainId()); - response.setDomainId(domain.getUuid()); - response.setDomainName(domain.getName()); - response.setDomainPath(domain.getPath()); + ApiResponseHelper.populateOwner(response, kubernetesCluster); response.setKeypair(kubernetesCluster.getKeyPair()); response.setState(kubernetesCluster.getState().toString()); response.setCores(String.valueOf(kubernetesCluster.getCores())); @@ -891,6 +899,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne response.setMinSize(kubernetesCluster.getMinSize()); response.setMaxSize(kubernetesCluster.getMaxSize()); response.setClusterType(kubernetesCluster.getClusterType()); + response.setCsiEnabled(kubernetesCluster.isCsiEnabled()); response.setCreated(kubernetesCluster.getCreated()); return response; @@ -1616,6 +1625,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne if (zone.isSecurityGroupEnabled()) { newCluster.setSecurityGroupId(finalSecurityGroup.getId()); } + newCluster.setCsiEnabled(cmd.getEnableCsi()); kubernetesClusterDao.persist(newCluster); addKubernetesClusterDetails(newCluster, defaultNetwork, cmd); return newCluster; diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterService.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterService.java index a809628a976..6bdb4265e01 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterService.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterService.java @@ -61,7 +61,7 @@ public interface KubernetesClusterService extends PluggableService, Configurable "cloud.kubernetes.cluster.network.offering", "DefaultNetworkOfferingforKubernetesService", "Name of the network offering that will be used to create isolated network in which Kubernetes cluster VMs will be launched", - false, + true, KubernetesServiceEnabled.key()); static final ConfigKey KubernetesClusterStartTimeout = new ConfigKey("Advanced", Long.class, "cloud.kubernetes.cluster.start.timeout", diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterVO.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterVO.java index 79fc15f6898..7dfd0043e32 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterVO.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterVO.java @@ -145,6 +145,9 @@ public class KubernetesClusterVO implements KubernetesCluster { @Column(name = "cni_config_details", updatable = true, length = 4096) private String cniConfigDetails; + @Column(name = "csi_enabled") + private boolean csiEnabled; + @Override public long getId() { return id; @@ -389,6 +392,14 @@ public class KubernetesClusterVO implements KubernetesCluster { this.clusterType = clusterType; } + public boolean isCsiEnabled() { + return csiEnabled; + } + + public void setCsiEnabled(boolean csiEnabled) { + this.csiEnabled = csiEnabled; + } + public KubernetesClusterVO() { this.uuid = UUID.randomUUID().toString(); } diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java index 9be5f4c0776..baf717612f8 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java @@ -232,13 +232,17 @@ public class KubernetesClusterActionWorker { protected final String deploySecretsScriptFilename = "deploy-cloudstack-secret"; protected final String deployProviderScriptFilename = "deploy-provider"; + protected final String deployCsiDriverScriptFilename = "deploy-csi-driver"; + protected final String deletePvScriptFilename = "delete-pv-reclaimpolicy-delete"; protected final String autoscaleScriptFilename = "autoscale-kube-cluster"; protected final String validateNodeScript = "validate-cks-node"; protected final String removeNodeFromClusterScript = "remove-node-from-cluster"; protected final String scriptPath = "/opt/bin/"; protected File deploySecretsScriptFile; protected File deployProviderScriptFile; + protected File deployCsiDriverScriptFile; protected File autoscaleScriptFile; + protected File deletePvScriptFile; protected KubernetesClusterManagerImpl manager; protected String[] keys; @@ -715,12 +719,16 @@ public class KubernetesClusterActionWorker { protected void retrieveScriptFiles() { deploySecretsScriptFile = retrieveScriptFile(deploySecretsScriptFilename); deployProviderScriptFile = retrieveScriptFile(deployProviderScriptFilename); + deployCsiDriverScriptFile = retrieveScriptFile(deployCsiDriverScriptFilename); + deletePvScriptFile = retrieveScriptFile(deletePvScriptFilename); autoscaleScriptFile = retrieveScriptFile(autoscaleScriptFilename); } protected void copyScripts(String nodeAddress, final int sshPort) { copyScriptFile(nodeAddress, sshPort, deploySecretsScriptFile, deploySecretsScriptFilename); copyScriptFile(nodeAddress, sshPort, deployProviderScriptFile, deployProviderScriptFilename); + copyScriptFile(nodeAddress, sshPort, deployCsiDriverScriptFile, deployCsiDriverScriptFilename); + copyScriptFile(nodeAddress, sshPort, deletePvScriptFile, deletePvScriptFilename); copyScriptFile(nodeAddress, sshPort, autoscaleScriptFile, autoscaleScriptFilename); } @@ -821,6 +829,43 @@ public class KubernetesClusterActionWorker { } } + protected boolean deployCsiDriver() { + File pkFile = getManagementServerSshPublicKeyFile(); + Pair publicIpSshPort = getKubernetesClusterServerIpSshPort(null); + publicIpAddress = publicIpSshPort.first(); + sshPort = publicIpSshPort.second(); + + try { + String command = String.format("sudo %s/%s", scriptPath, deployCsiDriverScriptFilename); + Pair result = SshHelper.sshExecute(publicIpAddress, sshPort, getControlNodeLoginUser(), + pkFile, null, command, 10000, 10000, 60000); + + // Maybe the file isn't present. Try and copy it + if (!result.first()) { + logMessage(Level.INFO, "CSI files missing. Adding them now", null); + retrieveScriptFiles(); + copyScripts(publicIpAddress, sshPort); + + if (!createCloudStackSecret(keys)) { + logTransitStateAndThrow(Level.ERROR, String.format("Failed to setup keys for Kubernetes cluster %s", + kubernetesCluster.getName()), kubernetesCluster.getId(), KubernetesCluster.Event.OperationFailed); + } + + // If at first you don't succeed ... + result = SshHelper.sshExecute(publicIpAddress, sshPort, getControlNodeLoginUser(), + pkFile, null, command, 10000, 10000, 60000); + if (!result.first()) { + throw new CloudRuntimeException(result.second()); + } + } + return true; + } catch (Exception e) { + String msg = String.format("Failed to deploy kubernetes provider: %s : %s", kubernetesCluster.getName(), e.getMessage()); + logAndThrow(Level.ERROR, msg); + return false; + } + } + public void setKeys(String[] keys) { this.keys = keys; } diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java index cf77a83420a..62bd8b4576a 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java @@ -106,6 +106,9 @@ public class KubernetesClusterDestroyWorker extends KubernetesClusterResourceMod ApiCommandResourceType.VirtualMachine); vmContext.setEventResourceId(vmID); try { + if (clusterVM.isControlNode() && kubernetesCluster.isCsiEnabled()) { + deletePVsWithReclaimPolicyDelete(); + } UserVm vm = userVmService.destroyVm(vmID, true); if (!userVmManager.expunge(userVM)) { logger.warn("Unable to expunge VM {}, destroying Kubernetes cluster will probably fail", vm); diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorker.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorker.java index d392612547b..cf69234d19e 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorker.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorker.java @@ -36,6 +36,7 @@ import java.util.stream.Collectors; import javax.inject.Inject; +import com.cloud.cpu.CPU; import com.cloud.deploy.DataCenterDeployment; import com.cloud.deploy.DeploymentPlan; import com.cloud.dc.DedicatedResourceVO; @@ -177,7 +178,7 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu } protected DeployDestination plan(final long nodesCount, final DataCenter zone, final ServiceOffering offering, - final Long domainId, final Long accountId, final Hypervisor.HypervisorType hypervisorType) throws InsufficientServerCapacityException { + final Long domainId, final Long accountId, final Hypervisor.HypervisorType hypervisorType, CPU.CPUArch arch) throws InsufficientServerCapacityException { final int cpu_requested = offering.getCpu() * offering.getSpeed(); final long ram_requested = offering.getRamSize() * 1024L * 1024L; boolean useDedicatedHosts = false; @@ -201,6 +202,15 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu if (hypervisorType != null) { hosts = hosts.stream().filter(x -> x.getHypervisorType() == hypervisorType).collect(Collectors.toList()); } + if (arch != null) { + hosts = hosts.stream().filter(x -> x.getArch().equals(arch)).collect(Collectors.toList()); + } + if (CollectionUtils.isEmpty(hosts)) { + String msg = String.format("Cannot find enough capacity for Kubernetes cluster(requested cpu=%d memory=%s) with offering: %s hypervisor: %s and arch: %s", + cpu_requested * nodesCount, toHumanReadableSize(ram_requested * nodesCount), offering.getName(), clusterTemplate.getHypervisorType().toString(), arch.getType()); + logAndThrow(Level.WARN, msg, new InsufficientServerCapacityException(msg, DataCenter.class, zone.getId())); + } + final Map> hosts_with_resevered_capacity = new ConcurrentHashMap>(); for (HostVO h : hosts) { hosts_with_resevered_capacity.put(h.getUuid(), new Pair(h, 0)); @@ -254,8 +264,8 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu } return new DeployDestination(zone, null, null, null); } - String msg = String.format("Cannot find enough capacity for Kubernetes cluster(requested cpu=%d memory=%s) with offering: %s and hypervisor: %s", - cpu_requested * nodesCount, toHumanReadableSize(ram_requested * nodesCount), offering.getName(), clusterTemplate.getHypervisorType().toString()); + String msg = String.format("Cannot find enough capacity for Kubernetes cluster(requested cpu=%d memory=%s) with offering: %s hypervisor: %s and arch: %s", + cpu_requested * nodesCount, toHumanReadableSize(ram_requested * nodesCount), offering.getName(), clusterTemplate.getHypervisorType().toString(), arch.getType()); logger.warn(msg); throw new InsufficientServerCapacityException(msg, DataCenter.class, zone.getId()); @@ -265,7 +275,7 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu * Plan Kubernetes Cluster Deployment * @return a map of DeployDestination per node type */ - protected Map planKubernetesCluster(Long domainId, Long accountId, Hypervisor.HypervisorType hypervisorType) throws InsufficientServerCapacityException { + protected Map planKubernetesCluster(Long domainId, Long accountId, Hypervisor.HypervisorType hypervisorType, CPU.CPUArch arch) throws InsufficientServerCapacityException { Map destinationMap = new HashMap<>(); DataCenter zone = dataCenterDao.findById(kubernetesCluster.getZoneId()); if (logger.isDebugEnabled()) { @@ -286,7 +296,7 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu if (logger.isDebugEnabled()) { logger.debug("Checking deployment destination for {} nodes on Kubernetes cluster : {} in zone : {}", nodeType.name(), kubernetesCluster.getName(), zone.getName()); } - DeployDestination planForNodeType = plan(nodes, zone, nodeOffering, domainId, accountId, hypervisorType); + DeployDestination planForNodeType = plan(nodes, zone, nodeOffering, domainId, accountId, hypervisorType, arch); destinationMap.put(nodeType.name(), planForNodeType); } return destinationMap; @@ -322,7 +332,7 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu if (Objects.nonNull(domainId) && !listDedicatedHostsInDomain(domainId).isEmpty()) { DeployDestination dest = null; try { - Map destinationMap = planKubernetesCluster(domainId, accountId, vm.getHypervisorType()); + Map destinationMap = planKubernetesCluster(domainId, accountId, vm.getHypervisorType(), clusterTemplate.getArch()); dest = destinationMap.get(nodeType.name()); } catch (InsufficientCapacityException e) { logTransitStateAndThrow(Level.ERROR, String.format("Provisioning the cluster failed due to insufficient capacity in the Kubernetes cluster: %s", kubernetesCluster.getUuid()), kubernetesCluster.getId(), KubernetesCluster.Event.CreateFailed, e); @@ -944,4 +954,47 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu protected List listDedicatedHostsInDomain(Long domainId) { return dedicatedResourceDao.listByDomainId(domainId); } + + public boolean deletePVsWithReclaimPolicyDelete() { + File pkFile = getManagementServerSshPublicKeyFile(); + Pair publicIpSshPort = getKubernetesClusterServerIpSshPort(null); + publicIpAddress = publicIpSshPort.first(); + sshPort = publicIpSshPort.second(); + try { + String command = String.format("sudo %s/%s", scriptPath, deletePvScriptFilename); + logMessage(Level.INFO, "Starting PV deletion script for cluster: " + kubernetesCluster.getName(), null); + Pair result = SshHelper.sshExecute(publicIpAddress, sshPort, getControlNodeLoginUser(), + pkFile, null, command, 10000, 10000, 600000); // 10 minute timeout + if (Boolean.FALSE.equals(result.first())) { + logMessage(Level.INFO, "PV delete script missing. Adding it now", null); + retrieveScriptFiles(); + if (deletePvScriptFile != null) { + copyScriptFile(publicIpAddress, sshPort, deletePvScriptFile, deletePvScriptFilename); + logMessage(Level.INFO, "Executing PV deletion script (this may take several minutes)...", null); + result = SshHelper.sshExecute(publicIpAddress, sshPort, getControlNodeLoginUser(), + pkFile, null, command, 10000, 10000, 600000); // 10 minute timeout + if (Boolean.FALSE.equals(result.first())) { + logMessage(Level.ERROR, "PV deletion script failed: " + result.second(), null); + throw new CloudRuntimeException(result.second()); + } + logMessage(Level.INFO, "PV deletion script completed successfully", null); + } else { + logMessage(Level.WARN, "PV delete script file not found in resources, skipping PV deletion", null); + return false; + } + } else { + logMessage(Level.INFO, "PV deletion script completed successfully", null); + } + + if (result.second() != null && !result.second().trim().isEmpty()) { + logMessage(Level.INFO, "PV deletion script output: " + result.second(), null); + } + + return true; + } catch (Exception e) { + String msg = String.format("Failed to delete PVs with reclaimPolicy=Delete: %s : %s", kubernetesCluster.getName(), e.getMessage()); + logMessage(Level.WARN, msg, e); + return false; + } + } } diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterScaleWorker.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterScaleWorker.java index c552b5d57c7..dba858ed809 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterScaleWorker.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterScaleWorker.java @@ -341,9 +341,9 @@ public class KubernetesClusterScaleWorker extends KubernetesClusterResourceModif VMTemplateVO clusterTemplate = templateDao.findById(kubernetesCluster.getTemplateId()); try { if (originalState.equals(KubernetesCluster.State.Running)) { - plan(newVmRequiredCount, zone, clusterServiceOffering, kubernetesCluster.getDomainId(), kubernetesCluster.getAccountId(), clusterTemplate.getHypervisorType()); + plan(newVmRequiredCount, zone, clusterServiceOffering, kubernetesCluster.getDomainId(), kubernetesCluster.getAccountId(), clusterTemplate.getHypervisorType(), clusterTemplate.getArch()); } else { - plan(kubernetesCluster.getTotalNodeCount() + newVmRequiredCount, zone, clusterServiceOffering, kubernetesCluster.getDomainId(), kubernetesCluster.getAccountId(), clusterTemplate.getHypervisorType()); + plan(kubernetesCluster.getTotalNodeCount() + newVmRequiredCount, zone, clusterServiceOffering, kubernetesCluster.getDomainId(), kubernetesCluster.getAccountId(), clusterTemplate.getHypervisorType(), clusterTemplate.getArch()); } } catch (InsufficientCapacityException e) { logTransitStateToFailedIfNeededAndThrow(Level.WARN, String.format("Scaling failed for Kubernetes cluster : %s in zone : %s, insufficient capacity", kubernetesCluster.getName(), zone.getName())); diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterStartWorker.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterStartWorker.java index 8cd539b78e4..aa9317e619b 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterStartWorker.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterStartWorker.java @@ -143,7 +143,7 @@ public class KubernetesClusterStartWorker extends KubernetesClusterResourceModif private Pair getKubernetesControlNodeConfig(final String controlNodeIp, final String serverIp, final List etcdIps, final String hostName, final boolean haSupported, - final boolean ejectIso, final boolean externalCni) throws IOException { + final boolean ejectIso, final boolean externalCni, final boolean setupCsi) throws IOException { String k8sControlNodeConfig = readK8sConfigFile("/conf/k8s-control-node.yml"); final String apiServerCert = "{{ k8s_control_node.apiserver.crt }}"; final String apiServerKey = "{{ k8s_control_node.apiserver.key }}"; @@ -161,6 +161,7 @@ public class KubernetesClusterStartWorker extends KubernetesClusterResourceModif final String certSans = "{{ k8s_control.server_ips }}"; final String k8sCertificate = "{{ k8s_control.certificate_key }}"; final String externalCniPlugin = "{{ k8s.external.cni.plugin }}"; + final String setupCsiDriver = "{{ k8s.setup.csi.driver }}"; final List addresses = new ArrayList<>(); addresses.add(controlNodeIp); @@ -212,6 +213,7 @@ public class KubernetesClusterStartWorker extends KubernetesClusterResourceModif k8sControlNodeConfig = k8sControlNodeConfig.replace(certSans, String.format("- %s", serverIp)); k8sControlNodeConfig = k8sControlNodeConfig.replace(k8sCertificate, KubernetesClusterUtil.generateClusterHACertificateKey(kubernetesCluster)); k8sControlNodeConfig = k8sControlNodeConfig.replace(externalCniPlugin, String.valueOf(externalCni)); + k8sControlNodeConfig = k8sControlNodeConfig.replace(setupCsiDriver, String.valueOf(setupCsi)); k8sControlNodeConfig = updateKubeConfigWithRegistryDetails(k8sControlNodeConfig); @@ -246,7 +248,7 @@ public class KubernetesClusterStartWorker extends KubernetesClusterResourceModif Long userDataId = kubernetesCluster.getCniConfigId(); Pair k8sControlNodeConfigAndControlIp = new Pair<>(null, null); try { - k8sControlNodeConfigAndControlIp = getKubernetesControlNodeConfig(controlNodeIp, serverIp, etcdIps, hostName, haSupported, Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()), Objects.nonNull(userDataId)); + k8sControlNodeConfigAndControlIp = getKubernetesControlNodeConfig(controlNodeIp, serverIp, etcdIps, hostName, haSupported, Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()), Objects.nonNull(userDataId), kubernetesCluster.isCsiEnabled()); } catch (IOException e) { logAndThrow(Level.ERROR, "Failed to read Kubernetes control node configuration file", e); } @@ -747,7 +749,7 @@ public class KubernetesClusterStartWorker extends KubernetesClusterResourceModif DeployDestination dest = null; try { VMTemplateVO clusterTemplate = templateDao.findById(kubernetesCluster.getTemplateId()); - Map destinationMap = planKubernetesCluster(domainId, accountId, clusterTemplate.getHypervisorType()); + Map destinationMap = planKubernetesCluster(domainId, accountId, clusterTemplate.getHypervisorType(), clusterTemplate.getArch()); dest = destinationMap.get(WORKER.name()); } catch (InsufficientCapacityException e) { logTransitStateAndThrow(Level.ERROR, String.format("Provisioning the cluster failed due to insufficient capacity in the Kubernetes cluster: %s", kubernetesCluster.getUuid()), kubernetesCluster.getId(), KubernetesCluster.Event.CreateFailed, e); @@ -858,6 +860,9 @@ public class KubernetesClusterStartWorker extends KubernetesClusterResourceModif } taintControlNodes(); deployProvider(); + if (kubernetesCluster.isCsiEnabled()) { + deployCsiDriver(); + } updateLoginUserDetails(clusterVMs.stream().map(InternalIdentity::getId).collect(Collectors.toList())); stateTransitTo(kubernetesCluster.getId(), KubernetesCluster.Event.OperationSucceeded); return true; diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionManagerImpl.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionManagerImpl.java index 99c9a4de051..99f826402ce 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionManagerImpl.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionManagerImpl.java @@ -17,6 +17,7 @@ package com.cloud.kubernetes.version; +import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; @@ -26,10 +27,13 @@ import org.apache.cloudstack.api.ApiCommandResourceType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.command.admin.kubernetes.version.AddKubernetesSupportedVersionCmd; import org.apache.cloudstack.api.command.admin.kubernetes.version.DeleteKubernetesSupportedVersionCmd; +import org.apache.cloudstack.api.command.admin.kubernetes.version.GetUploadParamsForKubernetesSupportedVersionCmd; import org.apache.cloudstack.api.command.admin.kubernetes.version.UpdateKubernetesSupportedVersionCmd; import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd; +import org.apache.cloudstack.api.command.user.iso.GetUploadParamsForIsoCmd; import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd; import org.apache.cloudstack.api.command.user.kubernetes.version.ListKubernetesSupportedVersionsCmd; +import org.apache.cloudstack.api.response.GetUploadParamsResponse; import org.apache.cloudstack.api.response.KubernetesSupportedVersionResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.context.CallContext; @@ -162,6 +166,33 @@ public class KubernetesVersionManagerImpl extends ManagerBase implements Kuberne return versions; } + private GetUploadParamsResponse registerKubernetesVersionIsoForUpload(final Long zoneId, final String versionName, final String isoChecksum) { + CallContext.register(CallContext.current(), ApiCommandResourceType.Iso); + String isoName = String.format("%s-Kubernetes-Binaries-ISO", versionName); + GetUploadParamsForIsoCmd uploadIso = new GetUploadParamsForIsoCmd(); + uploadIso = ComponentContext.inject(uploadIso); + uploadIso.setName(isoName); + uploadIso.setPublicIso(true); + if (zoneId != null) { + uploadIso.setZoneId(zoneId); + } + uploadIso.setDisplayText(isoName); + uploadIso.setBootable(false); + if (StringUtils.isNotEmpty(isoChecksum)) { + uploadIso.setChecksum(isoChecksum); + } + uploadIso.setAccountName(accountManager.getSystemAccount().getAccountName()); + uploadIso.setDomainId(accountManager.getSystemAccount().getDomainId()); + try { + return templateService.registerIsoForPostUpload(uploadIso); + } catch (MalformedURLException | ResourceAllocationException e) { + logger.error(String.format("Unable to register binaries ISO for supported kubernetes version, %s", versionName), e); + throw new CloudRuntimeException(String.format("Unable to register binaries ISO for supported kubernetes version, %s", versionName), e); + } finally { + CallContext.unregister(); + } + } + private VirtualMachineTemplate registerKubernetesVersionIso(final Long zoneId, final String versionName, final String isoUrl, final String isoChecksum, final boolean directDownload, CPU.CPUArch arch) throws IllegalAccessException, NoSuchFieldException, IllegalArgumentException, ResourceAllocationException { CallContext.register(CallContext.current(), ApiCommandResourceType.Iso); @@ -316,23 +347,8 @@ public class KubernetesVersionManagerImpl extends ManagerBase implements Kuberne return createKubernetesSupportedVersionListResponse(versions, versionsAndCount.second()); } - @Override - @ActionEvent(eventType = KubernetesVersionEventTypes.EVENT_KUBERNETES_VERSION_ADD, - eventDescription = "Adding Kubernetes supported version") - public KubernetesSupportedVersionResponse addKubernetesSupportedVersion(final AddKubernetesSupportedVersionCmd cmd) { - if (!KubernetesClusterService.KubernetesServiceEnabled.value()) { - throw new CloudRuntimeException("Kubernetes Service plugin is disabled"); - } - String name = cmd.getName(); - final String semanticVersion = cmd.getSemanticVersion(); - final Long zoneId = cmd.getZoneId(); - final String isoUrl = cmd.getUrl(); - final String isoChecksum = cmd.getChecksum(); - final Integer minimumCpu = cmd.getMinimumCpu(); - final Integer minimumRamSize = cmd.getMinimumRamSize(); - final boolean isDirectDownload = cmd.isDirectDownload(); - CPU.CPUArch arch = cmd.getArch(); - + private void validateKubernetesSupportedVersion(Long zoneId, String semanticVersion, Integer minimumCpu, + Integer minimumRamSize, boolean isDirectDownload) { if (minimumCpu == null || minimumCpu < KubernetesClusterService.MIN_KUBERNETES_CLUSTER_NODE_CPU) { throw new InvalidParameterValueException(String.format("Invalid value for %s parameter. Minimum %d vCPUs required.", ApiConstants.MIN_CPU_NUMBER, KubernetesClusterService.MIN_KUBERNETES_CLUSTER_NODE_CPU)); } @@ -351,6 +367,27 @@ public class KubernetesVersionManagerImpl extends ManagerBase implements Kuberne throw new InvalidParameterValueException(String.format("Zone: %s supports only direct download Kubernetes versions", zone.getName())); } } + } + + @Override + @ActionEvent(eventType = KubernetesVersionEventTypes.EVENT_KUBERNETES_VERSION_ADD, + eventDescription = "Adding Kubernetes supported version") + public KubernetesSupportedVersionResponse addKubernetesSupportedVersion(final AddKubernetesSupportedVersionCmd cmd) { + if (!KubernetesClusterService.KubernetesServiceEnabled.value()) { + throw new CloudRuntimeException("Kubernetes Service plugin is disabled"); + } + String name = cmd.getName(); + final String semanticVersion = cmd.getSemanticVersion(); + final Long zoneId = cmd.getZoneId(); + final String isoUrl = cmd.getUrl(); + final String isoChecksum = cmd.getChecksum(); + final Integer minimumCpu = cmd.getMinimumCpu(); + final Integer minimumRamSize = cmd.getMinimumRamSize(); + final boolean isDirectDownload = cmd.isDirectDownload(); + CPU.CPUArch arch = cmd.getArch(); + + validateKubernetesSupportedVersion(zoneId, semanticVersion, minimumCpu, minimumRamSize, isDirectDownload); + if (StringUtils.isEmpty(isoUrl)) { throw new InvalidParameterValueException(String.format("Invalid URL for ISO specified, %s", isoUrl)); } @@ -377,6 +414,30 @@ public class KubernetesVersionManagerImpl extends ManagerBase implements Kuberne return createKubernetesSupportedVersionResponse(supportedVersionVO); } + @Override + public GetUploadParamsResponse registerKubernetesSupportedVersionForPostUpload(GetUploadParamsForKubernetesSupportedVersionCmd cmd) { + if (!KubernetesClusterService.KubernetesServiceEnabled.value()) { + throw new CloudRuntimeException("Kubernetes Service plugin is disabled"); + } + String name = cmd.getName(); + final String semanticVersion = cmd.getSemanticVersion(); + final Long zoneId = cmd.getZoneId(); + final String isoChecksum = cmd.getChecksum(); + final Integer minimumCpu = cmd.getMinimumCpu(); + final Integer minimumRamSize = cmd.getMinimumRamSize(); + + validateKubernetesSupportedVersion(zoneId, semanticVersion, minimumCpu, minimumRamSize, false); + + GetUploadParamsResponse response = registerKubernetesVersionIsoForUpload(zoneId, name, isoChecksum); + + VMTemplateVO template = templateDao.findByUuid(response.getId().toString()); + KubernetesSupportedVersionVO supportedVersionVO = new KubernetesSupportedVersionVO(name, semanticVersion, template.getId(), zoneId, minimumCpu, minimumRamSize); + supportedVersionVO = kubernetesSupportedVersionDao.persist(supportedVersionVO); + CallContext.current().putContextParameter(KubernetesSupportedVersion.class, supportedVersionVO.getUuid()); + + return response; + } + @Override @ActionEvent(eventType = KubernetesVersionEventTypes.EVENT_KUBERNETES_VERSION_DELETE, eventDescription = "deleting Kubernetes supported version", async = true) @@ -445,6 +506,7 @@ public class KubernetesVersionManagerImpl extends ManagerBase implements Kuberne return cmdList; } cmdList.add(AddKubernetesSupportedVersionCmd.class); + cmdList.add(GetUploadParamsForKubernetesSupportedVersionCmd.class); cmdList.add(ListKubernetesSupportedVersionsCmd.class); cmdList.add(DeleteKubernetesSupportedVersionCmd.class); cmdList.add(UpdateKubernetesSupportedVersionCmd.class); diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionService.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionService.java index 8e4cd032556..cbe33e94d1e 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionService.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionService.java @@ -19,8 +19,10 @@ package com.cloud.kubernetes.version; import org.apache.cloudstack.api.command.admin.kubernetes.version.AddKubernetesSupportedVersionCmd; import org.apache.cloudstack.api.command.admin.kubernetes.version.DeleteKubernetesSupportedVersionCmd; +import org.apache.cloudstack.api.command.admin.kubernetes.version.GetUploadParamsForKubernetesSupportedVersionCmd; import org.apache.cloudstack.api.command.admin.kubernetes.version.UpdateKubernetesSupportedVersionCmd; import org.apache.cloudstack.api.command.user.kubernetes.version.ListKubernetesSupportedVersionsCmd; +import org.apache.cloudstack.api.response.GetUploadParamsResponse; import org.apache.cloudstack.api.response.KubernetesSupportedVersionResponse; import org.apache.cloudstack.api.response.ListResponse; @@ -31,6 +33,7 @@ public interface KubernetesVersionService extends PluggableService { static final String MIN_KUBERNETES_VERSION = "1.11.0"; ListResponse listKubernetesSupportedVersions(ListKubernetesSupportedVersionsCmd cmd); KubernetesSupportedVersionResponse addKubernetesSupportedVersion(AddKubernetesSupportedVersionCmd cmd) throws CloudRuntimeException; + GetUploadParamsResponse registerKubernetesSupportedVersionForPostUpload(GetUploadParamsForKubernetesSupportedVersionCmd cmd); boolean deleteKubernetesSupportedVersion(DeleteKubernetesSupportedVersionCmd cmd) throws CloudRuntimeException; KubernetesSupportedVersionResponse updateKubernetesSupportedVersion(UpdateKubernetesSupportedVersionCmd cmd) throws CloudRuntimeException; } diff --git a/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/admin/kubernetes/version/GetUploadParamsForKubernetesSupportedVersionCmd.java b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/admin/kubernetes/version/GetUploadParamsForKubernetesSupportedVersionCmd.java new file mode 100644 index 00000000000..7aa78df2187 --- /dev/null +++ b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/admin/kubernetes/version/GetUploadParamsForKubernetesSupportedVersionCmd.java @@ -0,0 +1,127 @@ +// 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.admin.kubernetes.version; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.kubernetes.version.KubernetesSupportedVersion; +import com.cloud.kubernetes.version.KubernetesVersionService; +import com.cloud.utils.exception.CloudRuntimeException; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.AbstractGetUploadParamsCmd; +import org.apache.cloudstack.api.ApiCommandResourceType; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.admin.AdminCmd; +import org.apache.cloudstack.api.response.GetUploadParamsResponse; +import org.apache.cloudstack.api.response.KubernetesSupportedVersionResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.commons.lang3.StringUtils; + +import javax.inject.Inject; + +@APICommand(name = "getUploadParamsForKubernetesSupportedVersion", + description = "Upload a supported Kubernetes version", + responseObject = KubernetesSupportedVersionResponse.class, + responseView = ResponseObject.ResponseView.Full, + entityType = {KubernetesSupportedVersion.class}, + authorized = {RoleType.Admin}) +public class GetUploadParamsForKubernetesSupportedVersionCmd extends AbstractGetUploadParamsCmd implements AdminCmd { + + @Inject + private KubernetesVersionService kubernetesVersionService; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + @Parameter(name = ApiConstants.SEMANTIC_VERSION, type = CommandType.STRING, required = true, + description = "the semantic version of the Kubernetes version. It needs to be specified in MAJOR.MINOR.PATCH format") + private String semanticVersion; + + @Parameter(name = ApiConstants.CHECKSUM, type = CommandType.STRING, + description = "the checksum value of the binaries ISO. " + ApiConstants.CHECKSUM_PARAMETER_PREFIX_DESCRIPTION) + private String checksum; + + @Parameter(name = ApiConstants.MIN_CPU_NUMBER, type = CommandType.INTEGER, required = true, + description = "the minimum number of CPUs to be set with the Kubernetes version") + private Integer minimumCpu; + + @Parameter(name = ApiConstants.MIN_MEMORY, type = CommandType.INTEGER, required = true, + description = "the minimum RAM size in MB to be set with the Kubernetes version") + private Integer minimumRamSize; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public String getSemanticVersion() { + if(StringUtils.isEmpty(semanticVersion)) { + throw new InvalidParameterValueException("Version can not be null"); + } + if(!semanticVersion.matches("[0-9]+(\\.[0-9]+)*")) { + throw new IllegalArgumentException("Invalid version format. Semantic version needed"); + } + return semanticVersion; + } + + public String getChecksum() { + return checksum; + } + + public Integer getMinimumCpu() { + return minimumCpu; + } + + public Integer getMinimumRamSize() { + return minimumRamSize; + } + + @Override + public long getEntityOwnerId() { + return CallContext.current().getCallingAccountId(); + } + + @Override + public ApiCommandResourceType getApiResourceType() { + return ApiCommandResourceType.KubernetesSupportedVersion; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + @Override + public void execute() throws ServerApiException, ConcurrentOperationException { + if (getZoneId() <= 0) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid zoneid"); + } + try { + GetUploadParamsResponse response = kubernetesVersionService.registerKubernetesSupportedVersionForPostUpload(this); + if (response == null) { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Kubernetes supported version"); + } + response.setResponseName(getCommandName()); + setResponseObject(response); + } catch (CloudRuntimeException ex) { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } + } +} diff --git a/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java index 4e92f9546f8..ad4f61f3e9b 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java +++ b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java @@ -207,6 +207,9 @@ public class CreateKubernetesClusterCmd extends BaseAsyncCreateCmd { since = "4.21.0") private Map cniConfigDetails; + @Parameter(name = ApiConstants.ENABLE_CSI, type = CommandType.BOOLEAN, description = "if true, setups up CloudStack CSI driver", since = "4.22.0") + private Boolean enableCsi; + @Parameter(name=ApiConstants.AS_NUMBER, type=CommandType.LONG, description="the AS Number of the network") private Long asNumber; @@ -371,6 +374,10 @@ public class CreateKubernetesClusterCmd extends BaseAsyncCreateCmd { return cniConfigId; } + public boolean getEnableCsi() { + return Objects.nonNull(enableCsi) ? enableCsi : Boolean.FALSE; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java index b811f4f9dcb..3ad924bda66 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java +++ b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java @@ -30,7 +30,7 @@ import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") @EntityReference(value = {KubernetesCluster.class}) -public class KubernetesClusterResponse extends BaseResponseWithAnnotations implements ControlledEntityResponse { +public class KubernetesClusterResponse extends BaseResponseWithAnnotations implements ControlledViewEntityResponse { @SerializedName(ApiConstants.ID) @Param(description = "the id of the Kubernetes cluster") private String id; @@ -91,6 +91,10 @@ public class KubernetesClusterResponse extends BaseResponseWithAnnotations imple @Param(description = "the ID of the template of the Kubernetes cluster") private String templateId; + @SerializedName(ApiConstants.TEMPLATE_NAME) + @Param(description = "the name of the template of the Kubernetes cluster") + private String templateName; + @SerializedName(ApiConstants.NETWORK_ID) @Param(description = "the ID of the network of the Kubernetes cluster") private String networkId; @@ -204,6 +208,10 @@ public class KubernetesClusterResponse extends BaseResponseWithAnnotations imple @Param(description = "Maximum size of the cluster") private Long maxSize; + @SerializedName(ApiConstants.CSI_ENABLED) + @Param(description = "Indicates if the CloudStack CSI driver has been setup in the cluster") + private Boolean isCsiEnabled; + @SerializedName(ApiConstants.CLUSTER_TYPE) @Param(description = "the type of the cluster") private KubernetesCluster.ClusterType clusterType; @@ -263,6 +271,14 @@ public class KubernetesClusterResponse extends BaseResponseWithAnnotations imple this.templateId = templateId; } + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + public String getNetworkId() { return networkId; } @@ -515,4 +531,8 @@ public class KubernetesClusterResponse extends BaseResponseWithAnnotations imple public void setCniConfigName(String cniConfigName) { this.cniConfigName = cniConfigName; } + + public void setCsiEnabled(Boolean csiEnabled) { + isCsiEnabled = csiEnabled; + } } diff --git a/plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node.yml b/plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node.yml index dc066e10d06..70291dd1c35 100644 --- a/plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node.yml +++ b/plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node.yml @@ -179,6 +179,11 @@ write_files: mkdir -p /opt/provider cp "${BINARIES_DIR}/provider.yaml" /opt/provider/provider.yaml fi + if [ -e "${BINARIES_DIR}/snapshot-crds.yaml" ]; then + mkdir -p /opt/csi + cp "${BINARIES_DIR}/snapshot-crds.yaml" /opt/csi/snapshot-crds.yaml + cp "${BINARIES_DIR}/manifest.yaml" /opt/csi/manifest.yaml + fi PAUSE_IMAGE=`ctr -n k8s.io images ls -q | grep "pause" | sort | tail -n 1` echo $PAUSE_IMAGE diff --git a/plugins/integrations/kubernetes-service/src/main/resources/script/delete-pv-reclaimpolicy-delete b/plugins/integrations/kubernetes-service/src/main/resources/script/delete-pv-reclaimpolicy-delete new file mode 100755 index 00000000000..aac0cbf07e4 --- /dev/null +++ b/plugins/integrations/kubernetes-service/src/main/resources/script/delete-pv-reclaimpolicy-delete @@ -0,0 +1,156 @@ +#!/bin/bash -e +# 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. + +set -e + +timestamp() { + date '+%Y-%m-%d %H:%M:%S' +} + +echo "$(timestamp) - Starting PV deletion script with reclaimPolicy=Delete" + +delete_workloads_using_pvc() { + local namespace=$1 + local pvc_name=$2 + + echo "$(timestamp) - Finding workloads using PVC $pvc_name in namespace $namespace..." + + local deleted_count=0 + + # Find & delete any deployment using the PVC + /opt/bin/kubectl get deployments -n "$namespace" -o json 2>/dev/null | grep -l "$pvc_name" | \ + while IFS= read -r deployment; do + if [ -n "$deployment" ]; then + deployment_name=$(echo "$deployment" | cut -d'/' -f2) + echo "$(timestamp) - Deleting Deployment: $deployment_name" + /opt/bin/kubectl delete deployment "$deployment_name" -n "$namespace" --ignore-not-found=true + deleted_count=$((deleted_count + 1)) + fi + done + + # Find and delete any StatefulSet using the PVC + /opt/bin/kubectl get statefulsets -n "$namespace" -o json 2>/dev/null | grep -l "$pvc_name" | \ + while IFS= read -r sts; do + if [ -n "$sts" ]; then + sts_name=$(echo "$sts" | cut -d'/' -f2) + echo "$(timestamp) - Deleting StatefulSet: $sts_name" + /opt/bin/kubectl delete statefulset "$sts_name" -n "$namespace" --ignore-not-found=true + deleted_count=$((deleted_count + 1)) + fi + done + + # Check standalone ReplicaSets (not owned by Deployments) + /opt/bin/kubectl get replicasets -n "$namespace" --no-headers -o custom-columns=NAME:.metadata.name | \ + while read rs_name; do + if [ -n "$rs_name" ]; then + rs_volumes=$(/opt/bin/kubectl get replicaset "$rs_name" -n "$namespace" -o jsonpath='{.spec.template.spec.volumes[*].persistentVolumeClaim.claimName}' 2>/dev/null || echo "") + if echo "$rs_volumes" | grep -q "$pvc_name"; then + owner_kind=$(/opt/bin/kubectl get replicaset "$rs_name" -n "$namespace" -o jsonpath='{.metadata.ownerReferences[0].kind}' 2>/dev/null || echo "") + if [ "$owner_kind" != "Deployment" ]; then + echo "$(timestamp) - Deleting standalone ReplicaSet: $rs_name" + /opt/bin/kubectl delete replicaset "$rs_name" -n "$namespace" --ignore-not-found=true + deleted_count=$((deleted_count + 1)) + fi + fi + fi + done + + # Find and delete any DaemonSet using the PVC + /opt/bin/kubectl get daemonsets -n "$namespace" -o json 2>/dev/null | grep -l "$pvc_name" | \ + while IFS= read -r ds; do + if [ -n "$ds" ]; then + ds_name=$(echo "$ds" | cut -d'/' -f2) + echo "$(timestamp) - Deleting DaemonSet: $ds_name" + /opt/bin/kubectl delete daemonset "$ds_name" -n "$namespace" --ignore-not-found=true + deleted_count=$((deleted_count + 1)) + fi + done + + # Find and delete any Job using the PVC + /opt/bin/kubectl get jobs -n "$namespace" -o json 2>/dev/null | grep -l "$pvc_name" | \ + while IFS= read -r job; do + if [ -n "$job" ]; then + job_name=$(echo "$job" | cut -d'/' -f2) + echo "$(timestamp) - Deleting Job: $job_name" + /opt/bin/kubectl delete job "$job_name" -n "$namespace" --ignore-not-found=true + deleted_count=$((deleted_count + 1)) + fi + done + + # Find and delete any CronJobs using the PVC + /opt/bin/kubectl get cronjobs -n "$namespace" -o json 2>/dev/null | grep -l "$pvc_name" | \ + while IFS= read -r cronjob; do + if [ -n "$cronjob" ]; then + cronjob_name=$(echo "$cronjob" | cut -d'/' -f2) + echo "$(timestamp) - Deleting CronJob: $cronjob_name" + /opt/bin/kubectl delete cronjob "$cronjob_name" -n "$namespace" --ignore-not-found=true + deleted_count=$((deleted_count + 1)) + fi + done + + # Find and delete any standalone Pods using the PVC + /opt/bin/kubectl get pods -n "$namespace" --no-headers -o custom-columns=NAME:.metadata.name | \ + while read pod_name; do + if [ -n "$pod_name" ]; then + pod_volumes=$(/opt/bin/kubectl get pod "$pod_name" -n "$namespace" -o jsonpath='{.spec.volumes[*].persistentVolumeClaim.claimName}' 2>/dev/null || echo "") + if echo "$pod_volumes" | grep -q "$pvc_name"; then + owner_kind=$(/opt/bin/kubectl get pod "$pod_name" -n "$namespace" -o jsonpath='{.metadata.ownerReferences[0].kind}' 2>/dev/null || echo "") + if [ -z "$owner_kind" ]; then + echo "$(timestamp) - Deleting standalone Pod: $pod_name" + /opt/bin/kubectl delete pod "$pod_name" -n "$namespace" --ignore-not-found=true + deleted_count=$((deleted_count + 1)) + fi + fi + fi + done + + if [ $deleted_count -eq 0 ]; then + echo "$(timestamp) - No workloads found using PVC $pvc_name" + else + echo "$(timestamp) - Deleted $deleted_count workload(s) using PVC $pvc_name" + fi + + echo "$(timestamp) - Waiting for pods to terminate..." + sleep 5 +} + +total_pvcs=0 +processed_pvcs=0 + +echo "$(timestamp) - Scanning for PVCs with associated PVs having reclaimPolicy=Delete..." + +while read namespace pvc_name pv_name; do + if [ -n "$pv_name" ] && [ "$pv_name" != "" ]; then + total_pvcs=$((total_pvcs + 1)) + reclaim_policy=$(/opt/bin/kubectl get pv "$pv_name" --no-headers -o custom-columns=RECLAIM:.spec.persistentVolumeReclaimPolicy 2>/dev/null || echo "") + if [ "$reclaim_policy" = "Delete" ]; then + processed_pvcs=$((processed_pvcs + 1)) + echo "$(timestamp) - Processing PVC $pvc_name in namespace $namespace (PV: $pv_name has reclaimPolicy=Delete)" + + delete_workloads_using_pvc "$namespace" "$pvc_name" + echo "$(timestamp) - Deleting PVC $pvc_name in namespace $namespace" + /opt/bin/kubectl delete pvc "$pvc_name" -n "$namespace" --ignore-not-found=true + + echo "$(timestamp) - Completed processing PVC $pvc_name" + echo "---" + fi + fi +done < <(/opt/bin/kubectl get pvc --all-namespaces --no-headers -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,VOLUME:.spec.volumeName) + +echo "$(timestamp) - Script completed successfully!" +echo "$(timestamp) - Summary: Processed $processed_pvcs PVC(s) out of $total_pvcs total PVC(s) found" diff --git a/plugins/integrations/kubernetes-service/src/main/resources/script/deploy-csi-driver b/plugins/integrations/kubernetes-service/src/main/resources/script/deploy-csi-driver new file mode 100644 index 00000000000..69684fa32bd --- /dev/null +++ b/plugins/integrations/kubernetes-service/src/main/resources/script/deploy-csi-driver @@ -0,0 +1,46 @@ +#!/bin/bash -e +# 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. + +(/opt/bin/kubectl get pods -A | grep cloudstack-csi-controller) && exit 0 + +if [ -e /opt/csi/snapshot-crds.yaml ]; then + /opt/bin/kubectl apply -f /opt/csi/snapshot-crds.yaml + sleep 5 + /opt/bin/kubectl apply -f /opt/csi/manifest.yaml + exit 0 +else + TARGET_DIR="/opt/csi" + mkdir -p "$TARGET_DIR" + CSI_URLS=( + "https://github.com/cloudstack/cloudstack-csi-driver/releases/download/v3.0.0/snapshot-crds.yaml" + "https://github.com/cloudstack/cloudstack-csi-driver/releases/download/v3.0.0/manifest.yaml" + ) + for url in "${CSI_URLS[@]}"; do + filename=$(basename "$url") + + curl -sSL ${url} -o ${TARGET_DIR}/${filename} + if [ $? -ne 0 ]; then + echo "Unable to connect to the internet to download the relevant files to install and setup CloudStack CSI driver" + exit 1 + else + /opt/bin/kubectl apply -f /opt/csi/snapshot-crds.yaml + /opt/bin/kubectl apply -f /opt/csi/manifest.yaml + exit 0 + fi + done +fi diff --git a/plugins/integrations/kubernetes-service/src/test/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImplTest.java b/plugins/integrations/kubernetes-service/src/test/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImplTest.java index 0793482b8f1..2a381f282de 100644 --- a/plugins/integrations/kubernetes-service/src/test/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImplTest.java +++ b/plugins/integrations/kubernetes-service/src/test/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImplTest.java @@ -430,7 +430,7 @@ public class KubernetesClusterManagerImplTest { VMTemplateVO cksIso = Mockito.mock(VMTemplateVO.class); Mockito.when(cksIso.getArch()).thenReturn(CPU.CPUArch.arm64); String cksClusterPreferredArch = kubernetesClusterManager.getCksClusterPreferredArch(systemVMArch, cksIso); - Assert.assertEquals(CPU.CPUArch.arm64.name(), cksClusterPreferredArch); + Assert.assertEquals(CPU.CPUArch.arm64.getType(), cksClusterPreferredArch); } @Test @@ -439,6 +439,6 @@ public class KubernetesClusterManagerImplTest { VMTemplateVO cksIso = Mockito.mock(VMTemplateVO.class); Mockito.when(cksIso.getArch()).thenReturn(CPU.CPUArch.amd64); String cksClusterPreferredArch = kubernetesClusterManager.getCksClusterPreferredArch(systemVMArch, cksIso); - Assert.assertEquals(CPU.CPUArch.amd64.name(), cksClusterPreferredArch); + Assert.assertEquals(CPU.CPUArch.amd64.getType(), cksClusterPreferredArch); } } diff --git a/plugins/integrations/prometheus/pom.xml b/plugins/integrations/prometheus/pom.xml index 43c45d8bd30..6f6b34215a7 100644 --- a/plugins/integrations/prometheus/pom.xml +++ b/plugins/integrations/prometheus/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/maintenance/pom.xml b/plugins/maintenance/pom.xml index 03f75d09200..5b129863a29 100644 --- a/plugins/maintenance/pom.xml +++ b/plugins/maintenance/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/plugins/metrics/pom.xml b/plugins/metrics/pom.xml index 6ae71da98bc..7f8e56de183 100644 --- a/plugins/metrics/pom.xml +++ b/plugins/metrics/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java b/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java index d2336f3cd58..f20c4484e85 100644 --- a/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java +++ b/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java @@ -22,6 +22,7 @@ import static com.cloud.utils.NumbersUtil.toReadableSize; import java.lang.reflect.InvocationTargetException; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -32,8 +33,6 @@ import java.util.stream.Collectors; import javax.inject.Inject; import javax.naming.ConfigurationException; -import com.cloud.dc.ClusterVO; -import com.cloud.utils.Ternary; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.ListClustersMetricsCmd; import org.apache.cloudstack.api.ListDbMetricsCmd; @@ -59,6 +58,7 @@ import org.apache.cloudstack.api.response.StoragePoolResponse; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.VolumeResponse; import org.apache.cloudstack.api.response.ZoneResponse; +import org.apache.cloudstack.backup.dao.BackupRepositoryDao; import org.apache.cloudstack.cluster.ClusterDrsAlgorithm; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.config.ConfigKey; @@ -101,6 +101,7 @@ import com.cloud.capacity.CapacityManager; import com.cloud.capacity.dao.CapacityDao; import com.cloud.capacity.dao.CapacityDaoImpl; import com.cloud.cluster.dao.ManagementServerHostDao; +import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; @@ -113,6 +114,7 @@ import com.cloud.host.Status; import com.cloud.host.dao.HostDao; import com.cloud.network.router.VirtualRouter; import com.cloud.org.Cluster; +import com.cloud.projects.Project; import com.cloud.server.DbStatsCollection; import com.cloud.server.ManagementServerHostStats; import com.cloud.server.StatsCollector; @@ -125,6 +127,7 @@ import com.cloud.usage.dao.UsageJobDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.utils.Pair; +import com.cloud.utils.Ternary; import com.cloud.utils.db.DbProperties; import com.cloud.utils.db.DbUtil; import com.cloud.utils.db.Filter; @@ -158,6 +161,8 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements @Inject private ImageStoreDao imageStoreDao; @Inject + BackupRepositoryDao backupRepositoryDao; + @Inject private VMInstanceDao vmInstanceDao; @Inject private DomainRouterDao domainRouterDao; @@ -185,6 +190,10 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements private static Gson gson = new Gson(); + private final List AccountTypesWithRecursiveUsageAccess = Arrays.asList( + Account.Type.ADMIN, Account.Type.DOMAIN_ADMIN, Account.Type.READ_ONLY_ADMIN + ); + protected MetricsServiceImpl() { super(); } @@ -246,17 +255,30 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements * @return the list of VMs. */ protected Pair, Integer> searchForUserVmsInternal(ListVMsUsageHistoryCmd cmd) { + final Long id = cmd.getId(); + Account caller = CallContext.current().getCallingAccount(); + List permittedAccounts = new ArrayList<>(); + boolean recursive = AccountTypesWithRecursiveUsageAccess.contains(caller.getType()); + Ternary domainIdRecursiveListProject = new Ternary<>(null, recursive, null); + accountMgr.buildACLSearchParameters(caller, id, null, null, permittedAccounts, domainIdRecursiveListProject, true, false); + Long domainId = domainIdRecursiveListProject.first(); + Boolean isRecursive = domainIdRecursiveListProject.second(); + Project.ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); + Filter searchFilter = new Filter(UserVmVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); List ids = getIdsListFromCmd(cmd.getId(), cmd.getIds()); String name = cmd.getName(); String keyword = cmd.getKeyword(); SearchBuilder sb = userVmDao.createSearchBuilder(); + sb.select(null, SearchCriteria.Func.DISTINCT, sb.entity().getId()); // select distinct + accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); sb.and("idIN", sb.entity().getId(), SearchCriteria.Op.IN); sb.and("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE); sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ); SearchCriteria sc = sb.create(); + accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); if (CollectionUtils.isNotEmpty(ids)) { sc.setParameters("idIN", ids.toArray()); } @@ -270,7 +292,14 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements sc.addAnd("displayName", SearchCriteria.Op.SC, ssc); } - return userVmDao.searchAndCount(sc, searchFilter); + Pair, Integer> uniqueVmPair = userVmDao.searchAndCount(sc, searchFilter); + Integer count = uniqueVmPair.second(); + if (count == 0) { + return new Pair<>(new ArrayList<>(), count); + } + List vmIds = uniqueVmPair.first().stream().map(UserVmVO::getId).collect(Collectors.toList()); + List vms = userVmDao.listByIds(vmIds); + return new Pair<>(vms, count); } /** @@ -332,17 +361,49 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements * @return the list of VMs. */ protected Pair, Integer> searchForVolumesInternal(ListVolumesUsageHistoryCmd cmd) { + final Long id = cmd.getId(); + Account caller = CallContext.current().getCallingAccount(); + List permittedAccounts = new ArrayList<>(); + boolean recursive = AccountTypesWithRecursiveUsageAccess.contains(caller.getType()); + Ternary domainIdRecursiveListProject = new Ternary<>(null, recursive, null); + accountMgr.buildACLSearchParameters(caller, id, null, null, permittedAccounts, domainIdRecursiveListProject, true, false); + Long domainId = domainIdRecursiveListProject.first(); + Boolean isRecursive = domainIdRecursiveListProject.second(); + Project.ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); + Filter searchFilter = new Filter(VolumeVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); List ids = getIdsListFromCmd(cmd.getId(), cmd.getIds()); String name = cmd.getName(); String keyword = cmd.getKeyword(); SearchBuilder sb = volumeDao.createSearchBuilder(); + sb.select(null, SearchCriteria.Func.DISTINCT, sb.entity().getId()); // select distinct + accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); sb.and("idIN", sb.entity().getId(), SearchCriteria.Op.IN); sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ); sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ); + boolean shouldListSystemVmVolumes = accountMgr.isRootAdmin(CallContext.current().getCallingAccountId()); + List vmIds = new ArrayList<>(); + if (!shouldListSystemVmVolumes) { + SearchBuilder vmSearch = userVmDao.createSearchBuilder(); + vmSearch.select(null, SearchCriteria.Func.DISTINCT, vmSearch.entity().getId()); + accountMgr.buildACLSearchBuilder(vmSearch, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + SearchCriteria vmSc = vmSearch.create(); + accountMgr.buildACLSearchCriteria(vmSc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + List vms = userVmDao.search(vmSc, null); + vmIds = vms.stream().map(UserVmVO::getId).collect(Collectors.toList()); + if (vmIds.isEmpty()) { + sb.and("instanceIdNull", sb.entity().getInstanceId(), SearchCriteria.Op.NULL); + } else { + sb.and().op("instanceIdNull", sb.entity().getInstanceId(), SearchCriteria.Op.NULL); + sb.or("instanceIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN); + sb.cp(); + } + } + SearchCriteria sc = sb.create(); + accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); if (CollectionUtils.isNotEmpty(ids)) { sc.setParameters("idIN", ids.toArray()); } @@ -355,8 +416,18 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements ssc.addOr("state", SearchCriteria.Op.EQ, keyword); sc.addAnd("name", SearchCriteria.Op.SC, ssc); } + if (!shouldListSystemVmVolumes && CollectionUtils.isNotEmpty(vmIds)) { + sc.setParameters("instanceIds", vmIds.toArray()); + } - return volumeDao.searchAndCount(sc, searchFilter); + Pair, Integer> uniqueVolumePair = volumeDao.searchAndCount(sc, searchFilter); + Integer count = uniqueVolumePair.second(); + if (count == 0) { + return new Pair<>(new ArrayList<>(), count); + } + List volumeIds = uniqueVolumePair.first().stream().map(VolumeVO::getId).collect(Collectors.toList()); + List volumes = volumeDao.listByIds(volumeIds); + return new Pair<>(volumes, count); } /** @@ -557,6 +628,7 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements response.setHosts(hostCountAndCpuSockets.first()); response.setStoragePools(storagePoolDao.countAll()); response.setImageStores(imageStoreDao.countAllImageStores()); + response.setBackupRepositories(backupRepositoryDao.countAll()); response.setObjectStores(objectStoreDao.countAllObjectStores()); response.setSystemvms(vmInstanceDao.countByTypes(VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm)); response.setRouters(domainRouterDao.countAllByRole(VirtualRouter.Role.VIRTUAL_ROUTER)); diff --git a/plugins/metrics/src/main/java/org/apache/cloudstack/response/InfrastructureResponse.java b/plugins/metrics/src/main/java/org/apache/cloudstack/response/InfrastructureResponse.java index cb1faf237b7..6fda3ff5953 100644 --- a/plugins/metrics/src/main/java/org/apache/cloudstack/response/InfrastructureResponse.java +++ b/plugins/metrics/src/main/java/org/apache/cloudstack/response/InfrastructureResponse.java @@ -47,6 +47,10 @@ public class InfrastructureResponse extends BaseResponse { @Param(description = "Number of images stores") private Integer imageStores; + @SerializedName("backuprepositories") + @Param(description = "Number of backup repositories", since = "4.22.0") + private Integer backupRepositories; + @SerializedName("objectstores") @Param(description = "Number of object stores") private Integer objectStores; @@ -103,6 +107,10 @@ public class InfrastructureResponse extends BaseResponse { this.imageStores = imageStores; } + public void setBackupRepositories(Integer backupRepositories) { + this.backupRepositories = backupRepositories; + } + public void setSystemvms(final Integer systemvms) { this.systemvms = systemvms; } diff --git a/plugins/metrics/src/test/java/org/apache/cloudstack/metrics/MetricsServiceImplTest.java b/plugins/metrics/src/test/java/org/apache/cloudstack/metrics/MetricsServiceImplTest.java index b37be68b3e4..9184d744410 100644 --- a/plugins/metrics/src/test/java/org/apache/cloudstack/metrics/MetricsServiceImplTest.java +++ b/plugins/metrics/src/test/java/org/apache/cloudstack/metrics/MetricsServiceImplTest.java @@ -19,13 +19,16 @@ package org.apache.cloudstack.metrics; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.cloudstack.api.ListVMsUsageHistoryCmd; +import org.apache.cloudstack.api.ListVolumesUsageHistoryCmd; import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.response.VmMetricsStatsResponse; import org.apache.commons.lang3.time.DateUtils; import org.junit.Assert; @@ -35,12 +38,18 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.MockedStatic; import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import com.cloud.exception.InvalidParameterValueException; +import com.cloud.storage.VolumeVO; +import com.cloud.storage.dao.VolumeDao; +import com.cloud.user.Account; +import com.cloud.user.AccountManager; import com.cloud.utils.Pair; +import com.cloud.utils.db.Filter; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.vm.UserVmVO; @@ -75,6 +84,12 @@ public class MetricsServiceImplTest { @Mock VmStatsDao vmStatsDaoMock; + @Mock + AccountManager accountManager; + + @Mock + VolumeDao volumeDao; + @Captor ArgumentCaptor stringCaptor1, stringCaptor2; @@ -95,12 +110,26 @@ public class MetricsServiceImplTest { @Mock VmStatsVO vmStatsVOMock; + @Mock + Account mockAccount; + @Mock + ListVolumesUsageHistoryCmd listVolumesUsageHistoryCmdMock; + @Mock + VolumeVO volumeVOMock; + @Mock + SearchBuilder volumeSearchBuilderMock; + @Mock + SearchCriteria volumeSearchCriteriaMock; + @Mock + Filter filterMock; + private void prepareSearchCriteriaWhenUseSetParameters() { Mockito.doNothing().when(scMock).setParameters(Mockito.anyString(), Mockito.any()); } private void preparesearchForUserVmsInternalTest() { + Mockito.when(mockAccount.getType()).thenReturn(Account.Type.NORMAL); expectedVmListAndCounter = new Pair<>(Arrays.asList(userVmVOMock), 1); Mockito.doReturn(1L).when(listVMsUsageHistoryCmdMock).getStartIndex(); @@ -111,8 +140,10 @@ public class MetricsServiceImplTest { Mockito.doReturn(userVmVOMock).when(sbMock).entity(); Mockito.doReturn(scMock).when(sbMock).create(); - Mockito.doReturn(new Pair, Integer>(Arrays.asList(userVmVOMock), 1)) + Mockito.doReturn(expectedVmListAndCounter) .when(userVmDaoMock).searchAndCount(Mockito.any(), Mockito.any()); + Mockito.doReturn(expectedVmListAndCounter.first()) + .when(userVmDaoMock).listByIds(Mockito.anyList()); } @Test @@ -124,12 +155,17 @@ public class MetricsServiceImplTest { Mockito.doReturn(null).when(listVMsUsageHistoryCmdMock).getName(); Mockito.doReturn(null).when(listVMsUsageHistoryCmdMock).getKeyword(); - Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); + try (MockedStatic callContextMocked = Mockito.mockStatic(CallContext.class)) { + CallContext callContextMock = Mockito.mock(CallContext.class); + callContextMocked.when(CallContext::current).thenReturn(callContextMock); + Mockito.when(callContextMock.getCallingAccount()).thenReturn(mockAccount); + Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); - Mockito.verify(scMock).setParameters(stringCaptor1.capture(), objectArrayCaptor.capture()); - Assert.assertEquals("idIN", stringCaptor1.getValue()); - Assert.assertEquals(fakeVmId1, objectArrayCaptor.getAllValues().get(0)[0]); - Assert.assertEquals(expectedVmListAndCounter, result); + Mockito.verify(scMock).setParameters(stringCaptor1.capture(), objectArrayCaptor.capture()); + Assert.assertEquals("idIN", stringCaptor1.getValue()); + Assert.assertEquals(fakeVmId1, objectArrayCaptor.getAllValues().get(0)[0]); + Assert.assertEquals(expectedVmListAndCounter, result); + } } @Test @@ -141,13 +177,17 @@ public class MetricsServiceImplTest { Mockito.doReturn(expected).when(listVMsUsageHistoryCmdMock).getIds(); Mockito.doReturn(null).when(listVMsUsageHistoryCmdMock).getName(); Mockito.doReturn(null).when(listVMsUsageHistoryCmdMock).getKeyword(); + try (MockedStatic callContextMocked = Mockito.mockStatic(CallContext.class)) { + CallContext callContextMock = Mockito.mock(CallContext.class); + callContextMocked.when(CallContext::current).thenReturn(callContextMock); + Mockito.when(callContextMock.getCallingAccount()).thenReturn(mockAccount); + Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); - Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); - - Mockito.verify(scMock).setParameters(stringCaptor1.capture(), objectArrayCaptor.capture()); - Assert.assertEquals("idIN", stringCaptor1.getValue()); - Assert.assertArrayEquals(expected.toArray(), objectArrayCaptor.getAllValues().get(0)); - Assert.assertEquals(expectedVmListAndCounter, result); + Mockito.verify(scMock).setParameters(stringCaptor1.capture(), objectArrayCaptor.capture()); + Assert.assertEquals("idIN", stringCaptor1.getValue()); + Assert.assertArrayEquals(expected.toArray(), objectArrayCaptor.getAllValues().get(0)); + Assert.assertEquals(expectedVmListAndCounter, result); + } } @Test @@ -159,12 +199,17 @@ public class MetricsServiceImplTest { Mockito.doReturn("fakeName").when(listVMsUsageHistoryCmdMock).getName(); Mockito.doReturn(null).when(listVMsUsageHistoryCmdMock).getKeyword(); - Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); + try (MockedStatic callContextMocked = Mockito.mockStatic(CallContext.class)) { + CallContext callContextMock = Mockito.mock(CallContext.class); + callContextMocked.when(CallContext::current).thenReturn(callContextMock); + Mockito.when(callContextMock.getCallingAccount()).thenReturn(mockAccount); + Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); - Mockito.verify(scMock).setParameters(stringCaptor1.capture(), objectArrayCaptor.capture()); - Assert.assertEquals("displayName", stringCaptor1.getValue()); - Assert.assertEquals("%fakeName%", objectArrayCaptor.getValue()[0]); - Assert.assertEquals(expectedVmListAndCounter, result); + Mockito.verify(scMock).setParameters(stringCaptor1.capture(), objectArrayCaptor.capture()); + Assert.assertEquals("displayName", stringCaptor1.getValue()); + Assert.assertEquals("%fakeName%", objectArrayCaptor.getValue()[0]); + Assert.assertEquals(expectedVmListAndCounter, result); + } } @Test @@ -177,16 +222,21 @@ public class MetricsServiceImplTest { Mockito.doReturn(null).when(listVMsUsageHistoryCmdMock).getName(); Mockito.doReturn("fakeKeyword").when(listVMsUsageHistoryCmdMock).getKeyword(); - Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); + try (MockedStatic callContextMocked = Mockito.mockStatic(CallContext.class)) { + CallContext callContextMock = Mockito.mock(CallContext.class); + callContextMocked.when(CallContext::current).thenReturn(callContextMock); + Mockito.when(callContextMock.getCallingAccount()).thenReturn(mockAccount); + Pair, Integer> result = spy.searchForUserVmsInternal(listVMsUsageHistoryCmdMock); - Mockito.verify(scMock, Mockito.times(2)).addOr(stringCaptor1.capture(), opCaptor.capture(), objectArrayCaptor.capture()); - List conditions = stringCaptor1.getAllValues(); - List params = objectArrayCaptor.getAllValues(); - Assert.assertEquals("displayName", conditions.get(0)); - Assert.assertEquals("state", conditions.get(1)); - Assert.assertEquals("%fakeKeyword%", params.get(0)[0]); - Assert.assertEquals("fakeKeyword", params.get(1)[0]); - Assert.assertEquals(expectedVmListAndCounter, result); + Mockito.verify(scMock, Mockito.times(2)).addOr(stringCaptor1.capture(), opCaptor.capture(), objectArrayCaptor.capture()); + List conditions = stringCaptor1.getAllValues(); + List params = objectArrayCaptor.getAllValues(); + Assert.assertEquals("displayName", conditions.get(0)); + Assert.assertEquals("state", conditions.get(1)); + Assert.assertEquals("%fakeKeyword%", params.get(0)[0]); + Assert.assertEquals("fakeKeyword", params.get(1)[0]); + Assert.assertEquals(expectedVmListAndCounter, result); + } } @Test @@ -317,4 +367,57 @@ public class MetricsServiceImplTest { spy.createStatsResponse(Arrays.asList(vmStatsVOMock)); } + + @Test + public void searchForVolumesInternalWithValidParameters() { + Mockito.doReturn(null).when(listVolumesUsageHistoryCmdMock).getId(); + Mockito.doReturn(Arrays.asList(1L, 2L)).when(listVolumesUsageHistoryCmdMock).getIds(); + Mockito.doReturn("volumeName").when(listVolumesUsageHistoryCmdMock).getName(); + Mockito.doReturn("keyword").when(listVolumesUsageHistoryCmdMock).getKeyword(); + Mockito.doReturn(volumeSearchBuilderMock).when(volumeDao).createSearchBuilder(); + Mockito.doReturn(volumeVOMock).when(volumeSearchBuilderMock).entity(); + SearchBuilder vmSearchBuilderMock = Mockito.mock(SearchBuilder.class); + Mockito.doReturn(vmSearchBuilderMock).when(userVmDaoMock).createSearchBuilder(); + Mockito.doReturn(userVmVOMock).when(vmSearchBuilderMock).entity(); + Mockito.doReturn(volumeSearchCriteriaMock).when(volumeSearchBuilderMock).create(); + Mockito.doReturn(volumeSearchCriteriaMock).when(volumeDao).createSearchCriteria(); + Mockito.doReturn(new Pair<>(Arrays.asList(volumeVOMock), 1)).when(volumeDao).searchAndCount(Mockito.any(), Mockito.any()); + Mockito.doReturn(Arrays.asList(volumeVOMock)).when(volumeDao).listByIds(Mockito.anyList()); + + + try (MockedStatic callContextMocked = Mockito.mockStatic(CallContext.class)) { + CallContext callContextMock = Mockito.mock(CallContext.class); + callContextMocked.when(CallContext::current).thenReturn(callContextMock); + Mockito.when(callContextMock.getCallingAccount()).thenReturn(mockAccount); + Pair, Integer> result = spy.searchForVolumesInternal(listVolumesUsageHistoryCmdMock); + + Assert.assertNotNull(result); + Assert.assertEquals(1, result.second().intValue()); + Assert.assertEquals(volumeVOMock, result.first().get(0)); + } + } + + @Test + public void searchForVolumesInternalWithValidParametersNoItem() { + Mockito.doReturn(1L).when(listVolumesUsageHistoryCmdMock).getId(); + Mockito.doReturn(volumeSearchBuilderMock).when(volumeDao).createSearchBuilder(); + Mockito.doReturn(volumeVOMock).when(volumeSearchBuilderMock).entity(); + Mockito.doReturn(volumeSearchCriteriaMock).when(volumeSearchBuilderMock).create(); + Mockito.doReturn(new Pair<>(Collections.emptyList(), 0)).when(volumeDao).searchAndCount(Mockito.any(), Mockito.any()); + + + try (MockedStatic callContextMocked = Mockito.mockStatic(CallContext.class)) { + CallContext callContextMock = Mockito.mock(CallContext.class); + callContextMocked.when(CallContext::current).thenReturn(callContextMock); + Mockito.when(callContextMock.getCallingAccount()).thenReturn(mockAccount); + Mockito.when(callContextMock.getCallingAccountId()).thenReturn(1L); + Mockito.when(accountManager.isRootAdmin(1L)).thenReturn(true); + Mockito.when(mockAccount.getType()).thenReturn(Account.Type.ADMIN); + Pair, Integer> result = spy.searchForVolumesInternal(listVolumesUsageHistoryCmdMock); + + Assert.assertNotNull(result); + Assert.assertEquals(0, result.second().intValue()); + } + } + } diff --git a/plugins/network-elements/bigswitch/pom.xml b/plugins/network-elements/bigswitch/pom.xml index b0bbb1db9cd..cd5ca8b5e99 100644 --- a/plugins/network-elements/bigswitch/pom.xml +++ b/plugins/network-elements/bigswitch/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/brocade-vcs/pom.xml b/plugins/network-elements/brocade-vcs/pom.xml index 77721c6c732..1eb716a6f9b 100644 --- a/plugins/network-elements/brocade-vcs/pom.xml +++ b/plugins/network-elements/brocade-vcs/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/cisco-vnmc/pom.xml b/plugins/network-elements/cisco-vnmc/pom.xml index 87ac0a79732..c183d03259a 100644 --- a/plugins/network-elements/cisco-vnmc/pom.xml +++ b/plugins/network-elements/cisco-vnmc/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java b/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java index 90597d7b1e1..e0ab727930e 100644 --- a/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java +++ b/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java @@ -136,7 +136,6 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection { String xml = ""; String line; while ((line = br.readLine()) != null) { - //xml += line.replaceAll("\n"," "); xml += line; } diff --git a/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/element/CiscoVnmcElementService.java b/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/element/CiscoVnmcElementService.java index 8388bb89bb5..8a52893274f 100644 --- a/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/element/CiscoVnmcElementService.java +++ b/plugins/network-elements/cisco-vnmc/src/main/java/com/cloud/network/element/CiscoVnmcElementService.java @@ -28,8 +28,6 @@ import com.cloud.utils.component.PluggableService; public interface CiscoVnmcElementService extends PluggableService { - //public static final Provider CiscoVnmc = new Provider("CiscoVnmc", true); - public CiscoVnmcController addCiscoVnmcResource(AddCiscoVnmcResourceCmd cmd); public CiscoVnmcResourceResponse createCiscoVnmcResourceResponse(CiscoVnmcController ciscoVnmcResourceVO); diff --git a/plugins/network-elements/dns-notifier/pom.xml b/plugins/network-elements/dns-notifier/pom.xml index 26cb5a39d00..b57bfb94e69 100644 --- a/plugins/network-elements/dns-notifier/pom.xml +++ b/plugins/network-elements/dns-notifier/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml cloud-plugin-example-dns-notifier diff --git a/plugins/network-elements/elastic-loadbalancer/pom.xml b/plugins/network-elements/elastic-loadbalancer/pom.xml index 1b43b805ebd..22c61f71087 100644 --- a/plugins/network-elements/elastic-loadbalancer/pom.xml +++ b/plugins/network-elements/elastic-loadbalancer/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/ElasticLbVmMapVO.java b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/ElasticLbVmMapVO.java index b9bad7f6575..96a43dfb19e 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/ElasticLbVmMapVO.java +++ b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/ElasticLbVmMapVO.java @@ -79,10 +79,6 @@ public class ElasticLbVmMapVO implements InternalIdentity { return elbVmId; } -// public String getLbName() { -// return lbName; -// } - public long getIpAddressId() { return ipAddressId; } diff --git a/plugins/network-elements/globodns/pom.xml b/plugins/network-elements/globodns/pom.xml index e817a398251..70bf2287e2a 100644 --- a/plugins/network-elements/globodns/pom.xml +++ b/plugins/network-elements/globodns/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/internal-loadbalancer/pom.xml b/plugins/network-elements/internal-loadbalancer/pom.xml index 4600dba9cb7..2051a7c25bb 100644 --- a/plugins/network-elements/internal-loadbalancer/pom.xml +++ b/plugins/network-elements/internal-loadbalancer/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/juniper-contrail/pom.xml b/plugins/network-elements/juniper-contrail/pom.xml index d2414853384..6d76cedf8dd 100644 --- a/plugins/network-elements/juniper-contrail/pom.xml +++ b/plugins/network-elements/juniper-contrail/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/juniper-contrail/src/test/java/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java b/plugins/network-elements/juniper-contrail/src/test/java/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java index 15f546db0f0..2107850c36b 100644 --- a/plugins/network-elements/juniper-contrail/src/test/java/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java +++ b/plugins/network-elements/juniper-contrail/src/test/java/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java @@ -32,6 +32,9 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd; @@ -86,6 +89,7 @@ import com.cloud.vm.VirtualMachineManager; import com.cloud.vm.dao.UserVmDao; public class ManagementServerMock { + protected Logger logger = LogManager.getLogger(getClass()); @Inject private AccountManager _accountMgr; @@ -217,15 +221,7 @@ public class ManagementServerMock { return null; } }; - try { - Mockito.when(_agentMgr.send(ArgumentMatchers.anyLong(), ArgumentMatchers.any(Commands.class))).thenAnswer(callback); - } catch (AgentUnavailableException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (OperationTimedoutException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + sendCommands(callback); long id = _userVmDao.getNextInSequence(Long.class, "id"); UserVmVO vm = new UserVmVO(id, name, name, tmpl.getId(), HypervisorType.XenServer, tmpl.getGuestOSId(), false, false, _zone.getDomainId(), Account.ACCOUNT_ID_SYSTEM, @@ -239,12 +235,21 @@ public class ManagementServerMock { try { _vmMgr.addVmToNetwork(vm, network, profile); } catch (Exception ex) { - // TODO Auto-generated catch block - //ex.printStackTrace(); + // ignored } return vm; } + private void sendCommands(Answer callback) { + try { + Mockito.when(_agentMgr.send(ArgumentMatchers.anyLong(), ArgumentMatchers.any(Commands.class))).thenAnswer(callback); + } catch (AgentUnavailableException e) { + logger.warn("no agent running", e); + } catch (OperationTimedoutException e) { + logger.warn("agent not responding (in time)", e); + } + } + private void deleteHost() { _hostDao.remove(_hostId); @@ -265,15 +270,7 @@ public class ManagementServerMock { return null; } }; - - try { - Mockito.when(_agentMgr.send(ArgumentMatchers.anyLong(), ArgumentMatchers.any(Commands.class))).thenAnswer(callback); - } catch (AgentUnavailableException e) { - e.printStackTrace(); - } catch (OperationTimedoutException e) { - e.printStackTrace(); - } - + sendCommands(callback); _userVmDao.remove(vm.getId()); } diff --git a/plugins/network-elements/netris/pom.xml b/plugins/network-elements/netris/pom.xml index e8ca26c243b..295fa643097 100644 --- a/plugins/network-elements/netris/pom.xml +++ b/plugins/network-elements/netris/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/netscaler/pom.xml b/plugins/network-elements/netscaler/pom.xml index e69837d6a01..88a8880e509 100644 --- a/plugins/network-elements/netscaler/pom.xml +++ b/plugins/network-elements/netscaler/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml index 72c69c53050..10a58431207 100644 --- a/plugins/network-elements/nicira-nvp/pom.xml +++ b/plugins/network-elements/nicira-nvp/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/nsx/pom.xml b/plugins/network-elements/nsx/pom.xml index 27b4062d768..e6431d074ca 100644 --- a/plugins/network-elements/nsx/pom.xml +++ b/plugins/network-elements/nsx/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/opendaylight/pom.xml b/plugins/network-elements/opendaylight/pom.xml index 5312ee1cbd0..38934e16da2 100644 --- a/plugins/network-elements/opendaylight/pom.xml +++ b/plugins/network-elements/opendaylight/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/ovs/pom.xml b/plugins/network-elements/ovs/pom.xml index 80f57e82c5d..ef1326cca6e 100644 --- a/plugins/network-elements/ovs/pom.xml +++ b/plugins/network-elements/ovs/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/palo-alto/pom.xml b/plugins/network-elements/palo-alto/pom.xml index 868e231a36a..ee16eccb162 100644 --- a/plugins/network-elements/palo-alto/pom.xml +++ b/plugins/network-elements/palo-alto/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/stratosphere-ssp/pom.xml b/plugins/network-elements/stratosphere-ssp/pom.xml index 6f5d300f123..0288c8a5dd7 100644 --- a/plugins/network-elements/stratosphere-ssp/pom.xml +++ b/plugins/network-elements/stratosphere-ssp/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/tungsten/pom.xml b/plugins/network-elements/tungsten/pom.xml index de5ab3f1ade..eb83c468f0c 100644 --- a/plugins/network-elements/tungsten/pom.xml +++ b/plugins/network-elements/tungsten/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java b/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java index 58084d3072d..b22d1e70be3 100644 --- a/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java +++ b/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java @@ -778,60 +778,6 @@ public class TungstenElementTest { verify(tungstenService, times(1)).deleteManagementNetwork(anyLong()); } - //@Test - //public void processConnectWithoutSecurityGroupTest() throws ConnectionException { - // Host host = mock(Host.class); - // StartupCommand startupCommand = mock(StartupCommand.class); - // TungstenProviderVO tungstenProvider = mock(TungstenProviderVO.class); - // DataCenterVO dataCenterVO = mock(DataCenterVO.class); - // VlanVO vlanVO1 = mock(VlanVO.class); - // VlanVO vlanVO2 = mock(VlanVO.class); - // List vlanList = Arrays.asList(vlanVO1, vlanVO2); - // Network publicNetwork = mock(Network.class); - // NetworkDetailVO networkDetail = mock(NetworkDetailVO.class); -// - // when(host.getHypervisorType()).thenReturn(Hypervisor.HypervisorType.KVM); - // when(tungstenProviderDao.findByZoneId(anyLong())).thenReturn(tungstenProvider); - // when(host.getPublicIpAddress()).thenReturn("192.168.100.100"); - // when(tungstenProvider.getGateway()).thenReturn("192.168.100.100"); - // when(dataCenterDao.findById(anyLong())).thenReturn(dataCenterVO); - // when(vlanDao.listByZone(anyLong())).thenReturn(vlanList); - // when(networkModel.getSystemNetworkByZoneAndTrafficType(anyLong(), eq(Networks.TrafficType.Public))).thenReturn(publicNetwork); - // when(networkDetailsDao.findDetail(anyLong(), anyString())).thenReturn(networkDetail); - // when(vlanVO1.getVlanGateway()).thenReturn("192.168.100.1"); - // when(vlanVO1.getVlanNetmask()).thenReturn("255.255.255.0"); - // when(vlanVO2.getVlanGateway()).thenReturn("192.168.101.1"); - // when(vlanVO2.getVlanNetmask()).thenReturn("255.255.255.0"); - // when(dataCenterVO.isSecurityGroupEnabled()).thenReturn(false); -// - // tungstenElement.processConnect(host, startupCommand, true); - // verify(agentManager, times(1)).easySend(anyLong(), any(SetupTungstenVRouterCommand.class)); - //} - - //@Test - //public void processConnectWithSecurityGroupTest() throws ConnectionException { - // Host host = mock(Host.class); - // StartupCommand startupCommand = mock(StartupCommand.class); - // TungstenProviderVO tungstenProvider = mock(TungstenProviderVO.class); - // DataCenterVO dataCenterVO = mock(DataCenterVO.class); - // NetworkVO network = mock(NetworkVO.class); - // NetworkDetailVO networkDetail = mock(NetworkDetailVO.class); - // Network publicNetwork = mock(Network.class); -// - // when(host.getHypervisorType()).thenReturn(Hypervisor.HypervisorType.KVM); - // when(tungstenProviderDao.findByZoneId(anyLong())).thenReturn(tungstenProvider); - // when(host.getPublicIpAddress()).thenReturn("192.168.100.100"); - // when(tungstenProvider.getGateway()).thenReturn("192.168.100.100"); - // when(dataCenterDao.findById(anyLong())).thenReturn(dataCenterVO); - // when(networkDao.listByZoneSecurityGroup(anyLong())).thenReturn(Arrays.asList(network)); - // when(networkDetailsDao.findDetail(anyLong(), anyString())).thenReturn(networkDetail); - // when(networkModel.getSystemNetworkByZoneAndTrafficType(anyLong(), eq(Networks.TrafficType.Public))).thenReturn(publicNetwork); - // when(dataCenterVO.isSecurityGroupEnabled()).thenReturn(true); -// - // tungstenElement.processConnect(host, startupCommand, true); - // verify(agentManager, times(1)).easySend(anyLong(), any(SetupTungstenVRouterCommand.class)); - //} - @Test public void processHostAboutToBeRemovedWithSecurityGroupTest() { HostVO hostVO = mock(HostVO.class); diff --git a/plugins/network-elements/vxlan/pom.xml b/plugins/network-elements/vxlan/pom.xml index 88c5882178e..e350a3cb98f 100644 --- a/plugins/network-elements/vxlan/pom.xml +++ b/plugins/network-elements/vxlan/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/outofbandmanagement-drivers/ipmitool/pom.xml b/plugins/outofbandmanagement-drivers/ipmitool/pom.xml index d647575ef78..82ee440c7ee 100644 --- a/plugins/outofbandmanagement-drivers/ipmitool/pom.xml +++ b/plugins/outofbandmanagement-drivers/ipmitool/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml b/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml index e91e103e252..aefaf6d5656 100644 --- a/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml +++ b/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/outofbandmanagement-drivers/redfish/pom.xml b/plugins/outofbandmanagement-drivers/redfish/pom.xml index 03e4e2adc4c..eecfe1a7add 100644 --- a/plugins/outofbandmanagement-drivers/redfish/pom.xml +++ b/plugins/outofbandmanagement-drivers/redfish/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/pom.xml b/plugins/pom.xml index d665f90b623..e7d13871285 100755 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/plugins/storage-allocators/random/pom.xml b/plugins/storage-allocators/random/pom.xml index 5dbd571c2fa..db55faba4f1 100644 --- a/plugins/storage-allocators/random/pom.xml +++ b/plugins/storage-allocators/random/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/storage/image/default/pom.xml b/plugins/storage/image/default/pom.xml index 5a7d236a8a6..0696ca054ff 100644 --- a/plugins/storage/image/default/pom.xml +++ b/plugins/storage/image/default/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/image/s3/pom.xml b/plugins/storage/image/s3/pom.xml index 70927f60804..607830bc2e8 100644 --- a/plugins/storage/image/s3/pom.xml +++ b/plugins/storage/image/s3/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/image/sample/pom.xml b/plugins/storage/image/sample/pom.xml index 999640392b2..e7044868e7b 100644 --- a/plugins/storage/image/sample/pom.xml +++ b/plugins/storage/image/sample/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/image/swift/pom.xml b/plugins/storage/image/swift/pom.xml index 761461b2bf1..1caffdae6c7 100644 --- a/plugins/storage/image/swift/pom.xml +++ b/plugins/storage/image/swift/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/object/ceph/pom.xml b/plugins/storage/object/ceph/pom.xml index 053450148d3..1f5a4bc5055 100644 --- a/plugins/storage/object/ceph/pom.xml +++ b/plugins/storage/object/ceph/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/object/cloudian/README.md b/plugins/storage/object/cloudian/README.md index a0f68d7bc12..f46f06f0a78 100644 --- a/plugins/storage/object/cloudian/README.md +++ b/plugins/storage/object/cloudian/README.md @@ -1,3 +1,22 @@ + + # Cloudian HyperStore Object Storage Plugin ## Plugin Purpose diff --git a/plugins/storage/object/cloudian/pom.xml b/plugins/storage/object/cloudian/pom.xml index 4c5e5185f34..818469290de 100644 --- a/plugins/storage/object/cloudian/pom.xml +++ b/plugins/storage/object/cloudian/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/object/minio/pom.xml b/plugins/storage/object/minio/pom.xml index d7044fc6859..d69c2a7498f 100644 --- a/plugins/storage/object/minio/pom.xml +++ b/plugins/storage/object/minio/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/object/simulator/pom.xml b/plugins/storage/object/simulator/pom.xml index edb6261fa1c..dc4ab014606 100644 --- a/plugins/storage/object/simulator/pom.xml +++ b/plugins/storage/object/simulator/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/sharedfs/storagevm/pom.xml b/plugins/storage/sharedfs/storagevm/pom.xml index 513a3ecf157..2a4ea7411e0 100644 --- a/plugins/storage/sharedfs/storagevm/pom.xml +++ b/plugins/storage/sharedfs/storagevm/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/adaptive/README.md b/plugins/storage/volume/adaptive/README.md index f018f01cd5b..d863cf117df 100644 --- a/plugins/storage/volume/adaptive/README.md +++ b/plugins/storage/volume/adaptive/README.md @@ -1,3 +1,22 @@ + + # CloudStack Volume Provider Adaptive Plugin Base The Adaptive Plugin Base is an abstract volume storage provider that diff --git a/plugins/storage/volume/adaptive/pom.xml b/plugins/storage/volume/adaptive/pom.xml index 44adf2e28cc..337544b9d88 100644 --- a/plugins/storage/volume/adaptive/pom.xml +++ b/plugins/storage/volume/adaptive/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/adapter/ProviderAdapterDiskOffering.java b/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/adapter/ProviderAdapterDiskOffering.java index 1db5efbb8ec..293f5f3db2a 100644 --- a/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/adapter/ProviderAdapterDiskOffering.java +++ b/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/adapter/ProviderAdapterDiskOffering.java @@ -34,7 +34,7 @@ public class ProviderAdapterDiskOffering { this.type = ProvisioningType.getProvisioningType(hiddenDiskOffering.getProvisioningType().toString()); } if (hiddenDiskOffering.getCacheMode() != null) { - this.diskCacheMode = DiskCacheMode.getDiskCasehMode(hiddenDiskOffering.getCacheMode().toString()); + this.diskCacheMode = DiskCacheMode.getDiskCacheMode(hiddenDiskOffering.getCacheMode().toString()); } if (hiddenDiskOffering.getState() != null) { this.state = State.valueOf(hiddenDiskOffering.getState().toString()); @@ -166,7 +166,7 @@ public class ProviderAdapterDiskOffering { } enum DiskCacheMode { - NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough"); + NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough"), HYPERVISOR_DEFAULT("hypervisor_default"); private final String _diskCacheMode; @@ -179,13 +179,15 @@ public class ProviderAdapterDiskOffering { return _diskCacheMode; } - public static DiskCacheMode getDiskCasehMode(String cacheMode) { + public static DiskCacheMode getDiskCacheMode(String cacheMode) { if (cacheMode.equals(NONE._diskCacheMode)) { return NONE; } else if (cacheMode.equals(WRITEBACK._diskCacheMode)) { return WRITEBACK; } else if (cacheMode.equals(WRITETHROUGH._diskCacheMode)) { return WRITETHROUGH; + } else if (cacheMode.equals(HYPERVISOR_DEFAULT._diskCacheMode)) { + return HYPERVISOR_DEFAULT; } else { throw new NotImplementedException("Invalid cache mode specified: " + cacheMode); } diff --git a/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/driver/AdaptiveDataStoreDriverImpl.java b/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/driver/AdaptiveDataStoreDriverImpl.java index 40d99526394..2ccd2bab6cd 100644 --- a/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/driver/AdaptiveDataStoreDriverImpl.java +++ b/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/driver/AdaptiveDataStoreDriverImpl.java @@ -857,6 +857,7 @@ public class AdaptiveDataStoreDriverImpl extends CloudStackPrimaryDataStoreDrive volumeVO.setPath(finalPath); volumeVO.setFormat(ImageFormat.RAW); volumeVO.setPoolId(storagePool.getId()); + volumeVO.setPoolType(storagePool.getPoolType()); volumeVO.setExternalUuid(managedVolume.getExternalUuid()); volumeVO.setDisplay(true); volumeVO.setDisplayVolume(true); diff --git a/plugins/storage/volume/cloudbyte/pom.xml b/plugins/storage/volume/cloudbyte/pom.xml index 2e4d219783a..453a03ee155 100644 --- a/plugins/storage/volume/cloudbyte/pom.xml +++ b/plugins/storage/volume/cloudbyte/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/driver/ElastistorPrimaryDataStoreDriver.java b/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/driver/ElastistorPrimaryDataStoreDriver.java index 3d4afcaf95c..9e26aa8625a 100644 --- a/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/driver/ElastistorPrimaryDataStoreDriver.java +++ b/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/driver/ElastistorPrimaryDataStoreDriver.java @@ -175,9 +175,6 @@ public class ElastistorPrimaryDataStoreDriver extends CloudStackPrimaryDataStore _volumeDao.update(volume.getId(), volume); - // create new volume details for the volume - //updateVolumeDetails(volume, esvolume); - long capacityBytes = storagePool.getCapacityBytes(); long usedBytes = storagePool.getUsedBytes(); diff --git a/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ElastistorUtil.java b/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ElastistorUtil.java index 6650dad7677..603908e024c 100644 --- a/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ElastistorUtil.java +++ b/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ElastistorUtil.java @@ -341,7 +341,6 @@ public class ElastistorUtil { String qosgroupid; String VolumeName = volumeName; String totaliops = String.valueOf(capacityIops); - //String totalthroughput = String.valueOf(capacityIops * 4); String totalthroughput = "0"; String quotasize = convertCapacityBytes(capacityBytes); @@ -679,14 +678,6 @@ public class ElastistorUtil { } LOGGER.info("tsm id is null"); return false; - - /* - * else { LOGGER.error("no volume is present in the tsm"); } } else { - * LOGGER.error( - * "List tsm failed, no tsm present in the eastistor for the given IP " - * ); return false; } return false; - */ - } public static boolean deleteElastistorVolume(String esvolumeid) throws Throwable { diff --git a/plugins/storage/volume/datera/pom.xml b/plugins/storage/volume/datera/pom.xml index 58f50d88ef7..6c4b5808a89 100644 --- a/plugins/storage/volume/datera/pom.xml +++ b/plugins/storage/volume/datera/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/default/pom.xml b/plugins/storage/volume/default/pom.xml index b1a3a7bf8e9..03d26fb7fd1 100644 --- a/plugins/storage/volume/default/pom.xml +++ b/plugins/storage/volume/default/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java b/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java index d2f0076f95f..e407bc6c2f3 100644 --- a/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java +++ b/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java @@ -505,6 +505,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri StoragePoolVO storagePoolVO = primaryStoreDao.findByUuid(datastoreUUID); if (storagePoolVO != null) { volumeVO.setPoolId(storagePoolVO.getId()); + volumeVO.setPoolType(storagePoolVO.getPoolType()); } else { logger.warn("Unable to find datastore {} while updating the new datastore of the volume {}", datastoreUUID, vol); } diff --git a/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java index a98ea8eea3c..e4eb10f51fb 100644 --- a/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java +++ b/plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java @@ -476,8 +476,8 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl extends BasePrimaryDataStor @Override public boolean cancelMaintain(DataStore store) { - storagePoolAutmation.cancelMaintain(store); dataStoreHelper.cancelMaintain(store); + storagePoolAutmation.cancelMaintain(store); return true; } diff --git a/plugins/storage/volume/flasharray/pom.xml b/plugins/storage/volume/flasharray/pom.xml index a25435ec8a1..5adad7a3cdf 100644 --- a/plugins/storage/volume/flasharray/pom.xml +++ b/plugins/storage/volume/flasharray/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/linstor/CHANGELOG.md b/plugins/storage/volume/linstor/CHANGELOG.md index 7da3516955d..337f7786db9 100644 --- a/plugins/storage/volume/linstor/CHANGELOG.md +++ b/plugins/storage/volume/linstor/CHANGELOG.md @@ -1,3 +1,22 @@ + + # Changelog All notable changes to Linstor CloudStack plugin will be documented in this file. diff --git a/plugins/storage/volume/linstor/pom.xml b/plugins/storage/volume/linstor/pom.xml index 347a6fc39bf..0b78f0e26a1 100644 --- a/plugins/storage/volume/linstor/pom.xml +++ b/plugins/storage/volume/linstor/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java index a664e7ed03b..a1ba41b1d6e 100644 --- a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java +++ b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java @@ -38,6 +38,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.libvirt.LibvirtException; +import com.cloud.utils.storage.TemplateDownloaderUtil; import com.linbit.linstor.api.ApiClient; import com.linbit.linstor.api.ApiConsts; import com.linbit.linstor.api.ApiException; @@ -694,7 +695,7 @@ public class LinstorStorageAdaptor implements StorageAdaptor { private String getFinalDirectDownloadPath(String templateFilePath, KVMStoragePool destPool) { String finalSourcePath = templateFilePath; - if (LibvirtStorageAdaptor.isTemplateExtractable(templateFilePath)) { + if (TemplateDownloaderUtil.isTemplateExtractable(templateFilePath)) { finalSourcePath = templateFilePath.substring(0, templateFilePath.lastIndexOf('.')); LibvirtStorageAdaptor.extractDownloadedTemplate(templateFilePath, destPool, finalSourcePath); } diff --git a/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java b/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java index 306e9259936..d3b797e319f 100644 --- a/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java +++ b/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java @@ -868,6 +868,7 @@ public class LinstorPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver devPath = createVolume(volumeInfo, storagePool); volume.setFolder("/dev/"); volume.setPoolId(storagePool.getId()); + volume.setPoolType(storagePool.getPoolType()); volume.setUuid(vol.getUuid()); volume.setPath(vol.getUuid()); diff --git a/plugins/storage/volume/linstor/src/test/java/org/apache/cloudstack/storage/datastore/util/LinstorUtilTest.java b/plugins/storage/volume/linstor/src/test/java/org/apache/cloudstack/storage/datastore/util/LinstorUtilTest.java index 55f0c6ebe6d..39d9a253c57 100644 --- a/plugins/storage/volume/linstor/src/test/java/org/apache/cloudstack/storage/datastore/util/LinstorUtilTest.java +++ b/plugins/storage/volume/linstor/src/test/java/org/apache/cloudstack/storage/datastore/util/LinstorUtilTest.java @@ -82,7 +82,6 @@ public class LinstorUtilTest { mockStoragePool("thinpool", "nodeC", ProviderKind.LVM_THIN) )); -// when(LinstorUtil.getLinstorAPI(LINSTOR_URL_TEST)).thenReturn(api); } @Test diff --git a/plugins/storage/volume/nexenta/pom.xml b/plugins/storage/volume/nexenta/pom.xml index d52836f12be..d1de59bd24e 100644 --- a/plugins/storage/volume/nexenta/pom.xml +++ b/plugins/storage/volume/nexenta/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/nexenta/src/main/java/org/apache/cloudstack/storage/datastore/driver/NexentaPrimaryDataStoreDriver.java b/plugins/storage/volume/nexenta/src/main/java/org/apache/cloudstack/storage/datastore/driver/NexentaPrimaryDataStoreDriver.java index 60f3bd2ac8d..dad4819c83e 100644 --- a/plugins/storage/volume/nexenta/src/main/java/org/apache/cloudstack/storage/datastore/driver/NexentaPrimaryDataStoreDriver.java +++ b/plugins/storage/volume/nexenta/src/main/java/org/apache/cloudstack/storage/datastore/driver/NexentaPrimaryDataStoreDriver.java @@ -187,9 +187,6 @@ public class NexentaPrimaryDataStoreDriver implements PrimaryDataStoreDriver { NexentaStorAppliance appliance = getNexentaStorAppliance(storagePoolId); StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId); - - -// _storagePoolDao.update(stoagePoolId); } else { errorMessage = String.format( "Invalid DataObjectType(%s) passed to deleteAsync", diff --git a/plugins/storage/volume/nexenta/src/test/java/org/apache/cloudstack/storage/datastore/util/NexentaStorApplianceTest.java b/plugins/storage/volume/nexenta/src/test/java/org/apache/cloudstack/storage/datastore/util/NexentaStorApplianceTest.java index 89b5ece576f..d283e4c35d7 100644 --- a/plugins/storage/volume/nexenta/src/test/java/org/apache/cloudstack/storage/datastore/util/NexentaStorApplianceTest.java +++ b/plugins/storage/volume/nexenta/src/test/java/org/apache/cloudstack/storage/datastore/util/NexentaStorApplianceTest.java @@ -60,7 +60,6 @@ public class NexentaStorApplianceTest { public void init() { final String url = "nmsUrl=https://admin:nexenta@10.1.3.182:8457;volume=cloudstack;storageType=iscsi"; NexentaUtil.NexentaPluginParameters parameters = NexentaUtil.parseNexentaPluginUrl(url); - //client = new NexentaNmsClient(parameters.getNmsUrl()); client = mock(NexentaNmsClient.class); appliance = new NexentaStorAppliance(client, parameters); } diff --git a/plugins/storage/volume/primera/pom.xml b/plugins/storage/volume/primera/pom.xml index ad17a695c22..ac4351b2f92 100644 --- a/plugins/storage/volume/primera/pom.xml +++ b/plugins/storage/volume/primera/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/sample/pom.xml b/plugins/storage/volume/sample/pom.xml index f0a171e83cb..425303a9eb2 100644 --- a/plugins/storage/volume/sample/pom.xml +++ b/plugins/storage/volume/sample/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/scaleio/pom.xml b/plugins/storage/volume/scaleio/pom.xml index 79b1a328953..b16640482c8 100644 --- a/plugins/storage/volume/scaleio/pom.xml +++ b/plugins/storage/volume/scaleio/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/api/VTreeMigrationInfo.java b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/api/VTreeMigrationInfo.java index f4e926bfd33..072b52b69d6 100644 --- a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/api/VTreeMigrationInfo.java +++ b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/api/VTreeMigrationInfo.java @@ -59,7 +59,7 @@ public class VTreeMigrationInfo { } public void setMigrationStatus(String migrationStatus) { - this.migrationStatus = EnumUtils.fromString(MigrationStatus.class, migrationStatus, MigrationStatus.None); + this.migrationStatus = EnumUtils.getEnumIgnoreCase(MigrationStatus.class, migrationStatus, MigrationStatus.None); } public void setMigrationStatus(MigrationStatus migrationStatus) { diff --git a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManager.java b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManager.java index 8529d5dac73..f8aaf495b39 100644 --- a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManager.java +++ b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManager.java @@ -28,7 +28,7 @@ public interface ScaleIOSDCManager { ConfigKey ConnectOnDemand = new ConfigKey<>("Storage", Boolean.class, "powerflex.connect.on.demand", - Boolean.FALSE.toString(), + Boolean.TRUE.toString(), "When true, connects PowerFlex client on Host when first Volume is mapped to SDC & client connections configured 'storage.pool.connected.clients.limit' are within the limit and disconnects when last Volume is unmapped from SDC; " + "and When false, connects PowerFlex client on Host when host connects to storage pool & client connections configured 'storage.pool.connected.clients.limit' are within the limit and disconnects when host disconnects from storage pool & no volumes mapped to SDC.", Boolean.TRUE, diff --git a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java index 3d7d1cf279c..c13ad61a6cd 100644 --- a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java +++ b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java @@ -61,15 +61,6 @@ import com.cloud.utils.exception.CloudRuntimeException; public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager, Configurable { private Logger logger = LogManager.getLogger(getClass()); - static ConfigKey ConnectOnDemand = new ConfigKey<>("Storage", - Boolean.class, - "powerflex.connect.on.demand", - Boolean.TRUE.toString(), - "Connect PowerFlex client on Host when first Volume is mapped to SDC and disconnect when last Volume is unmapped from SDC," + - " otherwise no action (that is connection remains in the same state whichever it is, connected or disconnected).", - Boolean.TRUE, - ConfigKey.Scope.Zone); - @Inject AgentManager agentManager; @Inject diff --git a/plugins/storage/volume/solidfire/pom.xml b/plugins/storage/volume/solidfire/pom.xml index 008ddf137d8..65ba90b0c38 100644 --- a/plugins/storage/volume/solidfire/pom.xml +++ b/plugins/storage/volume/solidfire/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/solidfire/src/test/java/org/apache/cloudstack/storage/test/VolumeTest.java b/plugins/storage/volume/solidfire/src/test/java/org/apache/cloudstack/storage/test/VolumeTest.java index 08f95b15d13..d721412b3ec 100644 --- a/plugins/storage/volume/solidfire/src/test/java/org/apache/cloudstack/storage/test/VolumeTest.java +++ b/plugins/storage/volume/solidfire/src/test/java/org/apache/cloudstack/storage/test/VolumeTest.java @@ -64,8 +64,6 @@ public class VolumeTest { DataCenterDao dcDao; @Inject PrimaryDataStoreDao primaryStoreDao; - // @Inject - // PrimaryDataStoreProviderManager primaryDataStoreProviderMgr; @Inject AgentManager agentMgr; Long dcId; @@ -109,25 +107,15 @@ public class VolumeTest { results.add(host); Mockito.when(hostDao.listAll()).thenReturn(results); Mockito.when(hostDao.findHypervisorHostInCluster(ArgumentMatchers.anyLong())).thenReturn(results); - // CreateObjectAnswer createVolumeFromImageAnswer = new - // CreateObjectAnswer(null,UUID.randomUUID().toString(), null); - - // Mockito.when(primaryStoreDao.findById(Mockito.anyLong())).thenReturn(primaryStore); } private PrimaryDataStoreInfo createPrimaryDataStore() { try { - // primaryDataStoreProviderMgr.configure("primary data store mgr", - // new HashMap()); - // PrimaryDataStoreProvider provider = - // primaryDataStoreProviderMgr.getDataStoreProvider("Solidfre Primary Data Store Provider"); Map params = new HashMap(); params.put("url", "nfs://test/test"); params.put("dcId", dcId.toString()); params.put("clusterId", clusterId.toString()); params.put("name", "my primary data store"); - // PrimaryDataStoreInfo primaryDataStoreInfo = - // provider.registerDataStore(params); return null; } catch (Exception e) { return null; diff --git a/plugins/storage/volume/storpool/README.md b/plugins/storage/volume/storpool/README.md index a9cf3442b20..1f6829b8544 100644 --- a/plugins/storage/volume/storpool/README.md +++ b/plugins/storage/volume/storpool/README.md @@ -1,3 +1,22 @@ + + # StorPool CloudStack Integration ## CloudStack Overview @@ -341,8 +360,6 @@ corresponding system disk offering. CloudStack has no way to specify max BW. Do they want to be able to specify max BW only is sufficient. -================================================================================ - StorPool provides the ‘storpool_qos’ service ([QoS user guide](https://kb.storpool.com/storpool_misc/qos.html#storpool-qos-user-guide)) that tracks and configures the storage tier for all volumes based on a specifically provided `qc` tag specifying the storage tier for each volume. To manage the QoS limits with a `qc` tag, you have to add a `qc` tag resource detail to each disk offering to which a tier should be applied, with a key `SP_QOSCLASS` and the value from the configuration file for the `storpool_qos` service: diff --git a/plugins/storage/volume/storpool/pom.xml b/plugins/storage/volume/storpool/pom.xml index 4c18425f41d..7bdc76da81f 100644 --- a/plugins/storage/volume/storpool/pom.xml +++ b/plugins/storage/volume/storpool/pom.xml @@ -17,7 +17,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadVolumeCommandWrapper.java b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadVolumeCommandWrapper.java index 1679e646e18..de8b9484d11 100644 --- a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadVolumeCommandWrapper.java +++ b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadVolumeCommandWrapper.java @@ -29,7 +29,6 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.utils.qemu.QemuImg; import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; import org.apache.cloudstack.utils.qemu.QemuImgFile; -//import java.io.File; import com.cloud.agent.api.storage.StorPoolDownloadVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; diff --git a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java index 4dcc67f3f06..545f7b33c5f 100644 --- a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java +++ b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java @@ -26,6 +26,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; +import com.cloud.utils.storage.TemplateDownloaderUtil; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -528,32 +529,15 @@ public class StorPoolStorageAdaptor implements StorageAdaptor { private String extractTemplate(String templateFilePath, File sourceFile, String srcTemplateFilePath, String templateName) { - if (isTemplateExtractable(templateFilePath)) { + if (TemplateDownloaderUtil.isTemplateExtractable(templateFilePath)) { srcTemplateFilePath = sourceFile.getParent() + "/" + templateName; - String extractCommand = getExtractCommandForDownloadedFile(templateFilePath, srcTemplateFilePath); + String extractCommand = TemplateDownloaderUtil.getExtractCommandForDownloadedFile(templateFilePath, srcTemplateFilePath); Script.runSimpleBashScript(extractCommand); Script.runSimpleBashScript("rm -f " + templateFilePath); } return srcTemplateFilePath; } - private boolean isTemplateExtractable(String templatePath) { - String type = Script.runSimpleBashScript("file " + templatePath + " | awk -F' ' '{print $2}'"); - return type.equalsIgnoreCase("bzip2") || type.equalsIgnoreCase("gzip") || type.equalsIgnoreCase("zip"); - } - - private String getExtractCommandForDownloadedFile(String downloadedTemplateFile, String templateFile) { - if (downloadedTemplateFile.endsWith(".zip")) { - return "unzip -p " + downloadedTemplateFile + " | cat > " + templateFile; - } else if (downloadedTemplateFile.endsWith(".bz2")) { - return "bunzip2 -c " + downloadedTemplateFile + " > " + templateFile; - } else if (downloadedTemplateFile.endsWith(".gz")) { - return "gunzip -c " + downloadedTemplateFile + " > " + templateFile; - } else { - throw new CloudRuntimeException("Unable to extract template " + downloadedTemplateFile); - } - } - private String getNameFromResponse(String resp, boolean tildeNeeded, boolean isSnapshot) { JsonParser jsonParser = new JsonParser(); JsonObject respObj = (JsonObject) jsonParser.parse(resp); diff --git a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/collector/StorPoolAbandonObjectsCollector.java b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/collector/StorPoolAbandonObjectsCollector.java index 84abb1e35d5..7bfa6332bd1 100644 --- a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/collector/StorPoolAbandonObjectsCollector.java +++ b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/collector/StorPoolAbandonObjectsCollector.java @@ -23,7 +23,6 @@ import com.cloud.dc.dao.ClusterDao; import com.cloud.storage.dao.SnapshotDetailsDao; import com.cloud.storage.dao.SnapshotDetailsVO; - import com.cloud.utils.component.ManagerBase; import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.db.DB; diff --git a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java index c305c393c9b..9dc94c20f11 100644 --- a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java +++ b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java @@ -934,7 +934,6 @@ public class StorPoolPrimaryDataStoreDriver implements PrimaryDataStoreDriver { if (resp.getError() != null) { err = String.format("Could not create Storpool volume for CS template %s. Error: %s", name, resp.getError()); } else { - //updateVolume(dstData.getId()); VolumeObjectTO dstTO = (VolumeObjectTO)dstData.getTO(); dstTO.setPath(StorPoolUtil.devPath(StorPoolUtil.getNameFromResponse(resp, false))); dstTO.setSize(size); diff --git a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/util/StorPoolHelper.java b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/util/StorPoolHelper.java index 685b99e12d5..ea3ba0e9613 100644 --- a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/util/StorPoolHelper.java +++ b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/util/StorPoolHelper.java @@ -178,32 +178,6 @@ public class StorPoolHelper { return tags; } - // Initialize custom logger for updated volume and snapshots -// public static void appendLogger(Logger log, String filePath, String kindOfLog) { -// Appender appender = null; -// PatternLayout patternLayout = new PatternLayout(); -// patternLayout.setConversionPattern("%d{YYYY-MM-dd HH:mm:ss.SSS} %m%n"); -// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); -// Timestamp timestamp = new Timestamp(System.currentTimeMillis()); -// String path = filePath + "-" + sdf.format(timestamp) + ".log"; -// try { -// appender = new RollingFileAppender(patternLayout, path); -// log.setAdditivity(false); -// log.addAppender(appender); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// if (kindOfLog.equals("update")) { -// StorPoolUtil.spLog( -// "You can find information about volumes and snapshots, which will be updated in Database with their globalIs in %s log file", -// path); -// } else if (kindOfLog.equals("abandon")) { -// StorPoolUtil.spLog( -// "You can find information about volumes and snapshots, for which CloudStack doesn't have information in %s log file", -// path); -// } -// } - public static void setSpClusterIdIfNeeded(long hostId, String clusterId, ClusterDao clusterDao, HostDao hostDao, ClusterDetailsDao clusterDetails) { HostVO host = hostDao.findById(hostId); diff --git a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/motion/StorPoolDataMotionStrategy.java b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/motion/StorPoolDataMotionStrategy.java index f260c566986..5789ac50871 100644 --- a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/motion/StorPoolDataMotionStrategy.java +++ b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/motion/StorPoolDataMotionStrategy.java @@ -425,6 +425,7 @@ public class StorPoolDataMotionStrategy implements DataMotionStrategy { newVol.setFolder(null); newVol.setPodId(storagePoolVO.getPodId()); newVol.setPoolId(storagePoolVO.getId()); + newVol.setPoolType(storagePoolVO.getPoolType()); newVol.setLastPoolId(lastPoolId); return _volumeDao.persist(newVol); diff --git a/plugins/user-authenticators/ldap/pom.xml b/plugins/user-authenticators/ldap/pom.xml index 80101f05e3d..c02d3d511e6 100644 --- a/plugins/user-authenticators/ldap/pom.xml +++ b/plugins/user-authenticators/ldap/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/ADLdapUserManagerImpl.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/ADLdapUserManagerImpl.java index e96606dca2f..bf5d503e841 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/ADLdapUserManagerImpl.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/ADLdapUserManagerImpl.java @@ -49,7 +49,7 @@ public class ADLdapUserManagerImpl extends OpenLdapUserManagerImpl implements Ld searchControls.setReturningAttributes(_ldapConfiguration.getReturnAttributes(domainId)); NamingEnumeration results = context.search(basedn, generateADGroupSearchFilter(groupName, domainId), searchControls); - final List users = new ArrayList(); + final List users = new ArrayList<>(); while (results.hasMoreElements()) { final SearchResult result = results.nextElement(); users.add(createUser(result, domainId)); @@ -58,10 +58,8 @@ public class ADLdapUserManagerImpl extends OpenLdapUserManagerImpl implements Ld } String generateADGroupSearchFilter(String groupName, Long domainId) { - final StringBuilder userObjectFilter = new StringBuilder(); - userObjectFilter.append("(objectClass="); - userObjectFilter.append(_ldapConfiguration.getUserObject(domainId)); - userObjectFilter.append(")"); + + final StringBuilder userObjectFilter = getUserObjectFilter(domainId); final StringBuilder memberOfFilter = new StringBuilder(); String groupCnName = _ldapConfiguration.getCommonNameAttribute() + "=" +groupName + "," + _ldapConfiguration.getBaseDn(domainId); @@ -75,10 +73,18 @@ public class ADLdapUserManagerImpl extends OpenLdapUserManagerImpl implements Ld result.append(memberOfFilter); result.append(")"); - logger.debug("group search filter = " + result); + logger.debug("group search filter = {}", result); return result.toString(); } + StringBuilder getUserObjectFilter(Long domainId) { + final StringBuilder userObjectFilter = new StringBuilder(); + userObjectFilter.append("(&(objectCategory=person)"); + userObjectFilter.append(super.getUserObjectFilter(domainId)); + userObjectFilter.append(")"); + return userObjectFilter; + } + protected boolean isUserDisabled(SearchResult result) throws NamingException { boolean isDisabledUser = false; String userAccountControl = LdapUtils.getAttributeValue(result.getAttributes(), _ldapConfiguration.getUserAccountControlAttribute()); diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/OpenLdapUserManagerImpl.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/OpenLdapUserManagerImpl.java index d0b6bc4bd34..80d394d7478 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/OpenLdapUserManagerImpl.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/OpenLdapUserManagerImpl.java @@ -75,23 +75,15 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { } private String generateSearchFilter(final String username, Long domainId) { - final StringBuilder userObjectFilter = new StringBuilder(); - userObjectFilter.append("(objectClass="); - userObjectFilter.append(_ldapConfiguration.getUserObject(domainId)); - userObjectFilter.append(")"); + final StringBuilder userObjectFilter = getUserObjectFilter(domainId); - final StringBuilder usernameFilter = new StringBuilder(); - usernameFilter.append("("); - usernameFilter.append(_ldapConfiguration.getUsernameAttribute(domainId)); - usernameFilter.append("="); - usernameFilter.append((username == null ? "*" : LdapUtils.escapeLDAPSearchFilter(username))); - usernameFilter.append(")"); + final StringBuilder usernameFilter = getUsernameFilter(username, domainId); String memberOfAttribute = getMemberOfAttribute(domainId); StringBuilder ldapGroupsFilter = new StringBuilder(); // this should get the trustmaps for this domain List ldapGroups = getMappedLdapGroups(domainId); - if (null != ldapGroups && ldapGroups.size() > 0) { + if (!ldapGroups.isEmpty()) { ldapGroupsFilter.append("(|"); for (String ldapGroup : ldapGroups) { ldapGroupsFilter.append(getMemberOfGroupString(ldapGroup, memberOfAttribute)); @@ -104,21 +96,35 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { if (null != pricipleGroup) { principleGroupFilter.append(getMemberOfGroupString(pricipleGroup, memberOfAttribute)); } - final StringBuilder result = new StringBuilder(); - result.append("(&"); - result.append(userObjectFilter); - result.append(usernameFilter); - result.append(ldapGroupsFilter); - result.append(principleGroupFilter); - result.append(")"); - String returnString = result.toString(); - if (logger.isTraceEnabled()) { - logger.trace("constructed ldap query: " + returnString); - } + String returnString = "(&" + + userObjectFilter + + usernameFilter + + ldapGroupsFilter + + principleGroupFilter + + ")"; + logger.trace("constructed ldap query: {}", returnString); return returnString; } + private StringBuilder getUsernameFilter(String username, Long domainId) { + final StringBuilder usernameFilter = new StringBuilder(); + usernameFilter.append("("); + usernameFilter.append(_ldapConfiguration.getUsernameAttribute(domainId)); + usernameFilter.append("="); + usernameFilter.append((username == null ? "*" : LdapUtils.escapeLDAPSearchFilter(username))); + usernameFilter.append(")"); + return usernameFilter; + } + + StringBuilder getUserObjectFilter(Long domainId) { + final StringBuilder userObjectFilter = new StringBuilder(); + userObjectFilter.append("(objectClass="); + userObjectFilter.append(_ldapConfiguration.getUserObject(domainId)); + userObjectFilter.append(")"); + return userObjectFilter; + } + private List getMappedLdapGroups(Long domainId) { List ldapGroups = new ArrayList<>(); // first get the trustmaps @@ -134,37 +140,31 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { private String getMemberOfGroupString(String group, String memberOfAttribute) { final StringBuilder memberOfFilter = new StringBuilder(); if (null != group) { - if(logger.isDebugEnabled()) { - logger.debug("adding search filter for '" + group + - "', using '" + memberOfAttribute + "'"); - } - memberOfFilter.append("(" + memberOfAttribute + "="); - memberOfFilter.append(group); - memberOfFilter.append(")"); + logger.debug("adding search filter for '{}', using '{}'", group, memberOfAttribute); + memberOfFilter.append("(") + .append(memberOfAttribute) + .append("=") + .append(group) + .append(")"); } return memberOfFilter.toString(); } private String generateGroupSearchFilter(final String groupName, Long domainId) { - final StringBuilder groupObjectFilter = new StringBuilder(); - groupObjectFilter.append("(objectClass="); - groupObjectFilter.append(_ldapConfiguration.getGroupObject(domainId)); - groupObjectFilter.append(")"); + String groupObjectFilter = "(objectClass=" + + _ldapConfiguration.getGroupObject(domainId) + + ")"; - final StringBuilder groupNameFilter = new StringBuilder(); - groupNameFilter.append("("); - groupNameFilter.append(_ldapConfiguration.getCommonNameAttribute()); - groupNameFilter.append("="); - groupNameFilter.append((groupName == null ? "*" : LdapUtils.escapeLDAPSearchFilter(groupName))); - groupNameFilter.append(")"); + String groupNameFilter = "(" + + _ldapConfiguration.getCommonNameAttribute() + + "=" + + (groupName == null ? "*" : LdapUtils.escapeLDAPSearchFilter(groupName)) + + ")"; - final StringBuilder result = new StringBuilder(); - result.append("(&"); - result.append(groupObjectFilter); - result.append(groupNameFilter); - result.append(")"); - - return result.toString(); + return "(&" + + groupObjectFilter + + groupNameFilter + + ")"; } @Override @@ -186,17 +186,9 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { basedn = _ldapConfiguration.getBaseDn(domainId); } - final StringBuilder userObjectFilter = new StringBuilder(); - userObjectFilter.append("(objectClass="); - userObjectFilter.append(_ldapConfiguration.getUserObject(domainId)); - userObjectFilter.append(")"); + final StringBuilder userObjectFilter = getUserObjectFilter(domainId); - final StringBuilder usernameFilter = new StringBuilder(); - usernameFilter.append("("); - usernameFilter.append(_ldapConfiguration.getUsernameAttribute(domainId)); - usernameFilter.append("="); - usernameFilter.append((username == null ? "*" : LdapUtils.escapeLDAPSearchFilter(username))); - usernameFilter.append(")"); + final StringBuilder usernameFilter = getUsernameFilter(username, domainId); final StringBuilder memberOfFilter = new StringBuilder(); if ("GROUP".equals(type)) { @@ -205,18 +197,17 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { memberOfFilter.append(")"); } - final StringBuilder searchQuery = new StringBuilder(); - searchQuery.append("(&"); - searchQuery.append(userObjectFilter); - searchQuery.append(usernameFilter); - searchQuery.append(memberOfFilter); - searchQuery.append(")"); + String searchQuery = "(&" + + userObjectFilter + + usernameFilter + + memberOfFilter + + ")"; - return searchUser(basedn, searchQuery.toString(), context, domainId); + return searchUser(basedn, searchQuery, context, domainId); } protected String getMemberOfAttribute(final Long domainId) { - return _ldapConfiguration.getUserMemberOfAttribute(domainId); + return LdapConfiguration.getUserMemberOfAttribute(domainId); } @Override @@ -243,7 +234,7 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { NamingEnumeration result = context.search(_ldapConfiguration.getBaseDn(domainId), generateGroupSearchFilter(groupName, domainId), controls); - final List users = new ArrayList(); + final List users = new ArrayList<>(); //Expecting only one result which has all the users if (result.hasMoreElements()) { Attribute attribute = result.nextElement().getAttributes().get(attributeName); @@ -254,7 +245,7 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { try{ users.add(getUserForDn(userdn, context, domainId)); } catch (NamingException e){ - logger.info("Userdn: " + userdn + " Not Found:: Exception message: " + e.getMessage()); + logger.info("Userdn: {} Not Found:: Exception message: {}", userdn, e.getMessage()); } } } @@ -286,17 +277,15 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { return false; } - public LdapUser searchUser(final String basedn, final String searchString, final LdapContext context, Long domainId) throws NamingException, IOException { + public LdapUser searchUser(final String basedn, final String searchString, final LdapContext context, Long domainId) throws NamingException { final SearchControls searchControls = new SearchControls(); searchControls.setSearchScope(_ldapConfiguration.getScope()); searchControls.setReturningAttributes(_ldapConfiguration.getReturnAttributes(domainId)); NamingEnumeration results = context.search(basedn, searchString, searchControls); - if(logger.isDebugEnabled()) { - logger.debug("searching user(s) with filter: \"" + searchString + "\""); - } - final List users = new ArrayList(); + logger.debug("searching user(s) with filter: \"{}\"", searchString); + final List users = new ArrayList<>(); while (results.hasMoreElements()) { final SearchResult result = results.nextElement(); users.add(createUser(result, domainId)); @@ -324,7 +313,7 @@ public class OpenLdapUserManagerImpl implements LdapUserManager { byte[] cookie = null; int pageSize = _ldapConfiguration.getLdapPageSize(domainId); context.setRequestControls(new Control[]{new PagedResultsControl(pageSize, Control.NONCRITICAL)}); - final List users = new ArrayList(); + final List users = new ArrayList<>(); NamingEnumeration results; do { results = context.search(basedn, generateSearchFilter(username, domainId), searchControls); diff --git a/plugins/user-authenticators/ldap/src/test/java/org/apache/cloudstack/ldap/ADLdapUserManagerImplTest.java b/plugins/user-authenticators/ldap/src/test/java/org/apache/cloudstack/ldap/ADLdapUserManagerImplTest.java index 58b14ec3684..f2ac1dffaf9 100644 --- a/plugins/user-authenticators/ldap/src/test/java/org/apache/cloudstack/ldap/ADLdapUserManagerImplTest.java +++ b/plugins/user-authenticators/ldap/src/test/java/org/apache/cloudstack/ldap/ADLdapUserManagerImplTest.java @@ -54,9 +54,8 @@ public class ADLdapUserManagerImplTest { String [] groups = {"dev", "dev-hyd"}; for (String group: groups) { String result = adLdapUserManager.generateADGroupSearchFilter(group, 1L); - assertTrue(("(&(objectClass=user)(memberOf:1.2.840.113556.1.4.1941:=CN=" + group + ",DC=cloud,DC=citrix,DC=com))").equals(result)); + assertTrue(("(&(&(objectCategory=person)(objectClass=user))(memberOf:1.2.840.113556.1.4.1941:=CN=" + group + ",DC=cloud,DC=citrix,DC=com))").equals(result)); } - } @Test @@ -69,7 +68,7 @@ public class ADLdapUserManagerImplTest { String [] groups = {"dev", "dev-hyd"}; for (String group: groups) { String result = adLdapUserManager.generateADGroupSearchFilter(group, 1L); - assertTrue(("(&(objectClass=user)(memberOf=CN=" + group + ",DC=cloud,DC=citrix,DC=com))").equals(result)); + assertTrue(("(&(&(objectCategory=person)(objectClass=user))(memberOf=CN=" + group + ",DC=cloud,DC=citrix,DC=com))").equals(result)); } } diff --git a/plugins/user-authenticators/md5/pom.xml b/plugins/user-authenticators/md5/pom.xml index bffcf5d43c4..f0f998c42c1 100644 --- a/plugins/user-authenticators/md5/pom.xml +++ b/plugins/user-authenticators/md5/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-authenticators/oauth2/pom.xml b/plugins/user-authenticators/oauth2/pom.xml index 83773bc20ae..6ab7b9f5fab 100644 --- a/plugins/user-authenticators/oauth2/pom.xml +++ b/plugins/user-authenticators/oauth2/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-authenticators/pbkdf2/pom.xml b/plugins/user-authenticators/pbkdf2/pom.xml index b148e7b4e2c..6ffa1188e13 100644 --- a/plugins/user-authenticators/pbkdf2/pom.xml +++ b/plugins/user-authenticators/pbkdf2/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-authenticators/plain-text/pom.xml b/plugins/user-authenticators/plain-text/pom.xml index ac990df26b9..54a9650b64f 100644 --- a/plugins/user-authenticators/plain-text/pom.xml +++ b/plugins/user-authenticators/plain-text/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-authenticators/saml2/pom.xml b/plugins/user-authenticators/saml2/pom.xml index 3cf1c7fbc7c..4cd6f70d096 100644 --- a/plugins/user-authenticators/saml2/pom.xml +++ b/plugins/user-authenticators/saml2/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-authenticators/sha256salted/pom.xml b/plugins/user-authenticators/sha256salted/pom.xml index f4da967ddfe..2b47e010c26 100644 --- a/plugins/user-authenticators/sha256salted/pom.xml +++ b/plugins/user-authenticators/sha256salted/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-two-factor-authenticators/static-pin/pom.xml b/plugins/user-two-factor-authenticators/static-pin/pom.xml index ba4680d5003..522e2451e7e 100644 --- a/plugins/user-two-factor-authenticators/static-pin/pom.xml +++ b/plugins/user-two-factor-authenticators/static-pin/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/user-two-factor-authenticators/totp/pom.xml b/plugins/user-two-factor-authenticators/totp/pom.xml index 60595853108..eb3cc0b1ca6 100644 --- a/plugins/user-two-factor-authenticators/totp/pom.xml +++ b/plugins/user-two-factor-authenticators/totp/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index b33d9dfe4c6..7d29ce609c6 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT pom Apache CloudStack Apache CloudStack is an IaaS ("Infrastructure as a Service") cloud orchestration platform. @@ -50,7 +50,7 @@ UTF-8 UTF-8 https://download.cloudstack.org/systemvm - 4.20.2.0 + 4.22.0.0 apache https://sonarcloud.io @@ -156,7 +156,7 @@ 2.3.3 2.3.7 2.26 - 9.4.51.v20230217 + 9.4.58.v20250814 9.4.27.v20200227 5.5.0 2.12.5 @@ -1016,19 +1016,17 @@ **/.vagrant **/*.json **/.checkstyle - **/*.md .java-version .python-version - systemvm/.pythen-version .idea/ .metadata/** .git/** .github/linters/codespell.txt .gitignore + .markdownlintignore CHANGES.md - CONTRIBUTING.md - README.md - INSTALL.md + ISSUE_TEMPLATE.md + PULL_REQUEST_TEMPLATE.md build/build.number debian/cloudstack-agent.dirs debian/cloudstack-usage.dirs @@ -1040,15 +1038,19 @@ dist/console-proxy/js/jquery.js engine/schema/dist/** plugins/hypervisors/hyperv/conf/agent.properties + plugins/hypervisors/hyperv/conf/uefi.properties plugins/hypervisors/hyperv/DotNet/ServerResource/** scripts/installer/windows/acs_license.rtf scripts/vm/systemvm/id_rsa.cloud services/console-proxy/server/conf/agent.properties + services/console-proxy/server/conf/uefi.properties services/console-proxy/server/conf/environment.properties services/console-proxy/server/js/jquery.js services/secondary-storage/conf/agent.properties + services/secondary-storage/conf/uefi.properties services/secondary-storage/conf/environment.properties systemvm/agent/conf/agent.properties + systemvm/agent/conf/uefi.properties systemvm/agent/conf/environment.properties systemvm/agent/js/jquery.js systemvm/agent/js/jquery.flot.navigate.js @@ -1056,7 +1058,6 @@ systemvm/agent/packages/** systemvm/debian/** test/integration/component/test_host_ha.sh - test/systemvm/README.md tools/appliance/*/template.json tools/cli/cloudmonkey.egg-info/* tools/devcloud/basebuild/puppet-devcloudinitial/files/network.conf @@ -1070,11 +1071,14 @@ tools/transifex/.tx/config ui/.* ui/.*/** + ui/docs/full-test-plan.template.md + ui/docs/smoke-test-plan.template.md ui/src/assets/** ui/public/** ui/legacy/** utils/testsmallfileinactive **/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker + .github/workflows/dependabot.yaml diff --git a/python/lib/cloudutils/configFileOps.py b/python/lib/cloudutils/configFileOps.py index c061071b96e..f4d704af783 100644 --- a/python/lib/cloudutils/configFileOps.py +++ b/python/lib/cloudutils/configFileOps.py @@ -68,14 +68,14 @@ class configFileOps: for entry in self.entries: if entry.op == "add": if entry.separator == "=": - matchString = "^\ *" + entry.name + ".*" + matchString = r"^\ *" + entry.name + ".*" elif entry.separator == " ": - matchString = "^\ *" + entry.name + "\ *" + entry.value + matchString = r"^\ *" + entry.name + r"\ *" + entry.value else: if entry.separator == "=": - matchString = "^\ *" + entry.name + "\ *=\ *" + entry.value + matchString = r"^\ *" + entry.name + r"\ *=\ *" + entry.value else: - matchString = "^\ *" + entry.name + "\ *" + entry.value + matchString = r"^\ *" + entry.name + r"\ *" + entry.value match = re.match(matchString, line) if match is not None: diff --git a/python/lib/cloudutils/networkConfig.py b/python/lib/cloudutils/networkConfig.py index ac51f92aa58..827664bbc73 100644 --- a/python/lib/cloudutils/networkConfig.py +++ b/python/lib/cloudutils/networkConfig.py @@ -45,8 +45,11 @@ class networkConfig: if not cmd.isSuccess(): logging.debug("Failed to get default route") raise CloudRuntimeException("Failed to get default route") - - result = cmd.getStdout().split(" ") + output = cmd.getStdout().strip() + result = output.split(" ") + if len(result) < 2: + logging.debug("Output for the default route incomplete: %s. It should have been ' '" % output) + raise CloudRuntimeException("Output for the default route incomplete") gateway = result[0] dev = result[1] @@ -150,10 +153,10 @@ class networkConfig: if line.find("HWaddr") != -1: macAddr = line.split("HWaddr ")[1].strip(" ") elif line.find("inet ") != -1: - m = re.search("addr:(.*)\ *Bcast:(.*)\ *Mask:(.*)", line) + m = re.search(r"addr:([^\s]+)\s*Bcast:([^\s]+)\s*Mask:([^\s]+)", line) if m is not None: - ipAddr = m.group(1).rstrip(" ") - netmask = m.group(3).rstrip(" ") + ipAddr = m.group(1).strip() + netmask = m.group(3).strip() if networkConfig.isBridgePort(dev): type = "brport" diff --git a/python/lib/cloudutils/utilities.py b/python/lib/cloudutils/utilities.py index 5f7e34ed61d..31f35ee6d44 100755 --- a/python/lib/cloudutils/utilities.py +++ b/python/lib/cloudutils/utilities.py @@ -63,7 +63,7 @@ class bash: return self.stdout.decode('utf-8').strip('\n') def getLines(self): - return self.stdout.decode('utf-8').strip('\n') + return self.stdout.decode('utf-8').strip('\n').split('\n') def getStderr(self): return self.stderr.decode('utf-8').strip('\n') diff --git a/quickcloud/pom.xml b/quickcloud/pom.xml index 016e28e55dd..cc0bacbd7e7 100644 --- a/quickcloud/pom.xml +++ b/quickcloud/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/scripts/installer/createtmplt.sh b/scripts/installer/createtmplt.sh index db3cfd71ee1..8d9b9876700 100755 --- a/scripts/installer/createtmplt.sh +++ b/scripts/installer/createtmplt.sh @@ -87,6 +87,8 @@ uncompress() { ;; [zZ][iI][pP]) unzip -p $1 | cat > $tmpfile ;; + XZ) xz -d -c $1 > $tmpfile + ;; *) printf "$1" return 0 ;; @@ -270,9 +272,4 @@ echo "volume.size=$volsize" >> /$tmpltfs/template.properties zfs snapshot -r $tmpltfs@vmops_ss rollback_if_needed $tmpltfs $? "Failed to snapshot filesystem" -#if [ "$cleanup" == "true" ] -#then - #rm -f $tmpltimg -#fi - exit 0 diff --git a/scripts/installer/createvolume.sh b/scripts/installer/createvolume.sh index 52792e9fc3a..716bb8556ce 100755 --- a/scripts/installer/createvolume.sh +++ b/scripts/installer/createvolume.sh @@ -88,6 +88,8 @@ uncompress() { ;; ZIP) unzip -p $1 | cat > $tmpfile ;; + XZ) xz -d -c $1 > $tmpfile + ;; *) printf "$1" return 0 ;; @@ -271,9 +273,4 @@ echo "volume.size=$volsize" >> /$volfs/volume.properties zfs snapshot -r $volfs@vmops_ss rollback_if_needed $volfs $? "Failed to snapshot filesystem" -#if [ "$cleanup" == "true" ] -#then - #rm -f $volimg -#fi - exit 0 diff --git a/scripts/storage/qcow2/createtmplt.sh b/scripts/storage/qcow2/createtmplt.sh index 4bb955e130c..de7010b0a25 100755 --- a/scripts/storage/qcow2/createtmplt.sh +++ b/scripts/storage/qcow2/createtmplt.sh @@ -65,6 +65,8 @@ uncompress() { ;; [zZ][iI][pP]) unzip -p $1 | cat > $tmpfile ;; + XZ) xz -d -c $1 > $tmpfile + ;; *) printf "$1" return 0 ;; diff --git a/scripts/storage/qcow2/createvolume.sh b/scripts/storage/qcow2/createvolume.sh index ff04ee3fe5e..b2ce249a3d1 100755 --- a/scripts/storage/qcow2/createvolume.sh +++ b/scripts/storage/qcow2/createvolume.sh @@ -66,6 +66,8 @@ uncompress() { ;; ZIP) unzip -p $1 | cat > $tmpfile ;; + XZ) xz -d -c $1 > $tmpfile + ;; *) printf "$1" return 0 ;; diff --git a/scripts/storage/secondary/createtmplt.sh b/scripts/storage/secondary/createtmplt.sh index ed9bbe869e1..cfc4be28a01 100755 --- a/scripts/storage/secondary/createtmplt.sh +++ b/scripts/storage/secondary/createtmplt.sh @@ -63,6 +63,8 @@ is_compressed() { ;; [zZ][iI][pP]) ctype="zip" ;; + XZ) ctype="xz" + ;; *) echo "File $1 does not appear to be compressed" >&2 return 1 ;; @@ -82,6 +84,8 @@ uncompress() { ;; [zZ][iI][pP]) unzip -q -p $1 | cat > $tmpfile ;; + XZ) xz -d -c $1 > $tmpfile + ;; *) printf "$1" return 0 ;; diff --git a/scripts/storage/secondary/createvolume.sh b/scripts/storage/secondary/createvolume.sh index ac69ebe88ab..a47d1fdc2d3 100755 --- a/scripts/storage/secondary/createvolume.sh +++ b/scripts/storage/secondary/createvolume.sh @@ -85,6 +85,8 @@ is_compressed() { ;; ZIP) ctype="zip" ;; + XZ) ctype="xz" + ;; *) echo "File $1 does not appear to be compressed" >&2 return 1 ;; @@ -104,6 +106,8 @@ uncompress() { ;; ZIP) unzip -q -p $1 | cat > $tmpfile ;; + XZ) xz -d -c $1 > $tmpfile + ;; *) printf "$1" return 0 ;; diff --git a/scripts/storage/secondary/listvmtmplt.sh b/scripts/storage/secondary/listvmtmplt.sh index 8463b51e4f6..c0f2132879b 100755 --- a/scripts/storage/secondary/listvmtmplt.sh +++ b/scripts/storage/secondary/listvmtmplt.sh @@ -53,11 +53,6 @@ for i in $(find /$rootdir -name template.properties ); do d=$(dirname $i) filename=$(grep "^filename" $i | awk -F"=" '{print $NF}') -# size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}') -# if [ -n "$filename" ] && [ -n "$size" ] -# then -# d=$d/$filename/$size -# fi echo ${d#/}/$filename #remove leading slash done diff --git a/scripts/storage/secondary/listvolume.sh b/scripts/storage/secondary/listvolume.sh index d039c659094..605b8b9a190 100755 --- a/scripts/storage/secondary/listvolume.sh +++ b/scripts/storage/secondary/listvolume.sh @@ -53,11 +53,6 @@ for i in $(find /$rootdir -name volume.properties ); do d=$(dirname $i) filename=$(grep "^filename" $i | awk -F"=" '{print $NF}') -# size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}') -# if [ -n "$filename" ] && [ -n "$size" ] -# then -# d=$d/$filename/$size -# fi echo ${d#/}/$filename #remove leading slash done diff --git a/scripts/util/create-kubernetes-binaries-iso.sh b/scripts/util/create-kubernetes-binaries-iso.sh index 58aec922b7f..ebaf072771c 100755 --- a/scripts/util/create-kubernetes-binaries-iso.sh +++ b/scripts/util/create-kubernetes-binaries-iso.sh @@ -112,6 +112,11 @@ echo "Downloading kubernetes cluster provider ${PROVIDER_URL}" provider_conf_file="${working_dir}/provider.yaml" curl -sSL ${PROVIDER_URL} -o ${provider_conf_file} +csi_conf_file="${working_dir}/manifest.yaml" +echo "Including CloudStack CSI Driver manifest" +wget https://github.com/cloudstack/cloudstack-csi-driver/releases/download/v3.0.0/snapshot-crds.yaml -O ${working_dir}/snapshot-crds.yaml +wget https://github.com/cloudstack/cloudstack-csi-driver/releases/download/v3.0.0/manifest.yaml -O ${csi_conf_file} + echo "Fetching k8s docker images..." ctr -v if [ $? -ne 0 ]; then @@ -143,6 +148,10 @@ output=`printf "%s\n" ${output} ${autoscaler_image}` provider_image=`grep "image:" ${provider_conf_file} | cut -d ':' -f2- | tr -d ' '` output=`printf "%s\n" ${output} ${provider_image}` +# Extract images from manifest.yaml and add to output +csi_images=`grep "image:" "${csi_conf_file}" | cut -d ':' -f2- | tr -d ' ' | tr -d "'"` +output=`printf "%s\n%s" "${output}" "${csi_images}"` + while read -r line; do echo "Downloading image $line ---" if [[ $line == kubernetesui* ]] || [[ $line == apache* ]] || [[ $line == weaveworks* ]]; then diff --git a/scripts/vm/hypervisor/kvm/nasbackup.sh b/scripts/vm/hypervisor/kvm/nasbackup.sh index e298006f7a8..7f4a4b62192 100755 --- a/scripts/vm/hypervisor/kvm/nasbackup.sh +++ b/scripts/vm/hypervisor/kvm/nasbackup.sh @@ -1,20 +1,21 @@ #!/usr/bin/bash -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you under the Apache License, Version 2.0 (the -## "License"); you may not use this file except in compliance -## with the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, -## software distributed under the License is distributed on an -## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -## KIND, either express or implied. See the License for the -## specific language governing permissions and limitations -## under the License. + +# 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. set -eo pipefail diff --git a/scripts/vm/hypervisor/kvm/nsrkvmbackup.sh b/scripts/vm/hypervisor/kvm/nsrkvmbackup.sh index 2fcfa0b6424..15ed6343192 100755 --- a/scripts/vm/hypervisor/kvm/nsrkvmbackup.sh +++ b/scripts/vm/hypervisor/kvm/nsrkvmbackup.sh @@ -1,20 +1,21 @@ #!/bin/bash -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you under the Apache License, Version 2.0 (the -## "License"); you may not use this file except in compliance -## with the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, -## software distributed under the License is distributed on an -## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -## KIND, either express or implied. See the License for the -## specific language governing permissions and limitations -## under the License. + +# 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. version=0.9.1 OPTIND=1 diff --git a/scripts/vm/hypervisor/kvm/nsrkvmrestore.sh b/scripts/vm/hypervisor/kvm/nsrkvmrestore.sh index 40a9021e850..0a6f5f98b94 100755 --- a/scripts/vm/hypervisor/kvm/nsrkvmrestore.sh +++ b/scripts/vm/hypervisor/kvm/nsrkvmrestore.sh @@ -1,20 +1,21 @@ #!/bin/bash -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you under the Apache License, Version 2.0 (the -## "License"); you may not use this file except in compliance -## with the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, -## software distributed under the License is distributed on an -## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -## KIND, either express or implied. See the License for the -## specific language governing permissions and limitations -## under the License. + +# 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. version=0.9.1 OPTIND=1 diff --git a/scripts/vm/hypervisor/ovm3/cloudstack.py b/scripts/vm/hypervisor/ovm3/cloudstack.py index e82863e7af7..39b5926509d 100644 --- a/scripts/vm/hypervisor/ovm3/cloudstack.py +++ b/scripts/vm/hypervisor/ovm3/cloudstack.py @@ -67,10 +67,6 @@ class CloudStack(Agent): 'get_module_version': getModuleVersion, 'get_ovs_version': ovmVersion, 'ping': ping, -# 'patch': ovmCsPatch, -# 'ovs_agent_set_ssl': ovsAgentSetSsl, -# 'ovs_agent_set_port': ovsAgentSetPort, -# 'ovs_restart_agent': ovsRestartAgent, } def getName(self): diff --git a/scripts/vm/hypervisor/xenserver/perfmon.py b/scripts/vm/hypervisor/xenserver/perfmon.py index 59c1ac3b367..fcdc8a62fa4 100755 --- a/scripts/vm/hypervisor/xenserver/perfmon.py +++ b/scripts/vm/hypervisor/xenserver/perfmon.py @@ -210,11 +210,6 @@ def get_vm_group_perfmon(args={}): total_counter = int(args['total_counter']) now = int(time.time()) / 60 - # Get pool's info of this host - #pool = login.xenapi.pool.get_all()[0] - # Get master node's address of pool - #master = login.xenapi.pool.get_master(pool) - #master_address = login.xenapi.host.get_address(master) session = login._session max_duration = 0 @@ -226,7 +221,6 @@ def get_vm_group_perfmon(args={}): rrd_updates = RRDUpdates() rrd_updates.refresh(login.xenapi, now * 60 - max_duration, session, {}) - #for uuid in rrd_updates.get_vm_list(): for vm_count in xrange(1, total_vm + 1): vm_name = args['vmname' + str(vm_count)] vm_uuid = getuuid(vm_name) diff --git a/scripts/vm/hypervisor/xenserver/xcposs/NFSSR.py b/scripts/vm/hypervisor/xenserver/xcposs/NFSSR.py index 306f9416616..84eb7307b85 100644 --- a/scripts/vm/hypervisor/xenserver/xcposs/NFSSR.py +++ b/scripts/vm/hypervisor/xenserver/xcposs/NFSSR.py @@ -175,20 +175,6 @@ class NFSSR(FileSR.FileSR): pass raise exn - #newpath = os.path.join(self.path, sr_uuid) - #if util.ioretry(lambda: util.pathexists(newpath)): - # if len(util.ioretry(lambda: util.listdir(newpath))) != 0: - # self.detach(sr_uuid) - # raise xs_errors.XenError('SRExists') - #else: - # try: - # util.ioretry(lambda: util.makedirs(newpath)) - # except util.CommandException, inst: - # if inst.code != errno.EEXIST: - # self.detach(sr_uuid) - # raise xs_errors.XenError('NFSCreate', - # opterr='remote directory creation error is %d' - # % inst.code) self.detach(sr_uuid) def delete(self, sr_uuid): diff --git a/scripts/vm/hypervisor/xenserver/xcpserver/NFSSR.py b/scripts/vm/hypervisor/xenserver/xcpserver/NFSSR.py index 62031e3708a..faaf6d96486 100755 --- a/scripts/vm/hypervisor/xenserver/xcpserver/NFSSR.py +++ b/scripts/vm/hypervisor/xenserver/xcpserver/NFSSR.py @@ -106,7 +106,6 @@ class NFSSR(FileSR.FileSR): def attach(self, sr_uuid): self.validate_remotepath(False) - #self.remotepath = os.path.join(self.dconf['serverpath'], sr_uuid) self.remotepath = self.dconf['serverpath'] util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget') self.mount_remotepath(sr_uuid) @@ -175,20 +174,6 @@ class NFSSR(FileSR.FileSR): pass raise exn - #newpath = os.path.join(self.path, sr_uuid) - #if util.ioretry(lambda: util.pathexists(newpath)): - # if len(util.ioretry(lambda: util.listdir(newpath))) != 0: - # self.detach(sr_uuid) - # raise xs_errors.XenError('SRExists') - #else: - # try: - # util.ioretry(lambda: util.makedirs(newpath)) - # except util.CommandException, inst: - # if inst.code != errno.EEXIST: - # self.detach(sr_uuid) - # raise xs_errors.XenError('NFSCreate', - # opterr='remote directory creation error is %d' - # % inst.code) self.detach(sr_uuid) def delete(self, sr_uuid): diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/NFSSR.py b/scripts/vm/hypervisor/xenserver/xenserver56/NFSSR.py index b8489e7b766..50e9e6077ce 100755 --- a/scripts/vm/hypervisor/xenserver/xenserver56/NFSSR.py +++ b/scripts/vm/hypervisor/xenserver/xenserver56/NFSSR.py @@ -178,20 +178,6 @@ class NFSSR(FileSR.FileSR): pass raise exn - #newpath = os.path.join(self.path, sr_uuid) - #if util.ioretry(lambda: util.pathexists(newpath)): - # if len(util.ioretry(lambda: util.listdir(newpath))) != 0: - # self.detach(sr_uuid) - # raise xs_errors.XenError('SRExists') - #else: - # try: - # util.ioretry(lambda: util.makedirs(newpath)) - # except util.CommandException, inst: - # if inst.code != errno.EEXIST: - # self.detach(sr_uuid) - # raise xs_errors.XenError('NFSCreate', - # opterr='remote directory creation error is %d' - # % inst.code) self.detach(sr_uuid) @FileSR.locking("SRUnavailable") diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/NFSSR.py b/scripts/vm/hypervisor/xenserver/xenserver56fp1/NFSSR.py index b8c115745af..9d2f81f8e8f 100755 --- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/NFSSR.py +++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/NFSSR.py @@ -107,7 +107,6 @@ class NFSSR(FileSR.FileSR): def attach(self, sr_uuid): self.validate_remotepath(False) - #self.remotepath = os.path.join(self.dconf['serverpath'], sr_uuid) self.remotepath = self.dconf['serverpath'] util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget') self.mount_remotepath(sr_uuid) @@ -176,20 +175,6 @@ class NFSSR(FileSR.FileSR): pass raise exn - #newpath = os.path.join(self.path, sr_uuid) - #if util.ioretry(lambda: util.pathexists(newpath)): - # if len(util.ioretry(lambda: util.listdir(newpath))) != 0: - # self.detach(sr_uuid) - # raise xs_errors.XenError('SRExists') - #else: - # try: - # util.ioretry(lambda: util.makedirs(newpath)) - # except util.CommandException, inst: - # if inst.code != errno.EEXIST: - # self.detach(sr_uuid) - # raise xs_errors.XenError('NFSCreate', - # opterr='remote directory creation error is %d' - # % inst.code) self.detach(sr_uuid) def delete(self, sr_uuid): diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py b/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py index 9a3fa8bc9a1..68aaeae2472 100755 --- a/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py +++ b/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py @@ -181,20 +181,6 @@ class NFSSR(FileSR.FileSR): pass raise exn - #newpath = os.path.join(self.path, sr_uuid) - #if util.ioretry(lambda: util.pathexists(newpath)): - # if len(util.ioretry(lambda: util.listdir(newpath))) != 0: - # self.detach(sr_uuid) - # raise xs_errors.XenError('SRExists') - #else: - # try: - # util.ioretry(lambda: util.makedirs(newpath)) - # except util.CommandException, inst: - # if inst.code != errno.EEXIST: - # self.detach(sr_uuid) - # raise xs_errors.XenError('NFSCreate', - # opterr='remote directory creation error is %d' - # % inst.code) self.detach(sr_uuid) def delete(self, sr_uuid): diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py index d71e27eb264..e7441202032 100755 --- a/scripts/vm/network/security_group.py +++ b/scripts/vm/network/security_group.py @@ -1382,15 +1382,6 @@ def verify_network_rules(vm_name, vm_id, vm_ip, vm_ip6, vm_mac, vif, brname, sec print("Cannot find vif") sys.exit(1) - #vm_name = "i-2-55-VM" - #vm_id = 55 - #vm_ip = "10.11.118.128" - #vm_ip6 = "fe80::1c00:b4ff:fe00:5" - #vm_mac = "1e:00:b4:00:00:05" - #vif = "vnet11" - #brname = "cloudbr0" - #sec_ips = "10.11.118.133;10.11.118.135;10.11.118.138;" # end with ";" and separated by ";" - vm_ips = [] if sec_ips is not None: vm_ips = sec_ips.split(';') diff --git a/scripts/vm/network/vnet/ovstunnel.py b/scripts/vm/network/vnet/ovstunnel.py index a39b6b18ecc..b47455b361d 100755 --- a/scripts/vm/network/vnet/ovstunnel.py +++ b/scripts/vm/network/vnet/ovstunnel.py @@ -49,17 +49,14 @@ def setup_ovs_bridge(bridge, key, cs_host_id): logging.debug("Bridge has been manually created:%s" % res) if res: -# result = "FAILURE:%s" % res result = 'false' else: # Verify the bridge actually exists, with the gre_key properly set res = lib.do_cmd([lib.VSCTL_PATH, "get", "bridge", bridge, "other_config:gre_key"]) if key in str(res): -# result = "SUCCESS:%s" % bridge result = 'true' else: -# result = "FAILURE:%s" % res result = 'false' lib.do_cmd([lib.VSCTL_PATH, "set", "bridge", bridge, "other_config:is-ovs-tun-network=True"]) @@ -134,10 +131,8 @@ def destroy_ovs_bridge(bridge): res = lib.do_cmd([lib.VSCTL_PATH, "del-br", bridge]) logging.debug("Bridge has been manually removed:%s" % res) if res: -# result = "FAILURE:%s" % res result = 'false' else: -# result = "SUCCESS:%s" % bridge result = 'true' logging.debug("Destroy_ovs_bridge completed with result:%s" % result) @@ -150,7 +145,6 @@ def create_tunnel(bridge, remote_ip, key, src_host, dst_host): res = lib.check_switch() if res != "SUCCESS": logging.debug("Openvswitch running: NO") -# return "FAILURE:%s" % res return 'false' # We need to keep the name below 14 characters @@ -189,7 +183,6 @@ def create_tunnel(bridge, remote_ip, key, src_host, dst_host): if len(iface_list) != 1: logging.debug("WARNING: Unexpected output while verifying " + "port %s on bridge %s" % (name, bridge)) -# return "FAILURE:VERIFY_PORT_FAILED" return 'false' # verify interface @@ -205,7 +198,6 @@ def create_tunnel(bridge, remote_ip, key, src_host, dst_host): if key not in str(key_validation) or remote_ip not in str(ip_validation): logging.debug("WARNING: Unexpected output while verifying " + "interface %s on bridge %s" % (name, bridge)) -# return "FAILURE:VERIFY_INTERFACE_FAILED" return 'false' logging.debug("Tunnel interface validated:%s" % verify_interface_ip) @@ -268,7 +260,6 @@ def destroy_tunnel(bridge, iface_name): ofport = get_field_of_interface(iface_name, "ofport") lib.del_flows(bridge, in_port=ofport) lib.del_port(bridge, iface_name) -# return "SUCCESS" return 'true' def get_field_of_interface(iface_name, field): diff --git a/server/pom.xml b/server/pom.xml index b6ef45d1ec9..2b35a0f42ac 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT @@ -194,7 +194,7 @@ org.apache.cloudstack cloud-framework-extensions - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT compile diff --git a/server/src/main/java/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/main/java/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java index b5fb77c8179..737d696abb6 100644 --- a/server/src/main/java/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java +++ b/server/src/main/java/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java @@ -297,8 +297,6 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat public boolean configure(String name, Map params) throws ConfigurationException { Map configs = _configDao.getConfiguration("management-server", params); String stoppedValue = configs.get("vm.resource.release.interval"); - // String destroyedValue = - // configs.get("capacity.skipcounting.destroyed.hours"); String destroyedValue = null; _secondsToSkipStoppedVMs = NumbersUtil.parseInt(stoppedValue, 86400); _secondsToSkipDestroyedVMs = NumbersUtil.parseInt(destroyedValue, 0); diff --git a/server/src/main/java/com/cloud/api/ApiDBUtils.java b/server/src/main/java/com/cloud/api/ApiDBUtils.java index 80043d0e279..57eeb63ea9f 100644 --- a/server/src/main/java/com/cloud/api/ApiDBUtils.java +++ b/server/src/main/java/com/cloud/api/ApiDBUtils.java @@ -75,9 +75,11 @@ import org.apache.cloudstack.api.response.VolumeResponse; import org.apache.cloudstack.api.response.VpcOfferingResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.backup.BackupOffering; +import org.apache.cloudstack.backup.BackupRepository; import org.apache.cloudstack.backup.BackupSchedule; import org.apache.cloudstack.backup.dao.BackupDao; import org.apache.cloudstack.backup.dao.BackupOfferingDao; +import org.apache.cloudstack.backup.dao.BackupRepositoryDao; import org.apache.cloudstack.backup.dao.BackupScheduleDao; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; @@ -493,6 +495,7 @@ public class ApiDBUtils { static BackupDao s_backupDao; static BackupScheduleDao s_backupScheduleDao; static BackupOfferingDao s_backupOfferingDao; + static BackupRepositoryDao s_backupRepositoryDao; static NicDao s_nicDao; static ResourceManagerUtil s_resourceManagerUtil; static SnapshotPolicyDetailsDao s_snapshotPolicyDetailsDao; @@ -751,6 +754,8 @@ public class ApiDBUtils { @Inject private BackupOfferingDao backupOfferingDao; @Inject + private BackupRepositoryDao backupRepositoryDao; + @Inject private BackupScheduleDao backupScheduleDao; @Inject private NicDao nicDao; @@ -899,6 +904,7 @@ public class ApiDBUtils { s_backupDao = backupDao; s_backupScheduleDao = backupScheduleDao; s_backupOfferingDao = backupOfferingDao; + s_backupRepositoryDao = backupRepositoryDao; s_resourceIconDao = resourceIconDao; s_resourceManagerUtil = resourceManagerUtil; s_objectStoreDao = objectStoreDao; @@ -1761,7 +1767,7 @@ public class ApiDBUtils { return null; } String jobInstanceId = null; - ApiCommandResourceType jobInstanceType = EnumUtils.fromString(ApiCommandResourceType.class, job.getInstanceType(), ApiCommandResourceType.None); + ApiCommandResourceType jobInstanceType = EnumUtils.getEnumIgnoreCase(ApiCommandResourceType.class, job.getInstanceType(), ApiCommandResourceType.None); if (job.getInstanceId() == null) { // when assert is hit, implement 'getInstanceId' of BaseAsyncCmd and return appropriate instance id @@ -2297,8 +2303,10 @@ public class ApiDBUtils { return s_backupScheduleDao.newBackupScheduleResponse(schedule); } - public static BackupOfferingResponse newBackupOfferingResponse(BackupOffering policy) { - return s_backupOfferingDao.newBackupOfferingResponse(policy); + public static BackupOfferingResponse newBackupOfferingResponse(BackupOffering offering) { + BackupRepository repository = s_backupRepositoryDao.findByUuid(offering.getExternalId()); + Boolean crossZoneInstanceCreationEnabled = repository != null ? Boolean.TRUE.equals(repository.crossZoneInstanceCreationEnabled()) : false; + return s_backupOfferingDao.newBackupOfferingResponse(offering, crossZoneInstanceCreationEnabled); } public static NicVO findByIp4AddressAndNetworkId(String ip4Address, long networkId) { diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index c44239b4447..8cc10ce4167 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -530,6 +530,15 @@ public class ApiResponseHelper implements ResponseGenerator { @Inject ResourceIconManager resourceIconManager; + public static String getPrettyDomainPath(String path) { + if (path == null) { + return null; + } + StringBuilder domainPath = new StringBuilder("ROOT"); + (domainPath.append(path)).deleteCharAt(domainPath.length() - 1); + return domainPath.toString(); + } + @Override public UserResponse createUserResponse(User user) { UserAccountJoinVO vUser = ApiDBUtils.newUserView(user); @@ -567,9 +576,7 @@ public class ApiResponseHelper implements ResponseGenerator { if (parentDomain != null) { domainResponse.setParentDomainId(parentDomain.getUuid()); } - StringBuilder domainPath = new StringBuilder("ROOT"); - (domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1); - domainResponse.setPath(domainPath.toString()); + domainResponse.setPath(getPrettyDomainPath(domain.getPath())); if (domain.getParent() != null) { domainResponse.setParentDomainName(ApiDBUtils.findDomainById(domain.getParent()).getName()); } @@ -822,21 +829,6 @@ public class ApiResponseHelper implements ResponseGenerator { } } populateOwner(vmSnapshotResponse, vmSnapshot); - Project project = ApiDBUtils.findProjectByProjectAccountId(vmSnapshot.getAccountId()); - if (project != null) { - vmSnapshotResponse.setProjectId(project.getUuid()); - vmSnapshotResponse.setProjectName(project.getName()); - } - Account account = ApiDBUtils.findAccountById(vmSnapshot.getAccountId()); - if (account != null) { - vmSnapshotResponse.setAccountName(account.getAccountName()); - } - DomainVO domain = ApiDBUtils.findDomainById(vmSnapshot.getDomainId()); - if (domain != null) { - vmSnapshotResponse.setDomainId(domain.getUuid()); - vmSnapshotResponse.setDomainName(domain.getName()); - vmSnapshotResponse.setDomainPath(domain.getPath()); - } List tags = _resourceTagDao.listBy(vmSnapshot.getId(), ResourceObjectType.VMSnapshot); List tagResponses = new ArrayList(); @@ -861,6 +853,7 @@ public class ApiResponseHelper implements ResponseGenerator { Volume vol = ApiDBUtils.findVolumeById(policy.getVolumeId()); if (vol != null) { policyResponse.setVolumeId(vol.getUuid()); + policyResponse.setVolumeName(vol.getName()); } policyResponse.setSchedule(policy.getSchedule()); policyResponse.setIntervalType(policy.getInterval()); @@ -2350,18 +2343,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setName(securityGroup.getName()); response.setDescription(securityGroup.getDescription()); - Account account = securiytGroupAccounts.get(securityGroup.getAccountId()); - - if (securityGroup.getAccountType() == Account.Type.PROJECT) { - response.setProjectId(securityGroup.getProjectUuid()); - response.setProjectName(securityGroup.getProjectName()); - } else { - response.setAccountName(securityGroup.getAccountName()); - } - - response.setDomainId(securityGroup.getDomainUuid()); - response.setDomainName(securityGroup.getDomainName()); - response.setDomainPath(securityGroup.getDomainPath()); + populateOwner(response, securityGroup); for (SecurityRule securityRule : securityRules) { SecurityGroupRuleResponse securityGroupData = new SecurityGroupRuleResponse(); @@ -2758,32 +2740,18 @@ public class ApiResponseHelper implements ResponseGenerator { // get domain from network_domain table Pair domainNetworkDetails = ApiDBUtils.getDomainNetworkDetails(network.getId()); if (domainNetworkDetails.first() != null) { - Domain domain = ApiDBUtils.findDomainById(domainNetworkDetails.first()); - if (domain != null) { - response.setDomainId(domain.getUuid()); - - StringBuilder domainPath = new StringBuilder("ROOT"); - (domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1); - response.setDomainPath(domainPath.toString()); - } + populateDomain(response, domainNetworkDetails.first()); } response.setSubdomainAccess(domainNetworkDetails.second()); } Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId()); if (dedicatedDomainId != null) { - Domain domain = ApiDBUtils.findDomainById(dedicatedDomainId); - if (domain != null) { - response.setDomainId(domain.getUuid()); - response.setDomainName(domain.getName()); - response.setDomainPath(domain.getPath()); - } - + populateDomain(response, dedicatedDomainId); } response.setSpecifyIpRanges(network.getSpecifyIpRanges()); - setVpcIdInResponse(network.getVpcId(), response::setVpcId, response::setVpcName); setResponseAssociatedNetworkInformation(response, network.getId()); @@ -3045,14 +3013,10 @@ public class ApiResponseHelper implements ResponseGenerator { } else { response.setAccountName(account.getAccountName()); } - - Domain domain = ApiDBUtils.findDomainById(object.getDomainId()); - response.setDomainId(domain.getUuid()); - response.setDomainName(domain.getName()); - response.setDomainPath(domain.getPath()); + populateDomain(response, object.getDomainId()); } - private void populateOwner(ControlledViewEntityResponse response, ControlledEntity object) { + public static void populateOwner(ControlledViewEntityResponse response, ControlledEntity object) { Account account = ApiDBUtils.findAccountById(object.getAccountId()); if (account.getType() == Account.Type.PROJECT) { @@ -3064,10 +3028,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setAccountName(account.getAccountName()); } - Domain domain = ApiDBUtils.findDomainById(object.getDomainId()); - response.setDomainId(domain.getUuid()); - response.setDomainName(domain.getName()); - response.setDomainPath(domain.getPath()); + populateDomain(response, object.getDomainId()); } public static void populateOwner(ControlledViewEntityResponse response, ControlledViewEntity object) { @@ -3081,7 +3042,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setDomainId(object.getDomainUuid()); response.setDomainName(object.getDomainName()); - response.setDomainPath(object.getDomainPath()); + response.setDomainPath(getPrettyDomainPath(object.getDomainPath())); } private void populateAccount(ControlledEntityResponse response, long accountId) { @@ -3105,10 +3066,22 @@ public class ApiResponseHelper implements ResponseGenerator { private void populateDomain(ControlledEntityResponse response, long domainId) { Domain domain = ApiDBUtils.findDomainById(domainId); - + if (domain == null) { + return; + } response.setDomainId(domain.getUuid()); response.setDomainName(domain.getName()); - response.setDomainPath(domain.getPath()); + response.setDomainPath(getPrettyDomainPath(domain.getPath())); + } + + private static void populateDomain(ControlledViewEntityResponse response, long domainId) { + Domain domain = ApiDBUtils.findDomainById(domainId); + if (domain == null) { + return; + } + response.setDomainId(domain.getUuid()); + response.setDomainName(domain.getName()); + response.setDomainPath(getPrettyDomainPath(domain.getPath())); } @Override @@ -3283,6 +3256,9 @@ public class ApiResponseHelper implements ResponseGenerator { PhysicalNetwork pnet = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId()); if (pnet != null) { response.setPhysicalNetworkId(pnet.getUuid()); + if (!pnet.getIsolationMethods().isEmpty()) { + response.setIsolationMethods(String.join(",", pnet.getIsolationMethods())); + } } if (result.getTrafficType() != null) { response.setTrafficType(result.getTrafficType().toString()); @@ -3293,6 +3269,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setVmwareLabel(result.getVmwareNetworkLabel()); response.setHypervLabel(result.getHypervNetworkLabel()); response.setOvm3Label(result.getOvm3NetworkLabel()); + response.setVlan(result.getVlan()); response.setObjectName("traffictype"); return response; @@ -4100,12 +4077,7 @@ public class ApiResponseHelper implements ResponseGenerator { usageRecResponse.setAccountName(account.getAccountName()); } - Domain domain = ApiDBUtils.findDomainById(usageRecord.getDomainId()); - if (domain != null) { - usageRecResponse.setDomainId(domain.getUuid()); - usageRecResponse.setDomainName(domain.getName()); - usageRecResponse.setDomainPath(domain.getPath()); - } + populateDomain(usageRecResponse, account.getDomainId()); if (usageRecord.getZoneId() != null) { DataCenter zone = ApiDBUtils.findZoneById(usageRecord.getZoneId()); @@ -4330,6 +4302,9 @@ public class ApiResponseHelper implements ResponseGenerator { if (volume != null) { builder.append("for ").append(volume.getName()).append(" (").append(volume.getUuid()).append(")"); } + if (vmInstance != null) { + builder.append(" attached to VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(")"); + } if (diskOff != null) { builder.append(" with disk offering ").append(diskOff.getName()).append(" (").append(diskOff.getUuid()).append(")"); } @@ -4892,18 +4867,11 @@ public class ApiResponseHelper implements ResponseGenerator { AffinityGroupResponse response = new AffinityGroupResponse(); - Account account = ApiDBUtils.findAccountById(group.getAccountId()); response.setId(group.getUuid()); - response.setAccountName(account.getAccountName()); response.setName(group.getName()); response.setType(group.getType()); response.setDescription(group.getDescription()); - Domain domain = ApiDBUtils.findDomainById(account.getDomainId()); - if (domain != null) { - response.setDomainId(domain.getUuid()); - response.setDomainName(domain.getName()); - response.setDomainPath(domain.getPath()); - } + populateOwner(response, group); response.setObjectName("affinitygroup"); return response; @@ -5033,7 +5001,7 @@ public class ApiResponseHelper implements ResponseGenerator { for (Long jobId : jobIds) { UpgradeRouterTemplateResponse routerResponse = new UpgradeRouterTemplateResponse(); AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId); - routerResponse.setAsyncJobId((job.getUuid())); + routerResponse.setJobId((job.getUuid())); routerResponse.setObjectName("asyncjobs"); responses.add(routerResponse); } @@ -5079,8 +5047,8 @@ public class ApiResponseHelper implements ResponseGenerator { } @Override - public BackupOfferingResponse createBackupOfferingResponse(BackupOffering policy) { - return ApiDBUtils.newBackupOfferingResponse(policy); + public BackupOfferingResponse createBackupOfferingResponse(BackupOffering offering) { + return ApiDBUtils.newBackupOfferingResponse(offering); } public ManagementServerResponse createManagementResponse(ManagementServerHost mgmt) { diff --git a/server/src/main/java/com/cloud/api/ApiServer.java b/server/src/main/java/com/cloud/api/ApiServer.java index c78ac05102f..5a3c8c2c717 100644 --- a/server/src/main/java/com/cloud/api/ApiServer.java +++ b/server/src/main/java/com/cloud/api/ApiServer.java @@ -39,6 +39,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Arrays; import java.util.Map; import java.util.Set; import java.util.TimeZone; @@ -251,6 +252,12 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer @Inject private MessageBus messageBus; + private static final Set sensitiveFields = new HashSet<>(Arrays.asList( + "password", "secretkey", "apikey", "token", + "sessionkey", "accesskey", "signature", + "authorization", "credential", "secret" + )); + private static final ConfigKey IntegrationAPIPort = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED , Integer.class , "integration.api.port" @@ -624,10 +631,23 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer logger.error("invalid request, no command sent"); if (logger.isTraceEnabled()) { logger.trace("dumping request parameters"); - for (final Object key : params.keySet()) { - final String keyStr = (String)key; - final String[] value = (String[])params.get(key); - logger.trace(" key: " + keyStr + ", value: " + ((value == null) ? "'null'" : value[0])); + + for (final Object key : params.keySet()) { + final String keyStr = (String) key; + final String[] value = (String[]) params.get(key); + + String lowerKeyStr = keyStr.toLowerCase(); + boolean isSensitive = sensitiveFields.stream() + .anyMatch(lowerKeyStr::contains); + + String logValue; + if (isSensitive) { + logValue = "******"; // mask sensitive values + } else { + logValue = (value == null) ? "'null'" : value[0]; + } + + logger.trace(" key: " + keyStr + ", value: " + logValue); } } throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "Invalid request, no command sent"); diff --git a/server/src/main/java/com/cloud/api/doc/ApiXmlDocWriter.java b/server/src/main/java/com/cloud/api/doc/ApiXmlDocWriter.java index 5de5cd03fe1..87d88df79e3 100644 --- a/server/src/main/java/com/cloud/api/doc/ApiXmlDocWriter.java +++ b/server/src/main/java/com/cloud/api/doc/ApiXmlDocWriter.java @@ -77,13 +77,11 @@ public class ApiXmlDocWriter { List asyncResponses = new ArrayList(); asyncResponses.add(TemplateResponse.class.getName()); asyncResponses.add(VolumeResponse.class.getName()); - //asyncResponses.add(LoadBalancerResponse.class.getName()); asyncResponses.add(HostResponse.class.getName()); asyncResponses.add(IPAddressResponse.class.getName()); asyncResponses.add(StoragePoolResponse.class.getName()); asyncResponses.add(UserVmResponse.class.getName()); asyncResponses.add(SecurityGroupResponse.class.getName()); - //asyncResponses.add(ExternalLoadBalancerResponse.class.getName()); asyncResponses.add(SnapshotResponse.class.getName()); return asyncResponses; diff --git a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java index f0a848196a4..99c6c3943a9 100644 --- a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java @@ -2111,7 +2111,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q } if (domainId != null && !domainId.equals(caller.getDomainId())) { - throw new PermissionDeniedException("Can't list domain id= " + domainId + " projects; unauthorized"); + throw new PermissionDeniedException("Can't list domain ID = " + domainId + " projects; unauthorized"); } if (StringUtils.isNotEmpty(username) && !username.equals(user.getUsername())) { @@ -3680,6 +3680,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q String[] offeringTagsArray = (offeringTags == null || offeringTags.isEmpty()) ? new String[0] : offeringTags.split(","); if (!CollectionUtils.isSubCollection(Arrays.asList(requiredTagsArray), Arrays.asList(offeringTagsArray))) { iteratorForTagsChecking.remove(); + count--; } } } @@ -5661,7 +5662,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q //Validation - 1.3 if (resourceIdStr != null) { - resourceId = resourceManagerUtil.getResourceId(resourceIdStr, resourceType); + resourceId = resourceManagerUtil.getResourceId(resourceIdStr, resourceType, true); } List detailList = new ArrayList<>(); diff --git a/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java index 9a301d440a9..de66b80ca55 100644 --- a/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java @@ -32,6 +32,7 @@ import org.apache.cloudstack.api.response.ResourceLimitAndCountResponse; import org.apache.cloudstack.api.response.UserResponse; import com.cloud.api.ApiDBUtils; +import com.cloud.api.ApiResponseHelper; import com.cloud.api.query.ViewResponseHelper; import com.cloud.api.query.vo.AccountJoinVO; import com.cloud.api.query.vo.UserAccountJoinVO; @@ -74,9 +75,7 @@ public class AccountJoinDaoImpl extends GenericDaoBase impl accountResponse.setAccountType(account.getType().ordinal()); accountResponse.setDomainId(account.getDomainUuid()); accountResponse.setDomainName(account.getDomainName()); - StringBuilder domainPath = new StringBuilder("ROOT"); - (domainPath.append(account.getDomainPath())).deleteCharAt(domainPath.length() - 1); - accountResponse.setDomainPath(domainPath.toString()); + accountResponse.setDomainPath(ApiResponseHelper.getPrettyDomainPath(account.getDomainPath())); accountResponse.setState(account.getState().toString()); accountResponse.setCreated(account.getCreated()); accountResponse.setNetworkDomain(account.getNetworkDomain()); diff --git a/server/src/main/java/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java index 08b896edb17..10ef67bbbea 100644 --- a/server/src/main/java/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java @@ -28,6 +28,7 @@ import org.apache.cloudstack.api.ResponseObject; import org.apache.cloudstack.api.response.AsyncJobResponse; import org.apache.cloudstack.framework.jobs.AsyncJob; +import com.cloud.api.ApiResponseHelper; import com.cloud.api.ApiSerializerHelper; import com.cloud.api.SerializationContext; import com.cloud.api.query.vo.AsyncJobJoinVO; @@ -60,9 +61,7 @@ public class AsyncJobJoinDaoImpl extends GenericDaoBase im jobResponse.setAccountId(job.getAccountUuid()); jobResponse.setAccount(job.getAccountName()); jobResponse.setDomainId(job.getDomainUuid()); - StringBuilder domainPath = new StringBuilder("ROOT"); - (domainPath.append(job.getDomainPath())).deleteCharAt(domainPath.length() - 1); - jobResponse.setDomainPath(domainPath.toString()); + jobResponse.setDomainPath(ApiResponseHelper.getPrettyDomainPath(job.getDomainPath())); jobResponse.setUserId(job.getUserUuid()); jobResponse.setCmd(job.getCmd()); jobResponse.setCreated(job.getCreated()); diff --git a/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java index 4a0929744cf..d4865c5550e 100644 --- a/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java @@ -21,6 +21,7 @@ import java.util.EnumSet; import java.util.List; +import com.cloud.api.ApiResponseHelper; import com.cloud.configuration.Resource; import com.cloud.user.AccountManager; import org.apache.cloudstack.annotation.AnnotationService; @@ -79,9 +80,7 @@ public class DomainJoinDaoImpl extends GenericDaoBase implem if (domain.getParentUuid() != null) { domainResponse.setParentDomainId(domain.getParentUuid()); } - StringBuilder domainPath = new StringBuilder("ROOT"); - (domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1); - domainResponse.setPath(domainPath.toString()); + domainResponse.setPath(ApiResponseHelper.getPrettyDomainPath(domain.getPath())); if (domain.getParent() != null) { domainResponse.setParentDomainName(domain.getParentName()); } diff --git a/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java index e7e2295923a..2c6c6481661 100644 --- a/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java @@ -207,10 +207,6 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase details = new HashMap<>(); @@ -504,11 +494,6 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation offeringDetails, - final Map externalDetails) { - if (MapUtils.isEmpty(externalDetails)) { + final Map externalDetails, final boolean cleanupExternalDetails) { + if (MapUtils.isEmpty(externalDetails) && !cleanupExternalDetails) { return false; } @@ -3816,6 +3816,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati .filter(detail -> detail.getKey().startsWith(VmDetailConstants.EXTERNAL_DETAIL_PREFIX)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + if (cleanupExternalDetails) { + return !MapUtils.isEmpty(existingExternalDetails); + } + if (MapUtils.isEmpty(existingExternalDetails) || existingExternalDetails.size() != externalDetails.size()) { return true; } @@ -3845,6 +3849,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati ServiceOffering.State state = cmd.getState(); boolean purgeResources = cmd.isPurgeResources(); final Map externalDetails = cmd.getExternalDetails(); + final boolean cleanupExternalDetails = cmd.isCleanupExternalDetails(); if (userId == null) { userId = Long.valueOf(User.UID_SYSTEM); @@ -3938,7 +3943,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati final boolean updateNeeded = name != null || displayText != null || sortKey != null || storageTags != null || hostTags != null || state != null; final boolean serviceOfferingExternalDetailsNeedUpdate = - serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails); + serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, cleanupExternalDetails); final boolean detailsUpdateNeeded = !filteredDomainIds.equals(existingDomainIds) || !filteredZoneIds.equals(existingZoneIds) || purgeResources != existingPurgeResources || serviceOfferingExternalDetailsNeedUpdate; @@ -4013,8 +4018,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati SearchCriteria externalDetailsRemoveSC = sb.create(); externalDetailsRemoveSC.setParameters("detailNameLike", VmDetailConstants.EXTERNAL_DETAIL_PREFIX + "%"); _serviceOfferingDetailsDao.remove(externalDetailsRemoveSC); - for (Map.Entry entry : externalDetails.entrySet()) { - detailsVO.add(new ServiceOfferingDetailsVO(id, entry.getKey(), entry.getValue(), true)); + if (!cleanupExternalDetails) { + for (Map.Entry entry : externalDetails.entrySet()) { + detailsVO.add(new ServiceOfferingDetailsVO(id, entry.getKey(), entry.getValue(), true)); + } } } } @@ -8440,7 +8447,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati !Enums.getIfPresent(DiskOffering.DiskCacheMode.class, cacheMode.toUpperCase()).isPresent()) { throw new InvalidParameterValueException(String.format("Invalid cache mode (%s). Please specify one of the following " + - "valid cache mode parameters: none, writeback or writethrough", cacheMode)); + "valid cache mode parameters: none, writeback, writethrough or hypervisor_default.", cacheMode)); } } diff --git a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 7089f1354ec..d079d8a2ce0 100644 --- a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -156,7 +156,7 @@ import com.google.gson.JsonParseException; import static com.cloud.vm.VirtualMachineManager.SystemVmEnableUserData; /** - * Class to manage console proxys.

+ * Class to manage console proxies.

* Possible console proxy state transition cases:
* - Stopped -> Starting -> Running
* - HA -> Stopped -> Starting -> Running
@@ -569,7 +569,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy if (!allowToLaunchNew(dataCenterId)) { String configKey = ConsoleProxyLaunchMax.key(); Integer configValue = ConsoleProxyLaunchMax.valueIn(dataCenterId); - logger.warn(String.format("The number of launched console proxys on zone [%s] has reached the limit [%s]. Limit set in [%s].", dataCenterId, configValue, configKey)); + logger.warn(String.format("The number of launched console proxies on zone [%s] has reached the limit [%s]. Limit set in [%s].", dataCenterId, configValue, configKey)); return null; } diff --git a/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java index d40b5b22698..97c453003a8 100644 --- a/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java +++ b/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java @@ -16,6 +16,9 @@ // under the License. package com.cloud.hypervisor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -24,18 +27,31 @@ import java.util.UUID; import javax.inject.Inject; import com.cloud.agent.api.to.GPUDeviceTO; +import com.cloud.agent.api.to.VirtualMachineMetadataTO; import com.cloud.cpu.CPU; +import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; +import com.cloud.dc.DataCenterVO; +import com.cloud.dc.HostPodVO; +import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; +import com.cloud.dc.dao.HostPodDao; import com.cloud.domain.Domain; +import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; import com.cloud.gpu.VgpuProfileVO; import com.cloud.gpu.dao.VgpuProfileDao; import com.cloud.network.vpc.VpcVO; import com.cloud.network.vpc.dao.VpcDao; +import com.cloud.projects.ProjectVO; +import com.cloud.projects.dao.ProjectDao; +import com.cloud.server.ResourceTag; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.UserVmVO; +import com.cloud.vm.dao.UserVmDao; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.backup.Backup; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; @@ -97,7 +113,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis @Inject protected AccountManager accountManager; @Inject - private DomainDao domainDao; + protected DomainDao domainDao; @Inject private DataCenterDao dcDao; @Inject @@ -125,7 +141,19 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis @Inject private UserVmManager userVmManager; @Inject + protected UserVmDao userVmDao; + @Inject + protected ProjectDao projectDao; + @Inject + protected ClusterDao clusterDao; + @Inject + protected DataCenterDao dataCenterDao; + @Inject + protected HostPodDao hostPodDao; + @Inject private ConfigurationManager configurationManager; + @Inject + ResourceTagDao tagsDao; public static ConfigKey VmMinMemoryEqualsMemoryDividedByMemOverprovisioningFactor = new ConfigKey("Advanced", Boolean.class, "vm.min.memory.equals.memory.divided.by.mem.overprovisioning.factor", "true", "If we set this to 'true', a minimum memory (memory/ mem.overprovisioning.factor) will be set to the VM, independent of using a scalable service offering or not.", true, ConfigKey.Scope.Cluster); @@ -212,7 +240,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis } to.setNicSecIps(secIps); } else { - logger.warn("Unabled to load NicVO for NicProfile {}", profile); + logger.warn("Unable to load NicVO for NicProfile {}", profile); //Workaround for dynamically created nics //FixMe: uuid and secondary IPs can be made part of nic profile to.setUuid(UUID.randomUUID().toString()); @@ -470,4 +498,144 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis logger.error("Unsupported operation: cannot remove template file"); return false; } + + /** + * Generates VirtualMachineMetadataTO object from VirtualMachineProfile + * It is a helper function to be used in the inherited classes to avoid repetition + * while generating metadata for multiple Guru implementations + * + * @param vmProfile virtual machine profile object + * @return A VirtualMachineMetadataTO ready to be appended to VirtualMachineTO object + * @see KVMGuru + */ + protected VirtualMachineMetadataTO makeVirtualMachineMetadata(VirtualMachineProfile vmProfile) { + String vmName = "unknown", + instanceName = "unknown", + displayName = "unknown", + instanceUuid = "unknown", + clusterName = "unknown", + clusterUuid = "unknown", + zoneUuid = "unknown", + zoneName = "unknown", + podUuid = "unknown", + podName = "unknown", + domainUuid = "unknown", + domainName = "unknown", + accountUuid = "unknown", + accountName = "unknown", + projectName = "", // the project can be empty + projectUuid = "", // the project can be empty + serviceOfferingName = "unknown"; + long created = 0L; + Integer cpuCores = -1, memory = -1; + List serviceOfferingTags = new ArrayList<>(); + HashMap resourceTags = new HashMap<>(); + + UserVmVO vmVO = userVmDao.findById(vmProfile.getVirtualMachine().getId()); + if (vmVO != null) { + instanceUuid = vmVO.getUuid(); + vmName = vmVO.getHostName(); // this returns the VM name field + instanceName = vmVO.getInstanceName(); + displayName = vmVO.getDisplayName(); + created = vmVO.getCreated().getTime() / 1000L; + + HostVO host = hostDao.findById(vmVO.getHostId()); + if (host != null) { + // Find zone and cluster + Long clusterId = host.getClusterId(); + ClusterVO cluster = clusterDao.findById(clusterId); + + if (cluster != null) { + clusterName = cluster.getName(); + clusterUuid = cluster.getUuid(); + + DataCenterVO zone = dataCenterDao.findById(cluster.getDataCenterId()); + if (zone != null) { + zoneUuid = zone.getUuid(); + zoneName = zone.getName(); + } + + HostPodVO pod = hostPodDao.findById(cluster.getPodId()); + if (pod != null) { + podUuid = pod.getUuid(); + podName = pod.getName(); + } + } + } else { + logger.warn("Could not find the Host object for the virtual machine (null value returned). Libvirt metadata for cluster, pod, zone will not be populated."); + } + + DomainVO domain = domainDao.findById(vmVO.getDomainId()); + if (domain != null) { + domainUuid = domain.getUuid(); + domainName = domain.getName(); + } else { + logger.warn("Could not find the Domain object for the virtual machine (null value returned). Libvirt metadata for domain will not be populated."); + } + + Account account = accountManager.getAccount(vmVO.getAccountId()); + if (account != null) { + accountUuid = account.getUuid(); + accountName = account.getName(); + + ProjectVO project = projectDao.findByProjectAccountId(account.getId()); + if (project != null) { + projectName = project.getName(); + projectUuid = project.getUuid(); + } + } else { + logger.warn("Could not find the Account object for the virtual machine (null value returned). Libvirt metadata for account and project will not be populated."); + } + + List resourceTagsList = tagsDao.listBy(vmVO.getId(), ResourceTag.ResourceObjectType.UserVm); + if (resourceTagsList != null) { + for (ResourceTag tag : resourceTagsList) { + resourceTags.put(tag.getKey(), tag.getValue()); + } + } + } else { + logger.warn("Could not find the VirtualMachine object by its profile (null value returned). Libvirt metadata will not be populated."); + } + + ServiceOffering serviceOffering = vmProfile.getServiceOffering(); + if (serviceOffering != null) { + serviceOfferingName = serviceOffering.getName(); + cpuCores = serviceOffering.getCpu(); + memory = serviceOffering.getRamSize(); + + String hostTagsCommaSeparated = serviceOffering.getHostTag(); + if (hostTagsCommaSeparated != null) { // when service offering has no host tags, this value is null + serviceOfferingTags = Arrays.asList(hostTagsCommaSeparated.split(",")); + } + } else { + logger.warn("Could not find the ServiceOffering object by its profile (null value returned). Libvirt metadata for service offering will not be populated."); + } + + + return new VirtualMachineMetadataTO( + vmName, // name + instanceName, // internalName + displayName, // displayName + instanceUuid , // instanceUUID + cpuCores, // cpuCores + memory, // memory + created, // created, unix epoch in seconds + System.currentTimeMillis() / 1000L, // started, unix epoch in seconds + domainUuid, // ownerDomainUUID + domainName, // ownerDomainName + accountUuid, // ownerAccountUUID + accountName, // ownerAccountName + projectUuid, + projectName, + serviceOfferingName, + serviceOfferingTags, // serviceOfferingTags + zoneName, + zoneUuid, + podName, + podUuid, + clusterName, + clusterUuid, + resourceTags + ); + } } diff --git a/server/src/main/java/com/cloud/hypervisor/KVMGuru.java b/server/src/main/java/com/cloud/hypervisor/KVMGuru.java index 64881df4c82..c17f80d2ad8 100644 --- a/server/src/main/java/com/cloud/hypervisor/KVMGuru.java +++ b/server/src/main/java/com/cloud/hypervisor/KVMGuru.java @@ -21,6 +21,8 @@ import com.cloud.agent.api.to.DataObjectType; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.configuration.ConfigurationManagerImpl; +import com.cloud.event.EventTypes; +import com.cloud.event.UsageEventUtils; import com.cloud.host.HostVO; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao; @@ -155,7 +157,6 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru { } @Override - public VirtualMachineTO implement(VirtualMachineProfile vm) { VirtualMachineTO to = toVirtualMachineTO(vm); setVmQuotaPercentage(to, vm); @@ -170,6 +171,9 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru { configureVmOsDescription(virtualMachine, to, host); configureVmMemoryAndCpuCores(to, host, virtualMachine, vm); + + to.setMetadata(makeVirtualMachineMetadata(vm)); + return to; } @@ -370,6 +374,8 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru { _volumeDao.update(volume.getId(), volume); _volumeDao.attachVolume(volume.getId(), vm.getId(), getNextAvailableDeviceId(vmVolumes)); } + UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_ATTACH, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), + volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), vm.getId(), volume.isDisplay()); } } catch (Exception e) { throw new RuntimeException("Could not restore VM " + vm.getName() + " due to : " + e.getMessage()); @@ -387,6 +393,8 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru { _volumeDao.attachVolume(restoredVolume.getId(), vm.getId(), getNextAvailableDeviceId(vmVolumes)); restoredVolume.setState(Volume.State.Ready); _volumeDao.update(restoredVolume.getId(), restoredVolume); + UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_ATTACH, restoredVolume.getAccountId(), restoredVolume.getDataCenterId(), restoredVolume.getId(), restoredVolume.getName(), + restoredVolume.getDiskOfferingId(), restoredVolume.getTemplateId(), restoredVolume.getSize(), Volume.class.getName(), restoredVolume.getUuid(), vm.getId(), restoredVolume.isDisplay()); return true; } catch (Exception e) { restoredVolume.setDisplay(false); diff --git a/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java index 1ded4ecedc6..f5031dc5667 100644 --- a/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java @@ -342,7 +342,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase for (ExternalLoadBalancerDeviceVO lbDevice : lbDevices) { if (lbDevice.getParentHostId() == hostId) { throw new CloudRuntimeException( - "This load balancer device can not be deleted as there are one or more load balancers applainces provisioned by cloudstack on the device."); + "This load balancer device can not be deleted as there are one or more load balancers appliances provisioned by cloudstack on the device."); } } } diff --git a/server/src/main/java/com/cloud/network/ExternalNetworkDeviceManagerImpl.java b/server/src/main/java/com/cloud/network/ExternalNetworkDeviceManagerImpl.java index a983af839ca..f756a4975cb 100644 --- a/server/src/main/java/com/cloud/network/ExternalNetworkDeviceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/ExternalNetworkDeviceManagerImpl.java @@ -139,20 +139,6 @@ public class ExternalNetworkDeviceManagerImpl extends ManagerBase implements Ext } private List listNetworkDevice(Long zoneId, Long physicalNetworkId, Long podId, Host.Type type) { -// List res = new ArrayList(); -// if (podId != null) { -// List devs = _hostDao.listBy(type, null, podId, zoneId); -// if (devs.size() == 1) { -// res.add(devs.get(0)); -// } else { -// logger.debug("List " + type + ": " + devs.size() + " found"); -// } -// } else { -// List devs = _hostDao.listBy(type, zoneId); -// res.addAll(devs); - // } - - // return res; return null; } diff --git a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java index 8c86ed55df8..58c56134560 100644 --- a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java @@ -2376,6 +2376,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C @Override public Pair, Integer> searchForNetworks(ListNetworksCmd cmd) { Long id = cmd.getId(); + String name = cmd.getName(); String keyword = cmd.getKeyword(); Long zoneId = cmd.getZoneId(); Account caller = CallContext.current().getCallingAccount(); @@ -2554,7 +2555,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C Pair, Integer> result = new Pair<>(new ArrayList<>(), 0); if (BooleanUtils.isTrue(isSystem)) { - SearchCriteria sc = createNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, + SearchCriteria sc = createNetworkSearchCriteria(sb, name, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, networkOfferingId, null, restartRequired, specifyIpRanges, vpcId, tags, display, vlanId, associatedNetworkId); addProjectNetworksConditionToSearch(sc, true); @@ -2562,12 +2563,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C } else { SearchCriteria additionalSC = _networksDao.createSearchCriteria(); - addAccountSpecificNetworksToSearch(additionalSC, sb, networkFilter, skipProjectNetworks, permittedAccounts, path, isRecursive); + addAccountSpecificNetworksToSearch(additionalSC, sb, networkFilter, skipProjectNetworks, permittedAccounts, path, isRecursive, projectId); addDomainSpecificNetworksToSearch(additionalSC, sb, networkFilter, permittedAccounts, domainId, path, isRecursive); addSharedNetworksToSearch(additionalSC, sb, networkFilter, permittedAccounts, path, isRecursive); if (CollectionUtils.isNotEmpty(additionalSC.getValues())) { - SearchCriteria sc = createNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, + SearchCriteria sc = createNetworkSearchCriteria(sb, name, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, networkOfferingId, aclType, restartRequired, specifyIpRanges, vpcId, tags, display, vlanId, associatedNetworkId); sc.addAnd("id", SearchCriteria.Op.SC, additionalSC); @@ -2622,7 +2623,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C private void addAccountSpecificNetworksToSearch(SearchCriteria additionalSC, SearchBuilder sb, Network.NetworkFilter networkFilter, boolean skipProjectNetworks, - List permittedAccounts, String path, boolean isRecursive) { + List permittedAccounts, String path, boolean isRecursive, Long projectId) { if (!Arrays.asList(Network.NetworkFilter.Account, Network.NetworkFilter.AccountDomain, Network.NetworkFilter.All).contains(networkFilter)) { return; } @@ -2641,7 +2642,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C } else { accountSC.addAnd("accountId", SearchCriteria.Op.IN, permittedAccounts.toArray()); } - addProjectNetworksConditionToSearch(accountSC, skipProjectNetworks); + addProjectNetworksConditionToSearch(accountSC, skipProjectNetworks, projectId); additionalSC.addOr("id", SearchCriteria.Op.SC, accountSC); } @@ -2680,7 +2681,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C } } - private SearchCriteria createNetworkSearchCriteria(SearchBuilder sb, String keyword, Long id, + private SearchCriteria createNetworkSearchCriteria(SearchBuilder sb, String name, String keyword, Long id, Boolean isSystem, Long zoneId, String guestIpType, String trafficType, Long physicalNetworkId, Long networkOfferingId, String aclType, Boolean restartRequired, Boolean specifyIpRanges, Long vpcId, Map tags, Boolean display, String vlanId, Long associatedNetworkId) { @@ -2691,6 +2692,10 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C sc.setJoinParameters("networkOfferingSearch", "systemOnly", isSystem); } + if (name != null) { + sc.addAnd("name", SearchCriteria.Op.EQ, name); + } + if (keyword != null) { SearchCriteria ssc = _networksDao.createSearchCriteria(); ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); @@ -2818,8 +2823,17 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C } } - private void addProjectNetworksConditionToSearch(SearchCriteria sc, boolean skipProjectNetworks) { - sc.getJoin("account").addAnd("type", skipProjectNetworks ? Op.NEQ : Op.EQ, Account.Type.PROJECT); + protected void addProjectNetworksConditionToSearch(SearchCriteria sc, boolean skipProjectNetworks) { + addProjectNetworksConditionToSearch(sc, skipProjectNetworks, null); + } + + protected void addProjectNetworksConditionToSearch(SearchCriteria sc, boolean skipProjectNetworks, + Long projectId) { + if (!skipProjectNetworks && projectId == -1) { + sc.getJoin("account").addAnd("type", Op.NNULL); + } else { + sc.getJoin("account").addAnd("type", skipProjectNetworks ? Op.NEQ : Op.EQ, Account.Type.PROJECT); + } sc.addAnd("id", Op.SC, sc.getJoin("account")); } diff --git a/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java index 83493ad702b..90380b77e44 100644 --- a/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java @@ -1457,6 +1457,7 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage public Counter createCounter(CreateCounterCmd cmd) { String source = cmd.getSource().toUpperCase(); String name = cmd.getName(); + String value = cmd.getValue(); Counter.Source src; // Validate Source try { @@ -1473,13 +1474,23 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage CounterVO counter = null; + CounterVO existingCounter = counterDao.findByNameProviderValue(name, value, provider.getName()); + if (existingCounter != null) { + throw new InvalidParameterValueException(String.format("Counter with name %s and value %s already exists. ", name,value)); + } logger.debug("Adding Counter " + name); - counter = counterDao.persist(new CounterVO(src, name, cmd.getValue(), provider)); + counter = counterDao.persist(new CounterVO(src, name, value, provider)); CallContext.current().setEventDetails(" Id: " + counter.getId() + " Name: " + name); return counter; } + @Override + @ActionEvent(eventType = EventTypes.EVENT_COUNTER_CREATE, eventDescription = "Creating a counter", async = true) + public Counter getCounter(long counterId) { + return counterDao.findById(counterId); + } + @Override @ActionEvent(eventType = EventTypes.EVENT_CONDITION_CREATE, eventDescription = "Condition", create = true) public Condition createCondition(CreateConditionCmd cmd) { diff --git a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java index 2ca6ca0d0be..b915027e9ab 100644 --- a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java +++ b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java @@ -365,7 +365,10 @@ public class CommandSetupHelper { final List destinations = rule.getDestinations(); final List stickinessPolicies = rule.getStickinessPolicies(); final LoadBalancerTO lb = new LoadBalancerTO(uuid, srcIp, srcPort, protocol, algorithm, revoked, false, inline, destinations, stickinessPolicies); - lb.setCidrList(rule.getCidrList()); + String cidrList = rule.getCidrList(); + if (cidrList != null && !cidrList.isEmpty()) { + lb.setCidrList(String.join(" ", cidrList.split(","))); + } lb.setLbProtocol(lb_protocol); lb.setLbSslCert(rule.getLbSslCert()); lbs[i++] = lb; diff --git a/server/src/main/java/com/cloud/network/rules/PrivateGatewayRules.java b/server/src/main/java/com/cloud/network/rules/PrivateGatewayRules.java index 1b827b384d0..8e70e4ec3a8 100644 --- a/server/src/main/java/com/cloud/network/rules/PrivateGatewayRules.java +++ b/server/src/main/java/com/cloud/network/rules/PrivateGatewayRules.java @@ -69,7 +69,6 @@ public class PrivateGatewayRules extends RuleApplier { // setup source nat if (_nicProfile != null) { _isAddOperation = true; - // result = setupVpcPrivateNetwork(router, true, guestNic); result = visitor.visit(this); } } catch (final Exception ex) { diff --git a/server/src/main/java/com/cloud/network/rules/RulesManagerImpl.java b/server/src/main/java/com/cloud/network/rules/RulesManagerImpl.java index db79cad9d65..1f1e294bc53 100644 --- a/server/src/main/java/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/main/java/com/cloud/network/rules/RulesManagerImpl.java @@ -564,9 +564,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules _accountMgr.checkAccess(vmOwner, SecurityChecker.AccessType.UseEntry, false, network); //is static nat is for vm secondary ip - //dstIp = guestNic.getIp4Address(); if (vmGuestIp != null) { - //dstIp = guestNic.getIp4Address(); if (!dstIp.equals(vmGuestIp)) { //check whether the secondary ip set to the vm or not @@ -667,7 +665,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules } } else if (ipAddress.getAssociatedWithVmId() != null && ipAddress.getAssociatedWithVmId().longValue() != vmId) { throw new NetworkRuleConflictException("Failed to enable static for the ip address " + ipAddress + " and vm id=" + vmId + - " as it's already assigned to antoher vm"); + " as it's already assigned to another vm"); } //check whether the vm ip is already associated with any public ip address diff --git a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java index 637ccabad05..49622e603c8 100644 --- a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java +++ b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java @@ -212,7 +212,6 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro try { cleanupFinishedWork(); cleanupUnfinishedWork(); - //processScheduledWork(); } catch (Throwable th) { logger.error("Problem with SG Cleanup", th); } diff --git a/server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java index 2a9bc27f302..ecb164018ac 100644 --- a/server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java +++ b/server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java @@ -488,6 +488,8 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ throw new InvalidParameterValueException("Cannot create Network ACL Item. ACL Id or network Id is required"); } Network network = networkModel.getNetwork(createNetworkACLCmd.getNetworkId()); + Account caller = CallContext.current().getCallingAccount(); + _accountMgr.checkAccess(caller, null, true, network); if (network.getVpcId() == null) { throw new InvalidParameterValueException("Network: " + network.getUuid() + " does not belong to VPC"); } @@ -749,6 +751,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ if (networkId != null) { final Network network = _networkDao.findById(networkId); + _accountMgr.checkAccess(caller, null, true, network); aclId = network.getNetworkACLId(); if (aclId == null) { // No aclId associated with the network. diff --git a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java index c4983e871da..52b4e07cbc8 100755 --- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java @@ -179,6 +179,7 @@ import com.cloud.org.Cluster; import com.cloud.org.Grouping; import com.cloud.org.Managed; import com.cloud.serializer.GsonHelper; +import com.cloud.server.ManagementService; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.service.dao.ServiceOfferingDetailsDao; @@ -307,6 +308,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, private UserVmManager userVmManager; @Inject private GpuService gpuService; + @Inject + ManagementService managementService; private List _discoverers; @@ -997,31 +1000,41 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, // Verify that host exists final HostVO host = _hostDao.findById(hostId); if (host == null) { - throw new InvalidParameterValueException("Host with id " + hostId + " doesn't exist"); + String errorMessage = String.format("Host with ID [%s] was not found", hostId); + logger.warn(errorMessage); + throw new InvalidParameterValueException(errorMessage); } + logger.info("Attempting to delete host with UUID [{}].", host.getUuid()); + _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), host.getDataCenterId()); if (!canDeleteHost(host) && !isForced) { - throw new CloudRuntimeException("Host " + host.getUuid() + - " cannot be deleted as it is not in maintenance mode. Either put the host into maintenance or perform a forced deletion."); + String errorMessage = String.format("Host with UUID [%s] is not in maintenance mode and no forced deletion was requested.", host.getUuid()); + logger.warn(errorMessage); + throw new CloudRuntimeException(errorMessage); } // Get storage pool host mappings here because they can be removed as a // part of handleDisconnect later final List pools = _storagePoolHostDao.listByHostIdIncludingRemoved(hostId); + logger.debug("Getting storage pools including those removed by host with UUID [{}]: [{}].", host.getUuid(), pools); + final ResourceStateAdapter.DeleteHostAnswer answer = (ResourceStateAdapter.DeleteHostAnswer)dispatchToStateAdapters(ResourceStateAdapter.Event.DELETE_HOST, false, host, isForced, isForceDeleteStorage); if (answer == null) { - throw new CloudRuntimeException(String.format("No resource adapter respond to DELETE_HOST event for %s, hypervisorType is %s, host type is %s", - host, host.getHypervisorType(), host.getType())); + String errorMessage = String.format("No resource adapter answer was returned to DELETE_HOST event for host [%s] with ID [%s], hypervisor type [%s] and host type [%s].", + host.getUuid(), hostId, host.getHypervisorType(), host.getType()); + logger.warn(errorMessage); + throw new CloudRuntimeException(errorMessage); } if (answer.getIsException()) { return false; } + logger.info("Host with UUID [{}] has been successfully deleted.", host.getUuid()); if (!answer.getIsContinue()) { return true; } @@ -1033,16 +1046,20 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, Transaction.execute(new TransactionCallbackNoReturn() { @Override public void doInTransactionWithoutResult(final TransactionStatus status) { + logger.debug("Releasing private IP address of host with UUID [{}].", host.getUuid()); _dcDao.releasePrivateIpAddress(host.getPrivateIpAddress(), host.getDataCenterId(), null); _agentMgr.disconnectWithoutInvestigation(hostId, Status.Event.Remove); // delete host details + logger.debug("Deleting details from database for host with UUID [{}].", host.getUuid()); _hostDetailsDao.deleteDetails(hostId); // if host is GPU enabled, delete GPU entries + logger.debug("Deleting GPU entries from database for host with UUID [{}].", host.getUuid()); _hostGpuGroupsDao.deleteGpuEntries(hostId); // delete host tags + logger.debug("Deleting tags from database for host with UUID [{}].", host.getUuid()); _hostTagsDao.deleteTags(hostId); host.setGuid(null); @@ -1051,6 +1068,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, _hostDao.update(host.getId(), host); Host hostRemoved = _hostDao.findById(hostId); + logger.debug("Removing host with UUID [{}] from database.", host.getUuid()); _hostDao.remove(hostId); if (clusterId != null) { final List hostIds = _hostDao.listIdsByClusterId(clusterId); @@ -1064,16 +1082,18 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, try { resourceStateTransitTo(host, ResourceState.Event.DeleteHost, _nodeId); } catch (final NoTransitionException e) { - logger.debug(String.format("Cannot transit %s to Enabled state", host), e); + logger.debug("Cannot transit host [{}] to Enabled state", host, e); } // Delete the associated entries in host ref table + logger.debug("Deleting storage pool entries from database for host with UUID [{}].", host.getUuid()); _storagePoolHostDao.deletePrimaryRecordsForHost(hostId); // Make sure any VMs that were marked as being on this host are cleaned up final List vms = _vmDao.listByHostId(hostId); for (final VMInstanceVO vm : vms) { // this is how VirtualMachineManagerImpl does it when it syncs VM states + logger.debug("Setting VM with UUID [{}] as stopped, as it was in host with UUID [{}], which has been removed.", vm.getUuid(), host.getUuid()); vm.setState(State.Stopped); vm.setHostId(null); _vmDao.persist(vm); @@ -1090,7 +1110,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, storagePool.setClusterId(null); _storagePoolDao.update(poolId, storagePool); _storagePoolDao.remove(poolId); - logger.debug("Local storage [id: {}] is removed as a part of {} removal", storagePool, hostRemoved); + logger.debug("Local storage [ID: {}] is removed as a part of host [{}] removal", poolId, hostRemoved.toString()); } } @@ -1099,6 +1119,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final SearchCriteria hostCapacitySC = _capacityDao.createSearchCriteria(); hostCapacitySC.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, hostId); hostCapacitySC.addAnd("capacityType", SearchCriteria.Op.IN, capacityTypes); + logger.debug("Deleting capacity entries from database for host with UUID [{}].", host.getUuid()); _capacityDao.remove(hostCapacitySC); // remove from dedicated resources final DedicatedResourceVO dr = _dedicatedDao.findByHostId(hostId); @@ -1107,6 +1128,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } // Remove comments (if any) + logger.debug("Deleting comments from database for host with UUID [{}].", host.getUuid()); annotationDao.removeByEntityType(AnnotationService.EntityType.HOST.name(), host.getUuid()); } }); @@ -2799,12 +2821,18 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, @Override public Host updateHost(final UpdateHostCmd cmd) throws NoTransitionException { + managementService.checkJsInterpretationAllowedIfNeededForParameterValue(ApiConstants.IS_TAG_A_RULE, + Boolean.TRUE.equals(cmd.getIsTagARule())); + return updateHost(cmd.getId(), cmd.getName(), cmd.getOsCategoryId(), - cmd.getAllocationState(), cmd.getUrl(), cmd.getHostTags(), cmd.getIsTagARule(), cmd.getAnnotation(), false, cmd.getExternalDetails()); + cmd.getAllocationState(), cmd.getUrl(), cmd.getHostTags(), cmd.getIsTagARule(), cmd.getAnnotation(), false, + cmd.getExternalDetails(), cmd.isCleanupExternalDetails()); } private Host updateHost(Long hostId, String name, Long guestOSCategoryId, String allocationState, - String url, List hostTags, Boolean isTagARule, String annotation, boolean isUpdateFromHostHealthCheck, Map externalDetails) throws NoTransitionException { + String url, List hostTags, Boolean isTagARule, String annotation, + boolean isUpdateFromHostHealthCheck, Map externalDetails, + boolean cleanupExternalDetails) throws NoTransitionException { // Verify that the host exists final HostVO host = _hostDao.findById(hostId); if (host == null) { @@ -2828,8 +2856,12 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, updateHostTags(host, hostId, hostTags, isTagARule); } - if (MapUtils.isNotEmpty(externalDetails)) { - _hostDetailsDao.replaceExternalDetails(hostId, externalDetails); + if (cleanupExternalDetails) { + _hostDetailsDao.removeExternalDetails(hostId); + } else { + if (MapUtils.isNotEmpty(externalDetails)) { + _hostDetailsDao.replaceExternalDetails(hostId, externalDetails); + } } if (url != null) { @@ -2888,7 +2920,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, @Override public Host autoUpdateHostAllocationState(Long hostId, ResourceState.Event resourceEvent) throws NoTransitionException { - return updateHost(hostId, null, null, resourceEvent.toString(), null, null, null, null, true, null); + return updateHost(hostId, null, null, resourceEvent.toString(), null, null, null, null, true, null, false); } @Override diff --git a/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java b/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java index e476c74d17d..51793f22e90 100644 --- a/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java @@ -328,8 +328,6 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio // setup XenServer default PV driver version initiateXenServerPVDriverVersion(); - // We should not update seed data UUID column here since this will be invoked in upgrade case as well. - //updateUuids(); // Set init to true _configDao.update("init", "Hidden", "true"); diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java index 1b96cd4ef15..e6032662e92 100644 --- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java +++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java @@ -789,6 +789,7 @@ import com.cloud.storage.GuestOSHypervisorVO; import com.cloud.storage.GuestOSVO; import com.cloud.storage.GuestOsCategory; import com.cloud.storage.ScopeType; +import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.storage.Storage; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePool; @@ -822,6 +823,7 @@ import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.SSHKeyPairDao; import com.cloud.user.dao.UserDao; import com.cloud.user.dao.UserDataDao; +import com.cloud.utils.EnumUtils; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.PasswordGenerator; @@ -1066,6 +1068,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe protected List _planners; + private boolean jsInterpretationEnabled = false; + private final List supportedHypervisors = new ArrayList<>(); public List getPlanners() { @@ -1146,6 +1150,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe supportedHypervisors.add(HypervisorType.KVM); supportedHypervisors.add(HypervisorType.XenServer); + jsInterpretationEnabled = JsInterpretationEnabled.value(); + return true; } @@ -1405,7 +1411,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe if (vmInstanceDetailVO != null && (ApiConstants.BootMode.LEGACY.toString().equalsIgnoreCase(vmInstanceDetailVO.getValue()) || ApiConstants.BootMode.SECURE.toString().equalsIgnoreCase(vmInstanceDetailVO.getValue()))) { - logger.info(" Live Migration of UEFI enabled VM : " + vm.getInstanceName() + " is not supported"); + logger.debug("{} VM is UEFI enabled, Checking for other UEFI enabled hosts as it can be live migrated to UEFI enabled host only.", vm.getInstanceName()); if (CollectionUtils.isEmpty(filteredHosts)) { filteredHosts = new ArrayList<>(allHosts); } @@ -1415,6 +1421,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe return new Pair<>(false, null); } filteredHosts.removeIf(host -> !uefiEnabledHosts.contains(host.getId())); + if (filteredHosts.isEmpty()) { + logger.warn("No UEFI enabled hosts are available for the live migration of VM {}", vm.getInstanceName()); + } return new Pair<>(!filteredHosts.isEmpty(), filteredHosts); } return new Pair<>(true, filteredHosts); @@ -2411,6 +2420,22 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe return new Pair<>(result.first(), result.second()); } + protected List getStatesForIpAddressSearch(final ListPublicIpAddressesCmd cmd) { + final String statesStr = cmd.getState(); + final List states = new ArrayList<>(); + if (StringUtils.isBlank(statesStr)) { + return states; + } + for (String s : StringUtils.split(statesStr, ",")) { + IpAddress.State state = EnumUtils.getEnumIgnoreCase(IpAddress.State.class, s.trim()); + if (state == null) { + throw new InvalidParameterValueException("Invalid state: " + s); + } + states.add(state); + } + return states; + } + @Override public Pair, Integer> searchForIPAddresses(final ListPublicIpAddressesCmd cmd) { final Long associatedNetworkId = cmd.getAssociatedNetworkId(); @@ -2421,20 +2446,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe final Long networkId = cmd.getNetworkId(); final Long vpcId = cmd.getVpcId(); - final String state = cmd.getState(); + final List states = getStatesForIpAddressSearch(cmd); Boolean isAllocated = cmd.isAllocatedOnly(); if (isAllocated == null) { - if (state != null && (state.equalsIgnoreCase(IpAddress.State.Free.name()) || state.equalsIgnoreCase(IpAddress.State.Reserved.name()))) { + if (states.contains(IpAddress.State.Free) || states.contains(IpAddress.State.Reserved)) { isAllocated = Boolean.FALSE; } else { isAllocated = Boolean.TRUE; // default } } else { - if (state != null && (state.equalsIgnoreCase(IpAddress.State.Free.name()) || state.equalsIgnoreCase(IpAddress.State.Reserved.name()))) { + if (states.contains(IpAddress.State.Free) || states.contains(IpAddress.State.Reserved)) { if (isAllocated) { throw new InvalidParameterValueException("Conflict: allocatedonly is true but state is Free"); } - } else if (state != null && state.equalsIgnoreCase(IpAddress.State.Allocated.name())) { + } else if (states.contains(IpAddress.State.Allocated)) { isAllocated = Boolean.TRUE; } } @@ -2513,10 +2538,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe Boolean isRecursive = cmd.isRecursive(); final List permittedAccounts = new ArrayList<>(); ListProjectResourcesCriteria listProjectResourcesCriteria = null; - boolean isAllocatedOrReserved = false; - if (isAllocated || IpAddress.State.Reserved.name().equalsIgnoreCase(state)) { - isAllocatedOrReserved = true; - } + boolean isAllocatedOrReserved = isAllocated || + (states.size() == 1 && IpAddress.State.Reserved.equals(states.get(0))); if (isAllocatedOrReserved || (vlanType == VlanType.VirtualNetwork && (caller.getType() != Account.Type.ADMIN || cmd.getDomainId() != null))) { final Ternary domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null); @@ -2530,7 +2553,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe buildParameters(sb, cmd, vlanType == VlanType.VirtualNetwork ? true : isAllocated); SearchCriteria sc = sb.create(); - setParameters(sc, cmd, vlanType, isAllocated); + setParameters(sc, cmd, vlanType, isAllocated, states); if (isAllocatedOrReserved || (vlanType == VlanType.VirtualNetwork && (caller.getType() != Account.Type.ADMIN || cmd.getDomainId() != null))) { _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); @@ -2598,7 +2621,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe buildParameters(searchBuilder, cmd, false); SearchCriteria searchCriteria = searchBuilder.create(); - setParameters(searchCriteria, cmd, vlanType, false); + setParameters(searchCriteria, cmd, vlanType, false, states); searchCriteria.setParameters("state", IpAddress.State.Free.name()); addrs.addAll(_publicIpAddressDao.search(searchCriteria, searchFilter)); // Free IPs on shared network } @@ -2611,7 +2634,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe sb2.and("quarantinedPublicIpsIdsNIN", sb2.entity().getId(), SearchCriteria.Op.NIN); SearchCriteria sc2 = sb2.create(); - setParameters(sc2, cmd, vlanType, isAllocated); + setParameters(sc2, cmd, vlanType, isAllocated, states); sc2.setParameters("ids", freeAddrIds.toArray()); _publicIpAddressDao.buildQuarantineSearchCriteria(sc2); addrs.addAll(_publicIpAddressDao.search(sc2, searchFilter)); // Allocated + Free @@ -2641,7 +2664,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe sb.and("isSourceNat", sb.entity().isSourceNat(), SearchCriteria.Op.EQ); sb.and("isStaticNat", sb.entity().isOneToOneNat(), SearchCriteria.Op.EQ); sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ); - sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ); + sb.and("state", sb.entity().getState(), SearchCriteria.Op.IN); sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ); sb.and(FOR_SYSTEMVMS, sb.entity().isForSystemVms(), SearchCriteria.Op.EQ); @@ -2684,7 +2707,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } } - protected void setParameters(SearchCriteria sc, final ListPublicIpAddressesCmd cmd, VlanType vlanType, Boolean isAllocated) { + protected void setParameters(SearchCriteria sc, final ListPublicIpAddressesCmd cmd, VlanType vlanType, + Boolean isAllocated, List states) { final Object keyword = cmd.getKeyword(); final Long physicalNetworkId = cmd.getPhysicalNetworkId(); final Long sourceNetworkId = cmd.getNetworkId(); @@ -2695,7 +2719,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe final Boolean sourceNat = cmd.isSourceNat(); final Boolean staticNat = cmd.isStaticNat(); final Boolean forDisplay = cmd.getDisplay(); - final String state = cmd.getState(); final Boolean forSystemVms = cmd.getForSystemVMs(); final boolean forProvider = cmd.isForProvider(); final Map tags = cmd.getTags(); @@ -2752,13 +2775,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe sc.setParameters("display", forDisplay); } - if (state != null) { - sc.setParameters("state", state); + if (CollectionUtils.isNotEmpty(states)) { + sc.setParameters("state", states.toArray()); } else if (isAllocated != null && isAllocated) { sc.setParameters("state", IpAddress.State.Allocated); } - if (IpAddressManagerImpl.getSystemvmpublicipreservationmodestrictness().value() && IpAddress.State.Free.name().equalsIgnoreCase(state)) { + if (IpAddressManagerImpl.getSystemvmpublicipreservationmodestrictness().value() && + states.contains(IpAddress.State.Free)) { sc.setParameters(FOR_SYSTEMVMS, false); } else { sc.setParameters(FOR_SYSTEMVMS, forSystemVms); @@ -4219,8 +4243,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(ListGuestVlansCmd.class); cmdList.add(AssignVolumeCmd.class); cmdList.add(ListSecondaryStorageSelectorsCmd.class); - cmdList.add(CreateSecondaryStorageSelectorCmd.class); - cmdList.add(UpdateSecondaryStorageSelectorCmd.class); + if (jsInterpretationEnabled) { + cmdList.add(CreateSecondaryStorageSelectorCmd.class); + cmdList.add(UpdateSecondaryStorageSelectorCmd.class); + } cmdList.add(RemoveSecondaryStorageSelectorCmd.class); cmdList.add(ListAffectedVmsForStorageScopeChangeCmd.class); cmdList.add(ListGuiThemesCmd.class); @@ -4274,7 +4300,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {exposeCloudStackVersionInApiXmlResponse, exposeCloudStackVersionInApiListCapabilities, vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier}; + return new ConfigKey[] {exposeCloudStackVersionInApiXmlResponse, exposeCloudStackVersionInApiListCapabilities, vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier, + JsInterpretationEnabled}; } protected class EventPurgeTask extends ManagedContextRunnable { @@ -4664,10 +4691,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe final Map capabilities = new HashMap<>(); final Account caller = getCaller(); - final boolean isCallerAdmin = _accountService.isAdmin(caller.getId()); + final boolean isCallerRootAdmin = _accountService.isRootAdmin(caller.getId()); + final boolean isCallerAdmin = isCallerRootAdmin || _accountService.isAdmin(caller.getId()); boolean securityGroupsEnabled = false; boolean elasticLoadBalancerEnabled; - boolean KVMSnapshotEnabled; String supportELB = "false"; final List networks = networkDao.listSecurityGroupEnabledNetworks(); if (networks != null && !networks.isEmpty()) { @@ -4684,7 +4711,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe final long diskOffMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value(); final long diskOffMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value(); - KVMSnapshotEnabled = Boolean.parseBoolean(_configDao.getValue("KVM.snapshot.enabled")); + final boolean KVMSnapshotEnabled = SnapshotManager.KVMSnapshotEnabled.value(); final boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId()); @@ -4746,7 +4773,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } capabilities.put(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT, fsVmMinCpu); capabilities.put(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE, fsVmMinRam); - if (isCallerAdmin) { + if (isCallerRootAdmin) { capabilities.put(ApiConstants.EXTENSIONS_PATH, extensionsManager.getExtensionsPath()); } capabilities.put(ApiConstants.ADDITONAL_CONFIG_ENABLED, UserVmManager.EnableAdditionalVmConfig.valueIn(caller.getId())); @@ -5780,4 +5807,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe public Answer getExternalVmConsole(VirtualMachine vm, Host host) { return extensionsManager.getInstanceConsole(vm, host); } + @Override + public void checkJsInterpretationAllowedIfNeededForParameterValue(String paramName, boolean paramValue) { + if (!paramValue || jsInterpretationEnabled) { + return; + } + throw new InvalidParameterValueException(String.format( + "The parameter %s cannot be set to true as JS interpretation is disabled", + paramName)); + } } diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java index cbeec1a60b3..df0283ae2d6 100644 --- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java @@ -221,6 +221,7 @@ import com.cloud.org.Grouping.AllocationState; import com.cloud.resource.ResourceState; import com.cloud.server.ConfigurationServer; import com.cloud.server.ManagementServer; +import com.cloud.server.ManagementService; import com.cloud.server.StatsCollector; import com.cloud.service.dao.ServiceOfferingDetailsDao; import com.cloud.storage.Storage.ImageFormat; @@ -414,6 +415,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C ResourceManager _resourceMgr; @Inject StorageManager storageManager; + @Inject + ManagementService managementService; protected List _discoverers; @@ -1031,6 +1034,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C throw new PermissionDeniedException(String.format("Cannot perform this operation, Zone is currently disabled: %s", zone)); } + managementService.checkJsInterpretationAllowedIfNeededForParameterValue(ApiConstants.IS_TAG_A_RULE, + Boolean.TRUE.equals(cmd.isTagARule())); + Map params = new HashMap<>(); params.put("zoneId", zone.getId()); params.put("clusterId", clusterId); @@ -1214,6 +1220,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C // Input validation Long id = cmd.getId(); + managementService.checkJsInterpretationAllowedIfNeededForParameterValue(ApiConstants.IS_TAG_A_RULE, + Boolean.TRUE.equals(cmd.isTagARule())); + StoragePoolVO pool = _storagePoolDao.findById(id); if (pool == null) { throw new IllegalArgumentException("Unable to find storage pool with ID: " + id); @@ -3049,6 +3058,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C StoragePoolVO storagePoolVO = _storagePoolDao.findByUuid(datastoreName); if (storagePoolVO != null) { volumeVO.setPoolId(storagePoolVO.getId()); + volumeVO.setPoolType(storagePoolVO.getPoolType()); } else { logger.warn("Unable to find datastore {} while updating the new datastore of the volume {}", datastoreName, volumeVO); } @@ -3072,7 +3082,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } - private void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer) { + @Override + public void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer) { StoragePoolHostVO poolHost = _storagePoolHostDao.findByPoolHost(pool.getId(), hostId); if (poolHost == null) { poolHost = new StoragePoolHostVO(pool.getId(), hostId, mspAnswer.getPoolInfo().getLocalPath().replaceAll("//", "/")); @@ -3082,8 +3093,10 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } StoragePoolVO poolVO = _storagePoolDao.findById(pool.getId()); - poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes()); - poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes()); + if (!Storage.StoragePoolType.StorPool.equals(poolVO.getPoolType())) { + poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes()); + poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes()); + } _storagePoolDao.update(pool.getId(), poolVO); } diff --git a/server/src/main/java/com/cloud/storage/StoragePoolAutomationImpl.java b/server/src/main/java/com/cloud/storage/StoragePoolAutomationImpl.java index eea4da4879f..93bc1261530 100644 --- a/server/src/main/java/com/cloud/storage/StoragePoolAutomationImpl.java +++ b/server/src/main/java/com/cloud/storage/StoragePoolAutomationImpl.java @@ -213,7 +213,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation { _storagePoolWorkDao.persist(work); } catch (Exception e) { if (logger.isDebugEnabled()) { - logger.debug("Work record already exists, re-using by re-setting values"); + logger.debug("Work record already exists, reusing by re-setting values"); } StoragePoolWorkVO work = _storagePoolWorkDao.findByPoolIdAndVmId(pool.getId(), vmInstance.getId()); work.setStartedAfterMaintenance(false); @@ -363,6 +363,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation { if (logger.isDebugEnabled()) { logger.debug("ModifyStoragePool add succeeded"); } + storageManager.updateStoragePoolHostVOAndBytes(pool, host.getId(), (ModifyStoragePoolAnswer) answer); if (pool.getPoolType() == Storage.StoragePoolType.DatastoreCluster) { logger.debug("Started synchronising datastore cluster storage pool {} with vCenter", pool); storageManager.syncDatastoreClusterStoragePool(pool.getId(), ((ModifyStoragePoolAnswer) answer).getDatastoreClusterChildren(), host.getId()); diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index f4536e8549f..43c2ffcbad4 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -1004,7 +1004,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (snapshotId == null && displayVolume) { // for volume created from snapshot, create usage event after volume creation UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId, null, size, - Volume.class.getName(), volume.getUuid(), displayVolume); + Volume.class.getName(), volume.getUuid(), volume.getInstanceId(), displayVolume); } if (volume != null && details != null) { @@ -1106,7 +1106,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic createdVolume = _volumeMgr.createVolumeFromSnapshot(volume, snapshot, vm); VolumeVO volumeVo = _volsDao.findById(createdVolume.getId()); UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, createdVolume.getAccountId(), createdVolume.getDataCenterId(), createdVolume.getId(), createdVolume.getName(), - createdVolume.getDiskOfferingId(), null, createdVolume.getSize(), Volume.class.getName(), createdVolume.getUuid(), volumeVo.isDisplayVolume()); + createdVolume.getDiskOfferingId(), null, createdVolume.getSize(), Volume.class.getName(), createdVolume.getUuid(), volume.getInstanceId(), volumeVo.isDisplayVolume()); return volumeVo; } @@ -1578,6 +1578,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } } + volume = _volsDao.findById(volumeId); if (newDiskOfferingId != null) { volume.setDiskOfferingId(newDiskOfferingId); _volumeMgr.saveVolumeDetails(newDiskOfferingId, volume.getId()); @@ -1592,7 +1593,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } // Update size if volume has same size as before, else it is already updated - volume = _volsDao.findById(volumeId); if (currentSize == volume.getSize() && currentSize != newSize) { volume.setSize(newSize); } else if (volume.getSize() != newSize) { @@ -1903,7 +1903,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } UsageEventUtils .publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), offeringId, - volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), volume.isDisplay()); + volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), volume.getInstanceId(), volume.isDisplay()); logger.debug("Volume [{}] has been successfully recovered, thus a new usage event {} has been published.", volume, EventTypes.EVENT_VOLUME_CREATE); } @@ -2937,8 +2937,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic List childDatastores = _storagePoolDao.listChildStoragePoolsInDatastoreCluster(storageId); Collections.shuffle(childDatastores); volume.setPoolId(childDatastores.get(0).getId()); + volume.setPoolType(childDatastores.get(0).getPoolType()); } else { volume.setPoolId(pool.getId()); + volume.setPoolType(pool.getPoolType()); } } @@ -2996,7 +2998,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (displayVolume) { // flag turned 1 equivalent to freshly created volume UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), volume.getDiskOfferingId(), - volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid()); + volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), volume.getInstanceId(), displayVolume); } else { // flag turned 0 equivalent to deleting a volume UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), Volume.class.getName(), @@ -3225,6 +3227,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (storagePoolVO != null) { VolumeVO volumeVO = _volsDao.findById(volumeId); volumeVO.setPoolId(storagePoolVO.getId()); + volumeVO.setPoolType(storagePoolVO.getPoolType()); _volsDao.update(volumeVO.getId(), volumeVO); } else { logger.warn("Unable to find datastore {} while updating the new datastore of the volume {}", datastoreName, volume); @@ -3256,6 +3259,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic handleTargetsForVMware(hostId, volumePool.getHostAddress(), volumePool.getPort(), volume.get_iScsiName()); } + UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DETACH, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), + volume.getDiskOfferingId(), null, volume.getSize(), Volume.class.getName(), volume.getUuid(), null, volume.isDisplay()); return _volsDao.findById(volumeId); } else { @@ -3645,12 +3650,16 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic * * If all of the above validations pass, we check if the size of the new disk offering is different from the volume. If it is, we log a warning message. */ - protected void validateConditionsToReplaceDiskOfferingOfVolume(VolumeVO volume, DiskOfferingVO newDiskOffering, StoragePool destPool) { + @Override + public boolean validateConditionsToReplaceDiskOfferingOfVolume(Volume volume, DiskOffering newDiskOffering, StoragePool destPool) { if (newDiskOffering == null) { - return; + return false; } - if ((destPool.isShared() && newDiskOffering.isUseLocalStorage()) || destPool.isLocal() && newDiskOffering.isShared()) { - throw new InvalidParameterValueException("You cannot move the volume to a shared storage and assign a disk offering for local storage and vice versa."); + if (destPool.isShared() && newDiskOffering.isUseLocalStorage()) { + throw new InvalidParameterValueException("You cannot move the volume to shared storage, with the disk offering configured for local storage."); + } + if (destPool.isLocal() && newDiskOffering.isShared()) { + throw new InvalidParameterValueException("You cannot move the volume to local storage, with the disk offering configured for shared storage."); } if (!doesStoragePoolSupportDiskOffering(destPool, newDiskOffering)) { throw new InvalidParameterValueException(String.format("Migration failed: target pool [%s, tags:%s] has no matching tags for volume [%s, uuid:%s, tags:%s]", destPool.getName(), @@ -3675,6 +3684,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic volume, oldDiskOffering, newDiskOffering); } logger.info("Changing disk offering to [{}] while migrating volume [{}].", newDiskOffering, volume); + return true; } /** @@ -4331,7 +4341,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic diskOfferingVO); UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), - volume.getUuid(), volume.isDisplayVolume()); + volume.getUuid(), volume.getInstanceId(), volume.isDisplayVolume()); volService.moveVolumeOnSecondaryStorageToAnotherAccount(volume, oldAccount, newAccount); } @@ -4855,6 +4865,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (attached) { ev = Volume.Event.OperationSucceeded; logger.debug("Volume: {} successfully attached to VM: {}", volInfo.getVolume(), volInfo.getAttachedVM()); + UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_ATTACH, volumeToAttach.getAccountId(), volumeToAttach.getDataCenterId(), volumeToAttach.getId(), volumeToAttach.getName(), + volumeToAttach.getDiskOfferingId(), volumeToAttach.getTemplateId(), volumeToAttach.getSize(), Volume.class.getName(), volumeToAttach.getUuid(), vm.getId(), volumeToAttach.isDisplay()); + provideVMInfo(dataStore, vm.getId(), volInfo.getId()); } else { logger.debug("Volume: {} failed to attach to VM: {}", volInfo.getVolume(), volInfo.getAttachedVM()); diff --git a/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java b/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java index 961a7a7da43..0910c46705a 100644 --- a/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java +++ b/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java @@ -81,7 +81,7 @@ public class VolumeStateListener implements StateListener // For the Resize Volume Event, this publishes an event with an incorrect disk offering ID, so do nothing for now } else { UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), vol.getDiskOfferingId(), null, vol.getSize(), - Volume.class.getName(), vol.getUuid(), vol.isDisplayVolume()); + Volume.class.getName(), vol.getUuid(), instanceId, vol.isDisplayVolume()); } } else if (transition.getToState() == State.Destroy && vol.getVolumeType() != Volume.Type.ROOT) { //Do not Publish Usage Event for ROOT Disk as it would have been published already while destroying a VM UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), diff --git a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java index 6e2059e5776..b245a371969 100644 --- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java +++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java @@ -53,7 +53,10 @@ public interface SnapshotManager extends Configurable { public static final ConfigKey BackupRetryInterval = new ConfigKey(Integer.class, "backup.retry.interval", "Advanced", "300", "Time in seconds between retries in backing up snapshot to secondary", false, ConfigKey.Scope.Global, null); - public static final ConfigKey VmStorageSnapshotKvm = new ConfigKey<>(Boolean.class, "kvm.vmstoragesnapshot.enabled", "Snapshots", "false", "For live snapshot of virtual machine instance on KVM hypervisor without memory. Requires qemu version 1.6+ (on NFS or Local file system) and qemu-guest-agent installed on guest VM", true, ConfigKey.Scope.Global, null); + public static final ConfigKey VmStorageSnapshotKvm = new ConfigKey<>(Boolean.class, "kvm.vmstoragesnapshot.enabled", "Snapshots", "true", "For live snapshot of virtual machine instance on KVM hypervisor without memory. Requires qemu version 1.6+ (on NFS or Local file system) and qemu-guest-agent installed on guest VM", true, ConfigKey.Scope.Global, null); + + ConfigKey KVMSnapshotEnabled = new ConfigKey<>(Boolean.class, "kvm.snapshot.enabled", "Snapshots", "true", "Whether volume snapshot is enabled on running instances " + + "on a KVM hosts", false, ConfigKey.Scope.Global, null); ConfigKey kvmIncrementalSnapshot = new ConfigKey<>(Boolean.class, "kvm.incremental.snapshot", "Snapshots", "false", "Whether differential snapshots are enabled for" + " KVM or not. When this is enabled, all KVM snapshots will be incremental. Bear in mind that it will generate a new full snapshot when the snapshot chain reaches the limit defined in snapshot.delta.max.", true, ConfigKey.Scope.Cluster, null); diff --git a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java index a27885527d4..4f91a66552e 100755 --- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -298,7 +298,7 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement @Override public ConfigKey[] getConfigKeys() { return new ConfigKey[] {BackupRetryAttempts, BackupRetryInterval, SnapshotHourlyMax, SnapshotDailyMax, SnapshotMonthlyMax, SnapshotWeeklyMax, usageSnapshotSelection, - SnapshotInfo.BackupSnapshotAfterTakingSnapshot, VmStorageSnapshotKvm, kvmIncrementalSnapshot, snapshotDeltaMax, snapshotShowChainSize, UseStorageReplication}; + SnapshotInfo.BackupSnapshotAfterTakingSnapshot, VmStorageSnapshotKvm, kvmIncrementalSnapshot, snapshotDeltaMax, snapshotShowChainSize, UseStorageReplication, KVMSnapshotEnabled}; } @Override @@ -1303,7 +1303,8 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement } protected SnapshotPolicyVO createSnapshotPolicy(long volumeId, String schedule, String timezone, IntervalType intervalType, int maxSnaps, boolean display, List zoneIds, List poolIds) { - SnapshotPolicyVO policy = new SnapshotPolicyVO(volumeId, schedule, timezone, intervalType, maxSnaps, display); + VolumeVO volume = _volsDao.findById(volumeId); + SnapshotPolicyVO policy = new SnapshotPolicyVO(volumeId, schedule, timezone, intervalType, maxSnaps, volume.getAccountId(), volume.getDomainId(), display); policy = _snapshotPolicyDao.persist(policy); if (CollectionUtils.isNotEmpty(zoneIds)) { List details = new ArrayList<>(); @@ -1388,28 +1389,54 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement } @Override - public Pair, Integer> listPoliciesforVolume(ListSnapshotPoliciesCmd cmd) { + public Pair, Integer> listSnapshotPolicies(ListSnapshotPoliciesCmd cmd) { Long volumeId = cmd.getVolumeId(); - boolean display = cmd.isDisplay(); Long id = cmd.getId(); - Pair, Integer> result = null; - // TODO - Have a better way of doing this. - if (id != null) { - result = _snapshotPolicyDao.listAndCountById(id, display, null); - if (result != null && result.first() != null && !result.first().isEmpty()) { - SnapshotPolicyVO snapshotPolicy = result.first().get(0); - volumeId = snapshotPolicy.getVolumeId(); + Account caller = CallContext.current().getCallingAccount(); + List permittedAccounts = new ArrayList<>(); + String keyword = cmd.getKeyword(); + + // Verify parameters + if (volumeId != null) { + VolumeVO volume = _volsDao.findById(volumeId); + if (volume != null) { + _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume); } } - VolumeVO volume = _volsDao.findById(volumeId); - if (volume == null) { - throw new InvalidParameterValueException("Unable to find a volume with id " + volumeId); + + Ternary domainIdRecursiveListProject = + new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null); + _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + Long domainId = domainIdRecursiveListProject.first(); + Boolean isRecursive = domainIdRecursiveListProject.second(); + ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); + + Filter searchFilter = new Filter(SnapshotPolicyVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal()); + SearchBuilder policySearch = _snapshotPolicyDao.createSearchBuilder(); + _accountMgr.buildACLSearchBuilder(policySearch, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + + policySearch.and("id", policySearch.entity().getId(), SearchCriteria.Op.EQ); + policySearch.and("volumeId", policySearch.entity().getVolumeId(), SearchCriteria.Op.EQ); + + SearchBuilder volumeSearch = _volsDao.createSearchBuilder(); + volumeSearch.and("name", volumeSearch.entity().getName(), SearchCriteria.Op.LIKE); + policySearch.join("volumeJoin", volumeSearch, policySearch.entity().getVolumeId(), volumeSearch.entity().getId(), JoinBuilder.JoinType.INNER); + + SearchCriteria sc = policySearch.create(); + _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + + if (volumeId != null) { + sc.setParameters("volumeId", volumeId); } - _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume); - if (result != null) - return new Pair, Integer>(result.first(), result.second()); - result = _snapshotPolicyDao.listAndCountByVolumeId(volumeId, display); - return new Pair, Integer>(result.first(), result.second()); + if (id != null) { + sc.setParameters("id", id); + } + if (keyword != null) { + sc.setJoinParameters("volumeJoin", "name", "%" + keyword + "%"); + } + + Pair, Integer> result = _snapshotPolicyDao.searchAndCount(sc, searchFilter); + return new Pair<>(result.first(), result.second()); } private List listPoliciesforVolume(long volumeId) { @@ -1510,7 +1537,7 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement if (vmId != null) { VMInstanceVO vm = _vmDao.findById(vmId); if (vm.getState() != VirtualMachine.State.Stopped && vm.getState() != VirtualMachine.State.Destroyed) { - boolean snapshotEnabled = Boolean.parseBoolean(_configDao.getValue("kvm.snapshot.enabled")); + boolean snapshotEnabled = KVMSnapshotEnabled.value(); if (!snapshotEnabled && !isFromVmSnapshot) { logger.debug("Snapshot is not supported on host " + host + " for the volume " + volume + " attached to the vm " + vm); return false; diff --git a/server/src/main/java/com/cloud/tags/ResourceManagerUtilImpl.java b/server/src/main/java/com/cloud/tags/ResourceManagerUtilImpl.java index e6d0b737bbe..8f1cf76025b 100644 --- a/server/src/main/java/com/cloud/tags/ResourceManagerUtilImpl.java +++ b/server/src/main/java/com/cloud/tags/ResourceManagerUtilImpl.java @@ -22,6 +22,7 @@ import java.util.Objects; import javax.inject.Inject; +import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.context.CallContext; @@ -130,6 +131,11 @@ public class ResourceManagerUtilImpl implements ResourceManagerUtil { @Override public long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType) { + return getResourceId(resourceId, resourceType, false); + } + + @Override + public long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType, boolean checkAccess) { Class clazz = s_typeMap.get(resourceType); Object entity = entityMgr.findByUuid(clazz, resourceId); if (entity != null) { @@ -140,6 +146,11 @@ public class ResourceManagerUtilImpl implements ResourceManagerUtil { } entity = entityMgr.findById(clazz, resourceId); if (entity != null) { + if (checkAccess && entity instanceof ControlledEntity) { + ControlledEntity controlledEntity = (ControlledEntity)entity; + Account caller = CallContext.current().getCallingAccount(); + accountMgr.checkAccess(caller, null, false, controlledEntity); + } return ((InternalIdentity)entity).getId(); } throw new InvalidParameterValueException("Unable to find resource by id " + resourceId + " and type " + resourceType); diff --git a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java index 2d5920eb919..954f20344f3 100644 --- a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java +++ b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java @@ -496,7 +496,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { boolean dataDiskDeletetionResult = true; List dataDiskTemplates = templateDao.listByParentTemplatetId(template.getId()); - if (dataDiskTemplates != null && dataDiskTemplates.size() > 0) { + if (CollectionUtils.isNotEmpty(dataDiskTemplates)) { logger.info("Template: {} has Datadisk template(s) associated with it. Delete Datadisk templates before deleting the template", template); for (VMTemplateVO dataDiskTemplate : dataDiskTemplates) { logger.info("Delete Datadisk template: {} from image store: {}", dataDiskTemplate, imageStore); @@ -562,6 +562,9 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { if (success) { if ((imageStores != null && imageStores.size() > 1) && (profile.getZoneIdList() != null)) { //if template is stored in more than one image stores, and the zone id is not null, then don't delete other templates. + if (templateMgr.TemplateDeleteFromPrimaryStorage.value()) { + templateMgr.evictTemplateFromStoragePoolsForZones(template.getId(), profile.getZoneIdList()); + } return cleanupTemplate(template, success); } @@ -574,7 +577,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { // find all eligible image stores for this template List iStores = templateMgr.getImageStoreByTemplate(template.getId(), null); - if (iStores == null || iStores.size() == 0) { + if (CollectionUtils.isEmpty(iStores)) { // remove any references from template_zone_ref List templateZones = templateZoneDao.listByTemplateId(template.getId()); if (templateZones != null) { @@ -595,6 +598,10 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { } + if (templateMgr.TemplateDeleteFromPrimaryStorage.value()) { + templateMgr.evictTemplateFromStoragePoolsForZones(template.getId(), profile.getZoneIdList()); + } + // remove its related ACL permission Pair, Long> templateClassForId = new Pair<>(VirtualMachineTemplate.class, template.getId()); _messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, templateClassForId); diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 7bb66958cb4..06ec17d48ef 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -1030,33 +1030,53 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, return adapter.delete(new TemplateProfile(userId, template, zoneId)); } + private Boolean templateIsUnusedInPool(VMTemplateStoragePoolVO templatePoolVO) { + VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId()); + + // If this is a routing template, consider it in use + if (template.getTemplateType() == TemplateType.SYSTEM) { + return false; + } + + // If the template is not yet downloaded to the pool, consider it in use + if (templatePoolVO.getDownloadState() != Status.DOWNLOADED) { + return false; + } + + if (template.getFormat() == ImageFormat.ISO || _volumeDao.isAnyVolumeActivelyUsingTemplateOnPool(template.getId(), templatePoolVO.getPoolId())) { + return false; + } + return true; + } + @Override public List getUnusedTemplatesInPool(StoragePoolVO pool) { List unusedTemplatesInPool = new ArrayList(); List allTemplatesInPool = _tmpltPoolDao.listByPoolId(pool.getId()); for (VMTemplateStoragePoolVO templatePoolVO : allTemplatesInPool) { - VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId()); - - // If this is a routing template, consider it in use - if (template.getTemplateType() == TemplateType.SYSTEM) { - continue; - } - - // If the template is not yet downloaded to the pool, consider it in - // use - if (templatePoolVO.getDownloadState() != Status.DOWNLOADED) { - continue; - } - - if (template.getFormat() != ImageFormat.ISO && !_volumeDao.isAnyVolumeActivelyUsingTemplateOnPool(template.getId(), pool.getId())) { + if (templateIsUnusedInPool(templatePoolVO)) { unusedTemplatesInPool.add(templatePoolVO); } } - return unusedTemplatesInPool; } + @Override + public void evictTemplateFromStoragePoolsForZones(Long templateId, List zoneIds) { + List poolIds = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(zoneIds)) { + List pools = _poolDao.listByDataCenterIds(zoneIds); + poolIds = pools.stream().map(StoragePoolVO::getId).collect(Collectors.toList()); + } + List templateStoragePoolVOS = _tmpltPoolDao.listByPoolIdsAndTemplate(poolIds, templateId); + for (VMTemplateStoragePoolVO templateStoragePoolVO: templateStoragePoolVOS) { + if (templateIsUnusedInPool(templateStoragePoolVO)) { + evictTemplateFromStoragePool(templateStoragePoolVO); + } + } + } + @Override @DB public void evictTemplateFromStoragePool(VMTemplateStoragePoolVO templatePoolVO) { @@ -2437,7 +2457,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {AllowPublicUserTemplates, TemplatePreloaderPoolSize, ValidateUrlIsResolvableBeforeRegisteringTemplate}; + return new ConfigKey[] {AllowPublicUserTemplates, + TemplatePreloaderPoolSize, + ValidateUrlIsResolvableBeforeRegisteringTemplate, + TemplateDeleteFromPrimaryStorage}; } public List getTemplateAdapters() { diff --git a/server/src/main/java/com/cloud/test/IPRangeConfig.java b/server/src/main/java/com/cloud/test/IPRangeConfig.java index 22ebb56963a..e041f739053 100644 --- a/server/src/main/java/com/cloud/test/IPRangeConfig.java +++ b/server/src/main/java/com/cloud/test/IPRangeConfig.java @@ -77,7 +77,6 @@ public class IPRangeConfig { } String pod = args[2]; String zone = args[3]; - ; String startIP = args[4]; String endIP = null; if (args.length == 6) { @@ -99,31 +98,6 @@ public class IPRangeConfig { } } - public List changePublicIPRangeGUI(String op, String zone, String startIP, String endIP, long physicalNetworkId) { - String result = checkErrors("public", op, null, zone, startIP, endIP); - if (!result.equals("success")) { - return DatabaseConfig.genReturnList("false", result); - } - - long zoneId = PodZoneConfig.getZoneId(zone); - result = changeRange(op, "public", -1, zoneId, startIP, endIP, null, physicalNetworkId); - - return DatabaseConfig.genReturnList("true", result); - } - - public List changePrivateIPRangeGUI(String op, String pod, String zone, String startIP, String endIP) { - String result = checkErrors("private", op, pod, zone, startIP, endIP); - if (!result.equals("success")) { - return DatabaseConfig.genReturnList("false", result); - } - - long podId = PodZoneConfig.getPodId(pod, zone); - long zoneId = PodZoneConfig.getZoneId(zone); - result = changeRange(op, "private", podId, zoneId, startIP, endIP, null, -1); - - return DatabaseConfig.genReturnList("true", result); - } - private String checkErrors(String type, String op, String pod, String zone, String startIP, String endIP) { if (!op.equals("add") && !op.equals("delete")) { return usage(); @@ -153,15 +127,7 @@ public class IPRangeConfig { } // Check that the IPs that are being added are compatible with either the zone's public netmask, or the pod's CIDR - if (type.equals("public")) { - // String publicNetmask = getPublicNetmask(zone); - // String publicGateway = getPublicGateway(zone); - - // if (publicNetmask == null) return "Please ensure that your zone's public net mask is specified"; - // if (!sameSubnet(startIP, endIP, publicNetmask)) return "Please ensure that your start IP and end IP are in the same subnet, as per the zone's netmask."; - // if (!sameSubnet(startIP, publicGateway, publicNetmask)) return "Please ensure that your start IP is in the same subnet as your zone's gateway, as per the zone's netmask."; - // if (!sameSubnet(endIP, publicGateway, publicNetmask)) return "Please ensure that your end IP is in the same subnet as your zone's gateway, as per the zone's netmask."; - } else if (type.equals("private")) { + if (type.equals("private")) { String cidrAddress = getCidrAddress(pod, zone); long cidrSize = getCidrSize(pod, zone); diff --git a/server/src/main/java/com/cloud/test/PodZoneConfig.java b/server/src/main/java/com/cloud/test/PodZoneConfig.java index 7cd6cb11871..2d32621a252 100644 --- a/server/src/main/java/com/cloud/test/PodZoneConfig.java +++ b/server/src/main/java/com/cloud/test/PodZoneConfig.java @@ -75,11 +75,6 @@ public class PodZoneConfig { } private String checkPodCidrSubnets(long dcId, HashMap> currentPodCidrSubnets) { - -// DataCenterDao _dcDao = null; -// final ComponentLocator locator = ComponentLocator.getLocator("management-server"); - -// _dcDao = locator.getDao(DataCenterDao.class); // For each pod, return an error if any of the following is true: // 1. The pod's CIDR subnet conflicts with the guest network subnet // 2. The pod's CIDR subnet conflicts with the CIDR subnet of any other pod @@ -87,7 +82,6 @@ public class PodZoneConfig { String zoneName = PodZoneConfig.getZoneName(dcId); //get the guest network cidr and guest netmask from the zone -// DataCenterVO dcVo = _dcDao.findById(dcId); String guestNetworkCidr = IPRangeConfig.getGuestNetworkCidr(dcId); diff --git a/server/src/main/java/com/cloud/vm/UserVmManager.java b/server/src/main/java/com/cloud/vm/UserVmManager.java index 21ac6e3eb36..972c6cbea89 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManager.java +++ b/server/src/main/java/com/cloud/vm/UserVmManager.java @@ -83,6 +83,12 @@ public interface UserVmManager extends UserVmService { "If set to true, tags specified in `resource.limit.host.tags` are also included in vm.strict.host.tags.", true); + ConfigKey VmDistinctHostNameScope = new ConfigKey<>(String.class, "vm.distinct.hostname.scope", ConfigKey.CATEGORY_ADVANCED, + "network", + "Defines the scope for enforcing unique VM hostnames which determines the resource boundary within which VM hostnames must be unique. Possible values: global, domain, subdomain, account, network.", + true, ConfigKey.Scope.Global, null, "VM distinct hostname scope", null, null, null, ConfigKey.Kind.Select, + "global,domain,subdomain,account,network"); + ConfigKey EnableAdditionalVmConfig = new ConfigKey<>( "Advanced", Boolean.class, @@ -92,6 +98,7 @@ public interface UserVmManager extends UserVmService { true, ConfigKey.Scope.Account); + static final int MAX_USER_DATA_LENGTH_BYTES = 2048; public static final String CKS_NODE = "cksnode"; diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index f1bbfa07292..2e30b4ecbd8 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -60,6 +60,8 @@ import javax.naming.ConfigurationException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; +import com.cloud.storage.SnapshotPolicyVO; +import com.cloud.storage.dao.SnapshotPolicyDao; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.acl.SecurityChecker.AccessType; @@ -103,8 +105,10 @@ import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd; import org.apache.cloudstack.api.command.user.volume.ChangeOfferingForVolumeCmd; import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd; import org.apache.cloudstack.backup.BackupManager; +import org.apache.cloudstack.backup.BackupScheduleVO; import org.apache.cloudstack.backup.BackupVO; import org.apache.cloudstack.backup.dao.BackupDao; +import org.apache.cloudstack.backup.dao.BackupScheduleDao; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDao; @@ -607,6 +611,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir ReservationDao reservationDao; @Inject ResourceLimitService resourceLimitService; + @Inject + SnapshotPolicyDao snapshotPolicyDao; + @Inject + BackupScheduleDao backupScheduleDao; @Inject private StatsCollector statsCollector; @@ -2400,6 +2408,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (Volume.State.Destroy.equals(volume.getState())) { _volumeService.recoverVolume(volume.getId()); _volsDao.attachVolume(volume.getId(), vmId, ROOT_DEVICE_ID); + UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_ATTACH, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), + volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), vmId, volume.isDisplay()); } else { _volumeService.publishVolumeCreationUsageEvent(volume); } @@ -4690,23 +4700,75 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } } - private void checkIfHostNameUniqueInNtwkDomain(String hostName, List networkList) { - // Check that hostName is unique in the network domain - Map> ntwkDomains = new HashMap>(); + private List getNetworksWithSameNetworkDomainInDomains(List networkList, boolean checkSubDomains) { + Set uniqueNtwkDomains = networkList.stream().map(NetworkVO::getNetworkDomain).collect(Collectors.toSet()); + Set domainIdList = new HashSet<>(); for (Network network : networkList) { - String ntwkDomain = network.getNetworkDomain(); - if (!ntwkDomains.containsKey(ntwkDomain)) { - List ntwkIds = new ArrayList(); - ntwkIds.add(network.getId()); - ntwkDomains.put(ntwkDomain, ntwkIds); - } else { - List ntwkIds = ntwkDomains.get(ntwkDomain); - ntwkIds.add(network.getId()); - ntwkDomains.put(ntwkDomain, ntwkIds); + domainIdList.add(network.getDomainId()); + } + Set finalDomainIdSet = new HashSet<>(domainIdList); + if (checkSubDomains) { + for (Long domainId : domainIdList) { + DomainVO domain = _domainDao.findById(domainId); + List childDomainIds = _domainDao.getDomainChildrenIds(domain.getPath()); + finalDomainIdSet.addAll(childDomainIds); } } + return _networkDao.listByNetworkDomainsAndDomainIds(uniqueNtwkDomains, finalDomainIdSet); + } - for (Entry> ntwkDomain : ntwkDomains.entrySet()) { + private List getNetworksForCheckUniqueHostName(List networkList) { + List finalNetworkList; + Set uniqueNtwkDomains; + switch (VmDistinctHostNameScope.value()) { + case "global": + uniqueNtwkDomains = networkList.stream().map(NetworkVO::getNetworkDomain).collect(Collectors.toSet()); + finalNetworkList = _networkDao.listByNetworkDomains(uniqueNtwkDomains); + break; + case "domain": + finalNetworkList = getNetworksWithSameNetworkDomainInDomains(networkList, false); + break; + case "subdomain": + finalNetworkList = getNetworksWithSameNetworkDomainInDomains(networkList, true); + break; + case "account": + uniqueNtwkDomains = networkList.stream().map(NetworkVO::getNetworkDomain).collect(Collectors.toSet()); + Set accountIds = networkList.stream().map(Network::getAccountId).collect(Collectors.toSet()); + finalNetworkList = _networkDao.listByNetworkDomainsAndAccountIds(uniqueNtwkDomains, accountIds); + break; + default: + Set vpcIds = networkList.stream().map(Network::getVpcId).filter(Objects::nonNull).collect(Collectors.toSet()); + finalNetworkList = new ArrayList<>(networkList); + for (Long vpcId : vpcIds) { + finalNetworkList.addAll(_networkDao.listByVpc(vpcId)); + } + break; + } + return finalNetworkList; + } + + private Map> getNetworkIdPerNetworkDomain(List networkList) { + Map> ntwkDomains = new HashMap<>(); + + List updatedNetworkList = getNetworksForCheckUniqueHostName(networkList); + for (Network network : updatedNetworkList) { + String ntwkDomain = network.getNetworkDomain(); + Set ntwkIds; + if (!ntwkDomains.containsKey(ntwkDomain)) { + ntwkIds = new HashSet<>(); + } else { + ntwkIds = ntwkDomains.get(ntwkDomain); + } + ntwkIds.add(network.getId()); + ntwkDomains.put(ntwkDomain, ntwkIds); + } + return ntwkDomains; + } + + private void checkIfHostNameUniqueInNtwkDomain(String hostName, List networkList) { + // Check that hostName is unique + Map> ntwkDomains = getNetworkIdPerNetworkDomain(networkList); + for (Entry> ntwkDomain : ntwkDomains.entrySet()) { for (Long ntwkId : ntwkDomain.getValue()) { // * get all vms hostNames in the network List hostNames = _vmInstanceDao.listDistinctHostNames(ntwkId); @@ -8045,6 +8107,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir updateVolumesOwner(volumes, oldAccount, newAccount, newAccountId); + updateSnapshotPolicyOwnership(volumes, newAccount); + updateBackupScheduleOwnership(vm, newAccount); + try { updateVmNetwork(cmd, caller, vm, newAccount, template); } catch (InsufficientCapacityException | ResourceAllocationException e) { @@ -8093,7 +8158,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir logger.trace("Generating a create volume event for volume [{}].", volume); UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), - volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), volume.isDisplayVolume()); + volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), volume.getInstanceId(), volume.isDisplayVolume()); } } @@ -8519,6 +8584,36 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } } + protected void updateSnapshotPolicyOwnership(List volumes, Account newAccount) { + logger.debug("Updating snapshot policy ownership for volumes of VM being assigned to account [{}]", newAccount); + + for (VolumeVO volume : volumes) { + List snapshotPolicies = snapshotPolicyDao.listByVolumeId(volume.getId()); + for (SnapshotPolicyVO policy : snapshotPolicies) { + logger.trace("Updating snapshot policy [{}] ownership from account [{}] to account [{}]", + policy.getId(), policy.getAccountId(), newAccount.getAccountId()); + + policy.setAccountId(newAccount.getAccountId()); + policy.setDomainId(newAccount.getDomainId()); + snapshotPolicyDao.update(policy.getId(), policy); + } + } + } + + protected void updateBackupScheduleOwnership(UserVmVO vm, Account newAccount) { + logger.debug("Updating backup schedule ownership for VM [{}] being assigned to account [{}]", vm, newAccount); + + List backupSchedules = backupScheduleDao.listByVM(vm.getId()); + for (BackupScheduleVO schedule : backupSchedules) { + logger.trace("Updating backup schedule [{}] ownership from account [{}] to account [{}]", + schedule.getId(), schedule.getAccountId(), newAccount.getAccountId()); + + schedule.setAccountId(newAccount.getAccountId()); + schedule.setDomainId(newAccount.getDomainId()); + backupScheduleDao.update(schedule.getId(), schedule); + } + } + /** * Attempts to create a network suitable for the creation of a VM ({@link NetworkOrchestrationService#createGuestNetwork}). * If no physical network is found, throws a {@link InvalidParameterValueException}. @@ -8866,6 +8961,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir handleManagedStorage(vm, root); _volsDao.attachVolume(newVol.getId(), vmId, newVol.getDeviceId()); + UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_ATTACH, newVol.getAccountId(), newVol.getDataCenterId(), newVol.getId(), newVol.getName(), + newVol.getDiskOfferingId(), newVol.getTemplateId(), newVol.getSize(), Volume.class.getName(), newVol.getUuid(), vmId, newVol.isDisplay()); // Detach, destroy and create the usage event for the old root volume. _volsDao.detachVolume(root.getId()); @@ -9243,7 +9340,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir return new ConfigKey[] {EnableDynamicallyScaleVm, AllowDiskOfferingChangeDuringScaleVm, AllowUserExpungeRecoverVm, VmIpFetchWaitInterval, VmIpFetchTrialMax, VmIpFetchThreadPoolMax, VmIpFetchTaskWorkers, AllowDeployVmIfGivenHostFails, EnableAdditionalVmConfig, DisplayVMOVFProperties, KvmAdditionalConfigAllowList, XenServerAdditionalConfigAllowList, VmwareAdditionalConfigAllowList, DestroyRootVolumeOnVmDestruction, - EnforceStrictResourceLimitHostTagCheck, StrictHostTags, AllowUserForceStopVm}; + EnforceStrictResourceLimitHostTagCheck, StrictHostTags, AllowUserForceStopVm, VmDistinctHostNameScope}; } @Override @@ -9513,11 +9610,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } else { String serviceOfferingUuid = backup.getDetail(ApiConstants.SERVICE_OFFERING_ID); if (serviceOfferingUuid == null) { - throw new CloudRuntimeException("Backup doesn't contain service offering uuid. Please specify a valid service offering id while creating the instance"); + throw new CloudRuntimeException("Backup doesn't contain a Service Offering UUID. Please specify a valid Service Offering while creating the Instance"); } serviceOffering = serviceOfferingDao.findByUuid(serviceOfferingUuid); if (serviceOffering == null) { - throw new CloudRuntimeException("Unable to find service offering with the uuid stored in backup. Please specify a valid service offering id while creating instance"); + throw new CloudRuntimeException("Unable to find Service Offering with the UUID stored in the Backup. Please specify a valid Service Offering while creating the Instance"); } } verifyServiceOffering(cmd, serviceOffering); @@ -9532,11 +9629,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } else { String templateUuid = backup.getDetail(ApiConstants.TEMPLATE_ID); if (templateUuid == null) { - throw new CloudRuntimeException("Backup doesn't contain Template uuid. Please specify a valid Template/ISO while creating the instance"); + throw new CloudRuntimeException("Backup doesn't contain a Template UUID. Please specify a valid Template/ISO while creating the Instance"); } template = _templateDao.findByUuid(templateUuid); if (template == null) { - throw new CloudRuntimeException("Unable to find template associated with the backup. Please specify a valid Template/ISO while creating instance"); + throw new CloudRuntimeException("Unable to find Template with the UUID stored in the Backup. Please specify a valid Template/ISO while creating the Instance"); } } verifyTemplate(cmd, template, serviceOffering.getId()); diff --git a/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java b/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java index aff838a3cdf..ef3ba917de7 100644 --- a/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java @@ -122,12 +122,14 @@ import com.cloud.projects.Project; import com.cloud.serializer.GsonHelper; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.DiskOfferingVO; +import com.cloud.storage.GuestOSVO; import com.cloud.storage.ScopeType; import com.cloud.storage.Storage; import com.cloud.storage.Volume; import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.DiskOfferingDao; +import com.cloud.storage.dao.GuestOSDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.template.VirtualMachineTemplate; @@ -166,6 +168,7 @@ import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.dao.VMInstanceDetailsDao; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -232,6 +235,8 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { private ResourceLimitService resourceLimitMgr; @Inject private AlertManager alertManager; + @Inject + private GuestOSDao _guestOSDao; private AsyncJobDispatcher asyncJobDispatcher; private Timer backupTimer; @@ -379,7 +384,15 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { ServiceOffering serviceOffering = serviceOfferingDao.findById(vm.getServiceOfferingId()); details.put(ApiConstants.SERVICE_OFFERING_ID, serviceOffering.getUuid()); VirtualMachineTemplate template = vmTemplateDao.findById(vm.getTemplateId()); - details.put(ApiConstants.TEMPLATE_ID, template.getUuid()); + if (template != null) { + long guestOSId = template.getGuestOSId(); + details.put(ApiConstants.TEMPLATE_ID, template.getUuid()); + GuestOSVO guestOS = _guestOSDao.findById(guestOSId); + if (guestOS != null) { + details.put(ApiConstants.OS_TYPE_ID, guestOS.getUuid()); + details.put(ApiConstants.OS_NAME, guestOS.getDisplayName()); + } + } List vmDetails = vmInstanceDetailsDao.listDetails(vm.getId()); HashMap settings = new HashMap<>(); @@ -387,7 +400,8 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { settings.put(detail.getName(), detail.getValue()); } if (!settings.isEmpty()) { - details.put(ApiConstants.VM_SETTINGS, new Gson().toJson(settings)); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + details.put(ApiConstants.VM_SETTINGS, gson.toJson(settings)); } String nicsJson = getNicDetailsAsJson(vm.getId()); @@ -588,7 +602,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { final BackupScheduleVO schedule = backupScheduleDao.findByVMAndIntervalType(vmId, intervalType); if (schedule == null) { - return backupScheduleDao.persist(new BackupScheduleVO(vmId, intervalType, scheduleString, timezoneId, nextDateTime, maxBackups, cmd.getQuiesceVM())); + return backupScheduleDao.persist(new BackupScheduleVO(vmId, intervalType, scheduleString, timezoneId, nextDateTime, maxBackups, cmd.getQuiesceVM(), vm.getAccountId(), vm.getDomainId())); } schedule.setScheduleType((short) intervalType.ordinal()); @@ -638,13 +652,59 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { return maxBackups; } - @Override - public List listBackupSchedule(final Long vmId) { - final VMInstanceVO vm = findVmById(vmId); - validateBackupForZone(vm.getDataCenterId()); - accountManager.checkAccess(CallContext.current().getCallingAccount(), null, true, vm); + public List listBackupSchedules(ListBackupScheduleCmd cmd) { + Account caller = CallContext.current().getCallingAccount(); + Long id = cmd.getId(); + Long vmId = cmd.getVmId(); + List permittedAccounts = new ArrayList<>(); + Long domainId = null; + Boolean isRecursive = null; + String keyword = cmd.getKeyword(); + Project.ListProjectResourcesCriteria listProjectResourcesCriteria = null; - return backupScheduleDao.listByVM(vmId).stream().map(BackupSchedule.class::cast).collect(Collectors.toList()); + if (vmId != null) { + final VMInstanceVO vm = findVmById(vmId); + validateBackupForZone(vm.getDataCenterId()); + accountManager.checkAccess(CallContext.current().getCallingAccount(), null, true, vm); + } + + Ternary domainIdRecursiveListProject = + new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null); + accountManager.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, true, false); + domainId = domainIdRecursiveListProject.first(); + isRecursive = domainIdRecursiveListProject.second(); + listProjectResourcesCriteria = domainIdRecursiveListProject.third(); + + Filter searchFilter = new Filter(BackupScheduleVO.class, "id", false, null, null); + SearchBuilder searchBuilder = backupScheduleDao.createSearchBuilder(); + + accountManager.buildACLSearchBuilder(searchBuilder, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + + searchBuilder.and("id", searchBuilder.entity().getId(), SearchCriteria.Op.EQ); + if (vmId != null) { + searchBuilder.and("vmId", searchBuilder.entity().getVmId(), SearchCriteria.Op.EQ); + } + if (keyword != null && !keyword.isEmpty()) { + SearchBuilder vmSearch = vmInstanceDao.createSearchBuilder(); + vmSearch.and("hostName", vmSearch.entity().getHostName(), SearchCriteria.Op.LIKE); + searchBuilder.join("vmJoin", vmSearch, searchBuilder.entity().getVmId(), vmSearch.entity().getId(), JoinBuilder.JoinType.INNER); + } + + SearchCriteria sc = searchBuilder.create(); + accountManager.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + + if (id != null) { + sc.setParameters("id", id); + } + if (vmId != null) { + sc.setParameters("vmId", vmId); + } + if (keyword != null && !keyword.isEmpty()) { + sc.setJoinParameters("vmJoin", "hostName", "%" + keyword + "%"); + } + + Pair, Integer> result = backupScheduleDao.searchAndCount(sc, searchFilter); + return new ArrayList<>(result.first()); } @Override @@ -2097,7 +2157,6 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { if (details.containsKey(ApiConstants.TEMPLATE_ID)) { VirtualMachineTemplate template = vmTemplateDao.findByUuid(details.get(ApiConstants.TEMPLATE_ID)); if (template != null) { - details.put(ApiConstants.TEMPLATE_ID, template.getUuid()); details.put(ApiConstants.TEMPLATE_NAME, template.getName()); details.put(ApiConstants.IS_ISO, String.valueOf(template.getFormat().equals(Storage.ImageFormat.ISO))); } @@ -2105,7 +2164,6 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { if (details.containsKey(ApiConstants.SERVICE_OFFERING_ID)) { ServiceOffering serviceOffering = serviceOfferingDao.findByUuid(details.get(ApiConstants.SERVICE_OFFERING_ID)); if (serviceOffering != null) { - details.put(ApiConstants.SERVICE_OFFERING_ID, serviceOffering.getUuid()); details.put(ApiConstants.SERVICE_OFFERING_NAME, serviceOffering.getName()); } } @@ -2140,10 +2198,15 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { response.setId(backup.getUuid()); response.setName(backup.getName()); response.setDescription(backup.getDescription()); - response.setVmName(vm.getHostName()); - response.setVmId(vm.getUuid()); - if (vm.getBackupOfferingId() == null || vm.getBackupOfferingId() != backup.getBackupOfferingId()) { - response.setVmOfferingRemoved(true); + if (vm != null) { + response.setVmName(vm.getHostName()); + response.setVmId(vm.getUuid()); + if (vm.getBackupOfferingId() == null || vm.getBackupOfferingId() != backup.getBackupOfferingId()) { + response.setVmOfferingRemoved(true); + } + } + if (vm == null || VirtualMachine.State.Expunging.equals(vm.getState())) { + response.setVmExpunged(true); } response.setExternalId(backup.getExternalId()); response.setType(backup.getType()); @@ -2159,9 +2222,11 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { } } // ACS 4.20: For backups taken prior this release the backup.backed_volumes column would be empty hence use vm_instance.backup_volumes - String backedUpVolumes; + String backedUpVolumes = ""; if (Objects.isNull(backup.getBackedUpVolumes())) { - backedUpVolumes = new Gson().toJson(vm.getBackupVolumeList().toArray(), Backup.VolumeInfo[].class); + if (vm != null) { + backedUpVolumes = new Gson().toJson(vm.getBackupVolumeList().toArray(), Backup.VolumeInfo[].class); + } } else { backedUpVolumes = new Gson().toJson(backup.getBackedUpVolumes().toArray(), Backup.VolumeInfo[].class); } @@ -2177,7 +2242,9 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager { if (Boolean.TRUE.equals(listVmDetails)) { Map vmDetails = new HashMap<>(); - vmDetails.put(ApiConstants.HYPERVISOR, vm.getHypervisorType().toString()); + if (vm != null) { + vmDetails.put(ApiConstants.HYPERVISOR, vm.getHypervisorType().toString()); + } Map details = getDetailsFromBackupDetails(backup.getId()); vmDetails.putAll(details); response.setVmDetails(vmDetails); diff --git a/server/src/main/java/org/apache/cloudstack/command/ReconcileCommandServiceImpl.java b/server/src/main/java/org/apache/cloudstack/command/ReconcileCommandServiceImpl.java index d0dcc1f86de..5edf05d1a5c 100644 --- a/server/src/main/java/org/apache/cloudstack/command/ReconcileCommandServiceImpl.java +++ b/server/src/main/java/org/apache/cloudstack/command/ReconcileCommandServiceImpl.java @@ -1064,6 +1064,7 @@ public class ReconcileCommandServiceImpl extends ManagerBase implements Reconcil logger.debug(String.format("Updating volume %s to %s state", sourceVolume, Volume.State.Ready)); sourceVolume.setState(Volume.State.Ready); sourceVolume.setPoolId(srcDataStore.getId()); // restore pool_id and update path + sourceVolume.setPoolType(srcDataStore.getPoolType()); sourceVolume.setPath(srcData.getPath()); sourceVolume.set_iScsiName(srcData.getPath()); sourceVolume.setUpdated(new Date()); @@ -1075,6 +1076,7 @@ public class ReconcileCommandServiceImpl extends ManagerBase implements Reconcil VolumeVO newVolume = (VolumeVO) newVol; newVolume.setInstanceId(null); newVolume.setPoolId(destDataStore.getId()); + newVolume.setPoolType(destDataStore.getPoolType()); newVolume.setState(Volume.State.Creating); newVolume.setPath(destData.getPath()); newVolume.set_iScsiName(destData.getPath()); diff --git a/server/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java b/server/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java index 005e24a8bce..4de1ab3fede 100644 --- a/server/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java @@ -423,7 +423,7 @@ public class DirectDownloadManagerImpl extends ManagerBase implements DirectDown } /** - * Return pretified PEM certificate + * Return prettified PEM certificate */ protected String getPretifiedCertificate(String certificateCer) { String cert = certificateCer.replaceAll("(.{64})", "$1\n"); diff --git a/server/src/main/java/org/apache/cloudstack/network/RoutedIpv4ManagerImpl.java b/server/src/main/java/org/apache/cloudstack/network/RoutedIpv4ManagerImpl.java index 45943e27d2b..ac12dc3a9b1 100644 --- a/server/src/main/java/org/apache/cloudstack/network/RoutedIpv4ManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/network/RoutedIpv4ManagerImpl.java @@ -607,10 +607,20 @@ public class RoutedIpv4ManagerImpl extends ComponentLifecycleBase implements Rou } protected Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(Integer cidrSize, Long ownerDomainId, Long ownerAccountId, Long zoneId) { - validateNetworkCidrSize(ownerAccountId, cidrSize); + validateNetworkCidrSize(cidrSize); List subnets = getZoneSubnetsForAccount(ownerDomainId, ownerAccountId, zoneId); for (DataCenterIpv4GuestSubnetVO subnet : subnets) { - Ipv4GuestSubnetNetworkMap result = getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(cidrSize, subnet); + Ipv4GuestSubnetNetworkMap result = getIpv4SubnetForGuestNetworkOrVpcInternal(cidrSize, subnet); + if (result != null) { + return result; + } + } + Boolean isAutoAllocationEnabled = RoutedIPv4NetworkCidrAutoAllocationEnabled.valueIn(ownerAccountId); + if (!Boolean.TRUE.equals(isAutoAllocationEnabled)) { + throw new InvalidParameterValueException("CIDR auto-allocation is disabled for this account"); + } + for (DataCenterIpv4GuestSubnetVO subnet : subnets) { + Ipv4GuestSubnetNetworkMap result = createIpv4SubnetForGuestNetworkOrVpcInternal(cidrSize, subnet); if (result != null) { return result; } @@ -618,11 +628,11 @@ public class RoutedIpv4ManagerImpl extends ComponentLifecycleBase implements Rou return null; } - protected Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(Integer cidrSize, DataCenterIpv4GuestSubnetVO subnet) { - Ipv4GuestSubnetNetworkMap map = ipv4GuestSubnetNetworkMapDao.findFirstAvailable(subnet.getId(), cidrSize); - if (map != null) { - return map; - } + protected Ipv4GuestSubnetNetworkMap getIpv4SubnetForGuestNetworkOrVpcInternal(Integer cidrSize, DataCenterIpv4GuestSubnetVO subnet) { + return ipv4GuestSubnetNetworkMapDao.findFirstAvailable(subnet.getId(), cidrSize); + } + + protected Ipv4GuestSubnetNetworkMap createIpv4SubnetForGuestNetworkOrVpcInternal(Integer cidrSize, DataCenterIpv4GuestSubnetVO subnet) { try { return createIpv4SubnetFromParentSubnet(subnet, cidrSize); } catch (Exception ex) { @@ -631,6 +641,14 @@ public class RoutedIpv4ManagerImpl extends ComponentLifecycleBase implements Rou return null; } + protected Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(Integer cidrSize, DataCenterIpv4GuestSubnetVO subnet) { + Ipv4GuestSubnetNetworkMap map = getIpv4SubnetForGuestNetworkOrVpcInternal(cidrSize, subnet); + if (map != null) { + return map; + } + return createIpv4SubnetForGuestNetworkOrVpcInternal(cidrSize, subnet); + } + protected void getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(String networkCidr, Long ownerDomainId, Long ownerAccountId, Long zoneId) { Ipv4GuestSubnetNetworkMapVO subnetMap = ipv4GuestSubnetNetworkMapDao.findBySubnet(networkCidr); if (subnetMap != null) { @@ -693,13 +711,9 @@ public class RoutedIpv4ManagerImpl extends ComponentLifecycleBase implements Rou } } - private void validateNetworkCidrSize(long accountId, Integer networkCidrSize) { + private void validateNetworkCidrSize(Integer networkCidrSize) { if (networkCidrSize == null) { - throw new CloudRuntimeException("network/vpc CidrSize is null"); - } - Boolean isAutoAllocationEnabled = RoutedIPv4NetworkCidrAutoAllocationEnabled.valueIn(accountId); - if (!Boolean.TRUE.equals(isAutoAllocationEnabled)) { - throw new CloudRuntimeException("CIDR auto-allocation is disabled for this account"); + throw new InvalidParameterValueException("network/vpc CidrSize is null"); } } @@ -755,7 +769,7 @@ public class RoutedIpv4ManagerImpl extends ComponentLifecycleBase implements Rou // Allocate a subnet automatically String networkCidr = getFreeNetworkCidr(subnetsInFreeIpRanges, networkCidrSize); if (networkCidr == null) { - throw new CloudRuntimeException("Failed to automatically allocate a subnet with specified cidrsize"); + throw new InvalidParameterValueException("Failed to automatically allocate a subnet with specified cidrsize"); } return networkCidr; } diff --git a/server/src/main/java/org/apache/cloudstack/storage/NfsMountManagerImpl.java b/server/src/main/java/org/apache/cloudstack/storage/NfsMountManagerImpl.java index 0d59a6e3a85..f06adac54ef 100644 --- a/server/src/main/java/org/apache/cloudstack/storage/NfsMountManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/storage/NfsMountManagerImpl.java @@ -97,7 +97,6 @@ public class NfsMountManagerImpl implements NfsMountManager { if (nfsVersion != null){ command.add("-o", "vers=" + nfsVersion); } - // command.add("-o", "soft,timeo=133,retrans=2147483647,tcp,acdirmax=0,acdirmin=0"); if ("Mac OS X".equalsIgnoreCase(System.getProperty("os.name"))) { command.add("-o", "resvport"); } diff --git a/server/src/main/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImpl.java b/server/src/main/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImpl.java index 9e1fc46e02e..383644f9aa2 100644 --- a/server/src/main/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImpl.java @@ -452,7 +452,7 @@ public class VolumeImportUnmanageManagerImpl implements VolumeImportUnmanageServ Account owner, StoragePoolVO pool, String volumeName) { DiskProfile diskProfile = volumeManager.importVolume(Volume.Type.DATADISK, volumeName, diskOffering, volume.getVirtualSize(), null, null, pool.getDataCenterId(), volume.getHypervisorType(), null, null, - owner, null, pool.getId(), volume.getPath(), null); + owner, null, pool.getId(), pool.getPoolType(), volume.getPath(), null); return volumeDao.findById(diskProfile.getVolumeId()); } diff --git a/server/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManagerImpl.java new file mode 100644 index 00000000000..7294ec051ea --- /dev/null +++ b/server/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManagerImpl.java @@ -0,0 +1,248 @@ +// 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.vm; + +import com.cloud.dc.DataCenter; +import com.cloud.dc.DataCenterVO; +import com.cloud.dc.dao.DataCenterDao; +import com.cloud.host.Host; +import com.cloud.host.HostVO; +import com.cloud.host.dao.HostDao; +import com.cloud.user.Account; +import com.cloud.user.AccountService; +import com.cloud.utils.DateUtil; +import com.cloud.utils.Pair; +import com.cloud.vm.ImportVMTaskVO; +import com.cloud.vm.UserVmVO; +import com.cloud.vm.dao.ImportVMTaskDao; +import com.cloud.vm.dao.UserVmDao; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.admin.vm.ListImportVMTasksCmd; +import org.apache.cloudstack.api.response.ImportVMTaskResponse; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.inject.Inject; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; + +import static org.apache.cloudstack.vm.ImportVmTask.Step.CloningInstance; +import static org.apache.cloudstack.vm.ImportVmTask.Step.Completed; +import static org.apache.cloudstack.vm.ImportVmTask.Step.ConvertingInstance; +import static org.apache.cloudstack.vm.ImportVmTask.Step.Importing; +import static org.apache.cloudstack.vm.ImportVmTask.Step.Prepare; + +public class ImportVmTasksManagerImpl implements ImportVmTasksManager { + + protected Logger logger = LogManager.getLogger(ImportVmTasksManagerImpl.class); + + @Inject + private ImportVMTaskDao importVMTaskDao; + @Inject + private DataCenterDao dataCenterDao; + @Inject + private AccountService accountService; + @Inject + private HostDao hostDao; + @Inject + private UserVmDao userVmDao; + + public ImportVmTasksManagerImpl() { + } + + @Override + public ListResponse listImportVMTasks(ListImportVMTasksCmd cmd) { + Long zoneId = cmd.getZoneId(); + Long accountId = cmd.getAccountId(); + String vcenter = cmd.getVcenter(); + Long convertHostId = cmd.getConvertHostId(); + Long startIndex = cmd.getStartIndex(); + Long pageSizeVal = cmd.getPageSizeVal(); + + ImportVmTask.TaskState state = getStateFromFilter(cmd.getTasksFilter()); + Pair, Integer> result = importVMTaskDao.listImportVMTasks(zoneId, accountId, vcenter, convertHostId, state, startIndex, pageSizeVal); + List tasks = result.first(); + + List responses = new ArrayList<>(); + for (ImportVMTaskVO task : tasks) { + responses.add(createImportVMTaskResponse(task)); + } + ListResponse listResponses = new ListResponse<>(); + listResponses.setResponses(responses, result.second()); + return listResponses; + } + + private ImportVmTask.TaskState getStateFromFilter(String tasksFilter) { + if (StringUtils.isBlank(tasksFilter) || tasksFilter.equalsIgnoreCase("all")) { + return null; + } + try { + return ImportVmTask.TaskState.getValue(tasksFilter); + } catch (IllegalArgumentException e) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Invalid value for task state: %s", tasksFilter)); + } + } + + @Override + public ImportVmTask createImportVMTaskRecord(DataCenter zone, Account owner, long userId, String displayName, String vcenter, String datacenterName, String sourceVMName, Host convertHost, Host importHost) { + logger.debug("Creating import VM task entry for VM: {} for account {} on zone {} " + + "from the vCenter: {} / datacenter: {} / source VM: {}", + sourceVMName, owner.getAccountName(), zone.getName(), displayName, vcenter, datacenterName); + ImportVMTaskVO importVMTaskVO = new ImportVMTaskVO(zone.getId(), owner.getAccountId(), userId, displayName, + vcenter, datacenterName, sourceVMName, convertHost.getId(), importHost.getId()); + importVMTaskVO.setState(ImportVmTask.TaskState.Running); + return importVMTaskDao.persist(importVMTaskVO); + } + + private String getStepDescription(ImportVMTaskVO importVMTaskVO, Host convertHost, Host importHost, + ImportVMTaskVO.Step step, Date updatedDate) { + String sourceVMName = importVMTaskVO.getSourceVMName(); + String vcenter = importVMTaskVO.getVcenter(); + String datacenter = importVMTaskVO.getDatacenter(); + + StringBuilder stringBuilder = new StringBuilder(); + if (Completed == step) { + stringBuilder.append("Completed at ").append(DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), updatedDate)); + } else { + if (CloningInstance == step) { + stringBuilder.append(String.format("Cloning source instance: %s on vCenter: %s / datacenter: %s", sourceVMName, vcenter, datacenter)); + } else if (ConvertingInstance == step) { + stringBuilder.append(String.format("Converting the cloned VMware instance to a KVM instance on the host: %s", convertHost.getName())); + } else if (Importing == step) { + stringBuilder.append(String.format("Importing the converted KVM instance on the host: %s", importHost.getName())); + } else if (Prepare == step) { + stringBuilder.append("Preparing to convert Vmware instance"); + } + } + return stringBuilder.toString(); + } + + @Override + public void updateImportVMTaskStep(ImportVmTask importVMTask, DataCenter zone, Account owner, Host convertHost, + Host importHost, Long vmId, ImportVmTask.Step step) { + ImportVMTaskVO importVMTaskVO = (ImportVMTaskVO) importVMTask; + logger.debug("Updating import VM task entry for VM: {} for account {} on zone {} " + + "from the vCenter: {} / datacenter: {} / source VM: {} to step: {}", + importVMTaskVO.getSourceVMName(), owner.getAccountName(), zone.getName(), importVMTaskVO.getDisplayName(), + importVMTaskVO.getVcenter(), importVMTaskVO.getDatacenter(), step); + Date updatedDate = DateUtil.now(); + String description = getStepDescription(importVMTaskVO, convertHost, importHost, step, updatedDate); + importVMTaskVO.setStep(step); + importVMTaskVO.setDescription(description); + importVMTaskVO.setUpdated(updatedDate); + if (Completed == step) { + Duration duration = Duration.between(importVMTaskVO.getCreated().toInstant(), updatedDate.toInstant()); + importVMTaskVO.setDuration(duration.toMillis()); + importVMTaskVO.setVmId(vmId); + importVMTaskVO.setState(ImportVmTask.TaskState.Completed); + } + importVMTaskDao.update(importVMTaskVO.getId(), importVMTaskVO); + } + + @Override + public void updateImportVMTaskErrorState(ImportVmTask importVMTask, ImportVmTask.TaskState state, String errorMsg) { + ImportVMTaskVO importVMTaskVO = (ImportVMTaskVO) importVMTask; + Date updatedDate = DateUtil.now(); + importVMTaskVO.setUpdated(updatedDate); + importVMTaskVO.setState(state); + importVMTaskVO.setDescription(errorMsg); + importVMTaskDao.update(importVMTaskVO.getId(), importVMTaskVO); + } + + private ImportVMTaskResponse createImportVMTaskResponse(ImportVMTaskVO task) { + ImportVMTaskResponse response = new ImportVMTaskResponse(); + DataCenterVO zone = dataCenterDao.findById(task.getZoneId()); + if (zone != null) { + response.setZoneId(zone.getUuid()); + response.setZoneName(zone.getName()); + } + Account account = accountService.getAccount(task.getAccountId()); + if (account != null) { + response.setAccountId(account.getUuid()); + response.setAccountName(account.getAccountName()); + } + response.setVcenter(task.getVcenter()); + response.setDatacenterName(task.getDatacenter()); + response.setSourceVMName(task.getSourceVMName()); + response.setDisplayName(task.getDisplayName()); + response.setStep(getStepDisplayField(task.getStep())); + response.setDescription(task.getDescription()); + response.setState(task.getState().name()); + + Date updated = task.getUpdated(); + Date currentDate = new Date(); + + if (updated != null) { + if (ImportVmTask.TaskState.Running == task.getState()) { + Duration stepDuration = Duration.between(updated.toInstant(), currentDate.toInstant()); + response.setStepDuration(getDurationDisplay(stepDuration.toMillis())); + } else { + Duration totalDuration = Duration.between(task.getCreated().toInstant(), updated.toInstant()); + response.setDuration(getDurationDisplay(totalDuration.toMillis())); + } + } + + HostVO host = hostDao.findById(task.getConvertHostId()); + if (host != null) { + response.setConvertInstanceHostId(host.getUuid()); + response.setConvertInstanceHostName(host.getName()); + } + if (task.getVmId() != null) { + UserVmVO userVm = userVmDao.findById(task.getVmId()); + if (userVm != null) { + // Migrated VM could have been removed from CloudStack after the migration + response.setVirtualMachineId(userVm.getUuid()); + } + } + response.setCreated(task.getCreated()); + response.setLastUpdated(task.getUpdated()); + response.setObjectName("importvmtask"); + return response; + } + + protected String getStepDisplayField(ImportVMTaskVO.Step step) { + int totalSteps = ImportVMTaskVO.Step.values().length; + return String.format("[%s/%s] %s", step.ordinal() + 1, totalSteps, step.name()); + } + + protected static String getDurationDisplay(Long durationMs) { + if (durationMs == null) { + return null; + } + long hours = durationMs / (1000 * 60 * 60); + long minutes = (durationMs / (1000 * 60)) % 60; + long seconds = (durationMs / 1000) % 60; + + StringBuilder result = new StringBuilder(); + if (hours > 0) { + result.append(String.format("%s hs ", hours)); + } + if (minutes > 0) { + result.append(String.format("%s min ", minutes)); + } + if (seconds > 0) { + result.append(String.format("%s secs", seconds)); + } + return result.toString(); + } +} diff --git a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java index 9f38182e4d5..13fa2608016 100644 --- a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java @@ -71,7 +71,6 @@ import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor; import com.cloud.hypervisor.HypervisorGuru; import com.cloud.hypervisor.HypervisorGuruManager; -import com.cloud.network.IpAddressManager; import com.cloud.network.Network; import com.cloud.network.NetworkModel; import com.cloud.network.Networks; @@ -122,6 +121,7 @@ import com.cloud.user.dao.UserDao; import com.cloud.uservm.UserVm; import com.cloud.utils.LogUtils; import com.cloud.utils.Pair; +import com.cloud.utils.UuidUtils; import com.cloud.utils.db.EntityManager; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; @@ -150,6 +150,7 @@ import org.apache.cloudstack.api.ResponseObject; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.command.admin.vm.ImportUnmanagedInstanceCmd; import org.apache.cloudstack.api.command.admin.vm.ImportVmCmd; +import org.apache.cloudstack.api.command.admin.vm.ListImportVMTasksCmd; import org.apache.cloudstack.api.command.admin.vm.ListUnmanagedInstancesCmd; import org.apache.cloudstack.api.command.admin.vm.ListVmsForImportCmd; import org.apache.cloudstack.api.command.admin.vm.UnmanageVMInstanceCmd; @@ -173,6 +174,8 @@ import org.apache.cloudstack.storage.volume.VolumeOnStorageTO; import org.apache.cloudstack.utils.volume.VirtualMachineDiskInfo; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -180,7 +183,9 @@ import org.apache.logging.log4j.Logger; import javax.inject.Inject; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -190,6 +195,10 @@ import java.util.stream.Collectors; import static org.apache.cloudstack.api.ApiConstants.MAX_IOPS; import static org.apache.cloudstack.api.ApiConstants.MIN_IOPS; +import static org.apache.cloudstack.vm.ImportVmTask.Step.CloningInstance; +import static org.apache.cloudstack.vm.ImportVmTask.Step.Completed; +import static org.apache.cloudstack.vm.ImportVmTask.Step.ConvertingInstance; +import static org.apache.cloudstack.vm.ImportVmTask.Step.Importing; public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { public static final String VM_IMPORT_DEFAULT_TEMPLATE_NAME = "system-default-vm-import-dummy-template.iso"; @@ -198,6 +207,28 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { private static final List importUnmanagedInstancesSupportedHypervisors = Arrays.asList(Hypervisor.HypervisorType.VMware, Hypervisor.HypervisorType.KVM); + private static final List forceConvertToPoolAllowedTypes = + Arrays.asList(Storage.StoragePoolType.NetworkFilesystem, Storage.StoragePoolType.Filesystem, + Storage.StoragePoolType.SharedMountPoint); + + ConfigKey ConvertVmwareInstanceToKvmExtraParamsAllowed = new ConfigKey<>(Boolean.class, + "convert.vmware.instance.to.kvm.extra.params.allowed", + "Advanced", + "false", + "Disabled by default. If enabled, allows extra parameters to be passed to the virt-v2v binary on KVM conversion hosts", + true, + ConfigKey.Scope.Global, + null); + + ConfigKey ConvertVmwareInstanceToKvmExtraParamsAllowedList = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, + String.class, + "convert.vmware.instance.to.kvm.extra.params.allowed.list", + "", + "Comma separated list of allowed extra parameters to be passed to the virt-v2v binary on KVM conversion hosts", + true, + ConfigKey.Kind.CSV, + null); + @Inject private AgentManager agentManager; @Inject @@ -271,8 +302,6 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { @Inject private PhysicalNetworkDao physicalNetworkDao; @Inject - private IpAddressManager ipAddressManager; - @Inject private StoragePoolHostDao storagePoolHostDao; @Inject private HypervisorGuruManager hypervisorGuruManager; @@ -282,6 +311,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { private ImageStoreDao imageStoreDao; @Inject private DataStoreManager dataStoreManager; + @Inject + private ImportVmTasksManager importVmTasksManager; protected Gson gson; @@ -557,11 +588,12 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { } if (storagePool == null) { - List pools = primaryDataStoreDao.listPoolsByCluster(cluster.getId()); + Set pools = new HashSet<>(primaryDataStoreDao.listPoolsByCluster(cluster.getId())); pools.addAll(primaryDataStoreDao.listByDataCenterId(zone.getId())); + boolean isNameUuid = StringUtils.isNotBlank(dsName) && UuidUtils.isUuid(dsName); for (StoragePool pool : pools) { String searchPoolParam = StringUtils.isNotBlank(dsPath) ? dsPath : dsName; - if (StringUtils.contains(pool.getPath(), searchPoolParam) && + if ((StringUtils.contains(pool.getPath(), searchPoolParam) || isNameUuid && pool.getUuid().equals(dsName)) && volumeApiService.doesStoragePoolSupportDiskOffering(pool, diskOffering)) { storagePool = pool; break; @@ -820,7 +852,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { } diskProfile.setSize(copyRemoteVolumeAnswer.getSize()); DiskProfile profile = volumeManager.updateImportedVolume(type, diskOffering, vm, template, deviceId, - storagePool.getId(), copyRemoteVolumeAnswer.getFilename(), chainInfo, diskProfile); + storagePool.getId(), storagePool.getPoolType(), copyRemoteVolumeAnswer.getFilename(), chainInfo, diskProfile); return new Pair<>(profile, storagePool); } @@ -836,7 +868,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { StoragePool storagePool = storagePools.get(0); DiskProfile profile = volumeManager.updateImportedVolume(type, diskOffering, vm, template, deviceId, - storagePool.getId(), diskPath, null, diskProfile); + storagePool.getId(), storagePool.getPoolType(), diskPath, null, diskProfile); return new Pair<>(profile, storagePool); } @@ -847,7 +879,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { StoragePool storagePool = primaryDataStoreDao.findById(poolId); DiskProfile profile = volumeManager.updateImportedVolume(type, diskOffering, vm, template, deviceId, - poolId, diskPath, null, diskProfile); + poolId, storagePool.getPoolType(), diskPath, null, diskProfile); return new Pair<>(profile, storagePool); } @@ -866,7 +898,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { } StoragePool storagePool = getStoragePool(disk, zone, cluster, diskOffering); DiskProfile profile = volumeManager.importVolume(type, name, diskOffering, diskSize, - minIops, maxIops, vm.getDataCenterId(), vm.getHypervisorType(), vm, template, owner, deviceId, storagePool.getId(), path, chainInfo); + minIops, maxIops, vm.getDataCenterId(), vm.getHypervisorType(), vm, template, owner, deviceId, storagePool.getId(), storagePool.getPoolType(), path, chainInfo); return new Pair(profile, storagePool); } @@ -1418,6 +1450,33 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { return responseGenerator.createUserVmResponse(ResponseObject.ResponseView.Full, "virtualmachine", userVm).get(0); } + protected void checkExtraParamsAllowed(String extraParams) { + if (StringUtils.isBlank(extraParams)) { + return; + } + if (BooleanUtils.isFalse(ConvertVmwareInstanceToKvmExtraParamsAllowed.value())) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, + "Extra parameters for Vmware to KVM conversion are disabled by the administrator"); + } + String allowedParamsStr = ConvertVmwareInstanceToKvmExtraParamsAllowedList.value(); + if (StringUtils.isBlank(allowedParamsStr)) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, + "Extra parameters for Vmware to KVM conversion are enabled but the allowed list of parameters is empty"); + } + List allowedParams = Arrays.asList(allowedParamsStr.split(",")); + List sanitizedParams = Arrays.asList(extraParams.split(" ")) + .stream() + .filter(x -> x.startsWith("-")) + .map(s -> s.replaceFirst("^-+", "").trim()) //Remove the starting hyphens as in --X or -x + .collect(Collectors.toList()); + for (String param : sanitizedParams) { + if (!allowedParams.contains(param)) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, + String.format("The parameter %s is not allowed by the administrator", param)); + } + } + } + private long getUserIdForImportInstance(Account owner) { long userId = CallContext.current().getCallingUserId(); List userVOs = userDao.listByAccount(owner.getAccountId()); @@ -1513,6 +1572,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { String source = cmd.getImportSource().toUpperCase(); ImportSource importSource = Enum.valueOf(ImportSource.class, source); if (ImportSource.VMWARE == importSource || ImportSource.UNMANAGED == importSource) { + checkExtraParamsAllowed(cmd.getExtraParams()); return baseImportInstance(cmd); } else { return importKvmInstance(cmd); @@ -1584,16 +1644,45 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { } private Pair getSourceVmwareUnmanagedInstance(String vcenter, String datacenterName, String username, - String password, String clusterName, String sourceHostName, - String sourceVM) { + String password, String clusterName, String sourceHostName, + String sourceVM, ServiceOfferingVO serviceOffering) { HypervisorGuru vmwareGuru = hypervisorGuruManager.getGuru(Hypervisor.HypervisorType.VMware); Map params = createParamsForTemplateFromVmwareVmMigration(vcenter, datacenterName, username, password, clusterName, sourceHostName, sourceVM); + addServiceOfferingDetailsToParams(params, serviceOffering); return vmwareGuru.getHypervisorVMOutOfBandAndCloneIfRequired(sourceHostName, sourceVM, params); } + /** + * Add the minimum resources to check on the hypervisor source VM before converting the instance against the selected offering resources + * @param params sets the minimum CPU number, CPU speed and memory to be checked against the source VM + * @param serviceOffering service offering for the converted VM + */ + protected void addServiceOfferingDetailsToParams(Map params, ServiceOfferingVO serviceOffering) { + if (serviceOffering != null) { + serviceOfferingDao.loadDetails(serviceOffering); + Map serviceOfferingDetails = serviceOffering.getDetails(); + + if (serviceOffering.getCpu() != null) { + params.put(VmDetailConstants.CPU_NUMBER, String.valueOf(serviceOffering.getCpu())); + } else if (MapUtils.isNotEmpty(serviceOfferingDetails) && serviceOfferingDetails.containsKey(ApiConstants.MIN_CPU_NUMBER)) { + params.put(VmDetailConstants.CPU_NUMBER, serviceOfferingDetails.get(ApiConstants.MIN_CPU_NUMBER)); + } + + if (serviceOffering.getSpeed() != null) { + params.put(VmDetailConstants.CPU_SPEED, String.valueOf(serviceOffering.getSpeed())); + } + + if (serviceOffering.getRamSize() != null) { + params.put(VmDetailConstants.MEMORY, String.valueOf(serviceOffering.getRamSize())); + } else if (MapUtils.isNotEmpty(serviceOfferingDetails) && serviceOfferingDetails.containsKey(ApiConstants.MIN_MEMORY)) { + params.put(VmDetailConstants.MEMORY, serviceOfferingDetails.get(ApiConstants.MIN_MEMORY)); + } + } + } + private String createOvfTemplateOfSourceVmwareUnmanagedInstance(String vcenter, String datacenterName, String username, String password, String clusterName, String sourceHostName, String sourceVMwareInstanceName, DataStoreTO convertLocation, int threadsCountToExportOvf) { @@ -1621,6 +1710,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { Long convertInstanceHostId = cmd.getConvertInstanceHostId(); Long importInstanceHostId = cmd.getImportInstanceHostId(); Long convertStoragePoolId = cmd.getConvertStoragePoolId(); + String extraParams = cmd.getExtraParams(); + boolean forceConvertToPool = cmd.getForceConvertToPool(); if ((existingVcenterId == null && vcenter == null) || (existingVcenterId != null && vcenter != null)) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, @@ -1631,6 +1722,10 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { "Please set all the information for a vCenter IP/Name, datacenter, username and password"); } + checkConversionStoragePool(convertStoragePoolId, forceConvertToPool); + + checkExtraParamsAllowed(extraParams); + if (existingVcenterId != null) { VmwareDatacenterVO existingDC = vmwareDatacenterDao.findById(existingVcenterId); if (existingDC == null) { @@ -1648,6 +1743,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { UnmanagedInstanceTO sourceVMwareInstance = null; DataStoreTO temporaryConvertLocation = null; String ovfTemplateOnConvertLocation = null; + ImportVmTask importVMTask = null; try { HostVO convertHost = selectKVMHostForConversionInCluster(destinationCluster, convertInstanceHostId); HostVO importHost = selectKVMHostForImportingInCluster(destinationCluster, importInstanceHostId); @@ -1656,12 +1752,21 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { "instance {} from VMware to KVM ", convertHost, sourceVMName); temporaryConvertLocation = selectInstanceConversionTemporaryLocation( - destinationCluster, convertHost, convertStoragePoolId); - List convertStoragePools = findInstanceConversionStoragePoolsInCluster(destinationCluster, serviceOffering, dataDiskOfferingMap); + destinationCluster, convertHost, importHost, convertStoragePoolId, forceConvertToPool); + List convertStoragePools = findInstanceConversionDestinationStoragePoolsInCluster(destinationCluster, serviceOffering, dataDiskOfferingMap, temporaryConvertLocation, forceConvertToPool); + long importStartTime = System.currentTimeMillis(); - Pair sourceInstanceDetails = getSourceVmwareUnmanagedInstance(vcenter, datacenterName, username, password, clusterName, sourceHostName, sourceVMName); + importVMTask = importVmTasksManager.createImportVMTaskRecord(zone, owner, userId, displayName, vcenter, datacenterName, sourceVMName, + convertHost, importHost); + importVmTasksManager.updateImportVMTaskStep(importVMTask, zone, owner, convertHost, importHost, null, CloningInstance); + + // sourceVMwareInstance could be a cloned instance from sourceVMName, of the sourceVMName itself if its powered off. + // isClonedInstance indicates if the VM is a clone of sourceVMName + + Pair sourceInstanceDetails = getSourceVmwareUnmanagedInstance(vcenter, datacenterName, username, password, clusterName, sourceHostName, sourceVMName, serviceOffering); sourceVMwareInstance = sourceInstanceDetails.first(); isClonedInstance = sourceInstanceDetails.second(); + boolean isWindowsVm = sourceVMwareInstance.getOperatingSystem().toLowerCase().contains("windows"); if (isWindowsVm) { checkConversionSupportOnHost(convertHost, sourceVMName, true); @@ -1672,22 +1777,25 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { if (cmd.getForceMsToImportVmFiles() || !conversionSupportAnswer.isOvfExportSupported()) { // Uses MS for OVF export to temporary conversion location int noOfThreads = UnmanagedVMsManager.ThreadsOnMSToImportVMwareVMFiles.value(); + importVmTasksManager.updateImportVMTaskStep(importVMTask, zone, owner, convertHost, importHost, null, ConvertingInstance); ovfTemplateOnConvertLocation = createOvfTemplateOfSourceVmwareUnmanagedInstance( vcenter, datacenterName, username, password, clusterName, sourceHostName, sourceVMwareInstance.getName(), temporaryConvertLocation, noOfThreads); convertedInstance = convertVmwareInstanceToKVMWithOVFOnConvertLocation(sourceVMName, sourceVMwareInstance, convertHost, importHost, convertStoragePools, serviceOffering, dataDiskOfferingMap, temporaryConvertLocation, - ovfTemplateOnConvertLocation); + ovfTemplateOnConvertLocation, forceConvertToPool, extraParams); } else { // Uses KVM Host for OVF export to temporary conversion location, through ovftool + importVmTasksManager.updateImportVMTaskStep(importVMTask, zone, owner, convertHost, importHost, null, ConvertingInstance); convertedInstance = convertVmwareInstanceToKVMAfterExportingOVFToConvertLocation( sourceVMName, sourceVMwareInstance, convertHost, importHost, convertStoragePools, serviceOffering, dataDiskOfferingMap, - temporaryConvertLocation, vcenter, username, password, datacenterName); + temporaryConvertLocation, vcenter, username, password, datacenterName, forceConvertToPool, extraParams); } sanitizeConvertedInstance(convertedInstance, sourceVMwareInstance); + importVmTasksManager.updateImportVMTaskStep(importVMTask, zone, owner, convertHost, importHost, null, Importing); UserVm userVm = importVirtualMachineInternal(convertedInstance, null, zone, destinationCluster, null, template, displayName, hostName, caller, owner, userId, serviceOffering, dataDiskOfferingMap, @@ -1696,9 +1804,11 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { long timeElapsedInSecs = (System.currentTimeMillis() - importStartTime) / 1000; logger.debug(String.format("VMware VM %s imported successfully to CloudStack instance %s (%s), Time taken: %d secs, OVF files imported from %s, Source VMware VM details - OS: %s, PowerState: %s, Disks: %s, NICs: %s", sourceVMName, displayName, displayName, timeElapsedInSecs, (ovfTemplateOnConvertLocation != null)? "MS" : "KVM Host", sourceVMwareInstance.getOperatingSystem(), sourceVMwareInstance.getPowerState(), sourceVMwareInstance.getDisks(), sourceVMwareInstance.getNics())); + importVmTasksManager.updateImportVMTaskStep(importVMTask, zone, owner, convertHost, importHost, userVm.getId(), Completed); return userVm; } catch (CloudRuntimeException e) { logger.error(String.format("Error importing VM: %s", e.getMessage()), e); + importVmTasksManager.updateImportVMTaskErrorState(importVMTask, ImportVmTask.TaskState.Failed, e.getMessage()); ActionEventUtils.onCompletedActionEvent(userId, owner.getId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_IMPORT, cmd.getEventDescription(), null, null, 0); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); @@ -1712,6 +1822,30 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { } } + /** + * Check whether the conversion storage pool exists and is suitable for the conversion or not. + * Secondary storage is only allowed when forceConvertToPool is false. + * @param convertStoragePoolId the ID of the storage pool (primary or secondary) + * @param forceConvertToPool when true, only primary storage pool must be allowed + * @throws CloudRuntimeException in case these requirements are not met + */ + protected void checkConversionStoragePool(Long convertStoragePoolId, boolean forceConvertToPool) { + if (forceConvertToPool && convertStoragePoolId == null) { + String msg = "The parameter forceconverttopool is set to true, but a primary storage pool has not been provided for conversion"; + logFailureAndThrowException(msg); + } + if (convertStoragePoolId != null) { + StoragePoolVO selectedStoragePool = primaryDataStoreDao.findById(convertStoragePoolId); + if (selectedStoragePool == null) { + logFailureAndThrowException(String.format("Cannot find a storage pool with ID %s", convertStoragePoolId)); + } + if (forceConvertToPool && !forceConvertToPoolAllowedTypes.contains(selectedStoragePool.getPoolType())) { + logFailureAndThrowException(String.format("The selected storage pool %s does not support direct conversion " + + "as its type %s", selectedStoragePool.getName(), selectedStoragePool.getPoolType().name())); + } + } + } + private void checkNetworkingBeforeConvertingVmwareInstance(DataCenter zone, Account owner, String displayName, String hostName, UnmanagedInstanceTO sourceVMwareInstance, Map nicNetworkMap, @@ -1953,20 +2087,25 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { String sourceVM, UnmanagedInstanceTO sourceVMwareInstance, HostVO convertHost, HostVO importHost, List convertStoragePools, ServiceOfferingVO serviceOffering, Map dataDiskOfferingMap, - DataStoreTO temporaryConvertLocation, String ovfTemplateDirConvertLocation - ) { - logger.debug("Delegating the conversion of instance {} from VMware to KVM to the host {} using OVF {} on conversion datastore", - sourceVM, convertHost, ovfTemplateDirConvertLocation); + DataStoreTO temporaryConvertLocation, String ovfTemplateDirConvertLocation, + boolean forceConvertToPool, String extraParams) { + + logger.debug("Delegating the conversion of instance {} from VMware to KVM to the host {} using OVF {} on conversion datastore", + sourceVM, convertHost, ovfTemplateDirConvertLocation); RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVM); List destinationStoragePools = selectInstanceConversionStoragePools(convertStoragePools, sourceVMwareInstance.getDisks(), serviceOffering, dataDiskOfferingMap); ConvertInstanceCommand cmd = new ConvertInstanceCommand(remoteInstanceTO, - Hypervisor.HypervisorType.KVM, temporaryConvertLocation, ovfTemplateDirConvertLocation, false, false); + Hypervisor.HypervisorType.KVM, temporaryConvertLocation, + ovfTemplateDirConvertLocation, false, false, sourceVM); + if (StringUtils.isNotBlank(extraParams)) { + cmd.setExtraParams(extraParams); + } int timeoutSeconds = UnmanagedVMsManager.ConvertVmwareInstanceToKvmTimeout.value() * 60 * 60; cmd.setWait(timeoutSeconds); return convertAndImportToKVM(cmd, convertHost, importHost, sourceVM, - remoteInstanceTO, destinationStoragePools, temporaryConvertLocation); + remoteInstanceTO, destinationStoragePools, temporaryConvertLocation, forceConvertToPool); } private UnmanagedInstanceTO convertVmwareInstanceToKVMAfterExportingOVFToConvertLocation( @@ -1974,14 +2113,13 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { HostVO importHost, List convertStoragePools, ServiceOfferingVO serviceOffering, Map dataDiskOfferingMap, DataStoreTO temporaryConvertLocation, String vcenterHost, String vcenterUsername, - String vcenterPassword, String datacenterName - ) { + String vcenterPassword, String datacenterName, boolean forceConvertToPool, String extraParams) { logger.debug("Delegating the conversion of instance {} from VMware to KVM to the host {} after OVF export through ovftool", sourceVM, convertHost); RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVMwareInstance.getName(), sourceVMwareInstance.getPath(), vcenterHost, vcenterUsername, vcenterPassword, datacenterName); List destinationStoragePools = selectInstanceConversionStoragePools(convertStoragePools, sourceVMwareInstance.getDisks(), serviceOffering, dataDiskOfferingMap); ConvertInstanceCommand cmd = new ConvertInstanceCommand(remoteInstanceTO, - Hypervisor.HypervisorType.KVM, temporaryConvertLocation, null, false, true); + Hypervisor.HypervisorType.KVM, temporaryConvertLocation, null, false, true, sourceVM); int timeoutSeconds = UnmanagedVMsManager.ConvertVmwareInstanceToKvmTimeout.value() * 60 * 60; cmd.setWait(timeoutSeconds); int noOfThreads = UnmanagedVMsManager.ThreadsOnKVMHostToImportVMwareVMFiles.value(); @@ -1990,16 +2128,19 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { noOfThreads = sourceVMwareInstance.getDisks().size(); } cmd.setThreadsCountToExportOvf(noOfThreads); - + if (StringUtils.isNotBlank(extraParams)) { + cmd.setExtraParams(extraParams); + } return convertAndImportToKVM(cmd, convertHost, importHost, sourceVM, - remoteInstanceTO, destinationStoragePools, temporaryConvertLocation); + remoteInstanceTO, destinationStoragePools, temporaryConvertLocation, forceConvertToPool); } private UnmanagedInstanceTO convertAndImportToKVM(ConvertInstanceCommand convertInstanceCommand, HostVO convertHost, HostVO importHost, String sourceVM, RemoteInstanceTO remoteInstanceTO, List destinationStoragePools, - DataStoreTO temporaryConvertLocation) { + DataStoreTO temporaryConvertLocation, + boolean forceConvertToPool) { Answer convertAnswer; try { convertAnswer = agentManager.send(convertHost.getId(), convertInstanceCommand); @@ -2021,7 +2162,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { try { ImportConvertedInstanceCommand importCmd = new ImportConvertedInstanceCommand( remoteInstanceTO, destinationStoragePools, temporaryConvertLocation, - ((ConvertInstanceAnswer)convertAnswer).getTemporaryConvertUuid()); + ((ConvertInstanceAnswer)convertAnswer).getTemporaryConvertUuid(), forceConvertToPool); importAnswer = agentManager.send(importHost.getId(), importCmd); } catch (AgentUnavailableException | OperationTimedoutException e) { String err = String.format( @@ -2042,17 +2183,23 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { return ((ImportConvertedInstanceAnswer) importAnswer).getConvertedInstance(); } - private List findInstanceConversionStoragePoolsInCluster( + private List findInstanceConversionDestinationStoragePoolsInCluster( Cluster destinationCluster, ServiceOfferingVO serviceOffering, - Map dataDiskOfferingMap - ) { - List pools = new ArrayList<>(); - pools.addAll(primaryDataStoreDao.findClusterWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem)); - pools.addAll(primaryDataStoreDao.findZoneWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getDataCenterId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem)); - if (pools.isEmpty()) { - String msg = String.format("Cannot find suitable storage pools in the cluster %s for the conversion", destinationCluster.getName()); - logger.error(msg); - throw new CloudRuntimeException(msg); + Map dataDiskOfferingMap, + DataStoreTO temporaryConvertLocation, boolean forceConvertToPool) { + List poolsList; + if (!forceConvertToPool) { + Set pools = new HashSet<>(primaryDataStoreDao.findClusterWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem)); + pools.addAll(primaryDataStoreDao.findZoneWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getDataCenterId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem)); + if (pools.isEmpty()) { + String msg = String.format("Cannot find suitable storage pools in the cluster %s for the conversion", destinationCluster.getName()); + logger.error(msg); + throw new CloudRuntimeException(msg); + } + poolsList = new ArrayList<>(pools); + } else { + DataStore dataStore = dataStoreManager.getDataStore(temporaryConvertLocation.getUuid(), temporaryConvertLocation.getRole()); + poolsList = Collections.singletonList(primaryDataStoreDao.findById(dataStore.getId())); } if (serviceOffering.getDiskOfferingId() != null) { @@ -2062,7 +2209,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { logger.error(msg); throw new CloudRuntimeException(msg); } - if (getStoragePoolWithTags(pools, diskOffering.getTags()) == null) { + if (getStoragePoolWithTags(poolsList, diskOffering.getTags()) == null) { String msg = String.format("Cannot find suitable storage pool for disk offering %s that belongs to the service offering %s", diskOffering.getName(), serviceOffering.getName()); logger.error(msg); throw new CloudRuntimeException(msg); @@ -2075,14 +2222,14 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { logger.error(msg); throw new CloudRuntimeException(msg); } - if (getStoragePoolWithTags(pools, diskOffering.getTags()) == null) { + if (getStoragePoolWithTags(poolsList, diskOffering.getTags()) == null) { String msg = String.format("Cannot find suitable storage pool for disk offering %s", diskOffering.getName()); logger.error(msg); throw new CloudRuntimeException(msg); } } - return pools; + return poolsList; } private StoragePoolVO getStoragePoolWithTags(List pools, String tags) { @@ -2128,39 +2275,63 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { throw new CloudRuntimeException(msg); } - protected DataStoreTO selectInstanceConversionTemporaryLocation(Cluster destinationCluster, - HostVO convertHost, - Long convertStoragePoolId) { - if (convertStoragePoolId != null) { - StoragePoolVO selectedStoragePool = primaryDataStoreDao.findById(convertStoragePoolId); - if (selectedStoragePool == null) { - logFailureAndThrowException(String.format("Cannot find a storage pool with ID %s", convertStoragePoolId)); - } - if ((selectedStoragePool.getScope() == ScopeType.CLUSTER && selectedStoragePool.getClusterId() != destinationCluster.getId()) || - (selectedStoragePool.getScope() == ScopeType.ZONE && selectedStoragePool.getDataCenterId() != destinationCluster.getDataCenterId())) { - logFailureAndThrowException(String.format("Cannot use the storage pool %s for the instance conversion as " + - "it is not in the scope of the cluster %s", selectedStoragePool.getName(), destinationCluster.getName())); - } - if (convertHost != null && selectedStoragePool.getScope() == ScopeType.CLUSTER && !selectedStoragePool.getClusterId().equals(convertHost.getClusterId())) { - logFailureAndThrowException(String.format("Cannot use the storage pool %s for the instance conversion as " + - "the host %s for conversion is in a different cluster", selectedStoragePool.getName(), convertHost.getName())); - } - if (selectedStoragePool.getScope() == ScopeType.HOST) { - logFailureAndThrowException(String.format("The storage pool %s is a local storage pool and not supported for temporary conversion location, cluster and zone wide NFS storage pools are supported", selectedStoragePool.getName())); - } else if (selectedStoragePool.getPoolType() != Storage.StoragePoolType.NetworkFilesystem) { - logFailureAndThrowException(String.format("The storage pool %s is not supported for temporary conversion location, only NFS storage pools are supported", selectedStoragePool.getName())); - } - return dataStoreManager.getPrimaryDataStore(convertStoragePoolId).getTO(); - } else { - long zoneId = destinationCluster.getDataCenterId(); - ImageStoreVO imageStore = imageStoreDao.findOneByZoneAndProtocol(zoneId, "nfs"); - if (imageStore == null) { - logFailureAndThrowException(String.format("Could not find an NFS secondary storage pool on zone %s to use as a temporary location " + - "for instance conversion", zoneId)); - } - DataStore dataStore = dataStoreManager.getDataStore(imageStore.getId(), DataStoreRole.Image); - return dataStore.getTO(); + private void checkBeforeSelectingTemporaryConversionStoragePool(StoragePoolVO selectedStoragePool, Long convertStoragePoolId, Cluster destinationCluster, HostVO convertHost) { + if (selectedStoragePool == null) { + logFailureAndThrowException(String.format("Cannot find a storage pool with ID %s", convertStoragePoolId)); } + if ((selectedStoragePool.getScope() == ScopeType.CLUSTER && selectedStoragePool.getClusterId() != destinationCluster.getId()) || + (selectedStoragePool.getScope() == ScopeType.ZONE && selectedStoragePool.getDataCenterId() != destinationCluster.getDataCenterId())) { + logFailureAndThrowException(String.format("Cannot use the storage pool %s for the instance conversion as " + + "it is not in the scope of the cluster %s", selectedStoragePool.getName(), destinationCluster.getName())); + } + if (convertHost != null && selectedStoragePool.getScope() == ScopeType.CLUSTER && !selectedStoragePool.getClusterId().equals(convertHost.getClusterId())) { + logFailureAndThrowException(String.format("Cannot use the storage pool %s for the instance conversion as " + + "the host %s for conversion is in a different cluster", selectedStoragePool.getName(), convertHost.getName())); + } + } + + private DataStoreTO getImageStoreOnDestinationZoneForTemporaryConversion(Cluster destinationCluster, boolean forceConvertToPool) { + if (forceConvertToPool) { + logFailureAndThrowException("Please select a primary storage pool when the parameter forceconverttopool is set to true"); + } + long zoneId = destinationCluster.getDataCenterId(); + ImageStoreVO imageStore = imageStoreDao.findOneByZoneAndProtocol(zoneId, "nfs"); + if (imageStore == null) { + logFailureAndThrowException(String.format("Could not find an NFS secondary storage pool on zone %s to use as a temporary location " + + "for instance conversion", zoneId)); + } + DataStore dataStore = dataStoreManager.getDataStore(imageStore.getId(), DataStoreRole.Image); + return dataStore.getTO(); + } + + private void checkDestinationOrTemporaryStoragePoolForConversion(StoragePoolVO selectedStoragePool, boolean forceConvertToPool, HostVO convertHost, HostVO importHost) { + if (selectedStoragePool.getScope() == ScopeType.HOST && (ObjectUtils.anyNull(convertHost, importHost) || + ObjectUtils.allNotNull(convertHost, importHost) && convertHost.getId() != importHost.getId() || + !forceConvertToPool) ) { + logFailureAndThrowException("Please select the same host as convert and importing host and " + + "set forceconvertopool to true to use a local storage pool for conversion"); + } + if (!forceConvertToPool && selectedStoragePool.getPoolType() != Storage.StoragePoolType.NetworkFilesystem) { + logFailureAndThrowException(String.format("The storage pool %s is not supported for temporary conversion location," + + "only NFS storage pools are supported when forceconverttopool is set to false", selectedStoragePool.getName())); + } + } + + protected DataStoreTO selectInstanceConversionTemporaryLocation(Cluster destinationCluster, + HostVO convertHost, HostVO importHost, + Long convertStoragePoolId, boolean forceConvertToPool) { + if (convertStoragePoolId == null) { + String msg = String.format("No convert storage pool has been provided, " + + "selecting an NFS secondary storage pool from the destination cluster (%s) zone", destinationCluster.getName()); + logger.debug(msg); + return getImageStoreOnDestinationZoneForTemporaryConversion(destinationCluster, forceConvertToPool); + } + + StoragePoolVO selectedStoragePool = primaryDataStoreDao.findById(convertStoragePoolId); + checkBeforeSelectingTemporaryConversionStoragePool(selectedStoragePool, convertStoragePoolId, destinationCluster, convertHost); + checkDestinationOrTemporaryStoragePoolForConversion(selectedStoragePool, forceConvertToPool, convertHost, importHost); + + return dataStoreManager.getPrimaryDataStore(convertStoragePoolId).getTO(); } protected Map createParamsForTemplateFromVmwareVmMigration(String vcenterHost, String datacenterName, @@ -2186,6 +2357,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { cmdList.add(UnmanageVMInstanceCmd.class); cmdList.add(ListVmsForImportCmd.class); cmdList.add(ImportVmCmd.class); + cmdList.add(ListImportVMTasksCmd.class); return cmdList; } @@ -2620,10 +2792,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { } String macAddress = networkModel.getNextAvailableMacAddressInNetwork(networkId); - String ipAddress = null; - if (network.getGuestType() != Network.GuestType.L2) { - ipAddress = ipAddressManager.acquireGuestIpAddress(network, null); - } + + String ipAddress = network.getGuestType() != Network.GuestType.L2 ? "auto" : null; Network.IpAddresses requestedIpPair = new Network.IpAddresses(ipAddress, null, macAddress); @@ -2865,7 +3035,9 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { RemoteKvmInstanceDisksCopyTimeout, ConvertVmwareInstanceToKvmTimeout, ThreadsOnMSToImportVMwareVMFiles, - ThreadsOnKVMHostToImportVMwareVMFiles + ThreadsOnKVMHostToImportVMwareVMFiles, + ConvertVmwareInstanceToKvmExtraParamsAllowed, + ConvertVmwareInstanceToKvmExtraParamsAllowedList }; } } diff --git a/server/src/main/resources/META-INF/cloudstack/server-compute/spring-server-compute-context.xml b/server/src/main/resources/META-INF/cloudstack/server-compute/spring-server-compute-context.xml index 0215abf44b4..3afae7676b7 100644 --- a/server/src/main/resources/META-INF/cloudstack/server-compute/spring-server-compute-context.xml +++ b/server/src/main/resources/META-INF/cloudstack/server-compute/spring-server-compute-context.xml @@ -37,4 +37,6 @@ + + diff --git a/server/src/test/java/com/cloud/api/APITest.java b/server/src/test/java/com/cloud/api/APITest.java index e76b7a74905..dbe91200027 100644 --- a/server/src/test/java/com/cloud/api/APITest.java +++ b/server/src/test/java/com/cloud/api/APITest.java @@ -187,7 +187,6 @@ public abstract class APITest { * @return login response string */ protected void login(String username, String password) { - //String md5Psw = createMD5String(password); // send login request HashMap params = new HashMap(); params.put("response", "json"); diff --git a/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java b/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java index 223b0740cf2..c0c019f6dbd 100644 --- a/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java +++ b/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java @@ -16,14 +16,6 @@ // under the License. package com.cloud.api; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.lang.reflect.Field; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -37,20 +29,6 @@ import java.util.Set; import java.util.TimeZone; import java.util.UUID; -import org.apache.cloudstack.annotation.dao.AnnotationDao; -import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse; -import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; -import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse; -import org.apache.cloudstack.api.response.GuestOSCategoryResponse; -import org.apache.cloudstack.api.response.IpQuarantineResponse; -import org.apache.cloudstack.api.response.NicSecondaryIpResponse; -import org.apache.cloudstack.api.response.ResourceIconResponse; -import org.apache.cloudstack.api.response.TemplateResponse; -import org.apache.cloudstack.api.response.UnmanagedInstanceResponse; -import org.apache.cloudstack.api.response.UsageRecordResponse; -import org.apache.cloudstack.context.CallContext; -import org.apache.cloudstack.usage.UsageService; -import org.apache.cloudstack.vm.UnmanagedInstanceTO; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -64,10 +42,30 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.util.ReflectionTestUtils; +import org.apache.cloudstack.annotation.dao.AnnotationDao; +import org.apache.cloudstack.api.ResponseObject; +import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse; +import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; +import org.apache.cloudstack.api.response.ConsoleSessionResponse; +import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse; +import org.apache.cloudstack.api.response.GuestOSCategoryResponse; +import org.apache.cloudstack.api.response.IpQuarantineResponse; +import org.apache.cloudstack.api.response.NicSecondaryIpResponse; +import org.apache.cloudstack.api.response.ResourceIconResponse; +import org.apache.cloudstack.api.response.TemplateResponse; +import org.apache.cloudstack.api.response.UnmanagedInstanceResponse; +import org.apache.cloudstack.api.response.UsageRecordResponse; +import org.apache.cloudstack.api.response.TrafficTypeResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.usage.UsageService; +import org.apache.cloudstack.vm.UnmanagedInstanceTO; + import com.cloud.capacity.Capacity; import com.cloud.configuration.Resource; import com.cloud.domain.DomainVO; import com.cloud.host.HostVO; +import com.cloud.network.Networks; +import com.cloud.network.PhysicalNetworkTrafficType; import com.cloud.network.PublicIpQuarantine; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.network.as.AutoScaleVmGroupVO; @@ -78,6 +76,8 @@ import com.cloud.network.dao.IPAddressVO; import com.cloud.network.dao.LoadBalancerVO; import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.dao.NetworkVO; +import com.cloud.network.dao.PhysicalNetworkVO; +import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; import com.cloud.resource.icon.ResourceIconVO; import com.cloud.server.ResourceIcon; import com.cloud.server.ResourceIconManager; @@ -97,8 +97,16 @@ import com.cloud.utils.net.Ip; import com.cloud.vm.ConsoleSessionVO; import com.cloud.vm.NicSecondaryIp; import com.cloud.vm.VMInstanceVO; -import org.apache.cloudstack.api.ResponseObject; -import org.apache.cloudstack.api.response.ConsoleSessionResponse; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + @RunWith(MockitoJUnitRunner.class) public class ApiResponseHelperTest { @@ -417,7 +425,40 @@ public class ApiResponseHelperTest { } } - private UnmanagedInstanceTO getUnmanagedInstaceForTests() { + @Test + public void testCreateTrafficTypeResponse() { + PhysicalNetworkVO pnet = new PhysicalNetworkVO(); + pnet.addIsolationMethod("VXLAN"); + pnet.addIsolationMethod("STT"); + + try (MockedStatic ignored = Mockito.mockStatic(ApiDBUtils.class)) { + when(ApiDBUtils.findPhysicalNetworkById(anyLong())).thenReturn(pnet); + String xenLabel = "xen"; + String kvmLabel = "kvm"; + String vmwareLabel = "vmware"; + String simulatorLabel = "simulator"; + String hypervLabel = "hyperv"; + String ovmLabel = "ovm"; + String vlan = "vlan"; + String trafficType = "Public"; + PhysicalNetworkTrafficType pnetTrafficType = new PhysicalNetworkTrafficTypeVO(pnet.getId(), Networks.TrafficType.getTrafficType(trafficType), xenLabel, kvmLabel, vmwareLabel, simulatorLabel, vlan, hypervLabel, ovmLabel); + + TrafficTypeResponse response = apiResponseHelper.createTrafficTypeResponse(pnetTrafficType); + assertFalse(UUID.fromString(response.getId()).toString().isEmpty()); + assertEquals(response.getphysicalNetworkId(), pnet.getUuid()); + assertEquals(response.getTrafficType(), trafficType); + assertEquals(response.getXenLabel(), xenLabel); + assertEquals(response.getKvmLabel(), kvmLabel); + assertEquals(response.getVmwareLabel(), vmwareLabel); + assertEquals(response.getHypervLabel(), hypervLabel); + assertEquals(response.getOvm3Label(), ovmLabel); + assertEquals(response.getVlan(), vlan); + assertEquals(response.getIsolationMethods(), "VXLAN,STT"); + + } + } + + private UnmanagedInstanceTO getUnmanagedInstanceForTests() { UnmanagedInstanceTO instance = Mockito.mock(UnmanagedInstanceTO.class); Mockito.when(instance.getPowerState()).thenReturn(UnmanagedInstanceTO.PowerState.PowerOff); Mockito.when(instance.getClusterName()).thenReturn("CL1"); @@ -436,7 +477,7 @@ public class ApiResponseHelperTest { @Test public void testCreateUnmanagedInstanceResponseVmwareDcVms() { - UnmanagedInstanceTO instance = getUnmanagedInstaceForTests(); + UnmanagedInstanceTO instance = getUnmanagedInstanceForTests(); UnmanagedInstanceResponse response = apiResponseHelper.createUnmanagedInstanceResponse(instance, null, null); Assert.assertEquals(1, response.getDisks().size()); Assert.assertEquals(1, response.getNics().size()); diff --git a/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java b/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java index 1ffd7967eec..a62f4d113af 100644 --- a/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java +++ b/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java @@ -1028,17 +1028,47 @@ public class ConfigurationManagerImplTest { Map offeringDetails = Map.of("key1", "value1"); Map externalDetails = Collections.emptyMap(); - boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails); + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, false); Assert.assertFalse(result); } + @Test + public void serviceOfferingExternalDetailsNeedUpdateReturnsFalseWhenExternalDetailsIsEmptyAndCleanupTrue() { + Map offeringDetails = Map.of("key1", "value1"); + Map externalDetails = Collections.emptyMap(); + + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, true); + + Assert.assertFalse(result); + } + + @Test + public void serviceOfferingExternalDetailsNeedUpdateReturnsTrueWhenExistingDetailsExistExternalDetailsIsEmptyAndCleanupTrue() { + Map offeringDetails = Map.of("External:key1", "value1"); + Map externalDetails = Collections.emptyMap(); + + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, true); + + Assert.assertTrue(result); + } + + @Test + public void serviceOfferingExternalDetailsNeedUpdateReturnsTrueWhenExistingExternalDetailsExistValidExternalDetailsAndCleanupTrue() { + Map offeringDetails = Map.of("External:key1", "value1"); + Map externalDetails = Collections.emptyMap(); + + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, true); + + Assert.assertTrue(result); + } + @Test public void serviceOfferingExternalDetailsNeedUpdateReturnsTrueWhenExistingExternalDetailsIsEmpty() { Map offeringDetails = Map.of("key1", "value1"); Map externalDetails = Map.of("External:key1", "value1"); - boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails); + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, false); Assert.assertTrue(result); } @@ -1048,7 +1078,7 @@ public class ConfigurationManagerImplTest { Map offeringDetails = Map.of("External:key1", "value1"); Map externalDetails = Map.of("External:key1", "value1", "External:key2", "value2"); - boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails); + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, false); Assert.assertTrue(result); } @@ -1058,7 +1088,7 @@ public class ConfigurationManagerImplTest { Map offeringDetails = Map.of("External:key1", "value1"); Map externalDetails = Map.of("External:key1", "differentValue"); - boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails); + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, false); Assert.assertTrue(result); } @@ -1068,7 +1098,7 @@ public class ConfigurationManagerImplTest { Map offeringDetails = Map.of("External:key1", "value1", "External:key2", "value2"); Map externalDetails = Map.of("External:key1", "value1", "External:key2", "value2"); - boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails); + boolean result = configurationManagerImplSpy.serviceOfferingExternalDetailsNeedUpdate(offeringDetails, externalDetails, false); Assert.assertFalse(result); } diff --git a/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java b/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java index 2189b451761..51b2dad3dec 100644 --- a/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java +++ b/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java @@ -114,6 +114,7 @@ import com.cloud.user.dao.UserDao; import com.cloud.utils.Pair; import com.cloud.utils.component.ComponentContext; import com.cloud.utils.db.EntityManager; +import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.Ip; import com.cloud.vm.DomainRouterVO; @@ -1299,4 +1300,34 @@ public class NetworkServiceImplTest { Assert.assertEquals("Mac address is not valid: invalid-mac", e.getMessage()); } } + + @Test + public void addProjectNetworksConditionToSearch_includesProjectNetworksWhenNotSkipped() { + SearchCriteria sc = Mockito.mock(SearchCriteria.class); + SearchCriteria accountJoin = Mockito.mock(SearchCriteria.class); + Mockito.when(sc.getJoin("account")).thenReturn(accountJoin); + service.addProjectNetworksConditionToSearch(sc, false, -1L); + Mockito.verify(accountJoin).addAnd("type", SearchCriteria.Op.NNULL); + Mockito.verify(sc).addAnd("id", SearchCriteria.Op.SC, accountJoin); + } + + @Test + public void addProjectNetworksConditionToSearch_excludesProjectNetworksWhenSkipped() { + SearchCriteria sc = Mockito.mock(SearchCriteria.class); + SearchCriteria accountJoin = Mockito.mock(SearchCriteria.class); + Mockito.when(sc.getJoin("account")).thenReturn(accountJoin); + service.addProjectNetworksConditionToSearch(sc, true, -1L); + Mockito.verify(accountJoin).addAnd("type", SearchCriteria.Op.NEQ, Account.Type.PROJECT); + Mockito.verify(sc).addAnd("id", SearchCriteria.Op.SC, accountJoin); + } + + @Test + public void addProjectNetworksConditionToSearch_includesSpecificProjectWhenProjectIdProvided() { + SearchCriteria sc = Mockito.mock(SearchCriteria.class); + SearchCriteria accountJoin = Mockito.mock(SearchCriteria.class); + Mockito.when(sc.getJoin("account")).thenReturn(accountJoin); + service.addProjectNetworksConditionToSearch(sc, false, 123L); + Mockito.verify(accountJoin).addAnd("type", SearchCriteria.Op.EQ, Account.Type.PROJECT); + Mockito.verify(sc).addAnd("id", SearchCriteria.Op.SC, accountJoin); + } } diff --git a/server/src/test/java/com/cloud/server/ManagementServerImplTest.java b/server/src/test/java/com/cloud/server/ManagementServerImplTest.java index ebced92f8fe..2f52df982b7 100644 --- a/server/src/test/java/com/cloud/server/ManagementServerImplTest.java +++ b/server/src/test/java/com/cloud/server/ManagementServerImplTest.java @@ -26,6 +26,7 @@ import static org.mockito.Mockito.when; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.cloudstack.annotation.dao.AnnotationDao; @@ -258,14 +259,14 @@ public class ManagementServerImplTest { Mockito.when(cmd.getId()).thenReturn(null); Mockito.when(cmd.isSourceNat()).thenReturn(null); Mockito.when(cmd.isStaticNat()).thenReturn(null); - Mockito.when(cmd.getState()).thenReturn(IpAddress.State.Free.name()); Mockito.when(cmd.getTags()).thenReturn(null); - spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.FALSE); + List states = Collections.singletonList(IpAddress.State.Free); + spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.FALSE, states); Mockito.verify(sc, Mockito.times(1)).setJoinParameters("vlanSearch", "vlanType", VlanType.VirtualNetwork); Mockito.verify(sc, Mockito.times(1)).setParameters("display", false); Mockito.verify(sc, Mockito.times(1)).setParameters("sourceNetworkId", 10L); - Mockito.verify(sc, Mockito.times(1)).setParameters("state", "Free"); + Mockito.verify(sc, Mockito.times(1)).setParameters("state", states.toArray()); Mockito.verify(sc, Mockito.times(1)).setParameters("forsystemvms", false); } @@ -281,14 +282,14 @@ public class ManagementServerImplTest { Mockito.when(cmd.getId()).thenReturn(null); Mockito.when(cmd.isSourceNat()).thenReturn(null); Mockito.when(cmd.isStaticNat()).thenReturn(null); - Mockito.when(cmd.getState()).thenReturn(IpAddress.State.Free.name()); Mockito.when(cmd.getTags()).thenReturn(null); - spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.FALSE); + List states = Collections.singletonList(IpAddress.State.Free); + spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.FALSE, states); Mockito.verify(sc, Mockito.times(1)).setJoinParameters("vlanSearch", "vlanType", VlanType.VirtualNetwork); Mockito.verify(sc, Mockito.times(1)).setParameters("display", false); Mockito.verify(sc, Mockito.times(1)).setParameters("sourceNetworkId", 10L); - Mockito.verify(sc, Mockito.times(1)).setParameters("state", "Free"); + Mockito.verify(sc, Mockito.times(1)).setParameters("state", states.toArray()); Mockito.verify(sc, Mockito.times(1)).setParameters("forsystemvms", false); } @@ -304,13 +305,13 @@ public class ManagementServerImplTest { Mockito.when(cmd.getId()).thenReturn(null); Mockito.when(cmd.isSourceNat()).thenReturn(null); Mockito.when(cmd.isStaticNat()).thenReturn(null); - Mockito.when(cmd.getState()).thenReturn(null); Mockito.when(cmd.getTags()).thenReturn(null); - spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.TRUE); + spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.TRUE, Collections.emptyList()); Mockito.verify(sc, Mockito.times(1)).setJoinParameters("vlanSearch", "vlanType", VlanType.VirtualNetwork); Mockito.verify(sc, Mockito.times(1)).setParameters("display", false); Mockito.verify(sc, Mockito.times(1)).setParameters("sourceNetworkId", 10L); + Mockito.verify(sc, Mockito.times(1)).setParameters("state", IpAddress.State.Allocated); Mockito.verify(sc, Mockito.times(1)).setParameters("forsystemvms", false); } @@ -326,13 +327,13 @@ public class ManagementServerImplTest { Mockito.when(cmd.getId()).thenReturn(null); Mockito.when(cmd.isSourceNat()).thenReturn(null); Mockito.when(cmd.isStaticNat()).thenReturn(null); - Mockito.when(cmd.getState()).thenReturn(null); Mockito.when(cmd.getTags()).thenReturn(null); - spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.TRUE); + spy.setParameters(sc, cmd, VlanType.VirtualNetwork, Boolean.TRUE, Collections.emptyList()); Mockito.verify(sc, Mockito.times(1)).setJoinParameters("vlanSearch", "vlanType", VlanType.VirtualNetwork); Mockito.verify(sc, Mockito.times(1)).setParameters("display", false); Mockito.verify(sc, Mockito.times(1)).setParameters("sourceNetworkId", 10L); + Mockito.verify(sc, Mockito.times(1)).setParameters("state", IpAddress.State.Allocated); Mockito.verify(sc, Mockito.times(1)).setParameters("forsystemvms", false); } @@ -1033,4 +1034,49 @@ public class ManagementServerImplTest { Assert.assertNotNull(spy.getExternalVmConsole(virtualMachine, host)); Mockito.verify(extensionManager).getInstanceConsole(virtualMachine, host); } + + @Test + public void getStatesForIpAddressSearchReturnsValidStates() { + ListPublicIpAddressesCmd cmd = Mockito.mock(ListPublicIpAddressesCmd.class); + Mockito.when(cmd.getState()).thenReturn("Allocated ,free"); + List result = spy.getStatesForIpAddressSearch(cmd); + Assert.assertEquals(2, result.size()); + Assert.assertTrue(result.contains(IpAddress.State.Allocated)); + Assert.assertTrue(result.contains(IpAddress.State.Free)); + } + + @Test + public void getStatesForIpAddressSearchReturnsEmptyListForNullState() { + ListPublicIpAddressesCmd cmd = Mockito.mock(ListPublicIpAddressesCmd.class); + Mockito.when(cmd.getState()).thenReturn(null); + List result = spy.getStatesForIpAddressSearch(cmd); + Assert.assertTrue(result.isEmpty()); + } + + @Test + public void getStatesForIpAddressSearchReturnsEmptyListForBlankState() { + ListPublicIpAddressesCmd cmd = Mockito.mock(ListPublicIpAddressesCmd.class); + Mockito.when(cmd.getState()).thenReturn(" "); + List result = spy.getStatesForIpAddressSearch(cmd); + Assert.assertTrue(result.isEmpty()); + } + + @Test(expected = InvalidParameterValueException.class) + public void getStatesForIpAddressSearchThrowsExceptionForInvalidState() { + ListPublicIpAddressesCmd cmd = Mockito.mock(ListPublicIpAddressesCmd.class); + Mockito.when(cmd.getState()).thenReturn("InvalidState"); + spy.getStatesForIpAddressSearch(cmd); + } + + @Test + public void getStatesForIpAddressSearchHandlesMixedValidAndInvalidStates() { + ListPublicIpAddressesCmd cmd = Mockito.mock(ListPublicIpAddressesCmd.class); + Mockito.when(cmd.getState()).thenReturn("Allocated,InvalidState"); + try { + spy.getStatesForIpAddressSearch(cmd); + Assert.fail("Expected InvalidParameterValueException to be thrown"); + } catch (InvalidParameterValueException e) { + Assert.assertEquals("Invalid state: InvalidState", e.getMessage()); + } + } } diff --git a/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java b/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java index 79be3695fbd..0575b430ef1 100644 --- a/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java +++ b/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java @@ -1545,7 +1545,7 @@ public class VolumeApiServiceImplTest { volumeApiServiceImpl.publishVolumeCreationUsageEvent(volumeVoMock); usageEventUtilsMocked.verify(() -> UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volumeVoMock.getAccountId(), volumeVoMock.getDataCenterId(), volumeVoMock.getId(), volumeVoMock.getName(), - null, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.isDisplay())); + null, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.getInstanceId(), volumeVoMock.isDisplay())); } } @@ -1558,7 +1558,7 @@ public class VolumeApiServiceImplTest { volumeApiServiceImpl.publishVolumeCreationUsageEvent(volumeVoMock); usageEventUtilsMocked.verify(() -> UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volumeVoMock.getAccountId(), volumeVoMock.getDataCenterId(), volumeVoMock.getId(), volumeVoMock.getName(), - null, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.isDisplay())); + null, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.getInstanceId(), volumeVoMock.isDisplay())); } } @@ -1573,7 +1573,7 @@ public class VolumeApiServiceImplTest { volumeApiServiceImpl.publishVolumeCreationUsageEvent(volumeVoMock); usageEventUtilsMocked.verify(() -> UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volumeVoMock.getAccountId(), volumeVoMock.getDataCenterId(), volumeVoMock.getId(), volumeVoMock.getName(), - null, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.isDisplay())); + null, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.getInstanceId(), volumeVoMock.isDisplay())); } } @@ -1589,7 +1589,7 @@ public class VolumeApiServiceImplTest { volumeApiServiceImpl.publishVolumeCreationUsageEvent(volumeVoMock); usageEventUtilsMocked.verify(() -> UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volumeVoMock.getAccountId(), volumeVoMock.getDataCenterId(), volumeVoMock.getId(), volumeVoMock.getName(), - offeringMockId, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.isDisplay())); + offeringMockId, volumeVoMock.getTemplateId(), volumeVoMock.getSize(), Volume.class.getName(), volumeVoMock.getUuid(), volumeVoMock.getInstanceId(), volumeVoMock.isDisplay())); } } diff --git a/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerImplTest.java b/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerImplTest.java index f178c6b8912..6dadbfe96eb 100644 --- a/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerImplTest.java +++ b/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerImplTest.java @@ -27,18 +27,25 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.org.Grouping; import com.cloud.storage.DataStoreRole; import com.cloud.storage.Snapshot; +import com.cloud.storage.SnapshotPolicyVO; import com.cloud.storage.SnapshotVO; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.SnapshotDao; +import com.cloud.storage.dao.SnapshotPolicyDao; import com.cloud.storage.dao.SnapshotZoneDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.user.ResourceLimitService; +import com.cloud.user.User; import com.cloud.user.dao.AccountDao; import com.cloud.utils.Pair; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd; +import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; @@ -51,6 +58,8 @@ import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao; import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO; import org.junit.Assert; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -89,9 +98,23 @@ public class SnapshotManagerImplTest { SnapshotZoneDao snapshotZoneDao; @Mock VolumeDao volumeDao; + @Mock + SnapshotPolicyDao snapshotPolicyDao; @InjectMocks SnapshotManagerImpl snapshotManager = new SnapshotManagerImpl(); + @Before + public void setUp() { + snapshotManager._snapshotPolicyDao = snapshotPolicyDao; + snapshotManager._volsDao = volumeDao; + snapshotManager._accountMgr = accountManager; + } + + @After + public void tearDown() { + CallContext.unregister(); + } + @Test public void testGetSnapshotZoneImageStoreValid() { final long snapshotId = 1L; @@ -395,4 +418,106 @@ public class SnapshotManagerImplTest { Mockito.when(dataCenterDao.findById(zoneId)).thenReturn(dataCenterVO); Assert.assertNotNull(snapshotManager.getCheckedDestinationZoneForSnapshotCopy(zoneId, false)); } + + @Test + public void testListSnapshotPolicies() { + long volumeId = 42L; + ListSnapshotPoliciesCmd cmd = Mockito.mock(ListSnapshotPoliciesCmd.class); + Mockito.when(cmd.getVolumeId()).thenReturn(volumeId); + Mockito.when(cmd.getId()).thenReturn(null); + Mockito.when(cmd.getStartIndex()).thenReturn(0L); + Mockito.when(cmd.getPageSizeVal()).thenReturn(10L); + + Account caller = Mockito.mock(Account.class); + Mockito.when(caller.getId()).thenReturn(1L); + CallContext.register(Mockito.mock(User.class), caller); + + SnapshotPolicyVO policy1 = Mockito.mock(SnapshotPolicyVO.class); + SnapshotPolicyVO policy2 = Mockito.mock(SnapshotPolicyVO.class); + List mockPolicies = List.of(policy1, policy2); + + SearchBuilder mockSearchBuilder = Mockito.mock(SearchBuilder.class); + SearchBuilder mockVolumeSearchBuilder = Mockito.mock(SearchBuilder.class); + SearchCriteria mockSearchCriteria = Mockito.mock(SearchCriteria.class); + + Mockito.when(snapshotPolicyDao.createSearchBuilder()).thenReturn(mockSearchBuilder); + Mockito.when(mockSearchBuilder.entity()).thenReturn(Mockito.mock(SnapshotPolicyVO.class)); + Mockito.when(mockSearchBuilder.create()).thenReturn(mockSearchCriteria); + Mockito.when(volumeDao.createSearchBuilder()).thenReturn(mockVolumeSearchBuilder); + Mockito.when(mockVolumeSearchBuilder.entity()).thenReturn(Mockito.mock(VolumeVO.class)); + Mockito.when(snapshotPolicyDao.searchAndCount(Mockito.any(), Mockito.any())).thenReturn(new Pair<>(mockPolicies, 2)); + + Pair, Integer> result = snapshotManager.listSnapshotPolicies(cmd); + + Assert.assertNotNull(result); + Assert.assertEquals(2, result.first().size()); + Assert.assertEquals(Integer.valueOf(2), result.second()); + Assert.assertEquals(mockPolicies, result.first()); + } + + @Test + public void testListSnapshotPolicies_NonRootAdmin() { + ListSnapshotPoliciesCmd cmd = Mockito.mock(ListSnapshotPoliciesCmd.class); + Mockito.when(cmd.getVolumeId()).thenReturn(1L); + Mockito.when(cmd.getId()).thenReturn(null); + Mockito.when(cmd.getStartIndex()).thenReturn(0L); + Mockito.when(cmd.getPageSizeVal()).thenReturn(10L); + + Account caller = Mockito.mock(Account.class); + Mockito.when(caller.getId()).thenReturn(2L); + CallContext.register(Mockito.mock(User.class), caller); + + SnapshotPolicyVO policy1 = Mockito.mock(SnapshotPolicyVO.class); + SnapshotPolicyVO policy2 = Mockito.mock(SnapshotPolicyVO.class); + List mockPolicies = List.of(policy1, policy2); + + SearchBuilder mockSearchBuilder = Mockito.mock(SearchBuilder.class); + SearchBuilder mockVolumeSearchBuilder = Mockito.mock(SearchBuilder.class); + SearchCriteria mockSearchCriteria = Mockito.mock(SearchCriteria.class); + + Mockito.when(snapshotPolicyDao.createSearchBuilder()).thenReturn(mockSearchBuilder); + Mockito.when(mockSearchBuilder.entity()).thenReturn(Mockito.mock(SnapshotPolicyVO.class)); + Mockito.when(mockSearchBuilder.create()).thenReturn(mockSearchCriteria); + Mockito.when(volumeDao.createSearchBuilder()).thenReturn(mockVolumeSearchBuilder); + Mockito.when(mockVolumeSearchBuilder.entity()).thenReturn(Mockito.mock(VolumeVO.class)); + Mockito.when(snapshotPolicyDao.searchAndCount(Mockito.any(), Mockito.any())).thenReturn(new Pair<>(mockPolicies, 2)); + + Pair, Integer> result = snapshotManager.listSnapshotPolicies(cmd); + + Assert.assertNotNull(result); + Assert.assertEquals(2, result.first().size()); + Assert.assertEquals(Integer.valueOf(2), result.second()); + Assert.assertEquals(mockPolicies, result.first()); + } + + @Test + public void testListSnapshotPolicies_RootAdmin() { + ListSnapshotPoliciesCmd cmd = Mockito.mock(ListSnapshotPoliciesCmd.class); + Mockito.when(cmd.getVolumeId()).thenReturn(1L); + Mockito.when(cmd.getId()).thenReturn(null); + Mockito.when(cmd.getStartIndex()).thenReturn(0L); + Mockito.when(cmd.getPageSizeVal()).thenReturn(10L); + + Account caller = Mockito.mock(Account.class); + Mockito.when(caller.getId()).thenReturn(1L); + CallContext.register(Mockito.mock(User.class), caller); + + SnapshotPolicyVO policy = Mockito.mock(SnapshotPolicyVO.class); + SearchBuilder mockSearchBuilder = Mockito.mock(SearchBuilder.class); + SearchBuilder mockVolumeSearchBuilder = Mockito.mock(SearchBuilder.class); + SearchCriteria mockSearchCriteria = Mockito.mock(SearchCriteria.class); + + Mockito.when(snapshotPolicyDao.createSearchBuilder()).thenReturn(mockSearchBuilder); + Mockito.when(mockSearchBuilder.entity()).thenReturn(Mockito.mock(SnapshotPolicyVO.class)); + Mockito.when(mockSearchBuilder.create()).thenReturn(mockSearchCriteria); + Mockito.when(volumeDao.createSearchBuilder()).thenReturn(mockVolumeSearchBuilder); + Mockito.when(mockVolumeSearchBuilder.entity()).thenReturn(Mockito.mock(VolumeVO.class)); + Mockito.when(snapshotPolicyDao.searchAndCount(Mockito.any(), Mockito.any())).thenReturn(new Pair<>(List.of(policy), 1)); + + Pair, Integer> result = snapshotManager.listSnapshotPolicies(cmd); + + Assert.assertNotNull(result); + Assert.assertEquals(1, result.first().size()); + Assert.assertEquals(Integer.valueOf(1), result.second()); + } } diff --git a/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java b/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java index 4d802319935..3b5d92103e7 100755 --- a/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java +++ b/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java @@ -209,6 +209,8 @@ public class SnapshotManagerTest { private static final String TEST_SNAPSHOT_POLICY_TIMEZONE = ""; private static final IntervalType TEST_SNAPSHOT_POLICY_INTERVAL = IntervalType.MONTHLY; private static final int TEST_SNAPSHOT_POLICY_MAX_SNAPS = 1; + private static final long TEST_SNAPSHOT_POLICY_ACCOUNT_ID = 1; + private static final long TEST_SNAPSHOT_POLICY_DOMAIN_ID = 1; private static final boolean TEST_SNAPSHOT_POLICY_DISPLAY = true; private static final boolean TEST_SNAPSHOT_POLICY_ACTIVE = true; private static final long TEST_ZONE_ID = 7L; @@ -251,7 +253,7 @@ public class SnapshotManagerTest { when(_resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(any(HypervisorType.class), anyLong())).thenReturn(null); snapshotPolicyVoInstance = new SnapshotPolicyVO(TEST_VOLUME_ID, TEST_SNAPSHOT_POLICY_SCHEDULE, TEST_SNAPSHOT_POLICY_TIMEZONE, TEST_SNAPSHOT_POLICY_INTERVAL, - TEST_SNAPSHOT_POLICY_MAX_SNAPS, TEST_SNAPSHOT_POLICY_DISPLAY); + TEST_SNAPSHOT_POLICY_MAX_SNAPS, TEST_SNAPSHOT_POLICY_ACCOUNT_ID, TEST_SNAPSHOT_POLICY_DOMAIN_ID, TEST_SNAPSHOT_POLICY_DISPLAY); apiDBUtilsMock = Mockito.mockStatic(ApiDBUtils.class); } @@ -442,7 +444,7 @@ public class SnapshotManagerTest { Mockito.doReturn(true).when(taggedResourceServiceMock).deleteTags(any(), any(), any()); SnapshotPolicyVO snapshotPolicyVo = new SnapshotPolicyVO(TEST_VOLUME_ID, TEST_SNAPSHOT_POLICY_SCHEDULE, TEST_SNAPSHOT_POLICY_TIMEZONE, TEST_SNAPSHOT_POLICY_INTERVAL, - TEST_SNAPSHOT_POLICY_MAX_SNAPS, TEST_SNAPSHOT_POLICY_DISPLAY); + TEST_SNAPSHOT_POLICY_MAX_SNAPS, TEST_SNAPSHOT_POLICY_ACCOUNT_ID, TEST_SNAPSHOT_POLICY_DOMAIN_ID, TEST_SNAPSHOT_POLICY_DISPLAY); _snapshotMgr.updateSnapshotPolicy(snapshotPolicyVo, TEST_SNAPSHOT_POLICY_SCHEDULE, TEST_SNAPSHOT_POLICY_TIMEZONE, TEST_SNAPSHOT_POLICY_INTERVAL, TEST_SNAPSHOT_POLICY_MAX_SNAPS, TEST_SNAPSHOT_POLICY_DISPLAY, TEST_SNAPSHOT_POLICY_ACTIVE, null, null); diff --git a/server/src/test/java/com/cloud/vm/UserVmManagerImplTest.java b/server/src/test/java/com/cloud/vm/UserVmManagerImplTest.java index 360800fac34..fe4ea0838f1 100644 --- a/server/src/test/java/com/cloud/vm/UserVmManagerImplTest.java +++ b/server/src/test/java/com/cloud/vm/UserVmManagerImplTest.java @@ -59,6 +59,7 @@ import java.util.Map; import java.util.TimeZone; import java.util.UUID; +import com.cloud.storage.dao.SnapshotPolicyDao; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.api.ApiCommandResourceType; @@ -79,6 +80,7 @@ import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd; import org.apache.cloudstack.backup.BackupManager; import org.apache.cloudstack.backup.BackupVO; import org.apache.cloudstack.backup.dao.BackupDao; +import org.apache.cloudstack.backup.dao.BackupScheduleDao; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; @@ -435,6 +437,13 @@ public class UserVmManagerImplTest { @Mock private UUIDManager uuidMgr; + + @Mock + private SnapshotPolicyDao snapshotPolicyDao; + + @Mock + private BackupScheduleDao backupScheduleDao; + MockedStatic unmanagedVMsManagerMockedStatic; private static final long vmId = 1l; @@ -1111,10 +1120,12 @@ public class UserVmManagerImplTest { public void recoverRootVolumeTestDestroyState() { Mockito.doReturn(Volume.State.Destroy).when(volumeVOMock).getState(); - userVmManagerImpl.recoverRootVolume(volumeVOMock, vmId); + try (MockedStatic ignored = Mockito.mockStatic(UsageEventUtils.class)) { + userVmManagerImpl.recoverRootVolume(volumeVOMock, vmId); - Mockito.verify(volumeApiService).recoverVolume(volumeVOMock.getId()); - Mockito.verify(volumeDaoMock).attachVolume(volumeVOMock.getId(), vmId, UserVmManagerImpl.ROOT_DEVICE_ID); + Mockito.verify(volumeApiService).recoverVolume(volumeVOMock.getId()); + Mockito.verify(volumeDaoMock).attachVolume(volumeVOMock.getId(), vmId, UserVmManagerImpl.ROOT_DEVICE_ID); + } } @Test(expected = InvalidParameterValueException.class) diff --git a/server/src/test/java/com/cloud/vpc/Site2SiteVpnTest.java b/server/src/test/java/com/cloud/vpc/Site2SiteVpnTest.java deleted file mode 100644 index f8a42df6c60..00000000000 --- a/server/src/test/java/com/cloud/vpc/Site2SiteVpnTest.java +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.vpc; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "classpath:/VpcTestContext.xml") -public class Site2SiteVpnTest { - -// private static void addDaos(MockComponentLocator locator) { -// locator.addDao("AccountDao", AccountDaoImpl.class); -// locator.addDao("Site2SiteCustomerGatewayDao", Site2SiteCustomerGatewayDaoImpl.class); -// locator.addDao("Site2SiteVpnGatewayDao", Site2SiteVpnGatewayDaoImpl.class); -// locator.addDao("Site2SiteVpnConnectionDao", Site2SiteVpnConnectionDaoImpl.class); -// -// locator.addDao("IPAddressDao", IPAddressDaoImpl.class); -// locator.addDao("VpcDao", VpcDaoImpl.class); -// locator.addDao("ConfiguratioDao", MockConfigurationDaoImpl.class); -// -// } -// -// private static void addManagers(MockComponentLocator locator) { -// locator.addManager("AccountManager", MockAccountManagerImpl.class); -// locator.addManager("VpcManager", MockVpcManagerImpl.class); -// } - - @Before - public void setUp() { -// locator = new MockComponentLocator("management-server"); -// addDaos(locator); -// addManagers(locator); -// logger.info("Finished setUp"); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testInjected() throws Exception { -// List>> list = -// new ArrayList>>(); -// list.add(new Pair>("Site2SiteVpnServiceProvider", MockSite2SiteVpnServiceProvider.class)); -// locator.addAdapterChain(Site2SiteVpnServiceProvider.class, list); -// logger.info("Finished add adapter"); -// locator.makeActive(new DefaultInterceptorLibrary()); -// logger.info("Finished make active"); -// Site2SiteVpnManagerImpl vpnMgr = ComponentLocator.inject(Site2SiteVpnManagerImpl.class); -// logger.info("Finished inject"); -// Assert.assertTrue(vpnMgr.configure("Site2SiteVpnMgr",new HashMap()) ); -// Assert.assertTrue(vpnMgr.start()); - - } - -} diff --git a/server/src/test/java/com/cloud/vpc/VpcTestConfiguration.java b/server/src/test/java/com/cloud/vpc/VpcTestConfiguration.java index 22c0b47e154..0d45d50d8ae 100644 --- a/server/src/test/java/com/cloud/vpc/VpcTestConfiguration.java +++ b/server/src/test/java/com/cloud/vpc/VpcTestConfiguration.java @@ -176,11 +176,6 @@ public class VpcTestConfiguration { return Mockito.mock(RemoteAccessVpnService.class); } -// @Bean -// public VpcDao vpcDao() { -// return Mockito.mock(VpcDao.class); -// } - @Bean public NetworkDao networkDao() { return Mockito.mock(NetworkDao.class); diff --git a/server/src/test/java/com/cloud/vpc/dao/MockNetworkDaoImpl.java b/server/src/test/java/com/cloud/vpc/dao/MockNetworkDaoImpl.java index 490f2ccba46..8a0bec56df7 100644 --- a/server/src/test/java/com/cloud/vpc/dao/MockNetworkDaoImpl.java +++ b/server/src/test/java/com/cloud/vpc/dao/MockNetworkDaoImpl.java @@ -29,6 +29,7 @@ import com.cloud.utils.db.SearchBuilder; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; @DB() public class MockNetworkDaoImpl extends GenericDaoBase implements NetworkDao { @@ -265,4 +266,18 @@ public class MockNetworkDaoImpl extends GenericDaoBase implemen return null; } + @Override + public List listByNetworkDomains(Set uniqueNtwkDomains) { + return List.of(); + } + + @Override + public List listByNetworkDomainsAndAccountIds(Set uniqueNtwkDomains, Set accountIds) { + return List.of(); + } + + @Override + public List listByNetworkDomainsAndDomainIds(Set uniqueNtwkDomains, Set domainIds) { + return List.of(); + } } diff --git a/server/src/test/java/org/apache/cloudstack/backup/BackupManagerTest.java b/server/src/test/java/org/apache/cloudstack/backup/BackupManagerTest.java index 5ee08d185bd..8b13fd47494 100644 --- a/server/src/test/java/org/apache/cloudstack/backup/BackupManagerTest.java +++ b/server/src/test/java/org/apache/cloudstack/backup/BackupManagerTest.java @@ -49,6 +49,7 @@ import com.cloud.storage.Volume; import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.DiskOfferingDao; +import com.cloud.storage.dao.GuestOSDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.user.Account; @@ -60,6 +61,8 @@ import com.cloud.user.User; import com.cloud.user.dao.AccountDao; import com.cloud.utils.DateUtil; import com.cloud.utils.Pair; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.fsm.NoTransitionException; import com.cloud.vm.VMInstanceDetailVO; @@ -77,6 +80,7 @@ import org.apache.cloudstack.api.command.admin.backup.UpdateBackupOfferingCmd; import org.apache.cloudstack.api.command.user.backup.CreateBackupCmd; import org.apache.cloudstack.api.command.user.backup.CreateBackupScheduleCmd; import org.apache.cloudstack.api.command.user.backup.DeleteBackupScheduleCmd; +import org.apache.cloudstack.api.command.user.backup.ListBackupScheduleCmd; import org.apache.cloudstack.api.response.BackupResponse; import org.apache.cloudstack.backup.dao.BackupDao; import org.apache.cloudstack.backup.dao.BackupDetailsDao; @@ -234,6 +238,9 @@ public class BackupManagerTest { @Mock DomainDao domainDao; + @Mock + private GuestOSDao _guestOSDao; + private Gson gson; private String[] hostPossibleValues = {"127.0.0.1", "hostname"}; @@ -1569,14 +1576,12 @@ public class BackupManagerTest { VMTemplateVO template = mock(VMTemplateVO.class); when(template.getFormat()).thenReturn(Storage.ImageFormat.QCOW2); - when(template.getUuid()).thenReturn(templateUuid); when(template.getName()).thenReturn("template1"); when(vmTemplateDao.findByUuid(templateUuid)).thenReturn(template); Map details = new HashMap<>(); details.put(ApiConstants.TEMPLATE_ID, templateUuid); ServiceOfferingVO serviceOffering = mock(ServiceOfferingVO.class); - when(serviceOffering.getUuid()).thenReturn(serviceOfferingUuid); when(serviceOffering.getName()).thenReturn("service-offering1"); when(serviceOfferingDao.findByUuid(serviceOfferingUuid)).thenReturn(serviceOffering); details.put(ApiConstants.SERVICE_OFFERING_ID, serviceOfferingUuid); @@ -1815,6 +1820,78 @@ public class BackupManagerTest { ); } + @Test + public void testListBackupSchedulesAsRootAdmin() { + long vmId = 1L; + ListBackupScheduleCmd cmd = Mockito.mock(ListBackupScheduleCmd.class); + Mockito.when(cmd.getVmId()).thenReturn(vmId); + Mockito.when(cmd.getId()).thenReturn(1L); + + // Mock VM for validation + VMInstanceVO vm = Mockito.mock(VMInstanceVO.class); + Mockito.when(vmInstanceDao.findById(vmId)).thenReturn(vm); + Mockito.when(vm.getDataCenterId()).thenReturn(1L); + overrideBackupFrameworkConfigValue(); + Mockito.doNothing().when(accountManager).checkAccess(Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.any()); + + BackupScheduleVO schedule1 = Mockito.mock(BackupScheduleVO.class); + BackupScheduleVO schedule2 = Mockito.mock(BackupScheduleVO.class); + List schedules = List.of(schedule1, schedule2); + + SearchBuilder searchBuilder = Mockito.mock(SearchBuilder.class); + SearchCriteria searchCriteria = Mockito.mock(SearchCriteria.class); + BackupScheduleVO entity = Mockito.mock(BackupScheduleVO.class); + + Mockito.when(backupScheduleDao.createSearchBuilder()).thenReturn(searchBuilder); + Mockito.when(searchBuilder.entity()).thenReturn(entity); + Mockito.when(searchBuilder.and(Mockito.anyString(), (Object) any(), Mockito.any())).thenReturn(searchBuilder); + Mockito.when(searchBuilder.create()).thenReturn(searchCriteria); + + Mockito.when(backupScheduleDao.searchAndCount(Mockito.any(), Mockito.any())).thenReturn(new Pair<>(schedules, schedules.size())); + List result = backupManager.listBackupSchedules(cmd); + + assertEquals(2, result.size()); + assertTrue(result.contains(schedule1)); + assertTrue(result.contains(schedule2)); + } + + @Test + public void testListBackupSchedulesAsNonAdmin() { + long vmId = 1L; + ListBackupScheduleCmd cmd = Mockito.mock(ListBackupScheduleCmd.class); + Mockito.when(cmd.getVmId()).thenReturn(vmId); + Mockito.when(cmd.getId()).thenReturn(1L); + + // Mock VM for validation + VMInstanceVO vm = Mockito.mock(VMInstanceVO.class); + Mockito.when(vmInstanceDao.findById(vmId)).thenReturn(vm); + Mockito.when(vm.getDataCenterId()).thenReturn(1L); + overrideBackupFrameworkConfigValue(); + Mockito.doNothing().when(accountManager).checkAccess(Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.any()); + + BackupScheduleVO schedule = Mockito.mock(BackupScheduleVO.class); + List schedules = List.of(schedule); + + SearchBuilder searchBuilder = Mockito.mock(SearchBuilder.class); + SearchCriteria searchCriteria = Mockito.mock(SearchCriteria.class); + BackupScheduleVO entity = Mockito.mock(BackupScheduleVO.class); + + Mockito.when(backupScheduleDao.createSearchBuilder()).thenReturn(searchBuilder); + Mockito.when(searchBuilder.create()).thenReturn(searchCriteria); + Mockito.when(searchBuilder.entity()).thenReturn(entity); + Mockito.when(searchBuilder.and(Mockito.anyString(), (Object) any(), Mockito.any())).thenReturn(searchBuilder); + Mockito.lenient().when(backupScheduleDao.search(Mockito.eq(searchCriteria), Mockito.any())).thenReturn(schedules); + + Mockito.doNothing().when(accountManager).buildACLSearchBuilder(Mockito.any(), Mockito.anyLong(), Mockito.anyBoolean(), Mockito.anyList(), Mockito.any()); + Mockito.doNothing().when(accountManager).buildACLSearchCriteria(Mockito.any(), Mockito.anyLong(), Mockito.anyBoolean(), Mockito.anyList(), Mockito.any()); + + Mockito.when(backupScheduleDao.searchAndCount(Mockito.any(), Mockito.any())).thenReturn(new Pair<>(schedules, schedules.size())); + List result = backupManager.listBackupSchedules(cmd); + + assertEquals(1, result.size()); + assertTrue(result.contains(schedule)); + } + @Test public void testCanCreateInstanceFromBackupAcrossZonesSuccess() { Long backupId = 1L; diff --git a/server/src/test/java/org/apache/cloudstack/network/RoutedIpv4ManagerImplTest.java b/server/src/test/java/org/apache/cloudstack/network/RoutedIpv4ManagerImplTest.java index 5351abe2e2d..81110dd3f53 100644 --- a/server/src/test/java/org/apache/cloudstack/network/RoutedIpv4ManagerImplTest.java +++ b/server/src/test/java/org/apache/cloudstack/network/RoutedIpv4ManagerImplTest.java @@ -545,12 +545,12 @@ public class RoutedIpv4ManagerImplTest { DataCenterIpv4GuestSubnetVO subnet3 = Mockito.mock(DataCenterIpv4GuestSubnetVO.class); when(dataCenterIpv4GuestSubnetDao.listNonDedicatedByDataCenterId(zoneId)).thenReturn(Arrays.asList(subnet3)); - doReturn(null).doReturn(null).doReturn(ipv4GuestSubnetNetworkMap).when(routedIpv4Manager).getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(eq(cidrSize), any()); + doReturn(null).doReturn(null).doReturn(ipv4GuestSubnetNetworkMap).when(routedIpv4Manager).getIpv4SubnetForGuestNetworkOrVpcInternal(eq(cidrSize), any()); Ipv4GuestSubnetNetworkMap result = routedIpv4Manager.getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(cidrSize, domainId, accountId, zoneId); Assert.assertEquals(ipv4GuestSubnetNetworkMap, result); - verify(routedIpv4Manager, times(3)).getOrCreateIpv4SubnetForGuestNetworkOrVpcInternal(eq(cidrSize), any()); + verify(routedIpv4Manager, times(3)).getIpv4SubnetForGuestNetworkOrVpcInternal(eq(cidrSize), any()); } @Test diff --git a/server/src/test/java/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java b/server/src/test/java/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java index eab5d3eeffd..2fa9a2d7a44 100644 --- a/server/src/test/java/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java +++ b/server/src/test/java/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java @@ -225,7 +225,6 @@ public class CreateNetworkOfferingTest extends TestCase { NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, false, false, false,null, null, null, false, null, null, false); - // System.out.println("Creating Vpc Network Offering"); assertNotNull("Vpc Isolated network offering with Vpc provider ", off); } @@ -245,7 +244,6 @@ public class CreateNetworkOfferingTest extends TestCase { NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, false, false, false,null, null, null, false, null, null, false); - // System.out.println("Creating Vpc Network Offering"); assertNotNull("Vpc Isolated network offering with Vpc and Netscaler provider ", off); } } diff --git a/server/src/test/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImplTest.java b/server/src/test/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImplTest.java index 419acc0ca0b..9ee34d32a17 100644 --- a/server/src/test/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImplTest.java +++ b/server/src/test/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageManagerImplTest.java @@ -277,7 +277,7 @@ public class VolumeImportUnmanageManagerImplTest { doNothing().when(volumeApiService).validateCustomDiskOfferingSizeRange(anyLong()); doReturn(true).when(volumeApiService).doesStoragePoolSupportDiskOffering(any(), any()); doReturn(diskProfile).when(volumeManager).importVolume(any(), anyString(), any(), eq(virtualSize), isNull(), isNull(), anyLong(), - any(), isNull(), isNull(), any(), isNull(), anyLong(), anyString(), isNull()); + any(), isNull(), isNull(), any(), isNull(), anyLong(), any(), anyString(), isNull()); when(diskProfile.getVolumeId()).thenReturn(volumeId); when(volumeDao.findById(volumeId)).thenReturn(volumeVO); diff --git a/server/src/test/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImplTest.java b/server/src/test/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImplTest.java index 99e461949be..a24ba7f068b 100644 --- a/server/src/test/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImplTest.java +++ b/server/src/test/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImplTest.java @@ -39,6 +39,8 @@ import java.util.Map; import java.util.UUID; import com.cloud.offering.DiskOffering; +import com.cloud.vm.ImportVMTaskVO; +import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ResponseGenerator; import org.apache.cloudstack.api.ResponseObject; import org.apache.cloudstack.api.ServerApiException; @@ -54,6 +56,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; @@ -236,6 +239,8 @@ public class UnmanagedVMsManagerImplTest { private DataStoreManager dataStoreManager; @Mock private StoragePoolHostDao storagePoolHostDao; + @Mock + private ImportVmTasksManager importVmTasksManager; @Mock private VMInstanceVO virtualMachine; @@ -244,8 +249,15 @@ public class UnmanagedVMsManagerImplTest { @Mock DeploymentPlanningManager deploymentPlanningManager; @Mock + ImportVMTaskVO importVMTaskVO; + @Mock private VMInstanceDetailsDao vmInstanceDetailsDao; + @Mock + private ConfigKey configKeyMockParamsAllowed; + @Mock + private ConfigKey configKeyMockParamsAllowedList; + private static final long virtualMachineId = 1L; private AutoCloseable closeable; @@ -720,7 +732,6 @@ public class UnmanagedVMsManagerImplTest { when(dataStore.getTO()).thenReturn(dataStoreTO); StoragePoolVO destPool = mock(StoragePoolVO.class); - when(destPool.getUuid()).thenReturn(UUID.randomUUID().toString()); when(destPool.getDataCenterId()).thenReturn(zoneId); when(destPool.getClusterId()).thenReturn(null); when(destPool.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); @@ -772,6 +783,8 @@ public class UnmanagedVMsManagerImplTest { when(agentManager.send(Mockito.eq(convertHostId), Mockito.any(CheckConvertInstanceCommand.class))).thenReturn(checkConvertInstanceAnswer); } + when(importVmTasksManager.createImportVMTaskRecord(any(DataCenter.class), any(Account.class), anyLong(), anyString(), + anyString(), anyString(), anyString(), any(Host.class), any(Host.class))).thenReturn(importVMTaskVO); when(volumeApiService.doesStoragePoolSupportDiskOffering(any(StoragePool.class), any(DiskOffering.class))).thenReturn(true); ConvertInstanceAnswer convertInstanceAnswer = mock(ConvertInstanceAnswer.class); @@ -895,7 +908,7 @@ public class UnmanagedVMsManagerImplTest { long poolId = 1L; when(primaryDataStoreDao.findById(poolId)).thenReturn(null); - unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, poolId); + unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, null, poolId, false); } @Test(expected = CloudRuntimeException.class) @@ -906,7 +919,7 @@ public class UnmanagedVMsManagerImplTest { when(pool.getScope()).thenReturn(ScopeType.CLUSTER); when(pool.getClusterId()).thenReturn(100L); when(primaryDataStoreDao.findById(poolId)).thenReturn(pool); - unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, poolId); + unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, null, poolId, false); } @@ -920,7 +933,7 @@ public class UnmanagedVMsManagerImplTest { HostVO host = mock(HostVO.class); when(primaryDataStoreDao.findById(poolId)).thenReturn(pool); when(host.getClusterId()).thenReturn(2L); - unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, host, poolId); + unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, host, null, poolId, false); } @@ -931,7 +944,7 @@ public class UnmanagedVMsManagerImplTest { StoragePoolVO pool = mock(StoragePoolVO.class); when(pool.getScope()).thenReturn(ScopeType.HOST); when(primaryDataStoreDao.findById(poolId)).thenReturn(pool); - unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, poolId); + unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, null, poolId, false); } @Test(expected = CloudRuntimeException.class) @@ -943,14 +956,14 @@ public class UnmanagedVMsManagerImplTest { when(pool.getClusterId()).thenReturn(1L); when(primaryDataStoreDao.findById(poolId)).thenReturn(pool); when(pool.getPoolType()).thenReturn(Storage.StoragePoolType.RBD); - unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, poolId); + unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, null, poolId, false); } @Test(expected = CloudRuntimeException.class) public void testSelectInstanceConversionTemporaryLocationNoPoolAvailable() { ClusterVO cluster = getClusterForTests(); when(imageStoreDao.findOneByZoneAndProtocol(anyLong(), anyString())).thenReturn(null); - unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, null); + unmanagedVMsManager.selectInstanceConversionTemporaryLocation(cluster, null, null, null, false); } @Test @@ -1220,4 +1233,122 @@ public class UnmanagedVMsManagerImplTest { Assert.fail("Exception encountered: " + e.getMessage()); } } + + @Test + public void testCheckConversionStoragePoolSecondaryStorageStaging() { + unmanagedVMsManager.checkConversionStoragePool(null, false); + Mockito.verifyNoInteractions(primaryDataStoreDao); + } + + @Test(expected = CloudRuntimeException.class) + public void testCheckConversionStoragePoolTemporarySecondaryStorageForceConvertToPool() { + unmanagedVMsManager.checkConversionStoragePool(null, true); + } + + @Test + public void testCheckConversionStoragePoolPrimaryStagingPool() { + StoragePoolVO destPool = mock(StoragePoolVO.class); + long destPoolId = 1L; + Mockito.when(primaryDataStoreDao.findById(destPoolId)).thenReturn(destPool); + unmanagedVMsManager.checkConversionStoragePool(destPoolId, false); + } + + @Test + public void testCheckConversionStoragePoolPrimaryStagingPoolTypeAllowedForce() { + StoragePoolVO destPool = mock(StoragePoolVO.class); + Mockito.when(destPool.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); + long destPoolId = 1L; + Mockito.when(primaryDataStoreDao.findById(destPoolId)).thenReturn(destPool); + unmanagedVMsManager.checkConversionStoragePool(destPoolId, true); + } + + @Test(expected = CloudRuntimeException.class) + public void testCheckConversionStoragePoolPrimaryStagingPoolTypeNotAllowedForce() { + StoragePoolVO destPool = mock(StoragePoolVO.class); + Mockito.when(destPool.getPoolType()).thenReturn(Storage.StoragePoolType.RBD); + long destPoolId = 1L; + Mockito.when(primaryDataStoreDao.findById(destPoolId)).thenReturn(destPool); + unmanagedVMsManager.checkConversionStoragePool(destPoolId, true); + } + + @Test + public void testCheckExtraParamsAllowedEmptyParams() { + unmanagedVMsManager.checkExtraParamsAllowed(null); + Mockito.verifyNoInteractions(configKeyMockParamsAllowed); + } + + @Test(expected = ServerApiException.class) + public void testCheckExtraParamsAllowedDisabledByAdministrator() { + unmanagedVMsManager.ConvertVmwareInstanceToKvmExtraParamsAllowed = configKeyMockParamsAllowed; + Mockito.when(configKeyMockParamsAllowed.value()).thenReturn(false); + unmanagedVMsManager.checkExtraParamsAllowed("--mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254 -x"); + } + + @Test(expected = ServerApiException.class) + public void testCheckExtraParamsAllowedEnabledButEmptyAllowedList() { + unmanagedVMsManager.ConvertVmwareInstanceToKvmExtraParamsAllowed = configKeyMockParamsAllowed; + unmanagedVMsManager.ConvertVmwareInstanceToKvmExtraParamsAllowedList = configKeyMockParamsAllowedList; + Mockito.when(configKeyMockParamsAllowed.value()).thenReturn(true); + Mockito.when(configKeyMockParamsAllowedList.value()).thenReturn(null); + unmanagedVMsManager.checkExtraParamsAllowed("--mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254 -x"); + } + + @Test + public void testCheckExtraParamsAllowedEnabledAndAllowedList() { + unmanagedVMsManager.ConvertVmwareInstanceToKvmExtraParamsAllowed = configKeyMockParamsAllowed; + unmanagedVMsManager.ConvertVmwareInstanceToKvmExtraParamsAllowedList = configKeyMockParamsAllowedList; + Mockito.when(configKeyMockParamsAllowed.value()).thenReturn(true); + Mockito.when(configKeyMockParamsAllowedList.value()).thenReturn("mac,network,x"); + unmanagedVMsManager.checkExtraParamsAllowed("--mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254 -x"); + } + + @Test(expected = ServerApiException.class) + public void testCheckExtraParamsAllowedEnabledParamNotInTheAllowedList() { + unmanagedVMsManager.ConvertVmwareInstanceToKvmExtraParamsAllowed = configKeyMockParamsAllowed; + unmanagedVMsManager.ConvertVmwareInstanceToKvmExtraParamsAllowedList = configKeyMockParamsAllowedList; + Mockito.when(configKeyMockParamsAllowed.value()).thenReturn(true); + Mockito.when(configKeyMockParamsAllowedList.value()).thenReturn("network,x"); + unmanagedVMsManager.checkExtraParamsAllowed("--mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254 -x"); + } + + @Test + public void testAddServiceOfferingDetailsToParamsFixedOffering() { + Map params = new HashMap<>(); + ServiceOfferingVO serviceOfferingVO = mock(ServiceOfferingVO.class); + Mockito.when(serviceOfferingVO.getCpu()).thenReturn(2); + Mockito.when(serviceOfferingVO.getRamSize()).thenReturn(2048); + unmanagedVMsManager.addServiceOfferingDetailsToParams(params, serviceOfferingVO); + Assert.assertEquals("2", params.get(VmDetailConstants.CPU_NUMBER)); + Assert.assertEquals("2048", params.get(VmDetailConstants.MEMORY)); + } + + @Test + public void testAddServiceOfferingDetailsToParamsCustomConstrainedOffering() { + Map params = new HashMap<>(); + ServiceOfferingVO serviceOfferingVO = mock(ServiceOfferingVO.class); + Map details = new HashMap<>(); + details.put(ApiConstants.MIN_CPU_NUMBER, "1"); + details.put(ApiConstants.MIN_MEMORY, "1024"); + Mockito.when(serviceOfferingVO.getDetails()).thenReturn(details); + Mockito.when(serviceOfferingVO.getCpu()).thenReturn(null); + Mockito.when(serviceOfferingVO.getSpeed()).thenReturn(1500); + Mockito.when(serviceOfferingVO.getRamSize()).thenReturn(null); + unmanagedVMsManager.addServiceOfferingDetailsToParams(params, serviceOfferingVO); + Assert.assertEquals("1", params.get(VmDetailConstants.CPU_NUMBER)); + Assert.assertEquals("1500", params.get(VmDetailConstants.CPU_SPEED)); + Assert.assertEquals("1024", params.get(VmDetailConstants.MEMORY)); + } + + @Test + public void testAddServiceOfferingDetailsToParamsCustomUnconstrainedOffering() { + Map params = new HashMap<>(); + ServiceOfferingVO serviceOfferingVO = mock(ServiceOfferingVO.class); + Mockito.when(serviceOfferingVO.getCpu()).thenReturn(null); + Mockito.when(serviceOfferingVO.getSpeed()).thenReturn(null); + Mockito.when(serviceOfferingVO.getRamSize()).thenReturn(null); + unmanagedVMsManager.addServiceOfferingDetailsToParams(params, serviceOfferingVO); + Assert.assertFalse(params.containsKey(VmDetailConstants.CPU_NUMBER)); + Assert.assertFalse(params.containsKey(VmDetailConstants.CPU_SPEED)); + Assert.assertFalse(params.containsKey(VmDetailConstants.MEMORY)); + } } diff --git a/server/src/test/java/org/apache/cloudstack/vm/schedule/VMSchedulerImplTest.java b/server/src/test/java/org/apache/cloudstack/vm/schedule/VMSchedulerImplTest.java index c51f07e96f7..3f9ffc714a1 100644 --- a/server/src/test/java/org/apache/cloudstack/vm/schedule/VMSchedulerImplTest.java +++ b/server/src/test/java/org/apache/cloudstack/vm/schedule/VMSchedulerImplTest.java @@ -238,7 +238,7 @@ public class VMSchedulerImplTest { Date expectedScheduledTime = Date.from(zonedDateTime.toInstant()); if (expectedScheduledTime.before(startDate)) { - expectedScheduledTime = DateUtils.addDays(expectedScheduledTime, 1); + expectedScheduledTime = Date.from(zonedDateTime.plusDays(1).toInstant()); } Date actualScheduledTime = vmScheduler.scheduleNextJob(vmSchedule, new Date()); diff --git a/server/src/test/resources/createNetworkOffering.xml b/server/src/test/resources/createNetworkOffering.xml index 81359cdc72f..023f0cb8967 100644 --- a/server/src/test/resources/createNetworkOffering.xml +++ b/server/src/test/resources/createNetworkOffering.xml @@ -1,83 +1,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/console-proxy/pom.xml b/services/console-proxy/pom.xml index 00678f74683..31a5a13a882 100644 --- a/services/console-proxy/pom.xml +++ b/services/console-proxy/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack-services - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/services/console-proxy/rdpconsole/pom.xml b/services/console-proxy/rdpconsole/pom.xml index 4063642bd9c..058ea891f9c 100644 --- a/services/console-proxy/rdpconsole/pom.xml +++ b/services/console-proxy/rdpconsole/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-service-console-proxy - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/services/console-proxy/rdpconsole/src/main/java/common/adapter/AwtCanvasAdapter.java b/services/console-proxy/rdpconsole/src/main/java/common/adapter/AwtCanvasAdapter.java index f3a73d70dbd..b60dccfc03e 100644 --- a/services/console-proxy/rdpconsole/src/main/java/common/adapter/AwtCanvasAdapter.java +++ b/services/console-proxy/rdpconsole/src/main/java/common/adapter/AwtCanvasAdapter.java @@ -70,7 +70,6 @@ public class AwtCanvasAdapter extends BaseElement { default: throw new RuntimeException("Order is not implemented: " + buf + "."); - // break; } buf.unref(); @@ -93,8 +92,6 @@ public class AwtCanvasAdapter extends BaseElement { Graphics2D g = (Graphics2D)image.getGraphics(); for (BitmapRectangle rectangle : order.rectangles) { - // *DEBUG*/System.out.println("["+this+"] DEBUG: Rectangle: " + - // rectangle.toString()); int x = rectangle.x; int y = rectangle.y; @@ -148,9 +145,6 @@ public class AwtCanvasAdapter extends BaseElement { * Example. */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); - // System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); ByteBuffer packet = new ByteBuffer(new byte[] {0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x04, 0x0a, 0x00, 0x0c, (byte)0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/RdpClient.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/RdpClient.java index 3dd7cf92127..767ca36cb18 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/RdpClient.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/RdpClient.java @@ -96,15 +96,6 @@ public class RdpClient extends PipelineImpl { assembleRDPPipeline(serverHostName, domain, userName, password, pcb, screen, canvas, sslState); } - // /* DEBUG */ -// @Override -// protected HashMap initElementMap(String id) { -// HashMap map = new HashMap(); -// map.put("IN", new ServerPacketSniffer("server <")); -// map.put("OUT", new ClientPacketSniffer("> client")); -// return map; -// } - /** * Assemble connection sequence and main pipeline. * diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/clip/ClipboardDataFormat.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/clip/ClipboardDataFormat.java index 3a165360933..29afc523ad7 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/clip/ClipboardDataFormat.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/clip/ClipboardDataFormat.java @@ -40,11 +40,6 @@ public class ClipboardDataFormat { // Names HTML_FORMAT, - - // RTF_AS_TEXT, - // RICH_TEXT_FORMAT_WITHOUT_OBJECTS, - // RICH_TEXT_FORMAT, - }; public final int id; @@ -115,15 +110,6 @@ public class ClipboardDataFormat { if (HTML_FORMAT.equals(name)) return buf.readVariableString(RdpConstants.CHARSET_8); // TODO: verify - // if (RTF_AS_TEXT.equals(name)) - // return buf.readVariableString(RdpConstants.CHARSET_8); // TODO: verify - // - // if (RICH_TEXT_FORMAT_WITHOUT_OBJECTS.equals(name)) - // return buf.readVariableString(RdpConstants.CHARSET_8); // TODO: verify - // - // if (RICH_TEXT_FORMAT.equals(name)) - // return buf.readVariableString(RdpConstants.CHARSET_8); // TODO: verify - return null; } diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/ntlmssp/asn1/TSRequest.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/ntlmssp/asn1/TSRequest.java index c5ba5d62ba9..11aee538fb0 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/ntlmssp/asn1/TSRequest.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/ntlmssp/asn1/TSRequest.java @@ -180,14 +180,8 @@ public class TSRequest extends Sequence { TSRequest request = new TSRequest("TSRequest"); // Read request from buffer - // System.out.println("Request BER tree before parsing: " + request); ByteBuffer toReadBuf = new ByteBuffer(packet); request.readTag(toReadBuf); - // System.out.println("Request BER tree after parsing: " + request); - - // System.out.println("version value: " + request.version.value); - // System.out.println("negoToken value: " + ((NegoItem) - // request.negoTokens.tags[0]).negoToken.value); // Write request to buffer and compare with original ByteBuffer toWriteBuf = new ByteBuffer(packet.length + 100, true); diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientConfirmActivePDU.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientConfirmActivePDU.java index b77f201dd77..bee26a635ad 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientConfirmActivePDU.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientConfirmActivePDU.java @@ -27,7 +27,7 @@ import streamer.debug.MockSource; import common.ScreenDescription; /** - * @see http://msdn.microsoft.com/en-us/library/cc240488.aspx + * @see microsoft msdn explanation */ public class ClientConfirmActivePDU extends BaseElement { diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSAttachUserRequest.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSAttachUserRequest.java index 47a07da73e0..df575473847 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSAttachUserRequest.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSAttachUserRequest.java @@ -60,9 +60,7 @@ public class ClientMCSAttachUserRequest extends OneTimeSwitch { * Example. */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); /* @formatter:off */ byte[] packet = new byte[] { diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java index 8213b74a14f..92c7291c21a 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java @@ -57,7 +57,6 @@ public class ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs extends OneT // Parse channel confirm response int typeAndFlags = buf.readUnsignedByte(); int type = typeAndFlags >> 2; - // int flags = typeAndFlags & 0x3; if (type != MCS_CHANNEL_CONFIRM_PDU) throw new RuntimeException("[" + this + "] ERROR: Incorrect type of MCS AttachUserConfirm PDU. Expected value: 15, actual value: " + type + ", data: " + buf + "."); @@ -74,11 +73,9 @@ public class ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs extends OneT // Channel Join Request PDU the connection SHOULD be dropped. // Initiator: 1007 (6+1001) - // int initiator=buf.readUnsignedShort(); buf.skipBytes(2); // Requested channel - // int requestedChannel=buf.readUnsignedShort(); buf.skipBytes(2); // Actual channel @@ -123,9 +120,7 @@ public class ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs extends OneT * @see http://msdn.microsoft.com/en-us/library/cc240834.aspx */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); /* @formatter:off */ byte[] clientRequestPacket = new byte[] { diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java index b7b52f0ab5f..5390fbf4a76 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java @@ -105,9 +105,7 @@ public class ClientSynchronizePDU extends OneTimeSwitch { * @see http://msdn.microsoft.com/en-us/library/cc240841.aspx */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); /* @formatter:off */ byte[] packet = new byte[] { diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerBitmapUpdate.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerBitmapUpdate.java index 6accc162f0b..39553c97e3c 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerBitmapUpdate.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerBitmapUpdate.java @@ -142,7 +142,6 @@ public class ServerBitmapUpdate extends BaseElement { // flag is not. // Note: Even when compression header is enabled, server sends nothing. - // rectangle.compressedBitmapHeader = buf.readBytes(8); } // (variable): A variable-length array of bytes describing a bitmap image. diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerDemandActivePDU.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerDemandActivePDU.java index d11a26b7296..9b95b0ccf33 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerDemandActivePDU.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerDemandActivePDU.java @@ -28,8 +28,8 @@ import streamer.debug.MockSource; import common.ScreenDescription; /** - * @see http://msdn.microsoft.com/en-us/library/cc240669.aspx - * @see http://msdn.microsoft.com/en-us/library/cc240484.aspx + * @see msdn cc240669 + * @see msdn cc240484 */ public class ServerDemandActivePDU extends BaseElement { @@ -83,7 +83,6 @@ public class ServerDemandActivePDU extends BaseElement { // (variable): A variable-length array of bytes containing a source // descriptor, - // ByteBuffer sourceDescriptor = buf.readBytes(lengthSourceDescriptor); buf.skipBytes(lengthSourceDescriptor); // (variable): An array of Capability Set (section 2.2.1.13.1.1.1) @@ -216,7 +215,7 @@ public class ServerDemandActivePDU extends BaseElement { public static final int CAPSSETTYPE_FRAME_ACKNOWLEDGE = 0x001E; /** - * @see http://msdn.microsoft.com/en-us/library/cc240486.aspx + * @see msdn cc240486 */ protected void handleCapabiltySets(ByteBuffer buf) { // (2 bytes): A 16-bit, unsigned integer. The number of capability sets @@ -312,7 +311,7 @@ public class ServerDemandActivePDU extends BaseElement { } /** - * @see http://msdn.microsoft.com/en-us/library/cc240554.aspx + * @see msdn cc240554 */ protected void handleBitmapCapabilities(ByteBuffer buf) { @@ -388,9 +387,7 @@ public class ServerDemandActivePDU extends BaseElement { * */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); /* @formatter:off */ byte[] packet = new byte[] { diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerIOChannelRouter.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerIOChannelRouter.java index 59613bb2b19..20d5f00a048 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerIOChannelRouter.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerIOChannelRouter.java @@ -73,7 +73,6 @@ public class ServerIOChannelRouter extends BaseElement { { // It is ServerErrorAlert-ValidClient // Ignore it - //throw new RuntimeException("[" + this + "] ERROR: Incorrect PDU length: " + length + ", data: " + buf + "."); } int type = buf.readUnsignedShortLE() & 0xf; @@ -88,14 +87,12 @@ public class ServerIOChannelRouter extends BaseElement { case PDUTYPE_CONFIRMACTIVEPDU: throw new RuntimeException("Unexpected client CONFIRM ACTIVE PDU. Data: " + buf + "."); case PDUTYPE_DEACTIVATEALLPDU: - // pushDataToPad("deactivate_all", buf); /* ignore */buf.unref(); break; case PDUTYPE_DATAPDU: handleDataPdu(buf); break; case PDUTYPE_SERVER_REDIR_PKT: - // pushDataToPad("server_redir", buf); /* ignore */buf.unref(); break; default: @@ -253,7 +250,6 @@ public class ServerIOChannelRouter extends BaseElement { long shareId = buf.readUnsignedIntLE(); if (shareId != state.serverShareId) throw new RuntimeException("Unexpected share ID: " + shareId + "."); -// buf.skipBytes(4); // Padding. buf.skipBytes(1); @@ -461,9 +457,7 @@ public class ServerIOChannelRouter extends BaseElement { * */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); byte[] packet = new byte[] { // TPKT diff --git a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerMCSPDU.java b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerMCSPDU.java index d28d0a09f70..71afe4506b3 100644 --- a/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerMCSPDU.java +++ b/services/console-proxy/rdpconsole/src/main/java/rdpclient/rdp/ServerMCSPDU.java @@ -42,7 +42,6 @@ public class ServerMCSPDU extends BaseElement { switch (type) { // Expected type: send data indication: 26 (0x1a, top 6 bits, or 0x68) case 0x1a: { - // int userId = buf.readUnsignedShort() + 1001; // User ID: 1002 (1001+1) buf.skipBytes(2); // Ignore user ID int channelId = buf.readUnsignedShort(); // Channel ID: 1003 @@ -78,9 +77,6 @@ public class ServerMCSPDU extends BaseElement { * */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); - // System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); byte[] packet = new byte[] { // TPKT diff --git a/services/console-proxy/rdpconsole/src/main/java/streamer/BaseElement.java b/services/console-proxy/rdpconsole/src/main/java/streamer/BaseElement.java index 15e1a871033..5f97da21d1f 100644 --- a/services/console-proxy/rdpconsole/src/main/java/streamer/BaseElement.java +++ b/services/console-proxy/rdpconsole/src/main/java/streamer/BaseElement.java @@ -187,7 +187,6 @@ public class BaseElement implements Element { if (buf == null) throw new NullPointerException(); - //return; if (outputPads.size() == 0) throw new RuntimeException("Number of outgoing connection is zero. Cannot send data to output. Data: " + buf + "."); diff --git a/services/console-proxy/rdpconsole/src/main/java/streamer/PipelineImpl.java b/services/console-proxy/rdpconsole/src/main/java/streamer/PipelineImpl.java index 84ed51440d0..df2652e5c9a 100644 --- a/services/console-proxy/rdpconsole/src/main/java/streamer/PipelineImpl.java +++ b/services/console-proxy/rdpconsole/src/main/java/streamer/PipelineImpl.java @@ -307,9 +307,6 @@ public class PipelineImpl implements Pipeline { * Example. */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); - // System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); Pipeline pipeline = new PipelineImpl("main"); diff --git a/services/console-proxy/rdpconsole/src/main/java/streamer/Queue.java b/services/console-proxy/rdpconsole/src/main/java/streamer/Queue.java index ea64b323d2c..be4ed29e71c 100644 --- a/services/console-proxy/rdpconsole/src/main/java/streamer/Queue.java +++ b/services/console-proxy/rdpconsole/src/main/java/streamer/Queue.java @@ -101,7 +101,6 @@ public class Queue extends BaseElement { * Example. */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); Element source1 = new FakeSource("source1") { diff --git a/services/console-proxy/rdpconsole/src/main/java/streamer/debug/MockSource.java b/services/console-proxy/rdpconsole/src/main/java/streamer/debug/MockSource.java index a77f1d4a84b..31ef8160066 100644 --- a/services/console-proxy/rdpconsole/src/main/java/streamer/debug/MockSource.java +++ b/services/console-proxy/rdpconsole/src/main/java/streamer/debug/MockSource.java @@ -75,7 +75,6 @@ public class MockSource extends FakeSource { new ByteBuffer(new byte[] {3, 1, 2, 3}), new ByteBuffer(new byte[] {4, 1, 2}), new ByteBuffer(new byte[] {5, 1})}; verbose = true; delay = 100; - // this.numBuffers = this.bufs.length; } }; diff --git a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Authentication.java b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Authentication.java index 4aa834dfcca..8d0f9173a5b 100644 --- a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Authentication.java +++ b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Authentication.java @@ -256,9 +256,7 @@ public class Vnc33Authentication extends OneTimeSwitch { * Example. */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); final String password = "test"; diff --git a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Hello.java b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Hello.java index 812c6a83644..d677abaffd5 100644 --- a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Hello.java +++ b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/Vnc33Hello.java @@ -82,9 +82,7 @@ public class Vnc33Hello extends OneTimeSwitch { * Example. */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); InputStream is = new ByteArrayInputStream("RFB 003.007\ntest".getBytes(RfbConstants.US_ASCII_CHARSET)); ByteArrayOutputStream initOS = new ByteArrayOutputStream(); diff --git a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncInitializer.java b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncInitializer.java index 0b96c7303e4..4f4d96d07d0 100644 --- a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncInitializer.java +++ b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncInitializer.java @@ -158,9 +158,7 @@ public class VncInitializer extends OneTimeSwitch { * Example. */ public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); final String desktopName = "test"; diff --git a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncMessageHandler.java b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncMessageHandler.java index 5914cb30f7a..e9b8933830f 100644 --- a/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncMessageHandler.java +++ b/services/console-proxy/rdpconsole/src/main/java/vncclient/vnc/VncMessageHandler.java @@ -330,9 +330,7 @@ public class VncMessageHandler extends BaseElement { */ public static void main(String[] args) { - // System.setProperty("streamer.Link.debug", "true"); System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); Element source = new MockSource("source") { { diff --git a/services/console-proxy/server/pom.xml b/services/console-proxy/server/pom.xml index 8eff010d322..3f5b9db68c2 100644 --- a/services/console-proxy/server/pom.xml +++ b/services/console-proxy/server/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-service-console-proxy - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java b/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java index a25abac981b..e75ccea9044 100644 --- a/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java +++ b/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java @@ -113,7 +113,6 @@ public class ConsoleProxy { } catch (URISyntaxException e) { System.out.println("Unable to convert log4j configuration Url to URI"); } - // DOMConfigurator.configure(configUrl); } else { System.out.println("Configure log4j with default properties"); } diff --git a/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyThumbnailHandler.java b/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyThumbnailHandler.java index e2ec7df5d69..703fed7a8a9 100644 --- a/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyThumbnailHandler.java +++ b/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyThumbnailHandler.java @@ -197,7 +197,7 @@ public class ConsoleProxyThumbnailHandler implements HttpHandler { startx = 0; g.drawString(text, startx, h / 2); } catch (Throwable e) { - logger.warn("Problem in generating text to thumnail image, return blank image"); + logger.warn("Problem in generating text to thumbnail image, return blank image"); } return img; } diff --git a/services/pom.xml b/services/pom.xml index 2d0e70fa419..b6a456b159d 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/services/secondary-storage/controller/pom.xml b/services/secondary-storage/controller/pom.xml index 901f8f3a76b..d8934bbb08b 100644 --- a/services/secondary-storage/controller/pom.xml +++ b/services/secondary-storage/controller/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-service-secondary-storage - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/services/secondary-storage/pom.xml b/services/secondary-storage/pom.xml index 06aa7b83089..0cc0115c0ca 100644 --- a/services/secondary-storage/pom.xml +++ b/services/secondary-storage/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack-services - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/services/secondary-storage/server/pom.xml b/services/secondary-storage/server/pom.xml index 29669623dd0..e6aec8a42f7 100644 --- a/services/secondary-storage/server/pom.xml +++ b/services/secondary-storage/server/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-service-secondary-storage - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 916773cc5a4..093840157d0 100644 --- a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -2225,8 +2225,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S Map tmpltInfos = new HashMap(); for (S3ObjectSummary objectSummary : objectSummaries) { String key = objectSummary.getKey(); - // String installPath = StringUtils.substringBeforeLast(key, - // S3Utils.SEPARATOR); String uniqueName = determineS3TemplateNameFromKey(key); // TODO: isPublic value, where to get? TemplateProp tInfo = new TemplateProp(uniqueName, key, objectSummary.getSize(), objectSummary.getSize(), true, false); @@ -2246,8 +2244,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S Map tmpltInfos = new HashMap(); for (S3ObjectSummary objectSummary : objectSummaries) { String key = objectSummary.getKey(); - // String installPath = StringUtils.substringBeforeLast(key, - // S3Utils.SEPARATOR); Long id = determineS3VolumeIdFromKey(key); // TODO: how to get volume template name TemplateProp tInfo = new TemplateProp(id.toString(), key, objectSummary.getSize(), objectSummary.getSize(), true, false); diff --git a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/DownloadManagerImpl.java b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/DownloadManagerImpl.java index 599dcfa0c48..dd3ecbdb8f3 100644 --- a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/DownloadManagerImpl.java +++ b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/DownloadManagerImpl.java @@ -1058,7 +1058,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { if (!loc.load()) { logger.warn("Post download installation was not completed for " + path); - // loc.purge(); _storage.cleanup(path, templateDir); continue; } @@ -1104,7 +1103,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { if (!loc.load()) { logger.warn("Post download installation was not completed for " + path); - // loc.purge(); _storage.cleanup(path, volumeDir); continue; } diff --git a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/UploadManagerImpl.java b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/UploadManagerImpl.java index ae02d7e8aa7..abddc3aa1bf 100644 --- a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/UploadManagerImpl.java +++ b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/UploadManagerImpl.java @@ -415,7 +415,6 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager { if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) { logger.info("UploadManager: starting additional services since we are inside system vm"); startAdditionalServices(); - //blockOutgoingOnPrivate(); } value = (String)params.get("install.numthreads"); diff --git a/services/secondary-storage/server/src/test/java/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResourceTest.java b/services/secondary-storage/server/src/test/java/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResourceTest.java index 3d62bc127af..e79d013afd8 100644 --- a/services/secondary-storage/server/src/test/java/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResourceTest.java +++ b/services/secondary-storage/server/src/test/java/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResourceTest.java @@ -71,7 +71,6 @@ public class LocalNfsSecondaryStorageResourceTest extends TestCase { } System.setProperty("paths.script", "/Users/edison/develop/asf-master/script"); - //resource.configure("test", new HashMap()); } @Test diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index 8c453edda44..eb68c1e0181 100755 --- a/setup/bindir/cloud-setup-databases.in +++ b/setup/bindir/cloud-setup-databases.in @@ -199,6 +199,10 @@ for full help self.info("No mysql root user specified, will not create Cloud DB schema\n", None) return + if self.areCloudDatabasesCreated() and not self.options.schemaonly and not self.options.forcerecreate: + self.errorAndExit("Aborting script as the databases (cloud, cloud_usage) already exist.\n" \ + "Please use the --force-recreate parameter if you want to recreate the databases and schemas, or use --schema-only if you only want to create the schemas only.") + replacements = ( ("CREATE USER cloud identified by 'cloud';", "CREATE USER %s@`localhost` identified by '%s'; CREATE USER %s@`%%` identified by '%s';"%( @@ -239,10 +243,6 @@ for full help ("DROP USER 'cloud'@'%' ;", "DO NULL;") ) - if self.areCloudDatabasesCreated() and not self.options.forcerecreate: - self.errorAndExit("Aborting script as the databases (cloud, cloud_usage) already exist.\n" \ - "Please use the --force-recreate parameter if you want to recreate the schemas.") - scriptsToRun = ["create-database","create-schema", "create-database-premium","create-schema-premium"] if self.options.schemaonly: scriptsToRun = ["create-schema", "create-schema-premium"] @@ -617,11 +617,11 @@ for example: self.parser.add_option("-d", "--deploy-as", action="store", type="string", dest="rootcreds", default="", help="Colon-separated user name and password of a MySQL user with administrative privileges") self.parser.add_option("-s", "--schema-only", action="store_true", dest="schemaonly", default=False, - help="Creates the db schema without having to pass root credentials - " \ + help="Creates the db schema only without having to pass root credentials - " \ "Please note: The databases (cloud, cloud_usage) and user (cloud) has to be configured " \ "manually prior to running this script when using this flag.") self.parser.add_option("--force-recreate", action="store_true", dest="forcerecreate", default=False, - help="Force recreation of the existing DB schemas. This option is disabled by default." \ + help="Force recreation of the existing DB databases and schemas. This option is disabled by default." \ "Please note: The databases (cloud, cloud_usage) and its tables data will be lost and recreated.") self.parser.add_option("-a", "--auto", action="store", type="string", dest="serversetup", default="", diff --git a/systemvm/agent/images/bright-green.png b/systemvm/agent/images/bright-green.png index 685dfc1f5f4..bcabbef7c80 100644 Binary files a/systemvm/agent/images/bright-green.png and b/systemvm/agent/images/bright-green.png differ diff --git a/systemvm/agent/images/gray-green.png b/systemvm/agent/images/gray-green.png index e785a63f83e..155c7f5b9d6 100644 Binary files a/systemvm/agent/images/gray-green.png and b/systemvm/agent/images/gray-green.png differ diff --git a/systemvm/agent/images/left.png b/systemvm/agent/images/left.png index fb7506618d7..01b05a3ddbf 100644 Binary files a/systemvm/agent/images/left.png and b/systemvm/agent/images/left.png differ diff --git a/systemvm/agent/images/right.png b/systemvm/agent/images/right.png index 4abac818410..d1514e2dc18 100644 Binary files a/systemvm/agent/images/right.png and b/systemvm/agent/images/right.png differ diff --git a/systemvm/agent/images/right2.png b/systemvm/agent/images/right2.png index cca9379fe5b..4a3f4752ed1 100644 Binary files a/systemvm/agent/images/right2.png and b/systemvm/agent/images/right2.png differ diff --git a/systemvm/agent/images/winlog.png b/systemvm/agent/images/winlog.png index c7668c52f53..59c4e11e229 100644 Binary files a/systemvm/agent/images/winlog.png and b/systemvm/agent/images/winlog.png differ diff --git a/systemvm/agent/noVNC/app/images/alt.png b/systemvm/agent/noVNC/app/images/alt.png index 2d5e35e7fb8..ee32a127146 100644 Binary files a/systemvm/agent/noVNC/app/images/alt.png and b/systemvm/agent/noVNC/app/images/alt.png differ diff --git a/systemvm/agent/noVNC/app/images/clipboard.png b/systemvm/agent/noVNC/app/images/clipboard.png index d7fe507eb79..8e6a365087a 100644 Binary files a/systemvm/agent/noVNC/app/images/clipboard.png and b/systemvm/agent/noVNC/app/images/clipboard.png differ diff --git a/systemvm/agent/noVNC/app/images/connect.png b/systemvm/agent/noVNC/app/images/connect.png index abdbe420d5c..385d27ec0e2 100644 Binary files a/systemvm/agent/noVNC/app/images/connect.png and b/systemvm/agent/noVNC/app/images/connect.png differ diff --git a/systemvm/agent/noVNC/app/images/ctrl.png b/systemvm/agent/noVNC/app/images/ctrl.png index fbc9e1314ec..7e4a91ee8fe 100644 Binary files a/systemvm/agent/noVNC/app/images/ctrl.png and b/systemvm/agent/noVNC/app/images/ctrl.png differ diff --git a/systemvm/agent/noVNC/app/images/ctrlaltdel.png b/systemvm/agent/noVNC/app/images/ctrlaltdel.png index dd0497819d4..1b54cec4aa7 100644 Binary files a/systemvm/agent/noVNC/app/images/ctrlaltdel.png and b/systemvm/agent/noVNC/app/images/ctrlaltdel.png differ diff --git a/systemvm/agent/noVNC/app/images/disconnect.png b/systemvm/agent/noVNC/app/images/disconnect.png index 97eb1a98821..fc107b2ba74 100644 Binary files a/systemvm/agent/noVNC/app/images/disconnect.png and b/systemvm/agent/noVNC/app/images/disconnect.png differ diff --git a/systemvm/agent/noVNC/app/images/drag.png b/systemvm/agent/noVNC/app/images/drag.png index f006202a793..f347078d89c 100644 Binary files a/systemvm/agent/noVNC/app/images/drag.png and b/systemvm/agent/noVNC/app/images/drag.png differ diff --git a/systemvm/agent/noVNC/app/images/error.png b/systemvm/agent/noVNC/app/images/error.png index 04e78e1a4ee..3246e4ec837 100644 Binary files a/systemvm/agent/noVNC/app/images/error.png and b/systemvm/agent/noVNC/app/images/error.png differ diff --git a/systemvm/agent/noVNC/app/images/esc.png b/systemvm/agent/noVNC/app/images/esc.png index e1b1bfa2a9c..6dbae178989 100644 Binary files a/systemvm/agent/noVNC/app/images/esc.png and b/systemvm/agent/noVNC/app/images/esc.png differ diff --git a/systemvm/agent/noVNC/app/images/expander.png b/systemvm/agent/noVNC/app/images/expander.png index 27937219e9b..3cc8ed4e710 100644 Binary files a/systemvm/agent/noVNC/app/images/expander.png and b/systemvm/agent/noVNC/app/images/expander.png differ diff --git a/systemvm/agent/noVNC/app/images/fullscreen.png b/systemvm/agent/noVNC/app/images/fullscreen.png index a7f26344292..9c594726993 100644 Binary files a/systemvm/agent/noVNC/app/images/fullscreen.png and b/systemvm/agent/noVNC/app/images/fullscreen.png differ diff --git a/systemvm/agent/noVNC/app/images/handle.png b/systemvm/agent/noVNC/app/images/handle.png index cf0e5d55f1c..d5850c7952e 100644 Binary files a/systemvm/agent/noVNC/app/images/handle.png and b/systemvm/agent/noVNC/app/images/handle.png differ diff --git a/systemvm/agent/noVNC/app/images/handle_bg.png b/systemvm/agent/noVNC/app/images/handle_bg.png index efb0357ac82..2165c21637f 100644 Binary files a/systemvm/agent/noVNC/app/images/handle_bg.png and b/systemvm/agent/noVNC/app/images/handle_bg.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-120x120.png b/systemvm/agent/noVNC/app/images/icons/novnc-120x120.png index 40823efbadf..a77e84e409b 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-120x120.png and b/systemvm/agent/noVNC/app/images/icons/novnc-120x120.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-144x144.png b/systemvm/agent/noVNC/app/images/icons/novnc-144x144.png index eee71f11c74..dd45211b57d 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-144x144.png and b/systemvm/agent/noVNC/app/images/icons/novnc-144x144.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-152x152.png b/systemvm/agent/noVNC/app/images/icons/novnc-152x152.png index 0694b2de39b..c058b884ad5 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-152x152.png and b/systemvm/agent/noVNC/app/images/icons/novnc-152x152.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-16x16.png b/systemvm/agent/noVNC/app/images/icons/novnc-16x16.png index 42108f40999..ebcc1b35625 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-16x16.png and b/systemvm/agent/noVNC/app/images/icons/novnc-16x16.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-192x192.png b/systemvm/agent/noVNC/app/images/icons/novnc-192x192.png index ef9201f4370..806a4ca2ce6 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-192x192.png and b/systemvm/agent/noVNC/app/images/icons/novnc-192x192.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-24x24.png b/systemvm/agent/noVNC/app/images/icons/novnc-24x24.png index 110613594b8..fda9115d1ee 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-24x24.png and b/systemvm/agent/noVNC/app/images/icons/novnc-24x24.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-32x32.png b/systemvm/agent/noVNC/app/images/icons/novnc-32x32.png index ff00dc305a7..4a6c217819e 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-32x32.png and b/systemvm/agent/noVNC/app/images/icons/novnc-32x32.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-48x48.png b/systemvm/agent/noVNC/app/images/icons/novnc-48x48.png index f24cd6cc939..2f120b497f8 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-48x48.png and b/systemvm/agent/noVNC/app/images/icons/novnc-48x48.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-60x60.png b/systemvm/agent/noVNC/app/images/icons/novnc-60x60.png index 06b0d609a0f..944d2b7166d 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-60x60.png and b/systemvm/agent/noVNC/app/images/icons/novnc-60x60.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-64x64.png b/systemvm/agent/noVNC/app/images/icons/novnc-64x64.png index 6d0fb34181b..84607e8480b 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-64x64.png and b/systemvm/agent/noVNC/app/images/icons/novnc-64x64.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-72x72.png b/systemvm/agent/noVNC/app/images/icons/novnc-72x72.png index 23163a22d06..4aeb332d0f9 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-72x72.png and b/systemvm/agent/noVNC/app/images/icons/novnc-72x72.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-76x76.png b/systemvm/agent/noVNC/app/images/icons/novnc-76x76.png index aef61c48043..859497e8572 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-76x76.png and b/systemvm/agent/noVNC/app/images/icons/novnc-76x76.png differ diff --git a/systemvm/agent/noVNC/app/images/icons/novnc-96x96.png b/systemvm/agent/noVNC/app/images/icons/novnc-96x96.png index 1a77c53f4cb..cb1d7dca984 100644 Binary files a/systemvm/agent/noVNC/app/images/icons/novnc-96x96.png and b/systemvm/agent/noVNC/app/images/icons/novnc-96x96.png differ diff --git a/systemvm/agent/noVNC/app/images/info.png b/systemvm/agent/noVNC/app/images/info.png index 21e358981af..84e04c6767a 100644 Binary files a/systemvm/agent/noVNC/app/images/info.png and b/systemvm/agent/noVNC/app/images/info.png differ diff --git a/systemvm/agent/noVNC/app/images/keyboard.png b/systemvm/agent/noVNC/app/images/keyboard.png index fe8056bda1e..379d1e0c881 100644 Binary files a/systemvm/agent/noVNC/app/images/keyboard.png and b/systemvm/agent/noVNC/app/images/keyboard.png differ diff --git a/systemvm/agent/noVNC/app/images/power.png b/systemvm/agent/noVNC/app/images/power.png index 7f871358d1f..9e26cc30fab 100644 Binary files a/systemvm/agent/noVNC/app/images/power.png and b/systemvm/agent/noVNC/app/images/power.png differ diff --git a/systemvm/agent/noVNC/app/images/settings.png b/systemvm/agent/noVNC/app/images/settings.png index 8d0c0d4e865..72959f4ac86 100644 Binary files a/systemvm/agent/noVNC/app/images/settings.png and b/systemvm/agent/noVNC/app/images/settings.png differ diff --git a/systemvm/agent/noVNC/app/images/shift.png b/systemvm/agent/noVNC/app/images/shift.png index b79d6973c8b..2fbea32a309 100644 Binary files a/systemvm/agent/noVNC/app/images/shift.png and b/systemvm/agent/noVNC/app/images/shift.png differ diff --git a/systemvm/agent/noVNC/app/images/tab.png b/systemvm/agent/noVNC/app/images/tab.png index 6adb7819d1e..cf7623a1cf8 100644 Binary files a/systemvm/agent/noVNC/app/images/tab.png and b/systemvm/agent/noVNC/app/images/tab.png differ diff --git a/systemvm/agent/noVNC/app/images/toggleextrakeys.png b/systemvm/agent/noVNC/app/images/toggleextrakeys.png index 0f80f6d5ba3..bedc2a4925d 100644 Binary files a/systemvm/agent/noVNC/app/images/toggleextrakeys.png and b/systemvm/agent/noVNC/app/images/toggleextrakeys.png differ diff --git a/systemvm/agent/noVNC/app/images/warning.png b/systemvm/agent/noVNC/app/images/warning.png index e9dd550c132..a6aa2f27eca 100644 Binary files a/systemvm/agent/noVNC/app/images/warning.png and b/systemvm/agent/noVNC/app/images/warning.png differ diff --git a/systemvm/agent/noVNC/app/images/windows.png b/systemvm/agent/noVNC/app/images/windows.png index 036e1ae1130..1bfdbbe5ef2 100644 Binary files a/systemvm/agent/noVNC/app/images/windows.png and b/systemvm/agent/noVNC/app/images/windows.png differ diff --git a/systemvm/agent/noVNC/vendor/pako/README.md b/systemvm/agent/noVNC/vendor/pako/README.md index 755df643d76..6b8b37a6ee1 100644 --- a/systemvm/agent/noVNC/vendor/pako/README.md +++ b/systemvm/agent/noVNC/vendor/pako/README.md @@ -1,3 +1,22 @@ + + This is an ES6-modules-compatible version of https://github.com/nodeca/pako, based on pako version 1.0.3. diff --git a/systemvm/agent/scripts/run-proxy.sh b/systemvm/agent/scripts/run-proxy.sh index f26f54b12b5..40e7c8f6447 100755 --- a/systemvm/agent/scripts/run-proxy.sh +++ b/systemvm/agent/scripts/run-proxy.sh @@ -33,16 +33,4 @@ do CP=${CP}:$file done -#CMDLINE=$(cat /proc/cmdline) -#for i in $CMDLINE -# do -# KEY=$(echo $i | cut -d= -f1) -# VALUE=$(echo $i | cut -d= -f2) -# case $KEY in -# mgmt_host) -# MGMT_HOST=$VALUE -# ;; -# esac -# done - java -mx700m -cp $CP:./conf com.cloud.consoleproxy.ConsoleProxy $@ diff --git a/systemvm/debian/opt/cloud/bin/baremetal_snat.sh b/systemvm/debian/opt/cloud/bin/baremetal_snat.sh index 2092ded4e4e..5952eec39c6 100755 --- a/systemvm/debian/opt/cloud/bin/baremetal_snat.sh +++ b/systemvm/debian/opt/cloud/bin/baremetal_snat.sh @@ -1,21 +1,21 @@ #!/bin/bash -#Licensed to the Apache Software Foundation (ASF) under one -#or more contributor license agreements. See the NOTICE file -#distributed with this work for additional information -#regarding copyright ownership. The ASF licenses this file -#to you under the Apache License, Version 2.0 (the -#"License"); you may not use this file except in compliance -#with the License. You may obtain a copy of the License at +# 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 +# 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. +# 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. set +u diff --git a/systemvm/debian/opt/cloud/bin/dnsmasq.sh b/systemvm/debian/opt/cloud/bin/dnsmasq.sh index d675e08c75b..8cba9c533c5 100755 --- a/systemvm/debian/opt/cloud/bin/dnsmasq.sh +++ b/systemvm/debian/opt/cloud/bin/dnsmasq.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash + # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -10,6 +11,7 @@ # 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 diff --git a/systemvm/debian/opt/cloud/bin/loadbalancer.sh b/systemvm/debian/opt/cloud/bin/loadbalancer.sh index 6a2dc6c20d6..c527f0b3fd4 100755 --- a/systemvm/debian/opt/cloud/bin/loadbalancer.sh +++ b/systemvm/debian/opt/cloud/bin/loadbalancer.sh @@ -144,7 +144,7 @@ fw_entry() { local lb_vif_list=$(get_lb_vif_list) for vif in $lb_vif_list; do -#TODO : The below delete will be used only when we upgrade the from older version to the newer one , the below delete become obsolute in the future. +#TODO : The below delete will be used only when we upgrade the from older version to the newer one, the below delete become obsolete in the future. sudo iptables -D INPUT -i $vif -p tcp -d $pubIp --dport $dport -j ACCEPT 2> /dev/null sudo iptables -A load_balancer_$vif -p tcp -d $pubIp --dport $dport -j ACCEPT @@ -161,7 +161,7 @@ fw_entry() { sudo iptables -A lb_stats -s $cidrs -p tcp -m state --state NEW -d $pubIp --dport $dport -j ACCEPT -#TODO : The below delete in the for-loop will be used only when we upgrade the from older version to the newer one , the below delete become obsolute in the future. +#TODO : The below delete in the for-loop will be used only when we upgrade the from older version to the newer one, the below delete become obsolete in the future. for i in $r do local pubIp=$(echo $i | cut -d: -f1) diff --git a/systemvm/debian/opt/cloud/bin/prepare_pxe.sh b/systemvm/debian/opt/cloud/bin/prepare_pxe.sh index 9c4c18eda7b..6da309bb1e5 100755 --- a/systemvm/debian/opt/cloud/bin/prepare_pxe.sh +++ b/systemvm/debian/opt/cloud/bin/prepare_pxe.sh @@ -1,9 +1,9 @@ #!/bin/sh -# + # 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 +# 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 @@ -16,7 +16,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# set +u diff --git a/systemvm/pom.xml b/systemvm/pom.xml index 941661082a7..9bffc45cf4e 100644 --- a/systemvm/pom.xml +++ b/systemvm/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/systemvm/systemvm-agent-descriptor.xml b/systemvm/systemvm-agent-descriptor.xml index 8cf40a16276..1d6e338eb23 100644 --- a/systemvm/systemvm-agent-descriptor.xml +++ b/systemvm/systemvm-agent-descriptor.xml @@ -60,6 +60,7 @@ log4j-cloud.xml consoleproxy.properties agent.properties + uefi.properties diff --git a/test/integration/component/test_base_image_updation.py b/test/integration/component/test_base_image_updation.py index bd78082be3e..fc4f6465f3a 100644 --- a/test/integration/component/test_base_image_updation.py +++ b/test/integration/component/test_base_image_updation.py @@ -575,7 +575,7 @@ class TestBaseImageUpdate(cloudstackTestCase): ) sleep_seconds = (self.services["recurring_snapshot"]["schedule"]) * 3600 + 600 sleep_minutes = sleep_seconds/60 - self.debug("Sleeping for %s minutes till the volume is snapshoted" %sleep_minutes) + self.debug("Sleeping for %s minutes till the volume is snapshotted" %sleep_minutes) time.sleep(sleep_seconds) retriesCount = self.services["retriesCount"] diff --git a/test/integration/component/test_egress_rules.py b/test/integration/component/test_egress_rules.py index 32f1dca5f9f..014303fc1f0 100644 --- a/test/integration/component/test_egress_rules.py +++ b/test/integration/component/test_egress_rules.py @@ -1165,8 +1165,8 @@ class TestInvalidAccountAuthroize(cloudstackTestCase): return @attr(tags = ["sg", "eip", "advancedsg"]) - def test_invalid_account_authroize(self): - """Test invalid account authroize + def test_invalid_account_authorize(self): + """Test invalid account authorize """ diff --git a/test/integration/component/test_escalations_ipaddresses.py b/test/integration/component/test_escalations_ipaddresses.py index fbcff2a5fd0..b91b67c16c3 100644 --- a/test/integration/component/test_escalations_ipaddresses.py +++ b/test/integration/component/test_escalations_ipaddresses.py @@ -4341,7 +4341,7 @@ class TestIpAddresses(cloudstackTestCase): vmgroup_disabled, "Failed to disable Autoscale VM group" ) - # Verifyign the state of the VM Group afte renabling + # Verifying the state of the VM Group after renabling self.assertEqual( "disabled", vmgroup_disabled.state, @@ -4375,7 +4375,7 @@ class TestIpAddresses(cloudstackTestCase): vmgroup_enabled, "Failed to enable Autoscale VM group" ) - # Verifyign the state of the VM Group afte renabling + # Verifying the state of the VM Group after renabling self.assertEqual( "enabled", vmgroup_enabled.state, diff --git a/test/integration/component/test_netscaler_nw_off.py b/test/integration/component/test_netscaler_nw_off.py index d9f6c9724f6..627c4a01c05 100644 --- a/test/integration/component/test_netscaler_nw_off.py +++ b/test/integration/component/test_netscaler_nw_off.py @@ -802,7 +802,7 @@ class TestNetScalerSharedMode(cloudstackTestCase): # Validate the following # 1. Add another netscaler device and spawn a new VM again - # 2. VM deployement should be successful + # 2. VM deployment should be successful self.debug("Adding another netscaler device: %s" % self.services["netscaler_2"]["ipaddress"]) @@ -1672,7 +1672,7 @@ class TestNwOffSToDUpgrade(cloudstackTestCase): # LB rules # 5. Deploy instance with dedicated network offering in account 3. # Create Lb rules. - # 6. Configure another instace of netscaler in dedicated mode + # 6. Configure another instance of netscaler in dedicated mode # 7. upgrade networkj for user 1 to dedicated network offering. # Create LB rules. LB rule creation should be successful @@ -2063,7 +2063,7 @@ class TestNwOffDToSUpgrade(cloudstackTestCase): # LB rules # 5. Deploy instance with dedicated network offering in account 3. # Create Lb rules. - # 6. Configure another instace of netscaler in dedicated mode + # 6. Configure another instance of netscaler in dedicated mode # 7. upgrade networkj for user 1 to dedicated network offering. # Create LB rules. LB rule creation should be successful diff --git a/test/integration/component/test_stopped_vm.py b/test/integration/component/test_stopped_vm.py index b7fe4b04b04..4e6fa1e3774 100644 --- a/test/integration/component/test_stopped_vm.py +++ b/test/integration/component/test_stopped_vm.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -""" P1 for stopped Virtual Maschine life cycle +""" P1 for stopped Virtual Machine life cycle """ # Import Local Modules from nose.plugins.attrib import attr diff --git a/test/integration/component/test_vpc_vm_life_cycle.py b/test/integration/component/test_vpc_vm_life_cycle.py index abe6d194a54..d487a7fa1bd 100644 --- a/test/integration/component/test_vpc_vm_life_cycle.py +++ b/test/integration/component/test_vpc_vm_life_cycle.py @@ -1274,7 +1274,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): except Exception as e: self.fail("Failed to deploy the virtual instance: %s" % e) - self.debug("Verify the deployment of virtual instace") + self.debug("Verify the deployment of virtual instance") vms = VirtualMachine.list( self.apiclient, id=vm.id, diff --git a/test/integration/plugins/linstor/README.md b/test/integration/plugins/linstor/README.md index 717f4e24e70..4505d1b7d57 100644 --- a/test/integration/plugins/linstor/README.md +++ b/test/integration/plugins/linstor/README.md @@ -1,9 +1,28 @@ + + # Linstor storage plugin -================================== + This directory contains the basic VM, Volume life cycle tests for Linstor storage pool (in KVM hypervisor). -# Running tests -=============== +## Running tests + To run the basic volume tests, first update the below test data of the CloudStack environment ``` diff --git a/test/integration/plugins/scaleio/README.md b/test/integration/plugins/scaleio/README.md index 6e1212ecb3a..47d458d34f8 100644 --- a/test/integration/plugins/scaleio/README.md +++ b/test/integration/plugins/scaleio/README.md @@ -1,9 +1,28 @@ + + # PowerFlex/ScaleIO storage plugin -================================== + This directory contains the basic VM, Volume life cycle tests for PowerFlex/ScaleIO storage pool (in KVM hypervisor). -# Running tests -=============== +## Running tests + To run the basic volume tests, first update the below test data of the CloudStack environment ``` diff --git a/test/integration/plugins/storpool/MigrateVolumeToStorPool.py b/test/integration/plugins/storpool/MigrateVolumeToStorPool.py index 4fc94d24383..85817902b02 100644 --- a/test/integration/plugins/storpool/MigrateVolumeToStorPool.py +++ b/test/integration/plugins/storpool/MigrateVolumeToStorPool.py @@ -440,5 +440,5 @@ class TestMigrateVolumeToAnotherPool(cloudstackTestCase): self.assertEqual( self.random_data_0, result[0], - "Check the random data is equal with the ramdom file!" + "Check the random data is equal with the random file!" ) diff --git a/test/integration/plugins/storpool/TestEncryptedVolumes.py b/test/integration/plugins/storpool/TestEncryptedVolumes.py index ac049fb77a2..e77cd0bd094 100644 --- a/test/integration/plugins/storpool/TestEncryptedVolumes.py +++ b/test/integration/plugins/storpool/TestEncryptedVolumes.py @@ -472,7 +472,7 @@ class TestEncryptedVolumes(cloudstackTestCase): self.assertEqual( self.random_data_0, result[0], - "Check the random data is equal with the ramdom file!" + "Check the random data is equal with the random file!" ) # Delete VM snapshot diff --git a/test/integration/plugins/storpool/TestStorPoolVolumes.py b/test/integration/plugins/storpool/TestStorPoolVolumes.py index 150fe830598..a6b81216f5e 100644 --- a/test/integration/plugins/storpool/TestStorPoolVolumes.py +++ b/test/integration/plugins/storpool/TestStorPoolVolumes.py @@ -1136,7 +1136,7 @@ class TestStoragePool(cloudstackTestCase): self.assertEqual( self.random_data_0, result[0], - "Check the random data is equal with the ramdom file!" + "Check the random data is equal with the random file!" ) @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true") diff --git a/test/integration/plugins/storpool/TestTagsOnStorPool.py b/test/integration/plugins/storpool/TestTagsOnStorPool.py index b813cd320c4..33ad41a463b 100644 --- a/test/integration/plugins/storpool/TestTagsOnStorPool.py +++ b/test/integration/plugins/storpool/TestTagsOnStorPool.py @@ -465,7 +465,7 @@ class TestStoragePool(cloudstackTestCase): self.assertEqual( self.random_data_0, result[0], - "Check the random data is equal with the ramdom file!" + "Check the random data is equal with the random file!" ) @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true") diff --git a/test/integration/plugins/storpool/TestVmSnapshots.py b/test/integration/plugins/storpool/TestVmSnapshots.py index 749e534f0da..b0f8192f1bb 100644 --- a/test/integration/plugins/storpool/TestVmSnapshots.py +++ b/test/integration/plugins/storpool/TestVmSnapshots.py @@ -336,7 +336,7 @@ class TestVmSnapshot(cloudstackTestCase): self.assertEqual( self.random_data_0, result[0], - "Check the random data is equal with the ramdom file!" + "Check the random data is equal with the random file!" ) @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true") diff --git a/test/integration/smoke/test_direct_download.py b/test/integration/smoke/test_direct_download.py index 6570bb9f0b3..e6960163bc2 100644 --- a/test/integration/smoke/test_direct_download.py +++ b/test/integration/smoke/test_direct_download.py @@ -251,7 +251,10 @@ class TestDirectDownloadTemplates(cloudstackTestCase): self.apiclient, id=poolId ) - return local_pool[0].tags + if local_pool[0].tags: + return local_pool[0].tags + else: + return "" def updateStoragePoolTags(self, poolId, tags): StoragePool.update( diff --git a/test/integration/smoke/test_network_traffic_type_api.py b/test/integration/smoke/test_network_traffic_type_api.py new file mode 100644 index 00000000000..10e9df47098 --- /dev/null +++ b/test/integration/smoke/test_network_traffic_type_api.py @@ -0,0 +1,73 @@ +# 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. + +# Import Local Modules +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.lib.base import ( + TrafficType, + PhysicalNetwork, + Zone, +) +from nose.plugins.attrib import attr + + +class TestTrafficTypeApi(cloudstackTestCase): + @classmethod + def setUpClass(cls): + cls.test_client = super(TestTrafficTypeApi, cls).getClsTestClient() + cls.api_client = cls.testClient.getApiClient() + cls.services = cls.testClient.getParsedTestDataConfig() + cls._cleanup = [] + cls.services["advanced_sg"]["zone"]["name"] = "TestTrafficTypeApi-zone" + cls.zone = Zone.create(cls.api_client, cls.services["advanced_sg"]["zone"]) + cls._cleanup.append(cls.zone) + + cls.physical_network = PhysicalNetwork.create( + cls.api_client, + cls.services["l2-network"], + isolationmethods="VLAN", + zoneid=cls.zone.id, + ) + cls._cleanup.append(cls.physical_network) + + @classmethod + def tearDownClass(cls): + super(TestTrafficTypeApi, cls).tearDownClass() + + + @attr(tags=["advanced"], required_hardware="false") + def test_list_api_fields(self): + traffic_type = TrafficType.add( + self.api_client, + physicalnetworkid=self.physical_network.id, + kvmnetworklabel="kvm", + traffictype="Public", + vlan="100", + ).traffictype + + traffic_types = TrafficType.list( + self.api_client, + physicalnetworkid=self.physical_network.id + ) + + assert len(traffic_types) == 1 + response = traffic_types[0] + self.assertEqual(response.id, traffic_type.id) + self.assertEqual(response.kvmnetworklabel, "kvm") + self.assertEqual(response.traffictype, "Public") + self.assertEqual(response.vlan, "100") + self.assertEqual(response.isolationmethods, "VLAN") diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py index 8c106f05a9f..c64de12b1c3 100644 --- a/test/integration/smoke/test_vm_snapshots.py +++ b/test/integration/smoke/test_vm_snapshots.py @@ -262,7 +262,7 @@ class TestVmSnapshot(cloudstackTestCase): self.assertEqual( self.random_data_0, result[0], - "Check the random data is equal with the ramdom file!" + "Check the random data is equal with the random file!" ) @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true") diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py index 6cf3f082bc2..ad1c359c27b 100644 --- a/test/integration/smoke/test_volumes.py +++ b/test/integration/smoke/test_volumes.py @@ -988,7 +988,7 @@ class TestVolumes(cloudstackTestCase): return True, list_volume_response[0] return False, None - # sleep interval is 1s, retries is 360, this will sleep atmost 360 seconds, or 6 mins + # sleep interval is 1s, retries is 360, this will sleep at most 360 seconds, or 6 mins res, response = wait_until(1, 360, checkVolumeResponse) if not res: self.fail("Failed to return root volume response") diff --git a/test/integration/testpaths/testpath_storage_migration.py b/test/integration/testpaths/testpath_storage_migration.py index 5b821bcb5da..c63cdfc8e22 100644 --- a/test/integration/testpaths/testpath_storage_migration.py +++ b/test/integration/testpaths/testpath_storage_migration.py @@ -2809,7 +2809,7 @@ class TestLiveStorageMigration(cloudstackTestCase): disk=root_volume_cluster, disk_type="rootdiskdevice") - # Get Destnation Pool + # Get Destination Pool # Avoid storage Pool on which ROOT disk exists storagePools_to_avoid = [root_volume_cluster.storage] @@ -2840,7 +2840,7 @@ class TestLiveStorageMigration(cloudstackTestCase): disk=data_volume_1_cluster, disk_type="datadiskdevice_1") - # Get Destnation Pool + # Get Destination Pool # Avoid storage Pool allocated for ROOT disk, and Pool on which DATA # disk1 exists storagePools_to_avoid = [ @@ -3021,7 +3021,7 @@ class TestLiveStorageMigration(cloudstackTestCase): disk=root_volume_cluster, disk_type="rootdiskdevice") - # Get Destnation Pool + # Get Destination Pool # Avoid storage Pool on which ROOT disk exists storagePools_to_avoid = [root_volume_cluster.storage] @@ -3052,7 +3052,7 @@ class TestLiveStorageMigration(cloudstackTestCase): disk=data_volume_1_cluster, disk_type="datadiskdevice_1") - # Get Destnation Pool + # Get Destination Pool # Avoid storage Pool allocated for ROOT disk, and Pool on which DATA # disk1 exists diff --git a/test/pom.xml b/test/pom.xml index eb9b3bfe918..7f315bb9215 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT diff --git a/test/scripts/deploycluster.sh b/test/scripts/deploycluster.sh index dbd2c7b606c..f012efc8ebb 100755 --- a/test/scripts/deploycluster.sh +++ b/test/scripts/deploycluster.sh @@ -60,7 +60,7 @@ deploy_server() { if [ $? -gt 0 ]; then echo "failed to setup db.properties file on remote $1"; return 2; fi #ssh root@$1 "cd /root/cloudstack-oss && nohup ant run &" - #if [ $? -gt 0 ]; then echo "failed to start the softare on remote $1"; return 2; fi + #if [ $? -gt 0 ]; then echo "failed to start the software on remote $1"; return 2; fi echo "Remote management server is deployed as a part of cluster setup; you have to start it manually by logging in remotely" } diff --git a/test/systemvm/README.md b/test/systemvm/README.md index ad84037a958..89e79c2ebff 100644 --- a/test/systemvm/README.md +++ b/test/systemvm/README.md @@ -1,5 +1,24 @@ -Requirements -============ + + +# Requirements + To run these tests, first get the vagrant setup for the systemvm working, see ../../tools/vagrant/systemvm. @@ -7,8 +26,8 @@ Then, install dependencies pip install nose paramiko python-vagrant envassert cuisine fabric -Running tests -============= +## Running tests + Then run the tests using your favorite python unittest runner nosetests-2.7 @@ -22,8 +41,8 @@ not recommended. You can also run these tests out of the box with PyDev or PyCharm or whatever. -Adding tests -============ +## Adding tests + Simply create new test_xxx.py files with test cases that extend from SystemVMTestCase. @@ -55,8 +74,8 @@ class HelloSystemVMTestCase(SystemVMTestCase): assert something_to_do('foo') ``` -Edit, test, edit, test -====================== +## Edit, test, edit, test + The SystemVM Vagrantfile sets up rsync from systemvm/patches. These rsyncs run once, when you type 'vagrant up'. To do these rsyncs every time you change a patch file, run 'vagrant rsync-auto'. With that, your development process can diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py index ad72b4c7938..e41a04ff2e1 100644 --- a/tools/apidoc/gen_toc.py +++ b/tools/apidoc/gen_toc.py @@ -272,7 +272,8 @@ known_categories = { 'Extension' : 'Extension', 'Extensions' : 'Extension', 'CustomAction' : 'Extension', - 'CustomActions' : 'Extension' + 'CustomActions' : 'Extension', + 'ImportVmTask': 'Import VM Task' } diff --git a/tools/apidoc/generatetoc_header.xsl b/tools/apidoc/generatetoc_header.xsl index 26e52dbc1df..0bcee63d657 100644 --- a/tools/apidoc/generatetoc_header.xsl +++ b/tools/apidoc/generatetoc_header.xsl @@ -57,7 +57,7 @@ version="1.0">

Using the CloudStack API

For information about how the APIs work, and tips on how to use them, see the - Developer's Guide.

+ Developer's Guide.

diff --git a/tools/apidoc/images/cloudstack.png b/tools/apidoc/images/cloudstack.png index 2f3d899701a..ef282829559 100644 Binary files a/tools/apidoc/images/cloudstack.png and b/tools/apidoc/images/cloudstack.png differ diff --git a/tools/apidoc/pom.xml b/tools/apidoc/pom.xml index 8e1946e0cf9..b0e081df97f 100644 --- a/tools/apidoc/pom.xml +++ b/tools/apidoc/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloud-tools - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/tools/appliance/README.md b/tools/appliance/README.md index bc5b2014a59..022bddbcd8f 100644 --- a/tools/appliance/README.md +++ b/tools/appliance/README.md @@ -1,3 +1,4 @@ + # Introduction diff --git a/tools/appliance/systemvmtemplate/scripts/configure_locale.sh b/tools/appliance/systemvmtemplate/scripts/configure_locale.sh index 8db7e4e5598..f5477506cfd 100755 --- a/tools/appliance/systemvmtemplate/scripts/configure_locale.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_locale.sh @@ -22,13 +22,15 @@ set -x function configure_locale() { grep LANG=en_US.UTF-8 /etc/default/locale && \ grep LC_ALL=en_US.UTF-8 /etc/default/locale && \ - grep "en_US.UTF-8 UTF-8" /etc/locale.gen && + grep "^en_US.UTF-8 UTF-8" /etc/locale.gen && return cat >> /etc/default/locale << EOF LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 EOF + + grep "^en_US.UTF-8 UTF-8" /etc/locale.gen || \ cat >> /etc/locale.gen << EOF en_US.UTF-8 UTF-8 EOF diff --git a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh index 219586a9729..8bc71d29c1c 100755 --- a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh @@ -19,7 +19,7 @@ set -e set -x -CLOUDSTACK_RELEASE=4.21.0 +CLOUDSTACK_RELEASE=4.22.0 function configure_apache2() { # Enable ssl, rewrite and auth diff --git a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json index e87c37be61e..f15552ca5cc 100644 --- a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json @@ -32,8 +32,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:892cf1185a214d16ff62a18c6b89cdcd58719647c99916f6214bfca6f9915275d727b666c0b8fbf022c425ef18647e9759974abf7fc440431c39b50c296a98d3", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.11.0/arm64/iso-cd/debian-12.11.0-arm64-netinst.iso", + "iso_checksum": "sha512:55ab206cd8b0da2898767c3eb6ab5ebef101e3925ec91b3b5f0a286136195b7072588f6ac2d059c545c6938978704ae78cd18d7d9d2a86a7380e46ce27ee4e7b", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.12.0/arm64/iso-cd/debian-12.12.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index 4d803b25890..c16bf1fb2a2 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -31,8 +31,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:892cf1185a214d16ff62a18c6b89cdcd58719647c99916f6214bfca6f9915275d727b666c0b8fbf022c425ef18647e9759974abf7fc440431c39b50c296a98d3", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.11.0/arm64/iso-cd/debian-12.11.0-arm64-netinst.iso", + "iso_checksum": "sha512:55ab206cd8b0da2898767c3eb6ab5ebef101e3925ec91b3b5f0a286136195b7072588f6ac2d059c545c6938978704ae78cd18d7d9d2a86a7380e46ce27ee4e7b", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.12.0/arm64/iso-cd/debian-12.12.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json index e825e98e5f1..941eea9dcd7 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json @@ -27,8 +27,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:0921d8b297c63ac458d8a06f87cd4c353f751eb5fe30fd0d839ca09c0833d1d9934b02ee14bbd0c0ec4f8917dde793957801ae1af3c8122cdf28dde8f3c3e0da", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.11.0/amd64/iso-cd/debian-12.11.0-amd64-netinst.iso", + "iso_checksum": "sha512:c93055182057dd19a334260671c7e10880541b7721ad9c8df87be47e0a11d5bbf85018350ff224ff6a5f6a68320b07e95d539cef9dc020c93966bfaa86d4b2ce", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.12.0/amd64/iso-cd/debian-12.12.0-amd64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemuargs": [ diff --git a/tools/checkstyle/pom.xml b/tools/checkstyle/pom.xml index 1d89bd5aa80..63f840d64f2 100644 --- a/tools/checkstyle/pom.xml +++ b/tools/checkstyle/pom.xml @@ -22,7 +22,7 @@ Apache CloudStack Developer Tools - Checkstyle Configuration org.apache.cloudstack checkstyle - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT UTF-8 diff --git a/tools/devcloud-kvm/README.md b/tools/devcloud-kvm/README.md index 3261fbe4b8e..fb1405916df 100644 --- a/tools/devcloud-kvm/README.md +++ b/tools/devcloud-kvm/README.md @@ -1,3 +1,4 @@ + This directory hosts configs for setting up the devcloud-kvm environment. diff --git a/tools/devcloud-kvm/pom.xml b/tools/devcloud-kvm/pom.xml index ad3e9dc7ab5..a8cd23db979 100644 --- a/tools/devcloud-kvm/pom.xml +++ b/tools/devcloud-kvm/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloud-tools - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/tools/devcloud4/README.md b/tools/devcloud4/README.md index 96d33c914d4..d940f79630d 100644 --- a/tools/devcloud4/README.md +++ b/tools/devcloud4/README.md @@ -1,3 +1,22 @@ + + # Devcloud 4 ## Introduction diff --git a/tools/devcloud4/advanced/README.md b/tools/devcloud4/advanced/README.md index 8c82b4e3a50..229e9385753 100644 --- a/tools/devcloud4/advanced/README.md +++ b/tools/devcloud4/advanced/README.md @@ -1,3 +1,22 @@ + + ### Configure virtualbox 1. Open virtualbox and navigate to its preferences/settings window. diff --git a/tools/devcloud4/basic/README.md b/tools/devcloud4/basic/README.md index 21b5d97fd4a..91fa81462d6 100644 --- a/tools/devcloud4/basic/README.md +++ b/tools/devcloud4/basic/README.md @@ -1,3 +1,22 @@ + + ### Configure virtualbox 1. Open virtualbox and navigate to its preferences/settings window. diff --git a/tools/devcloud4/common/binary-installation/README.md b/tools/devcloud4/common/binary-installation/README.md index e69de29bb2d..ef14affc68c 100644 --- a/tools/devcloud4/common/binary-installation/README.md +++ b/tools/devcloud4/common/binary-installation/README.md @@ -0,0 +1,18 @@ + diff --git a/tools/devcloud4/common/configure-network.sh b/tools/devcloud4/common/configure-network.sh index bcab6602d92..06d67d80b7e 100755 --- a/tools/devcloud4/common/configure-network.sh +++ b/tools/devcloud4/common/configure-network.sh @@ -1,23 +1,23 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Usage ./reset-network.sh interface ip netmask -# -# 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. -# [ $# -lt 3 ] && { echo -e "Missing arguments\nUsage: ./reset-network interface ip netmask label"; exit 1; } diff --git a/tools/devcloud4/common/development-installation/README.md b/tools/devcloud4/common/development-installation/README.md index e69de29bb2d..ef14affc68c 100644 --- a/tools/devcloud4/common/development-installation/README.md +++ b/tools/devcloud4/common/development-installation/README.md @@ -0,0 +1,18 @@ + diff --git a/tools/devcloud4/common/development-installation/files/default/createtmplt.sh b/tools/devcloud4/common/development-installation/files/default/createtmplt.sh index 2f8f3421350..ca5022bae4f 100755 --- a/tools/devcloud4/common/development-installation/files/default/createtmplt.sh +++ b/tools/devcloud4/common/development-installation/files/default/createtmplt.sh @@ -75,6 +75,8 @@ is_compressed() { ;; ZIP) ctype="zip" ;; + XZ) ctype="xz" + ;; *) echo "File $1 does not appear to be compressed" >&2 return 1 ;; @@ -94,6 +96,8 @@ uncompress() { ;; ZIP) unzip -q -p $1 | cat > $tmpfile ;; + XZ) xz -d -c $1 > $tmpfile + ;; *) printf "$1" return 0 ;; diff --git a/tools/devcloud4/pom.xml b/tools/devcloud4/pom.xml index 1167a695405..1af63b439ad 100644 --- a/tools/devcloud4/pom.xml +++ b/tools/devcloud4/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloud-tools - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 0b29c106555..fd813e077fd 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -19,7 +19,7 @@ FROM ubuntu:22.04 -LABEL Vendor="Apache.org" License="ApacheV2" Version="4.22.0.0-SNAPSHOT" Author="Apache CloudStack " +LABEL Vendor="Apache.org" License="ApacheV2" Version="4.23.0.0-SNAPSHOT" Author="Apache CloudStack " ARG DEBIAN_FRONTEND=noninteractive diff --git a/tools/docker/Dockerfile.marvin b/tools/docker/Dockerfile.marvin index 5838e5d2428..f0a55109402 100644 --- a/tools/docker/Dockerfile.marvin +++ b/tools/docker/Dockerfile.marvin @@ -19,11 +19,11 @@ # build for cloudstack_home_dir not this folder FROM python:2 -LABEL Vendor="Apache.org" License="ApacheV2" Version="4.22.0.0-SNAPSHOT" Author="Apache CloudStack " +LABEL Vendor="Apache.org" License="ApacheV2" Version="4.23.0.0-SNAPSHOT" Author="Apache CloudStack " ENV WORK_DIR=/marvin -ENV PKG_URL=https://builds.cloudstack.org/job/build-master-marvin/lastSuccessfulBuild/artifact/tools/marvin/dist/Marvin-4.22.0.0-SNAPSHOT.tar.gz +ENV PKG_URL=https://builds.cloudstack.org/job/build-master-marvin/lastSuccessfulBuild/artifact/tools/marvin/dist/Marvin-4.23.0.0-SNAPSHOT.tar.gz RUN apt-get update && apt-get install -y vim RUN pip install --upgrade paramiko nose requests diff --git a/tools/docker/README.md b/tools/docker/README.md index 024eebb2aad..676101c32d6 100644 --- a/tools/docker/README.md +++ b/tools/docker/README.md @@ -1,3 +1,22 @@ + + # Docker Files for Apache CloudStack Dockerfiles used to build CloudStack images are available on Docker hub. diff --git a/tools/docker/docker-compose.yml b/tools/docker/docker-compose.yml index 86934f6407f..8179be28af6 100644 --- a/tools/docker/docker-compose.yml +++ b/tools/docker/docker-compose.yml @@ -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 @@ -24,7 +24,7 @@ services: - db:/var/lib/mysql environment: MYSQL_DATABASE: cloud -# MYSQL_ROOT_PASSWORD: root + # MYSQL_ROOT_PASSWORD: root MYSQL_ALLOW_EMPTY_PASSWORD: 1 MYSQL_USER: cloud MYSQL_PASSWORD: cloud diff --git a/tools/logo/apache_cloudstack.png b/tools/logo/apache_cloudstack.png index d0fde45ac28..89bf57007ae 100644 Binary files a/tools/logo/apache_cloudstack.png and b/tools/logo/apache_cloudstack.png differ diff --git a/tools/marvin/marvin/misc/build/CI.md b/tools/marvin/marvin/misc/build/CI.md index 659ccea8558..07fc45406c5 100644 --- a/tools/marvin/marvin/misc/build/CI.md +++ b/tools/marvin/marvin/misc/build/CI.md @@ -17,8 +17,7 @@ specific language governing permissions and limitations under the License. --> -about -===== +# about This document talks about the *evolving* continuous test infrastructure used to setup, deploy, configure and test Apache CloudStack. Information here is useful for anyone involved in build, test, continuous integration even operators of CloudStack. @@ -96,22 +95,19 @@ b. multiple cluster c. inter-zone tests d. multi-pod tests -marvin integration -================== +## marvin integration once cloudstack has been installed and the hypervisors prepared we are ready to use marvin to stitch together zones, pods, clusters and compute and storage to put together a 'cloud'. once configured - we perform a cursory health check to see if we have all systemVMs running in all zones and that built-in templates are downloaded in all zones. Subsequently, we are able to launch tests on this environment Only the latest tests from git are run on the setup. This allows us to test in a pseudo-continuous fashion with a nightly build deployed on the environment. Each test run takes a few hours to finish. -control via github -================== +## control via github there are two GitHub repositories controlling the test infrastructure. a. The puppet recipes at gh:acs-infra-test b. The gh:cloud-autodeploy repo that has the scripts to orchestrate the overall workflow -workflow -======== +## workflow When jenkins triggers the job following sequence of actions occur on the test infrastructure @@ -149,11 +145,10 @@ The $distro argument chooses the hostOS of the mgmt server - this can be ubuntu 12. Tests are run using the nose test runner with the marvin plugin and reports are recorded by jenkins. -limitations -=========== +## limitations + +## enhancements -enhancements -============ - packaging tests - puppetize the cobbler appliance - dogfooding @@ -164,14 +159,12 @@ enhancements - external devices (LB, VPX, FW) - mcollective? -future -====== +## future + - not everyone deploys cloudstack the same - multiple hv environments with multiple hv configurations - multiple storage configurations -troubleshooting -=============== +## troubleshooting -acknowledgements -================ +## acknowledgements diff --git a/tools/marvin/marvin/misc/build/configure.py b/tools/marvin/marvin/misc/build/configure.py index c88a0c1ae3f..e5ab5c571df 100644 --- a/tools/marvin/marvin/misc/build/configure.py +++ b/tools/marvin/marvin/misc/build/configure.py @@ -164,7 +164,7 @@ def cleanPrimaryStorage(cscfg): def seedSecondaryStorage(cscfg, hypervisor): """ erase secondary store and seed system VM template via puppet. The - secseeder.sh script is executed on mgmt server bootup which will mount and + secseeder.sh script is executed on mgmt server boot up which will mount and place the system VM templates on the NFS """ mgmt_server = cscfg.mgtSvr[0].mgtSvrIp diff --git a/tools/marvin/pom.xml b/tools/marvin/pom.xml index 9dc4fc345cc..8e81a394685 100644 --- a/tools/marvin/pom.xml +++ b/tools/marvin/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloud-tools - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/tools/marvin/setup.py b/tools/marvin/setup.py index f5c99b28ac9..05ce9d41023 100644 --- a/tools/marvin/setup.py +++ b/tools/marvin/setup.py @@ -27,7 +27,7 @@ except ImportError: raise RuntimeError("python setuptools is required to build Marvin") -VERSION = "4.22.0.0-SNAPSHOT" +VERSION = "4.23.0.0-SNAPSHOT" setup(name="Marvin", version=VERSION, diff --git a/tools/ngui/precache.py b/tools/ngui/precache.py index e8f23011ccb..fe63fdc93a9 100644 --- a/tools/ngui/precache.py +++ b/tools/ngui/precache.py @@ -16,4 +16,4 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -apicache = {u'authorize': {u'securitygroupingress': {u'name': u'authorizeSecurityGroupIngress', u'related': [u'authorizeSecurityGroupEgress'], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the security group. If the account parameter is used, domainId must also be used.'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'start port for this ingress rule'}, {u'name': u'securitygroupid', u'required': False, u'related': [u'createSecurityGroup', u'listSecurityGroups'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list associated'}, {u'name': u'usersecuritygrouplist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'user to security group mapping'}, {u'name': u'securitygroupname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The name of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the security group. Must be used with domainId.'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'protocol', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'TCP is default. UDP is the other supported protocol'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'an optional project of the security group'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'end port for this ingress rule'}], u'requiredparams': [], u'description': u'Authorizes a particular ingress rule for this security group'}, u'securitygroupegress': {u'name': u'authorizeSecurityGroupEgress', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the security group. Must be used with domainId.'}, {u'name': u'securitygroupname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The name of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the security group. If the account parameter is used, domainId must also be used.'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'securitygroupid', u'required': False, u'related': [u'createSecurityGroup', u'listSecurityGroups'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'protocol', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'TCP is default. UDP is the other supported protocol'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'an optional project of the security group'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'end port for this egress rule'}, {u'name': u'usersecuritygrouplist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'user to security group mapping'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'start port for this egress rule'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list associated'}], u'requiredparams': [], u'description': u'Authorizes a particular egress rule for this security group'}}, u'restore': {u'virtualmachine': {u'name': u'restoreVirtualMachine', u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine'], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'virtualmachineid'], u'description': u'Restore a VM to original template or specific snapshot'}}, u'suspend': {u'project': {u'name': u'suspendProject', u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be suspended'}], u'requiredparams': [u'id'], u'description': u'Suspends a project'}}, u'revoke': {u'securitygroupingress': {u'name': u'revokeSecurityGroupIngress', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The ID of the ingress rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a particular ingress rule from this security group'}, u'securitygroupegress': {u'name': u'revokeSecurityGroupEgress', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The ID of the egress rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a particular egress rule from this security group'}}, u'disassociate': {u'ipaddress': {u'name': u'disassociateIpAddress', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the id of the public ip address to disassociate'}], u'requiredparams': [u'id'], u'description': u'Disassociates an ip address from the account.'}}, u'migrate': {u'volume': {u'name': u'migrateVolume', u'related': [u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'isasync': True, u'params': [{u'name': u'volumeid', u'required': True, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the volume'}, {u'name': u'storageid', u'required': True, u'related': [u'cancelStorageMaintenance', u'enableStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'destination storage pool ID to migrate the volume to'}], u'requiredparams': [u'volumeid', u'storageid'], u'description': u'Migrate volume'}, u'systemvm': {u'name': u'migrateSystemVm', u'related': [], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'rebootSystemVm', u'listSystemVms'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'hostid', u'required': True, u'related': [u'addHost', u'updateHost', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'destination Host ID to migrate VM to'}], u'requiredparams': [u'virtualmachineid', u'hostid'], u'description': u'Attempts Migration of a system virtual machine to the host specified.'}, u'virtualmachine': {u'name': u'migrateVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'storageid', u'required': False, u'related': [u'cancelStorageMaintenance'], u'length': 255, u'type': u'long', u'description': u'Destination storage pool ID to migrate VM volumes to. Required for migrating the root disk volume'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Destination Host ID to migrate VM to. Required for live migrating a VM from host to host'}], u'requiredparams': [u'virtualmachineid'], u'description': u'Attempts Migration of a VM to a different host or Root volume of the vm to a different storage pool'}}, u'lock': {u'account': {u'name': u'lockAccount', u'related': [u'markDefaultZoneForAccount'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Locks the specified account on this domain.'}, {u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Locks the specified account.'}], u'requiredparams': [u'domainid', u'account'], u'description': u'Locks an account'}, u'user': {u'name': u'lockUser', u'related': [u'listUsers'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers'], u'length': 255, u'type': u'uuid', u'description': u'Locks user by user ID.'}], u'requiredparams': [u'id'], u'description': u'Locks a user account'}}, u'dissociate': {u'lun': {u'name': u'dissociateLun', u'related': [], u'isasync': False, u'params': [{u'name': u'iqn', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Guest IQN.'}, {u'name': u'path', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'LUN path.'}], u'requiredparams': [u'iqn', u'path'], u'description': u'Dissociate a LUN'}}, u'activate': {u'project': {u'name': u'activateProject', u'related': [u'createProject', u'listProjectAccounts'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be modified'}], u'requiredparams': [u'id'], u'description': u'Activates a project'}}, u'reconnect': {u'host': {u'name': u'reconnectHost', u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'reconnectHost', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}], u'requiredparams': [u'id'], u'description': u'Reconnects a host.'}}, u'cancel': {u'hostmaintenance': {u'name': u'cancelHostMaintenance', u'related': [u'listSwifts', u'addHost', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}], u'requiredparams': [u'id'], u'description': u'Cancels host maintenance.'}, u'storagemaintenance': {u'name': u'cancelStorageMaintenance', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'cancelStorageMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the primary storage ID'}], u'requiredparams': [u'id'], u'description': u'Cancels maintenance for primary storage'}}, u'query': {u'asyncjobresult': {u'name': u'queryAsyncJobResult', u'related': [], u'isasync': False, u'params': [{u'name': u'jobid', u'required': True, u'related': [u'queryAsyncJobResult'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the asynchronous job'}], u'requiredparams': [u'jobid'], u'description': u'Retrieves the current status of asynchronous job.'}}, u'recover': {u'virtualmachine': {u'name': u'recoverVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Recovers a virtual machine.'}}, u'extract': {u'volume': {u'name': u'extractVolume', u'related': [u'extractTemplate', u'extractIso'], u'isasync': True, u'params': [{u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the url to which the volume would be extracted'}, {u'name': u'id', u'required': True, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'listVolumes', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the volume'}, {u'name': u'mode', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone where the volume is located'}], u'requiredparams': [u'id', u'mode', u'zoneid'], u'description': u'Extracts volume'}, u'iso': {u'name': u'extractIso', u'related': [u'extractTemplate'], u'isasync': True, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone where the ISO is originally located'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the url to which the ISO would be extracted'}, {u'name': u'mode', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD'}, {u'name': u'id', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the ISO file'}], u'requiredparams': [u'mode', u'id'], u'description': u'Extracts an ISO'}, u'template': {u'name': u'extractTemplate', u'related': [], u'isasync': True, u'params': [{u'name': u'mode', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD'}, {u'name': u'id', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the template'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the url to which the ISO would be extracted'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone where the ISO is originally located'}], u'requiredparams': [u'mode', u'id'], u'description': u'Extracts a template'}}, u'copy': {u'iso': {u'name': u'copyIso', u'related': [u'updateIso', u'listIsos'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'Template ID.'}, {u'name': u'destzoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is being copied to.'}, {u'name': u'sourcezoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is currently hosted on.'}], u'requiredparams': [u'id', u'destzoneid', u'sourcezoneid'], u'description': u'Copies an iso from one zone to another.'}, u'template': {u'name': u'copyTemplate', u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'registerTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'copyTemplate', u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'registerTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'Template ID.'}, {u'name': u'destzoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is being copied to.'}, {u'name': u'sourcezoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is currently hosted on.'}], u'requiredparams': [u'id', u'destzoneid', u'sourcezoneid'], u'description': u'Copies a template from one zone to another.'}}, u'prepare': {u'hostformaintenance': {u'name': u'prepareHostForMaintenance', u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}], u'requiredparams': [u'id'], u'description': u'Prepares a host for maintenance.'}, u'template': {u'name': u'prepareTemplate', u'related': [u'registerIso', u'updateTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'zone ID of the template to be prepared in primary storage(s).'}, {u'name': u'templateid', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'template ID of the template to be prepared in primary storage(s).'}], u'requiredparams': [u'zoneid', u'templateid'], u'description': u'load template into primary storage'}}, u'attach': {u'volume': {u'name': u'attachVolume', u'related': [u'detachVolume', u'resizeVolume', u'uploadVolume', u'createVolume'], u'isasync': True, u'params': [{u'name': u'deviceid', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the ID of the device to map the volume to within the guest OS. If no deviceId is passed in, the next available deviceId will be chosen. Possible values for a Linux OS are:* 1 - /dev/xvdb* 2 - /dev/xvdc* 4 - /dev/xvde* 5 - /dev/xvdf* 6 - /dev/xvdg* 7 - /dev/xvdh* 8 - /dev/xvdi* 9 - /dev/xvdj'}, {u'name': u'id', u'required': True, u'related': [u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u' the ID of the virtual machine'}], u'requiredparams': [u'id', u'virtualmachineid'], u'description': u'Attaches a disk volume to a virtual machine.'}, u'iso': {u'name': u'attachIso', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'id', u'required': True, u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the ISO file'}], u'requiredparams': [u'virtualmachineid', u'id'], u'description': u'Attaches an ISO to a virtual machine.'}}, u'create': {u'loadbalancerrule': {u'name': u'createLoadBalancerRule', u'related': [u'updateLoadBalancerRule'], u'isasync': True, u'params': [{u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end public port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when LB rule is being created for VPC guest network 2) in all other cases defaulted to true'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the load balancer. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the load balancer'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'zone where the load balancer is going to be created. This parameter is required when LB service provider is ElasticLoadBalancerVm'}, {u'name': u'publicipid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'public ip address id from where the network traffic will be load balanced from'}, {u'name': u'algorithm', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'load balancer algorithm (source, roundrobin, leastconn)'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the load balancer rule'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'publicport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the public port from where the network traffic will be load balanced from'}, {u'name': u'description', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the description of the load balancer rule'}, {u'name': u'privateport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the private port of the private ip address/virtual machine where the network traffic will be load balanced to'}, {u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The guest network this rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)'}], u'requiredparams': [u'algorithm', u'name', u'publicport', u'privateport'], u'description': u'Creates a load balancer rule'}, u'domain': {u'name': u'createDomain', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'creates domain with this name'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Domain UUID, required for adding domain from another Region'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network domain for networks in the domain'}, {u'name': u'parentdomainid', u'required': False, u'related': [u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'assigns new domain a parent domain by domain ID of the parent. If no parent domain is specied, the ROOT domain is assumed.'}], u'requiredparams': [u'name'], u'description': u'Creates a domain'}, u'snapshotpolicy': {u'name': u'createSnapshotPolicy', u'related': [u'listSnapshotPolicies'], u'isasync': False, u'params': [{u'name': u'intervaltype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'valid values are HOURLY, DAILY, WEEKLY, and MONTHLY'}, {u'name': u'maxsnaps', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'maximum number of snapshots to retain'}, {u'name': u'schedule', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'time the snapshot is scheduled to be taken. Format is:* if HOURLY, MM* if DAILY, MM:HH* if WEEKLY, MM:HH:DD (1-7)* if MONTHLY, MM:HH:DD (1-28)'}, {u'name': u'timezone', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'volumeid', u'required': True, u'related': [u'detachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}], u'requiredparams': [u'intervaltype', u'maxsnaps', u'schedule', u'timezone', u'volumeid'], u'description': u'Creates a snapshot policy for the account.'}, u'diskoffering': {u'name': u'createDiskOffering', u'related': [u'listDiskOfferings'], u'isasync': False, u'params': [{u'name': u'customized', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'whether disk offering is custom or not'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'alternate display text of the disk offering'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the containing domain, null for public offerings'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the disk offering'}, {u'name': u'disksize', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'size of the disk offering in GB'}, {u'name': u'storagetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the storage type of the disk offering. Values are local and shared.'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'tags for the disk offering'}], u'requiredparams': [u'displaytext', u'name'], u'description': u'Creates a disk offering.'}, u'securitygroup': {u'name': u'createSecurityGroup', u'related': [u'listSecurityGroups'], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the security group. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the security group. If the account parameter is used, domainId must also be used.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the security group'}, {u'name': u'description', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the description of the security group'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Deploy vm for the project'}], u'requiredparams': [u'name'], u'description': u'Creates a security group'}, u'portforwardingrule': {u'name': u'createPortForwardingRule', u'related': [u'listIpForwardingRules'], u'isasync': True, u'params': [{u'name': u'privateport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the starting port of port forwarding rule's private port range"}, {u'name': u'ipaddressid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the IP address id of the port forwarding rule'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the port fowarding rule. Valid values are TCP or UDP.'}, {u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when PF rule is being created for VPC guest network 2) in all other cases defaulted to true'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine for the port forwarding rule'}, {u'name': u'privateendport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the ending port of port forwarding rule's private port range"}, {u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network of the vm the Port Forwarding rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)'}, {u'name': u'publicendport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the ending port of port forwarding rule's private port range"}, {u'name': u'publicport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the starting port of port forwarding rule's public port range"}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}], u'requiredparams': [u'privateport', u'ipaddressid', u'protocol', u'virtualmachineid', u'publicport'], u'description': u'Creates a port forwarding rule'}, u'pod': {u'name': u'createPod', u'related': [u'updatePod', u'listPods'], u'isasync': False, u'params': [{u'name': u'startip', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the starting IP address for the Pod'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Pod'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID in which the Pod will be created'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address for the Pod'}, {u'name': u'netmask', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask for the Pod'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Pod for allocation of new resources'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway for the Pod'}], u'requiredparams': [u'startip', u'name', u'zoneid', u'netmask', u'gateway'], u'description': u'Creates a new Pod.'}, u'ipforwardingrule': {u'name': u'createIpForwardingRule', u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'isasync': True, u'params': [{u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the end port for the rule'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'ipaddressid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id of the forwarding rule, already associated via associateIp'}, {u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default'}, {u'name': u'startport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the start port for the rule'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the rule. Valid values are TCP or UDP.'}], u'requiredparams': [u'ipaddressid', u'startport', u'protocol'], u'description': u'Creates an ip forwarding rule'}, u'vpnconnection': {u'name': u'createVpnConnection', u'related': [u'listVpnConnections', u'resetVpnConnection'], u'isasync': True, u'params': [{u'name': u's2svpngatewayid', u'required': True, u'related': [u'createVpnGateway', u'listVpnGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the vpn gateway'}, {u'name': u's2scustomergatewayid', u'required': True, u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway', u'listVpnCustomerGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the customer gateway'}], u'requiredparams': [u's2svpngatewayid', u's2scustomergatewayid'], u'description': u'Create site to site vpn connection'}, u'vpncustomergateway': {u'name': u'createVpnCustomerGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the gateway. If used with the account parameter returns the gateway associated with the account for the specified domain.'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'public ip address id of the customer gateway'}, {u'name': u'esplifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 2 VPN connection to the customer gateway, in seconds'}, {u'name': u'esppolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ESP policy of the customer gateway'}, {u'name': u'ikepolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IKE policy of the customer gateway'}, {u'name': u'cidrlist', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'guest cidr list of the customer gateway'}, {u'name': u'dpd', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If DPD is enabled for VPN connection'}, {u'name': u'ipsecpsk', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IPsec Preshared-Key of the customer gateway'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the gateway. Must be used with the domainId parameter.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of this customer gateway'}, {u'name': u'ikelifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 1 VPN connection to the customer gateway, in seconds'}], u'requiredparams': [u'gateway', u'esppolicy', u'ikepolicy', u'cidrlist', u'ipsecpsk'], u'description': u'Creates site to site vpn customer gateway'}, u'lbstickinesspolicy': {u'name': u'createLBStickinessPolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'lbruleid', u'required': True, u'related': [u'listIpForwardingRules'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the LB Stickiness policy'}, {u'name': u'methodname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the LB Stickiness policy method, possible values can be obtained from ListNetworks API '}, {u'name': u'description', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the description of the LB Stickiness policy'}, {u'name': u'param', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'param list. Example: param[0].name=cookiename¶m[0].value=LBCookie '}], u'requiredparams': [u'lbruleid', u'name', u'methodname'], u'description': u'Creates a Load Balancer stickiness policy '}, u'vpcoffering': {u'name': u'createVPCOffering', u'related': [u'listVPCOfferings'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the vpc offering'}, {u'name': u'supportedservices', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'services supported by the vpc offering'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the vpc offering'}], u'requiredparams': [u'displaytext', u'supportedservices', u'name'], u'description': u'Creates VPC offering'}, u'network': {u'name': u'createNetwork', u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'isasync': False, u'params': [{u'name': u'endipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IPv6 address in the IPv6 network range'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'ip6cidr', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the CIDR of IPv6 network, must be at least /64'}, {u'name': u'acltype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Access control type; supported values are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network'}, {u'name': u'gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the network'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID the network belongs to'}, {u'name': u'subdomainaccess', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Defines whether to allow subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address in the network IP range'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a network'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network domain'}, {u'name': u'ip6gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the IPv6 network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account who will own the network'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the network'}, {u'name': u'startipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IPv6 address in the IPv6 network range'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the network'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'the VPC network belongs to'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address in the network IP range. If not specified, will be defaulted to startIP'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ID or VID of the network'}, {u'name': u'networkofferingid', u'required': True, u'related': [u'createNetworkOffering', u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'the network offering id'}], u'requiredparams': [u'displaytext', u'zoneid', u'name', u'networkofferingid'], u'description': u'Creates a network'}, u'zone': {u'name': u'createZone', u'related': [u'listZones'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the containing domain, null for public zones'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Zone'}, {u'name': u'ip6dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for IPv6 network in the Zone'}, {u'name': u'domain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network domain name for the networks in the zone'}, {u'name': u'internaldns1', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first internal DNS for the Zone'}, {u'name': u'localstorageenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if local storage offering enabled, false otherwise'}, {u'name': u'securitygroupenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network is security group enabled, false otherwise'}, {u'name': u'networktype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'network type of the zone, can be Basic or Advanced'}, {u'name': u'internaldns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second internal DNS for the Zone'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Zone for allocation of new resources'}, {u'name': u'guestcidraddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the guest CIDR address for the Zone'}, {u'name': u'dns1', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for the Zone'}, {u'name': u'ip6dns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for IPv6 network in the Zone'}, {u'name': u'dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for the Zone'}], u'requiredparams': [u'name', u'internaldns1', u'networktype', u'dns1'], u'description': u'Creates a Zone.'}, u'remoteaccessvpn': {u'name': u'createRemoteAccessVpn', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the VPN. Must be used with domainId.'}, {u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default'}, {u'name': u'publicipid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn server'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the VPN. If the account parameter is used, domainId must also be used.'}, {u'name': u'iprange', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the range of ip addresses to allocate to vpn clients. The first ip in the range will be taken by the vpn server'}], u'requiredparams': [u'publicipid'], u'description': u'Creates a l2tp/ipsec remote access vpn'}, u'instancegroup': {u'name': u'createInstanceGroup', u'related': [], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account of the instance group. The account parameter must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The project of the instance group'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the instance group'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID of account owning the instance group'}], u'requiredparams': [u'name'], u'description': u'Creates a vm group'}, u'autoscalepolicy': {u'name': u'createAutoScalePolicy', u'related': [u'updateAutoScalePolicy'], u'isasync': True, u'params': [{u'name': u'action', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the action to be executed if all the conditions evaluate to true for the specified duration.'}, {u'name': u'quiettime', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the cool down period for which the policy should not be evaluated after the action has been taken'}, {u'name': u'conditionids', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the conditions that are being evaluated on every interval'}, {u'name': u'duration', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the duration for which the conditions have to be true before action is taken'}], u'requiredparams': [u'action', u'conditionids', u'duration'], u'description': u'Creates an autoscale policy for a provision or deprovision action, the action is taken when the all the conditions evaluates to true for the specified duration. The policy is in effect once it is attached to a autscale vm group.'}, u'tags': {u'name': u'createTags', u'related': [], u'isasync': True, u'params': [{u'name': u'tags', u'required': True, u'related': [], u'length': 255, u'type': u'map', u'description': u'Map of tags (key/value pairs)'}, {u'name': u'resourcetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of the resource'}, {u'name': u'customer', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"identifies client specific tag. When the value is not null, the tag can't be used by cloudStack code internally"}, {u'name': u'resourceids', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of resources to create the tags for'}], u'requiredparams': [u'tags', u'resourcetype', u'resourceids'], u'description': u'Creates resource tag(s)'}, u'serviceoffering': {u'name': u'createServiceOffering', u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'isasync': False, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the service offering'}, {u'name': u'storagetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the storage type of the service offering. Values are local and shared.'}, {u'name': u'issystem', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'is this a system vm offering'}, {u'name': u'cpunumber', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'the CPU number of the service offering'}, {u'name': u'systemvmtype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the system VM type. Possible types are "domainrouter", "consoleproxy" and "secondarystoragevm".'}, {u'name': u'limitcpuuse', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'restrict the CPU usage to committed service offering'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host tag for this service offering.'}, {u'name': u'offerha', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the HA for the service offering'}, {u'name': u'memory', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'the total memory of the service offering in MB'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the containing domain, null for public offerings'}, {u'name': u'cpuspeed', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'the CPU speed of the service offering in MHz.'}, {u'name': u'networkrate', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'data transfer rate in megabits per second allowed. Supported only for non-System offering and system offerings having "domainrouter" systemvmtype'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the service offering'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tags for this service offering.'}], u'requiredparams': [u'name', u'cpunumber', u'memory', u'cpuspeed', u'displaytext'], u'description': u'Creates a service offering.'}, u'condition': {u'name': u'createCondition', u'related': [], u'isasync': True, u'params': [{u'name': u'threshold', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'Threshold value.'}, {u'name': u'counterid', u'required': True, u'related': [u'listConditions', u'listCounters', u'createCounter'], u'length': 255, u'type': u'uuid', u'description': u'ID of the Counter.'}, {u'name': u'relationaloperator', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Relational Operator to be used with threshold.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account of the condition. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID of the account.'}], u'requiredparams': [u'threshold', u'counterid', u'relationaloperator'], u'description': u'Creates a condition'}, u'storagepool': {u'name': u'createStoragePool', u'related': [u'cancelStorageMaintenance', u'listStoragePools'], u'isasync': False, u'params': [{u'name': u'clusterid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID for the storage pool'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the storage pool'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name for the storage pool'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tags for the storage pool'}, {u'name': u'podid', u'required': True, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the storage pool'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL of the storage pool'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'the details for the storage pool'}], u'requiredparams': [u'clusterid', u'zoneid', u'name', u'podid', u'url'], u'description': u'Creates a storage pool.'}, u'vpngateway': {u'name': u'createVpnGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'vpcid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn gateway'}], u'requiredparams': [u'vpcid'], u'description': u'Creates site to site vpn local gateway'}, u'autoscalevmgroup': {u'name': u'createAutoScaleVmGroup', u'related': [u'updateAutoScaleVmGroup'], u'isasync': True, u'params': [{u'name': u'vmprofileid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the autoscale profile that contains information about the vms in the vm group.'}, {u'name': u'scaledownpolicyids', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaledown autoscale policies'}, {u'name': u'scaleuppolicyids', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaleup autoscale policies'}, {u'name': u'interval', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the frequency at which the conditions have to be evaluated'}, {u'name': u'minmembers', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the minimum number of members in the vmgroup, the number of instances in the vm group will be equal to or more than this number.'}, {u'name': u'maxmembers', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the maximum number of members in the vmgroup, The number of instances in the vm group will be equal to or less than this number.'}, {u'name': u'lbruleid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'vmprofileid', u'scaledownpolicyids', u'scaleuppolicyids', u'minmembers', u'maxmembers', u'lbruleid'], u'description': u'Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.'}, u'networkacl': {u'name': u'createNetworkACL', u'related': [], u'isasync': True, u'params': [{u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the ending port of ACL'}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the traffic type for the ACL,can be Ingress or Egress, defaulted to Ingress if not specified'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to allow traffic from/to'}, {u'name': u'networkid', u'required': True, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network of the vm the ACL will be created for'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the ACL rule. Valid values are TCP/UDP/ICMP.'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the starting port of ACL'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}], u'requiredparams': [u'networkid', u'protocol'], u'description': u'Creates a ACL rule the given network (the network has to belong to VPC)'}, u'template': {u'name': u'createTemplate', u'related': [u'cancelStorageMaintenance', u'enableStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'isasync': True, u'params': [{u'name': u'ostypeid', u'required': True, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS Type that best represents the OS of this template.'}, {u'name': u'templatetag', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tag for this template.'}, {u'name': u'bits', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'32 or 64 bit'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template is a public template, false otherwise'}, {u'name': u'volumeid', u'required': False, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template supports the password reset feature; default is false'}, {u'name': u'snapshotid', u'required': False, u'related': [u'createSnapshot', u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the template. This is usually used for display purposes.'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'Template details in key/value pairs.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the template'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template is a featured template, false otherwise'}, {u'name': u'requireshvm', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template requires HVM, false otherwise'}], u'requiredparams': [u'ostypeid', u'displaytext', u'name'], u'description': u'Creates a template of a virtual machine. The virtual machine must be in a STOPPED state. A template created from this command is automatically designated as a private template visible to the account that created it.'}, u'privategateway': {u'name': u'createPrivateGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'vlan', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the Vlan for the private gateway'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the Private gateway'}, {u'name': u'netmask', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the Private gateway'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID the network belongs to'}, {u'name': u'vpcid', u'required': True, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'the VPC network belongs to'}, {u'name': u'ipaddress', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the IP address of the Private gateaway'}], u'requiredparams': [u'vlan', u'gateway', u'netmask', u'vpcid', u'ipaddress'], u'description': u'Creates a private gateway'}, u'volumeonfiler': {u'name': u'createVolumeOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'volumename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'volume name.'}, {u'name': u'aggregatename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'aggregate name.'}, {u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}, {u'name': u'snapshotpolicy', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'snapshot policy.'}, {u'name': u'ipaddress', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ip address.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'password.'}, {u'name': u'size', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'volume size.'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'user name.'}, {u'name': u'snapshotreservation', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'snapshot reservation.'}], u'requiredparams': [u'volumename', u'aggregatename', u'poolname', u'ipaddress', u'password', u'size', u'username'], u'description': u'Create a volume'}, u'staticroute': {u'name': u'createStaticRoute', u'related': [], u'isasync': True, u'params': [{u'name': u'gatewayid', u'required': True, u'related': [u'createPrivateGateway'], u'length': 255, u'type': u'uuid', u'description': u'the gateway id we are creating static route for'}, {u'name': u'cidr', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'static route cidr'}], u'requiredparams': [u'gatewayid', u'cidr'], u'description': u'Creates a static route'}, u'volume': {u'name': u'createVolume', u'related': [u'detachVolume', u'uploadVolume'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the disk volume'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'the project associated with the volume. Mutually exclusive with account parameter'}, {u'name': u'diskofferingid', u'required': False, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk offering. Either diskOfferingId or snapshotId must be passed in.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the disk volume. Must be used with the domainId parameter.'}, {u'name': u'size', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Arbitrary volume size'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the disk offering. If used with the account parameter returns the disk volume associated with the account for the specified domain.'}, {u'name': u'snapshotid', u'required': False, u'related': [u'createSnapshot', u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'the snapshot ID for the disk volume. Either diskOfferingId or snapshotId must be passed in.'}], u'requiredparams': [u'name'], u'description': u'Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.'}, u'user': {u'name': u'createUser', u'related': [u'lockUser', u'listUsers'], u'isasync': False, u'params': [{u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Creates the user under the specified account. If no account is specified, the username will be used as the account name.'}, {u'name': u'userid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'User UUID, required for adding account from external provisioning system'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Unique username.'}, {u'name': u'timezone', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Creates the user under the specified domain. Has to be accompanied with the account parameter'}, {u'name': u'email', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'email'}, {u'name': u'lastname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'lastname'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.'}, {u'name': u'firstname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'firstname'}], u'requiredparams': [u'account', u'username', u'email', u'lastname', u'password', u'firstname'], u'description': u'Creates a user for an account that already exists'}, u'vpc': {u'name': u'createVPC', u'related': [u'updateVPC', u'restartVPC', u'listVPCs'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the VPC'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the VPC'}, {u'name': u'vpcofferingid', u'required': True, u'related': [u'listVPCOfferings', u'createVPCOffering'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VPC offering'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'VPC network domain. All networks inside the VPC will belong to this domain'}, {u'name': u'cidr', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u"the cidr of the VPC. All VPC guest networks' cidrs should be within this CIDR"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the VPC. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the VPC. If used with the account parameter returns the VPC associated with the account for the specified domain.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'create VPC for the project'}], u'requiredparams': [u'displaytext', u'zoneid', u'name', u'vpcofferingid', u'cidr'], u'description': u'Creates a VPC'}, u'storagenetworkiprange': {u'name': u'createStorageNetworkIpRange', u'related': [u'listStorageNetworkIpRange', u'updateStorageNetworkIpRange'], u'isasync': True, u'params': [{u'name': u'startip', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Optional. The vlan the ip range sits on, default to Null when it is not specified which means you network is not on any Vlan. This is mainly for Vmware as other hypervisors can directly reterive bridge from pyhsical network traffic type table'}, {u'name': u'podid', u'required': True, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'UUID of pod where the ip range belongs to'}, {u'name': u'netmask', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask for storage network'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway for storage network'}], u'requiredparams': [u'startip', u'podid', u'netmask', u'gateway'], u'description': u'Creates a Storage network IP range.'}, u'pool': {u'name': u'createPool', u'related': [], u'isasync': False, u'params': [{u'name': u'algorithm', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'algorithm.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'algorithm', u'name'], u'description': u'Create a pool'}, u'autoscalevmprofile': {u'name': u'createAutoScaleVmProfile', u'related': [u'updateAutoScaleVmProfile', u'listAutoScaleVmProfiles'], u'isasync': True, u'params': [{u'name': u'otherdeployparams', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'parameters other than zoneId/serviceOfferringId/templateId of the auto deployed virtual machine'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'availability zone for the auto deployed virtual machine'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering', u'updateServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the service offering of the auto deployed virtual machine'}, {u'name': u'expungevmgraceperiod', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the time allowed for existing connections to get closed before a vm is destroyed'}, {u'name': u'counterparam', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161'}, {u'name': u'templateid', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template of the auto deployed virtual machine'}, {u'name': u'autoscaleuserid', u'required': False, u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'updateUser'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the user used to launch and destroy the VMs'}], u'requiredparams': [u'zoneid', u'serviceofferingid', u'templateid'], u'description': u'Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature.'}, u'account': {u'name': u'createAccount', u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'getUser', u'updateUser'], u'isasync': False, u'params': [{u'name': u'lastname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'lastname'}, {u'name': u'accounttype', u'required': True, u'related': [], u'length': 255, u'type': u'short', u'description': u'Type of the account. Specify 0 for user, 1 for root admin, and 2 for domain admin'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Unique username.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.'}, {u'name': u'firstname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'firstname'}, {u'name': u'userid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'User UUID, required for adding account from external provisioning system'}, {u'name': u'timezone', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Creates the user under the specified account. If no account is specified, the username will be used as the account name.'}, {u'name': u'accountdetails', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'details for account used to store specific parameters'}, {u'name': u'email', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'email'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"Network domain for the account's networks"}, {u'name': u'accountid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Account UUID, required for adding account from external provisioning system'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'Creates the user under the specified domain.'}], u'requiredparams': [u'lastname', u'accounttype', u'username', u'password', u'firstname', u'email'], u'description': u'Creates an account'}, u'firewallrule': {u'name': u'createFirewallRule', u'related': [u'listEgressFirewallRules'], u'isasync': True, u'params': [{u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the firewall rule. Valid values are TCP/UDP/ICMP.'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of firewallrule: system/user'}, {u'name': u'ipaddressid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the IP address id of the port forwarding rule'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the starting port of firewall rule'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the ending port of firewall rule'}], u'requiredparams': [u'protocol', u'ipaddressid'], u'description': u'Creates a firewall rule for a given ip address'}, u'networkoffering': {u'name': u'createNetworkOffering', u'related': [u'updateNetworkOffering'], u'isasync': False, u'params': [{u'name': u'serviceproviderlist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network'}, {u'name': u'serviceofferingid', u'required': False, u'related': [u'updateHypervisorCapabilities'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID used by virtual router provider'}, {u'name': u'supportedservices', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'services supported by the network offering'}, {u'name': u'networkrate', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'data transfer rate in megabits per second allowed'}, {u'name': u'ispersistent', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports persistent networks; defaulted to false if not specified'}, {u'name': u'servicecapabilitylist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'desired service capabilities as part of network offering'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the network offering'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the tags for the network offering.'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the network offering'}, {u'name': u'conservemode', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the network offering is IP conserve mode enabled'}, {u'name': u'guestiptype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'guest type of the network offering: Shared or Isolated'}, {u'name': u'traffictype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the traffic type for the network offering. Supported type in current release is GUEST only'}, {u'name': u'specifyvlan', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports vlans'}, {u'name': u'availability', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the availability of network offering. Default value is Optional'}, {u'name': u'specifyipranges', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports specifying ip ranges; defaulted to false if not specified'}], u'requiredparams': [u'supportedservices', u'name', u'displaytext', u'guestiptype', u'traffictype'], u'description': u'Creates a network offering.'}, u'vlaniprange': {u'name': u'createVlanIpRange', u'related': [u'listVlanIpRanges'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a VLAN'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'project who will own the VLAN. If VLAN is Zone wide, this parameter should be ommited'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ID or VID of the VLAN. If not specified, will be defaulted to the vlan of the network or if vlan of the network is null - to Untagged'}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the network id'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if VLAN is of Virtual type, false if Direct'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Have to be specified for Direct Untagged vlan only.'}, {u'name': u'ip6cidr', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the CIDR of IPv6 network, must be at least /64'}, {u'name': u'endipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IPv6 address in the IPv6 network range'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address in the VLAN IP range'}, {u'name': u'startipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IPv6 address in the IPv6 network range'}, {u'name': u'gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the VLAN IP range'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the VLAN IP range'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address in the VLAN IP range'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account who will own the VLAN. If VLAN is Zone wide, this parameter should be ommited'}, {u'name': u'ip6gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the IPv6 network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the physical network id'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the VLAN IP range'}], u'requiredparams': [], u'description': u'Creates a VLAN IP range.'}, u'counter': {u'name': u'createCounter', u'related': [u'listCounters'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the counter.'}, {u'name': u'source', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Source of the counter.'}, {u'name': u'value', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Value of the counter e.g. oid in case of snmp.'}], u'requiredparams': [u'name', u'source', u'value'], u'description': u'Adds metric counter'}, u'lunonfiler': {u'name': u'createLunOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'size', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'LUN size.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'size', u'name'], u'description': u'Create a LUN from a pool'}, u'project': {u'name': u'createProject', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account who will be Admin for the project'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the project'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a project'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'display text of the project'}], u'requiredparams': [u'name', u'displaytext'], u'description': u'Creates a project'}, u'physicalnetwork': {u'name': u'createPhysicalNetwork', u'related': [u'listPhysicalNetworks'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the physical network'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the physical network'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'Tag the physical network'}, {u'name': u'networkspeed', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the speed for the physical network[1G/10G]'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the VLAN for the physical network'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a physical network'}, {u'name': u'broadcastdomainrange', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the broadcast domain range for the physical network[Pod or Zone]. In Acton release it can be Zone only in Advance zone, and Pod in Basic'}, {u'name': u'isolationmethods', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the isolation method for the physical network[VLAN/L3/GRE]'}], u'requiredparams': [u'name', u'zoneid'], u'description': u'Creates a physical network'}, u'snapshot': {u'name': u'createSnapshot', u'related': [u'listSnapshots'], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The account of the snapshot. The account parameter must be used with the domainId parameter.'}, {u'name': u'volumeid', u'required': True, u'related': [u'detachVolume'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the disk volume'}, {u'name': u'policyid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'policy id of the snapshot, if this is null, then use MANUAL_POLICY.'}], u'requiredparams': [u'volumeid'], u'description': u'Creates an instant snapshot of a volume.'}, u'virtualrouterelement': {u'name': u'createVirtualRouterElement', u'related': [], u'isasync': True, u'params': [{u'name': u'nspid', u'required': True, u'related': [u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'the network service provider ID of the virtual router element'}], u'requiredparams': [u'nspid'], u'description': u'Create a virtual router element.'}, u'egressfirewallrule': {u'name': u'createEgressFirewallRule', u'related': [u'createFirewallRule', u'listEgressFirewallRules'], u'isasync': True, u'params': [{u'name': u'networkid', u'required': True, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the network id of the port forwarding rule'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the starting port of firewall rule'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of firewallrule: system/user'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the firewall rule. Valid values are TCP/UDP/ICMP.'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the ending port of firewall rule'}], u'requiredparams': [u'networkid', u'protocol'], u'description': u'Creates a egress firewall rule for a given network '}, u'sshkeypair': {u'name': u'createSSHKeyPair', u'related': [u'listSSHKeyPairs'], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the keypair'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the ssh key. Must be used with domainId.'}], u'requiredparams': [u'name'], u'description': u'Create a new keypair and returns the private key'}}, u'deploy': {u'virtualmachine': {u'name': u'deployVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'keypair', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the ssh key pair used to login to the virtual machine'}, {u'name': u'userdata', u'required': False, u'related': [], u'length': 2048, u'type': u'string', u'description': u'an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding.'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor on which to deploy the virtual machine'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.'}, {u'name': u'size', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId'}, {u'name': u'diskofferingid', u'required': False, u'related': [u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume. If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume created.'}, {u'name': u'securitygroupids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of security groups id that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupnames parameter'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the service offering for the virtual machine'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"the ip address for default vm's network"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the virtual machine. Must be used with domainId.'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'destination Host ID to deploy the VM to - parameter available for root admin only'}, {u'name': u'iptonetworklist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u"ip to network mapping. Can't be specified with networkIds parameter. Example: iptonetworklist[0].ip=10.10.10.11&iptonetworklist[0].ipv6=fc00:1234:5678::abcd&iptonetworklist[0].networkid=uuid - requests to use ip 10.10.10.11 in network id=uuid"}, {u'name': u'ip6address', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"the ipv6 address for default vm's network"}, {u'name': u'keyboard', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional keyboard device type for the virtual machine. valid value can be one of de,de-ch,es,fi,fr,fr-be,fr-ch,is,it,jp,nl-be,no,pt,uk,us'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'Deploy vm for the project'}, {u'name': u'networkids', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'list', u'description': u"list of network ids used by virtual machine. Can't be specified with ipToNetworkList parameter"}, {u'name': u'displayname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional user generated name for the virtual machine'}, {u'name': u'securitygroupnames', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of security groups names that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupids parameter'}, {u'name': u'templateid', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the template for the virtual machine'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'availability zone for the virtual machine'}, {u'name': u'group', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional group for the virtual machine'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'host name for the virtual machine'}, {u'name': u'startvm', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports specifying ip ranges; defaulted to true if not specified'}], u'requiredparams': [u'serviceofferingid', u'templateid', u'zoneid'], u'description': u'Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.'}}, u'restart': {u'network': {u'name': u'restartNetwork', u'related': [u'associateIpAddress'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The id of the network to restart.'}, {u'name': u'cleanup', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If cleanup old network elements'}], u'requiredparams': [u'id'], u'description': u'Restarts the network; includes 1) restarting network elements - virtual routers, dhcp servers 2) reapplying all public ips 3) reapplying loadBalancing/portForwarding rules'}, u'vpc': {u'name': u'restartVPC', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': False, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VPC'}], u'requiredparams': [], u'description': u'Restarts a VPC'}}, u'reboot': {u'systemvm': {u'name': u'rebootSystemVm', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'rebootSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Reboots a system VM.'}, u'router': {u'name': u'rebootRouter', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'rebootRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Starts a router.'}, u'virtualmachine': {u'name': u'rebootVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Reboots a virtual machine.'}}, u'mark': {u'defaultzoneforaccount': {u'name': u'markDefaultZoneForAccount', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': True, u'related': [u'markDefaultZoneForAccount'], u'length': 255, u'type': u'string', u'description': u'Name of the account that is to be marked.'}, {u'name': u'domainid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Marks the account that belongs to the specified domain.'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The Zone ID with which the account is to be marked.'}], u'requiredparams': [u'account', u'domainid', u'zoneid'], u'description': u'Marks a default zone for this account'}}, u'start': {u'systemvm': {u'name': u'startSystemVm', u'related': [u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Starts a system virtual machine.'}, u'router': {u'name': u'startRouter', u'related': [u'destroyRouter', u'rebootRouter'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'destroyRouter', u'rebootRouter', u'startRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Starts a router.'}, u'virtualmachine': {u'name': u'startVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'destination Host ID to deploy the VM to - parameter available for root admin only'}], u'requiredparams': [u'id'], u'description': u'Starts a virtual machine.'}}, u'add': {u'trafficmonitor': {u'name': u'addTrafficMonitor', u'related': [u'listTrafficMonitors'], u'isasync': False, u'params': [{u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the traffic monitor Host'}, {u'name': u'includezones', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Traffic going into the listed zones will be metered'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'Zone in which to add the external firewall appliance.'}, {u'name': u'excludezones', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Traffic going into the listed zones will not be metered'}], u'requiredparams': [u'url', u'zoneid'], u'description': u'Adds Traffic Monitor Host for Direct Network Usage'}, u'secondarystorage': {u'name': u'addSecondaryStorage', u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the secondary storage'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL for the secondary storage'}], u'requiredparams': [u'url'], u'description': u'Adds secondary storage.'}, u'nictovirtualmachine': {u'name': u'addNicToVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'networkid', u'required': True, u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'Network ID'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'IP Address for the new network'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'addNicToVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'networkid', u'virtualmachineid'], u'description': u'Adds VM to specified network by creating a NIC'}, u'netscalerloadbalancer': {u'name': u'addNetscalerLoadBalancer', u'related': [u'listNetscalerLoadBalancers', u'configureNetscalerLoadBalancer'], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach netscaler load balancer device'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach netscaler load balancer device'}, {u'name': u'networkdevicetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Netscaler device type supports NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the netscaler load balancer appliance.'}], u'requiredparams': [u'password', u'physicalnetworkid', u'username', u'networkdevicetype', u'url'], u'description': u'Adds a netscaler load balancer device'}, u'cluster': {u'name': u'addCluster', u'related': [u'listClusters', u'updateCluster'], u'isasync': False, u'params': [{u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'vsmpassword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the VSM associated with this cluster'}, {u'name': u'podid', u'required': True, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'vsmipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ipaddress of the VSM associated with this cluster'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the cluster: XenServer,KVM,VMware,Hyperv,BareMetal,Simulator'}, {u'name': u'vsmusername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the VSM associated with this cluster'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the cluster'}, {u'name': u'clustertype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of the cluster: CloudManaged, ExternalManaged'}, {u'name': u'clustername', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the cluster'}, {u'name': u'password', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the host'}], u'requiredparams': [u'podid', u'hypervisor', u'clustertype', u'clustername', u'zoneid'], u'description': u'Adds a new cluster'}, u's3': {u'name': u'addS3', u'related': [], u'isasync': False, u'params': [{u'name': u'connectiontimeout', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'connection timeout (milliseconds)'}, {u'name': u'accesskey', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'S3 access key'}, {u'name': u'bucket', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the template storage bucket'}, {u'name': u'endpoint', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'S3 host name'}, {u'name': u'secretkey', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'S3 secret key'}, {u'name': u'sockettimeout', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'socket timeout (milliseconds)'}, {u'name': u'maxerrorretry', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'maximum number of times to retry on error'}, {u'name': u'usehttps', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'connect to the S3 endpoint via HTTPS?'}], u'requiredparams': [u'accesskey', u'bucket', u'secretkey'], u'description': u'Adds S3'}, u'accounttoproject': {u'name': u'addAccountToProject', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the account to be added to the project'}, {u'name': u'email', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'email to which invitation to the project is going to be sent'}, {u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to add the account to'}], u'requiredparams': [u'projectid'], u'description': u'Adds acoount to a project'}, u'region': {u'name': u'addRegion', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the region'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Id of the Region'}, {u'name': u'endpoint', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Region service endpoint'}], u'requiredparams': [u'name', u'id', u'endpoint'], u'description': u'Adds a Region'}, u'externalloadbalancer': {u'name': u'addExternalLoadBalancer', u'related': [], u'isasync': False, u'params': [{u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Username of the external load balancer appliance.'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the external load balancer appliance.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Password of the external load balancer appliance.'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'Zone in which to add the external load balancer appliance.'}], u'requiredparams': [u'username', u'url', u'password', u'zoneid'], u'description': u'Adds F5 external load balancer appliance.'}, u'vpnuser': {u'name': u'addVpnUser', u'related': [u'listVpnUsers'], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'password for the username'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'username for the vpn user'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the vpn user. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'add vpn user to the specific project'}], u'requiredparams': [u'password', u'username'], u'description': u'Adds vpn users'}, u'baremetalhost': {u'name': u'addBaremetalHost', u'related': [u'listSwifts', u'addHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'ip address intentionally allocated to this host after provisioning'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of tags to be added to the host'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host URL'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the host'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the host'}, {u'name': u'clustername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name for the host'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID for the host'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the host'}, {u'name': u'podid', u'required': True, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the host'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Host for allocation of new resources'}], u'requiredparams': [u'url', u'username', u'zoneid', u'hypervisor', u'podid', u'password'], u'description': u'add a baremetal host'}, u'traffictype': {u'name': u'addTrafficType', u'related': [u'updateTrafficType'], u'isasync': True, u'params': [{u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The VLAN id to be used for Management traffic by VMware host'}, {u'name': u'kvmnetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a KVM host'}, {u'name': u'traffictype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the trafficType to be added to the physical network'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'vmwarenetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a VMware host'}, {u'name': u'xennetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a XenServer host'}], u'requiredparams': [u'traffictype', u'physicalnetworkid'], u'description': u'Adds traffic type to a physical network'}, u'niciranvpdevice': {u'name': u'addNiciraNvpDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'hostname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hostname of ip address of the Nicira NVP Controller.'}, {u'name': u'l3gatewayserviceuuid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The L3 Gateway Service UUID configured on the Nicira Controller'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to access the Nicira Controller API'}, {u'name': u'transportzoneuuid', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'The Transportzone UUID configured on the Nicira Controller'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to access the Nicira Controller API'}], u'requiredparams': [u'physicalnetworkid', u'hostname', u'username', u'transportzoneuuid', u'password'], u'description': u'Adds a Nicira NVP device'}, u'host': {u'name': u'addHost', u'related': [u'updateHost', u'listHosts'], u'isasync': False, u'params': [{u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the host'}, {u'name': u'podid', u'required': True, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'clustername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name for the host'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the host'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host URL'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID for the host'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the host'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of tags to be added to the host'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Host for allocation of new resources'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the host'}], u'requiredparams': [u'username', u'podid', u'zoneid', u'url', u'password', u'hypervisor'], u'description': u'Adds a new host.'}, u'f5loadbalancer': {u'name': u'addF5LoadBalancer', u'related': [u'configureF5LoadBalancer', u'listF5LoadBalancers'], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach F5 BigIP load balancer device'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach F5 BigIP load balancer device'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'networkdevicetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'supports only F5BigIpLoadBalancer'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the F5 load balancer appliance.'}], u'requiredparams': [u'password', u'username', u'physicalnetworkid', u'networkdevicetype', u'url'], u'description': u'Adds a F5 BigIP load balancer device'}, u'networkdevice': {u'name': u'addNetworkDevice', u'related': [], u'isasync': False, u'params': [{u'name': u'networkdevicetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall'}, {u'name': u'networkdeviceparameterlist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'parameters for network device'}], u'requiredparams': [], u'description': u'Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer'}, u'bigswitchvnsdevice': {u'name': u'addBigSwitchVnsDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'physicalnetworkid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'hostname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hostname of ip address of the BigSwitch VNS Controller.'}], u'requiredparams': [u'physicalnetworkid', u'hostname'], u'description': u'Adds a BigSwitch VNS device'}, u'srxfirewall': {u'name': u'addSrxFirewall', u'related': [], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach SRX firewall device'}, {u'name': u'networkdevicetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'supports only JuniperSRXFirewall'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach SRX firewall device'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the SRX appliance.'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}], u'requiredparams': [u'password', u'networkdevicetype', u'username', u'url', u'physicalnetworkid'], u'description': u'Adds a SRX firewall device'}, u'swift': {u'name': u'addSwift', u'related': [u'listSwifts', u'addHost', u'updateHost', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account for swift'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL for swift'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for swift'}, {u'name': u'key', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u' key for the user for swift'}], u'requiredparams': [u'url'], u'description': u'Adds Swift.'}, u'externalfirewall': {u'name': u'addExternalFirewall', u'related': [], u'isasync': False, u'params': [{u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the external firewall appliance.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Password of the external firewall appliance.'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Zone in which to add the external firewall appliance.'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Username of the external firewall appliance.'}], u'requiredparams': [u'url', u'password', u'zoneid', u'username'], u'description': u'Adds an external firewall appliance'}, u'networkserviceprovider': {u'name': u'addNetworkServiceProvider', u'related': [u'updateNetworkServiceProvider'], u'isasync': True, u'params': [{u'name': u'destinationphysicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the destination Physical Network ID to bridge to'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name for the physical network service provider'}, {u'name': u'servicelist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of services to be enabled for this physical network service provider'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID to add the provider to'}], u'requiredparams': [u'name', u'physicalnetworkid'], u'description': u'Adds a network serviceProvider to a physical network'}}, u'verbs': [u'authorize', u'restore', u'suspend', u'revoke', u'disassociate', u'migrate', u'lock', u'dissociate', u'activate', u'reconnect', u'cancel', u'query', u'recover', u'extract', u'detach', u'prepare', u'start', u'create', u'associate', u'reboot', u'mark', u'attach', u'add', u'change', u'deploy', u'ldap', u'destroy', u'enable', u'configure', u'get', u'modify', u'stop', u'update', u'disable', u'resize', u'copy', u'generate', u'restart', u'reset', u'register', u'list', u'upload', u'remove', u'assign', u'delete'], u'resize': {u'volume': {u'name': u'resizeVolume', u'related': [u'detachVolume', u'uploadVolume', u'createVolume'], u'isasync': True, u'params': [{u'name': u'diskofferingid', u'required': False, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'new disk offering id'}, {u'name': u'id', u'required': False, u'related': [u'detachVolume', u'resizeVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'shrinkok', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Verify OK to Shrink'}, {u'name': u'size', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'New volume size in G'}], u'requiredparams': [], u'description': u'Resizes a volume'}}, u'ldap': {u'config': {u'name': u'ldapConfig', u'related': [u'ldapRemove'], u'isasync': False, u'params': [{u'name': u'hostname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hostname or ip address of the ldap server eg: my.ldap.com'}, {u'name': u'ssl', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Check Use SSL if the external LDAP server is configured for LDAP over SSL.'}, {u'name': u'truststore', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enter the path to trust certificates store.'}, {u'name': u'queryfilter', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'You specify a query filter here, which narrows down the users, who can be part of this domain.'}, {u'name': u'searchbase', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.'}, {u'name': u'port', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Specify the LDAP port if required, default is 389.'}, {u'name': u'binddn', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specify the distinguished name of a user with the search permission on the directory.'}, {u'name': u'truststorepass', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enter the password for trust store.'}, {u'name': u'bindpass', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enter the password.'}], u'requiredparams': [u'hostname', u'queryfilter', u'searchbase'], u'description': u'Configure the LDAP context for this site.'}, u'remove': {u'name': u'ldapRemove', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'Remove the LDAP context for this site.'}}, u'destroy': {u'systemvm': {u'name': u'destroySystemVm', u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'stopSystemVm', u'changeServiceForSystemVm'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startSystemVm', u'destroySystemVm', u'rebootSystemVm', u'listSystemVms', u'stopSystemVm', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Destroyes a system virtual machine.'}, u'router': {u'name': u'destroyRouter', u'related': [u'rebootRouter'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'destroyRouter', u'rebootRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Destroys a router.'}, u'volumeonfiler': {u'name': u'destroyVolumeOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'volumename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'volume name.'}, {u'name': u'ipaddress', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ip address.'}, {u'name': u'aggregatename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'aggregate name.'}], u'requiredparams': [u'volumename', u'ipaddress', u'aggregatename'], u'description': u'Destroy a Volume'}, u'lunonfiler': {u'name': u'destroyLunOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'path', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'LUN path.'}], u'requiredparams': [u'path'], u'description': u'Destroy a LUN'}, u'virtualmachine': {u'name': u'destroyVirtualMachine', u'related': [u'listVirtualMachines'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listVirtualMachines', u'destroyVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Destroys a virtual machine. Once destroyed, only the administrator can recover it.'}}, u'get': {u'apilimit': {u'name': u'getApiLimit', u'related': [u'resetApiLimit'], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'Get API limit count for the caller'}, u'vmpassword': {u'name': u'getVMPassword', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Returns an encrypted password for the VM'}, u'user': {u'name': u'getUser', u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'updateUser'], u'isasync': False, u'params': [{u'name': u'userapikey', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'API key of the user'}], u'requiredparams': [u'userapikey'], u'description': u'Find user account by API key'}, u'cloudidentifier': {u'name': u'getCloudIdentifier', u'related': [], u'isasync': False, u'params': [{u'name': u'userid', u'required': True, u'related': [u'lockUser', u'listUsers', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'the user ID for the cloud identifier'}], u'requiredparams': [u'userid'], u'description': u'Retrieves a cloud identifier.'}}, u'count': 355, u'enable': {u'account': {u'name': u'enableAccount', u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'disableAccount'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'Enables specified account in this domain.'}, {u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'enableAccount', u'disableAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enables specified account.'}], u'requiredparams': [], u'description': u'Enables an account'}, u'storagemaintenance': {u'name': u'enableStorageMaintenance', u'related': [u'cancelStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'cancelStorageMaintenance', u'enableStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'Primary storage ID'}], u'requiredparams': [u'id'], u'description': u'Puts storage pool into maintenance state'}, u'cisconexusvsm': {u'name': u'enableCiscoNexusVSM', u'related': [u'disableCiscoNexusVSM'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableCiscoNexusVSM', u'enableCiscoNexusVSM'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Cisco Nexus 1000v VSM device to be enabled'}], u'requiredparams': [u'id'], u'description': u'Enable a Cisco Nexus VSM device'}, u'staticnat': {u'name': u'enableStaticNat', u'related': [], u'isasync': False, u'params': [{u'name': u'ipaddressid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id for which static nat feature is being enabled'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine for enabling static nat feature'}, {u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network of the vm the static nat will be enabled for. Required when public Ip address is not associated with any Guest network yet (VPC case)'}], u'requiredparams': [u'ipaddressid', u'virtualmachineid'], u'description': u'Enables static nat for given ip address'}, u'user': {u'name': u'enableUser', u'related': [u'lockUser', u'listUsers', u'createUser'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'Enables user by user ID.'}], u'requiredparams': [u'id'], u'description': u'Enables a user account'}, u'autoscalevmgroup': {u'name': u'enableAutoScaleVmGroup', u'related': [u'createAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}], u'requiredparams': [u'id'], u'description': u'Enables an AutoScale Vm Group'}}, u'configure': {u'srxfirewall': {u'name': u'configureSrxFirewall', u'related': [u'listSrxFirewalls', u'addSrxFirewall'], u'isasync': True, u'params': [{u'name': u'fwdeviceid', u'required': True, u'related': [u'listSrxFirewalls', u'configureSrxFirewall', u'addSrxFirewall'], u'length': 255, u'type': u'uuid', u'description': u'SRX firewall device ID'}, {u'name': u'fwdevicecapacity', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'capacity of the firewall device, Capacity will be interpreted as number of networks device can handle'}], u'requiredparams': [u'fwdeviceid'], u'description': u'Configures a SRX firewall device'}, u'f5loadbalancer': {u'name': u'configureF5LoadBalancer', u'related': [], u'isasync': True, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'configureF5LoadBalancer'], u'length': 255, u'type': u'uuid', u'description': u'F5 load balancer device ID'}, {u'name': u'lbdevicecapacity', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'capacity of the device, Capacity will be interpreted as number of networks device can handle'}], u'requiredparams': [u'lbdeviceid'], u'description': u'configures a F5 load balancer device'}, u'netscalerloadbalancer': {u'name': u'configureNetscalerLoadBalancer', u'related': [u'listNetscalerLoadBalancers'], u'isasync': True, u'params': [{u'name': u'podids', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'list', u'description': u"Used when NetScaler device is provider of EIP service. This parameter represents the list of pod's, for which there exists a policy based route on datacenter L3 router to route pod's subnet IP to a NetScaler device."}, {u'name': u'lbdevicecapacity', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'capacity of the device, Capacity will be interpreted as number of networks device can handle'}, {u'name': u'lbdeviceid', u'required': True, u'related': [u'listNetscalerLoadBalancers', u'configureNetscalerLoadBalancer'], u'length': 255, u'type': u'uuid', u'description': u'Netscaler load balancer device ID'}, {u'name': u'inline', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if netscaler load balancer is intended to be used in in-line with firewall, false if netscaler load balancer will side-by-side with firewall'}, {u'name': u'lbdevicededicated', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this netscaler device to dedicated for a account, false if the netscaler device will be shared by multiple accounts'}], u'requiredparams': [u'lbdeviceid'], u'description': u'configures a netscaler load balancer device'}, u'virtualrouterelement': {u'name': u'configureVirtualRouterElement', u'related': [u'createVirtualRouterElement'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createVirtualRouterElement', u'configureVirtualRouterElement'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual router provider'}, {u'name': u'enabled', u'required': True, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Enabled/Disabled the service provider'}], u'requiredparams': [u'id', u'enabled'], u'description': u'Configures a virtual router element.'}}, u'associate': {u'ipaddress': {u'name': u'associateIpAddress', u'related': [], u'isasync': True, u'params': [{u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network this ip address should be associated to.'}, {u'name': u'vpcid', u'required': False, u'related': [u'restartVPC', u'listVPCs'], u'length': 255, u'type': u'uuid', u'description': u'the VPC you want the ip address to be associated with'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account to associate with this IP address'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone you want to acquire an public IP address from'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'Deploy vm for the project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain to associate with this IP address'}], u'requiredparams': [], u'description': u'Acquires and associates a public IP to an account.'}, u'lun': {u'name': u'associateLun', u'related': [], u'isasync': False, u'params': [{u'name': u'iqn', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Guest IQN to which the LUN associate.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'LUN name.'}], u'requiredparams': [u'iqn', u'name'], u'description': u'Associate a LUN with a guest IQN'}}, u'stop': {u'systemvm': {u'name': u'stopSystemVm', u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'isasync': True, u'params': [{u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force stop the VM. The caller knows the VM is stopped.'}, {u'name': u'id', u'required': True, u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'stopSystemVm', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Stops a system VM.'}, u'router': {u'name': u'stopRouter', u'related': [u'changeServiceForRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'isasync': True, u'params': [{u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force stop the VM. The caller knows the VM is stopped.'}, {u'name': u'id', u'required': True, u'related': [u'changeServiceForRouter', u'stopRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Stops a router.'}, u'virtualmachine': {u'name': u'stopVirtualMachine', u'related': [u'listVirtualMachines', u'destroyVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend). The caller knows the VM is stopped.'}], u'requiredparams': [u'id'], u'description': u'Stops a virtual machine.'}}, u'modify': {u'pool': {u'name': u'modifyPool', u'related': [], u'isasync': False, u'params': [{u'name': u'algorithm', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'algorithm.'}, {u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'algorithm', u'poolname'], u'description': u'Modify pool'}}, u'update': {u'loadbalancerrule': {u'name': u'updateLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'description', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the description of the load balancer rule'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of the load balancer rule to update'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the load balancer rule'}, {u'name': u'algorithm', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'load balancer algorithm (source, roundrobin, leastconn)'}], u'requiredparams': [u'id'], u'description': u'Updates load balancer'}, u'domain': {u'name': u'updateDomain', u'related': [u'listDomainChildren', u'createDomain'], u'isasync': False, u'params': [{u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"Network domain for the domain's networks; empty string will update domainName with NULL value"}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates domain with this name'}, {u'name': u'id', u'required': True, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'ID of domain to update'}], u'requiredparams': [u'id'], u'description': u'Updates a domain with a new name'}, u'projectinvitation': {u'name': u'updateProjectInvitation', u'related': [], u'isasync': True, u'params': [{u'name': u'accept', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, accept the invitation, decline if false. True by default'}, {u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to join'}, {u'name': u'token', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list invitations for specified account; this parameter has to be specified with domainId'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account that is joining the project'}], u'requiredparams': [u'projectid'], u'description': u'Accepts or declines project invitation'}, u'diskoffering': {u'name': u'updateDiskOffering', u'related': [u'createDiskOffering', u'listDiskOfferings'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the disk offering'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'updates alternate display text of the disk offering with this value'}, {u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the disk offering, integer'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates name of the disk offering with this value'}], u'requiredparams': [u'id'], u'description': u'Updates a disk offering.'}, u'virtualmachine': {u'name': u'updateVirtualMachine', u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'displayname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'user generated name'}, {u'name': u'group', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'group of the virtual machine'}, {u'name': u'haenable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if high-availability is enabled for the virtual machine, false otherwise'}, {u'name': u'id', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'ostypeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS type that best represents this VM.'}, {u'name': u'userdata', u'required': False, u'related': [], u'length': 2048, u'type': u'string', u'description': u'an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding.'}], u'requiredparams': [u'id'], u'description': u'Updates properties of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. Therefore, stop the VM manually before issuing this call.'}, u'portforwardingrule': {u'name': u'updatePortForwardingRule', u'related': [u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'isasync': True, u'params': [{u'name': u'privateport', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the private port of the port forwarding rule'}, {u'name': u'publicport', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the public port of the port forwarding rule'}, {u'name': u'privateip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the private IP address of the port forwarding rule'}, {u'name': u'ipaddressid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the IP address id of the port forwarding rule'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the port fowarding rule. Valid values are TCP or UDP.'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine for the port forwarding rule'}], u'requiredparams': [u'privateport', u'publicport', u'ipaddressid', u'protocol'], u'description': u'Updates a port forwarding rule. Only the private port and the virtual machine can be updated.'}, u'cluster': {u'name': u'updateCluster', u'related': [], u'isasync': False, u'params': [{u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the cluster'}, {u'name': u'id', u'required': True, u'related': [u'updateCluster'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Cluster'}, {u'name': u'managedstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'whether this cluster is managed by cloudstack'}, {u'name': u'clustername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'clustertype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the cluster'}], u'requiredparams': [u'id'], u'description': u'Updates an existing cluster'}, u'hostpassword': {u'name': u'updateHostPassword', u'related': [], u'isasync': False, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new password for the host/cluster'}, {u'name': u'hostid', u'required': False, u'related': [u'listSwifts', u'addHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the host/cluster'}], u'requiredparams': [u'password', u'username'], u'description': u'Update password of a host/pool on management server.'}, u'pod': {u'name': u'updatePod', u'related': [], u'isasync': False, u'params': [{u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address for the Pod'}, {u'name': u'gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway for the Pod'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'id', u'required': True, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Pod'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Pod'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the starting IP address for the Pod'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the Pod'}], u'requiredparams': [u'id'], u'description': u'Updates a Pod.'}, u'isopermissions': {u'name': u'updateIsoPermissions', u'related': [], u'isasync': False, u'params': [{u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template/iso is extractable, false other wise. Can be set only by root admin'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for featured template/iso, false otherwise'}, {u'name': u'accounts', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of accounts. If specified, "op" parameter has to be passed in.'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for public template/iso, false for private templates/isos'}, {u'name': u'projectids', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of projects. If specified, "op" parameter has to be passed in.'}, {u'name': u'op', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'permission operator (add, remove, reset)'}, {u'name': u'id', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}], u'requiredparams': [u'id'], u'description': u'Updates iso permissions'}, u'resourcelimit': {u'name': u'updateResourceLimit', u'related': [], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Update resource for a specified account. Must be used with the domainId parameter.'}, {u'name': u'resourcetype', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Type of resource to update. Values are 0, 1, 2, 3, and 4. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create.3 - Snapshot. Number of snapshots a user can create.4 - Template. Number of templates that a user can register/create.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Update resource limits for all accounts in specified domain. If used with the account parameter, updates resource limits for a specified account in specified domain.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Update resource limits for project'}, {u'name': u'max', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u' Maximum resource limit.'}], u'requiredparams': [u'resourcetype'], u'description': u'Updates resource limits for an account or domain.'}, u'vpcoffering': {u'name': u'updateVPCOffering', u'related': [u'listVPCOfferings', u'createVPCOffering'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the VPC offering'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'update state for the VPC offering; supported states - Enabled/Disabled'}, {u'name': u'id', u'required': False, u'related': [u'listVPCOfferings', u'createVPCOffering', u'updateVPCOffering'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VPC offering'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the VPC offering'}], u'requiredparams': [], u'description': u'Updates VPC offering'}, u'network': {u'name': u'updateNetwork', u'related': [u'listNetscalerLoadBalancerNetworks'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network'}, {u'name': u'networkofferingid', u'required': False, u'related': [u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'network offering ID'}, {u'name': u'changecidr', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force update even if cidr type is different'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new name for the network'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new display text for the network'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network domain'}], u'requiredparams': [u'id'], u'description': u'Updates a network'}, u'zone': {u'name': u'updateZone', u'related': [u'listZones', u'createZone'], u'isasync': False, u'params': [{u'name': u'internaldns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first internal DNS for the Zone'}, {u'name': u'dnssearchorder', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the dns search order list'}, {u'name': u'internaldns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second internal DNS for the Zone'}, {u'name': u'domain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network domain name for the networks in the zone; empty string will update domain with NULL value'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'the details for the Zone'}, {u'name': u'ip6dns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for IPv6 network in the Zone'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'ip6dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for IPv6 network in the Zone'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Zone'}, {u'name': u'id', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Zone'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'updates a private zone to public if set, but not vice-versa'}, {u'name': u'dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for the Zone'}, {u'name': u'guestcidraddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the guest CIDR address for the Zone'}, {u'name': u'dhcpprovider', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the dhcp Provider for the Zone'}, {u'name': u'dns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for the Zone'}, {u'name': u'localstorageenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if local storage offering enabled, false otherwise'}], u'requiredparams': [u'id'], u'description': u'Updates a Zone.'}, u'instancegroup': {u'name': u'updateInstanceGroup', u'related': [u'createInstanceGroup'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateInstanceGroup', u'createInstanceGroup'], u'length': 255, u'type': u'uuid', u'description': u'Instance group ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'new instance group name'}], u'requiredparams': [u'id'], u'description': u'Updates a vm group'}, u'autoscalepolicy': {u'name': u'updateAutoScalePolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'duration', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the duration for which the conditions have to be true before action is taken'}, {u'name': u'id', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale policy'}, {u'name': u'quiettime', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the cool down period for which the policy should not be evaluated after the action has been taken'}, {u'name': u'conditionids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the conditions that are being evaluated on every interval'}], u'requiredparams': [u'id'], u'description': u'Updates an existing autoscale policy.'}, u'serviceoffering': {u'name': u'updateServiceOffering', u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering'], u'isasync': False, u'params': [{u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the service offering, integer'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the service offering to be updated'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the service offering to be updated'}, {u'name': u'id', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering', u'updateServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the service offering to be updated'}], u'requiredparams': [u'id'], u'description': u'Updates a service offering.'}, u'storagepool': {u'name': u'updateStoragePool', u'related': [u'cancelStorageMaintenance', u'createStoragePool', u'listStoragePools'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'cancelStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'the Id of the storage pool'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma-separated list of tags for the storage pool'}], u'requiredparams': [u'id'], u'description': u'Updates a storage pool.'}, u'hypervisorcapabilities': {u'name': u'updateHypervisorCapabilities', u'related': [], u'isasync': False, u'params': [{u'name': u'securitygroupenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'set true to enable security group for this hypervisor.'}, {u'name': u'maxguestslimit', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the max number of Guest VMs per host for this hypervisor.'}, {u'name': u'id', u'required': False, u'related': [u'listHypervisorCapabilities'], u'length': 255, u'type': u'uuid', u'description': u'ID of the hypervisor capability'}], u'requiredparams': [], u'description': u'Updates a hypervisor capabilities.'}, u'template': {u'name': u'updateTemplate', u'related': [u'registerIso', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if image is bootable, false otherwise'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the image supports the password reset feature; default is false'}, {u'name': u'format', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the image'}, {u'name': u'ostypeid', u'required': False, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS type that best represents the OS of this image.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the image file'}, {u'name': u'id', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the image file'}, {u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the template, integer'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the image'}], u'requiredparams': [u'id'], u'description': u'Updates attributes of a template.'}, u'defaultnicforvirtualmachine': {u'name': u'updateDefaultNicForVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'nicid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'NIC ID'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'nicid', u'virtualmachineid'], u'description': u'Changes the default NIC on a VM'}, u'traffictype': {u'name': u'updateTrafficType', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateTrafficType'], u'length': 255, u'type': u'uuid', u'description': u'traffic type id'}, {u'name': u'xennetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a XenServer host'}, {u'name': u'vmwarenetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a VMware host'}, {u'name': u'kvmnetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a KVM host'}], u'requiredparams': [u'id'], u'description': u'Updates traffic type of a physical network'}, u'host': {u'name': u'updateHost', u'related': [u'listHosts'], u'isasync': False, u'params': [{u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Change resource state of host, valid values are [Enable, Disable]. Operation may failed if host in states not allowing Enable/Disable'}, {u'name': u'oscategoryid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of Os category to update the host with'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of tags to be added to the host'}, {u'name': u'id', u'required': True, u'related': [u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the host to update'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new uri for the secondary storage: nfs://host/path'}], u'requiredparams': [u'id'], u'description': u'Updates a host.'}, u'user': {u'name': u'updateUser', u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'updateUser'], u'length': 255, u'type': u'uuid', u'description': u'User uuid'}, {u'name': u'timezone', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'email', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'email'}, {u'name': u'usersecretkey', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The secret key for the user. Must be specified with userApiKey'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Unique username'}, {u'name': u'firstname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'first name'}, {u'name': u'lastname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'last name'}, {u'name': u'password', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hashed password (default is MD5). If you wish to use any other hasing algorithm, you would need to write a custom authentication adapter'}, {u'name': u'userapikey', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The API key for the user. Must be specified with userSecretKey'}], u'requiredparams': [u'id'], u'description': u'Updates a user account'}, u'vpc': {u'name': u'updateVPC', u'related': [u'restartVPC', u'listVPCs'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the VPC'}, {u'name': u'id', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VPC'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the VPC'}], u'requiredparams': [], u'description': u'Updates a VPC'}, u'resourcecount': {u'name': u'updateResourceCount', u'related': [], u'isasync': False, u'params': [{u'name': u'resourcetype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Type of resource to update. If specifies valid values are 0, 1, 2, 3, and 4. If not specified will update all resource counts0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create.3 - Snapshot. Number of snapshots a user can create.4 - Template. Number of templates that a user can register/create.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Update resource limits for project'}, {u'name': u'domainid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'If account parameter specified then updates resource counts for a specified account in this domain else update resource counts for all accounts & child domains in specified domain.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Update resource count for a specified account. Must be used with the domainId parameter.'}], u'requiredparams': [u'domainid'], u'description': u'Recalculate and update resource count for an account or domain.'}, u'storagenetworkiprange': {u'name': u'updateStorageNetworkIpRange', u'related': [], u'isasync': True, u'params': [{u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Optional. the vlan the ip range sits on'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask for storage network'}, {u'name': u'id', u'required': True, u'related': [u'updateStorageNetworkIpRange'], u'length': 255, u'type': u'uuid', u'description': u'UUID of storage network ip range'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address'}], u'requiredparams': [u'id'], u'description': u'Update a Storage network IP range, only allowed when no IPs in this range have been allocated.'}, u'configuration': {u'name': u'updateConfiguration', u'related': [u'listConfigurations'], u'isasync': False, u'params': [{u'name': u'value', u'required': False, u'related': [], u'length': 4095, u'type': u'string', u'description': u'the value of the configuration'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the configuration'}], u'requiredparams': [u'name'], u'description': u'Updates a configuration.'}, u'templatepermissions': {u'name': u'updateTemplatePermissions', u'related': [], u'isasync': False, u'params': [{u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for featured template/iso, false otherwise'}, {u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template/iso is extractable, false other wise. Can be set only by root admin'}, {u'name': u'projectids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of projects. If specified, "op" parameter has to be passed in.'}, {u'name': u'op', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'permission operator (add, remove, reset)'}, {u'name': u'id', u'required': True, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for public template/iso, false for private templates/isos'}, {u'name': u'accounts', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of accounts. If specified, "op" parameter has to be passed in.'}], u'requiredparams': [u'id'], u'description': u'Updates a template visibility permissions. A public template is visible to all accounts within the same domain. A private template is visible only to the owner of the template. A priviledged template is a private template with account permissions added. Only accounts specified under the template permissions are visible to them.'}, u'autoscalevmprofile': {u'name': u'updateAutoScaleVmProfile', u'related': [u'listAutoScaleVmProfiles'], u'isasync': True, u'params': [{u'name': u'expungevmgraceperiod', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the time allowed for existing connections to get closed before a vm is destroyed'}, {u'name': u'autoscaleuserid', u'required': False, u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the user used to launch and destroy the VMs'}, {u'name': u'templateid', u'required': False, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template of the auto deployed virtual machine'}, {u'name': u'id', u'required': True, u'related': [u'updateAutoScaleVmProfile', u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm profile'}, {u'name': u'counterparam', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161'}], u'requiredparams': [u'id'], u'description': u'Updates an existing autoscale vm profile.'}, u'account': {u'name': u'updateAccount', u'related': [u'markDefaultZoneForAccount', u'listAccounts', u'lockAccount'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain where the account exists'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"Network domain for the account's networks; empty string will update domainName with NULL value"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the current account name'}, {u'name': u'accountdetails', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'details for account used to store specific parameters'}, {u'name': u'newname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'new name for the account'}], u'requiredparams': [u'newname'], u'description': u'Updates account information for the authenticated user'}, u'networkoffering': {u'name': u'updateNetworkOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the network offering, integer'}, {u'name': u'id', u'required': False, u'related': [u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'the id of the network offering'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the network offering'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the network offering'}, {u'name': u'availability', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the availability of network offering. Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'update state for the network offering'}], u'requiredparams': [], u'description': u'Updates a network offering.'}, u'vpncustomergateway': {u'name': u'updateVpnCustomerGateway', u'related': [u'createVpnCustomerGateway'], u'isasync': True, u'params': [{u'name': u'ikelifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 1 VPN connection to the customer gateway, in seconds'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the gateway. If used with the account parameter returns the gateway associated with the account for the specified domain.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of this customer gateway'}, {u'name': u'id', u'required': True, u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway'], u'length': 255, u'type': u'uuid', u'description': u'id of customer gateway'}, {u'name': u'esplifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 2 VPN connection to the customer gateway, in seconds'}, {u'name': u'ikepolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IKE policy of the customer gateway'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the gateway. Must be used with the domainId parameter.'}, {u'name': u'esppolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ESP policy of the customer gateway'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'public ip address id of the customer gateway'}, {u'name': u'ipsecpsk', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IPsec Preshared-Key of the customer gateway'}, {u'name': u'dpd', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If DPD is enabled for VPN connection'}, {u'name': u'cidrlist', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'guest cidr of the customer gateway'}], u'requiredparams': [u'id', u'ikepolicy', u'esppolicy', u'gateway', u'ipsecpsk', u'cidrlist'], u'description': u'Update site to site vpn customer gateway'}, u'region': {u'name': u'updateRegion', u'related': [u'addRegion', u'listRegions'], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates region with this name'}, {u'name': u'endpoint', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates region with this end point'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Id of region to update'}], u'requiredparams': [u'id'], u'description': u'Updates a region'}, u'project': {u'name': u'updateProject', u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be modified'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'display text of the project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'new Admin account for the project'}], u'requiredparams': [u'id'], u'description': u'Updates a project'}, u'physicalnetwork': {u'name': u'updatePhysicalNetwork', u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'isasync': True, u'params': [{u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the VLAN for the physical network'}, {u'name': u'id', u'required': True, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'physical network id'}, {u'name': u'networkspeed', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the speed for the physical network[1G/10G]'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'Tag the physical network'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enabled/Disabled'}], u'requiredparams': [u'id'], u'description': u'Updates a physical network'}, u'iso': {u'name': u'updateIso', u'related': [u'listIsos'], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the image file'}, {u'name': u'id', u'required': True, u'related': [u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the image file'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the image'}, {u'name': u'format', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the image'}, {u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the template, integer'}, {u'name': u'ostypeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS type that best represents the OS of this image.'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the image supports the password reset feature; default is false'}, {u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if image is bootable, false otherwise'}], u'requiredparams': [u'id'], u'description': u'Updates an ISO file.'}, u'networkserviceprovider': {u'name': u'updateNetworkServiceProvider', u'related': [], u'isasync': True, u'params': [{u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enabled/Disabled/Shutdown the physical network service provider'}, {u'name': u'id', u'required': True, u'related': [u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'network service provider id'}, {u'name': u'servicelist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of services to be enabled for this physical network service provider'}], u'requiredparams': [u'id'], u'description': u'Updates a network serviceProvider of a physical network'}, u'autoscalevmgroup': {u'name': u'updateAutoScaleVmGroup', u'related': [], u'isasync': True, u'params': [{u'name': u'scaledownpolicyids', u'required': False, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaledown autoscale policies'}, {u'name': u'interval', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the frequency at which the conditions have to be evaluated'}, {u'name': u'minmembers', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the minimum number of members in the vmgroup, the number of instances in the vm group will be equal to or more than this number.'}, {u'name': u'maxmembers', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the maximum number of members in the vmgroup, The number of instances in the vm group will be equal to or less than this number.'}, {u'name': u'id', u'required': True, u'related': [u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}, {u'name': u'scaleuppolicyids', u'required': False, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaleup autoscale policies'}], u'requiredparams': [u'id'], u'description': u'Updates an existing autoscale vm group.'}}, u'disable': {u'account': {u'name': u'disableAccount', u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'isasync': True, u'params': [{u'name': u'lock', u'required': True, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If true, only lock the account; else disable the account'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Disables specified account.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'Disables specified account in this domain.'}, {u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'disableAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}], u'requiredparams': [u'lock'], u'description': u'Disables an account'}, u'autoscalevmgroup': {u'name': u'disableAutoScaleVmGroup', u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'disableAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}], u'requiredparams': [u'id'], u'description': u'Disables an AutoScale Vm Group'}, u'cisconexusvsm': {u'name': u'disableCiscoNexusVSM', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableCiscoNexusVSM'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Cisco Nexus 1000v VSM device to be deleted'}], u'requiredparams': [u'id'], u'description': u'disable a Cisco Nexus VSM device'}, u'staticnat': {u'name': u'disableStaticNat', u'related': [], u'isasync': True, u'params': [{u'name': u'ipaddressid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id for which static nat feature is being disableed'}], u'requiredparams': [u'ipaddressid'], u'description': u'Disables static rule for given ip address'}, u'user': {u'name': u'disableUser', u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'Disables user by user ID.'}], u'requiredparams': [u'id'], u'description': u'Disables a user account'}}, u'detach': {u'volume': {u'name': u'detachVolume', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': False, u'related': [u'detachVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'deviceid', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the device ID on the virtual machine where volume is detached from'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'listVirtualMachines'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine where the volume is detached from'}], u'requiredparams': [], u'description': u'Detaches a disk volume from a virtual machine.'}, u'iso': {u'name': u'detachIso', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'virtualmachineid'], u'description': u'Detaches any ISO file (if any) currently attached to a virtual machine.'}}, u'generate': {u'usagerecords': {u'name': u'generateUsageRecords', u'related': [], u'isasync': False, u'params': [{u'name': u'enddate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'End date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'List events for the specified domain.'}, {u'name': u'startdate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'Start date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.'}], u'requiredparams': [u'enddate', u'startdate'], u'description': u'Generates usage records. This will generate records only if there any records to be generated, i.e if the scheduled usage job was not run or failed'}}, u'change': {u'serviceforvirtualmachine': {u'name': u'changeServiceForVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID to apply to the virtual machine'}], u'requiredparams': [u'id', u'serviceofferingid'], u'description': u'Changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" state for this command to take effect.'}, u'serviceforsystemvm': {u'name': u'changeServiceForSystemVm', u'related': [u'rebootSystemVm', u'listSystemVms'], u'isasync': False, u'params': [{u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID to apply to the system vm'}, {u'name': u'id', u'required': True, u'related': [u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system vm'}], u'requiredparams': [u'serviceofferingid', u'id'], u'description': u'Changes the service offering for a system vm (console proxy or secondary storage). The system vm must be in a "Stopped" state for this command to take effect.'}, u'serviceforrouter': {u'name': u'changeServiceForRouter', u'related': [u'destroyRouter', u'rebootRouter', u'startRouter'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'changeServiceForRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the router'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering', u'updateServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID to apply to the domain router'}], u'requiredparams': [u'id', u'serviceofferingid'], u'description': u'Upgrades domain router to a new service offering'}}, u'reset': {u'apilimit': {u'name': u'resetApiLimit', u'related': [], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the acount whose limit to be reset'}], u'requiredparams': [], u'description': u'Reset api count'}, u'sshkeyforvirtualmachine': {u'name': u'resetSSHKeyForVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'keypair', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the ssh key pair used to login to the virtual machine'}, {u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the ssh key. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.'}], u'requiredparams': [u'keypair', u'id'], u'description': u'Resets the SSH Key for virtual machine. The virtual machine must be in a "Stopped" state. [async]'}, u'passwordforvirtualmachine': {u'name': u'resetPasswordForVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Resets the password for virtual machine. The virtual machine must be in a "Stopped" state and the template must already support this feature for this command to take effect. [async]'}, u'vpnconnection': {u'name': u'resetVpnConnection', u'related': [u'listVpnConnections'], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for connection. Must be used with domainId.'}, {u'name': u'id', u'required': True, u'related': [u'listVpnConnections', u'resetVpnConnection'], u'length': 255, u'type': u'uuid', u'description': u'id of vpn connection'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for connection. If the account parameter is used, domainId must also be used.'}], u'requiredparams': [u'id'], u'description': u'Reset site to site vpn connection'}}, u'register': {u'userkeys': {u'name': u'registerUserKeys', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'User id'}], u'requiredparams': [u'id'], u'description': u'This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user'}, u'iso': {u'name': u'registerIso', u'related': [u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'ostypeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS Type that best represents the OS of this ISO. If the iso is bootable this parameter needs to be passed'}, {u'name': u'checksum', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the MD5 checksum value of this ISO'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the ISO'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId. If the account parameter is used, domainId must also be used.'}, {u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this ISO is bootable. If not passed explicitly its assumed to be true'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'Register iso for the project'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if you want to register the ISO to be publicly available to all users, false otherwise.'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone you wish to register the ISO to.'}, {u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the iso or its derivatives are extractable; default is false'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the ISO. This is usually used for display purposes.'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if you want this ISO to be featured'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL to where the ISO is currently being hosted'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account name. Must be used with domainId.'}], u'requiredparams': [u'name', u'zoneid', u'displaytext', u'url'], u'description': u'Registers an existing ISO into the CloudStack Cloud.'}, u'sshkeypair': {u'name': u'registerSSHKeyPair', u'related': [u'createSSHKeyPair', u'listSSHKeyPairs'], u'isasync': False, u'params': [{u'name': u'publickey', u'required': True, u'related': [], u'length': 5120, u'type': u'string', u'description': u'Public key material of the keypair'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the keypair'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the ssh key. Must be used with domainId.'}], u'requiredparams': [u'publickey', u'name'], u'description': u'Register a public key in a keypair under a certain name'}, u'template': {u'name': u'registerTemplate', u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template or its derivatives are extractable; default is false'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone the template is to be hosted on'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId. If the account parameter is used, domainId must also be used.'}, {u'name': u'checksum', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the MD5 checksum value of this template'}, {u'name': u'templatetag', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tag for this template.'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template is available to all accounts; default is true'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template supports the password reset feature; default is false'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the template. This is usually used for display purposes.'}, {u'name': u'sshkeyenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template supports the sshkey upload feature; default is false'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'Register template for the project'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the template'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template is a featured template, false otherwise'}, {u'name': u'format', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the template. Possible values include QCOW2, RAW, and VHD.'}, {u'name': u'requireshvm', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template requires HVM'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional accountName. Must be used with domainId.'}, {u'name': u'ostypeid', u'required': True, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS Type that best represents the OS of this template.'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the target hypervisor for the template'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL of where the template is hosted. Possible URL include http:// and https://'}, {u'name': u'bits', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'32 or 64 bits support. 64 by default'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'Template details in key/value pairs.'}], u'requiredparams': [u'zoneid', u'displaytext', u'name', u'format', u'ostypeid', u'hypervisor', u'url'], u'description': u'Registers an existing template into the CloudStack cloud. '}}, u'list': {u'instancegroups': {u'name': u'listInstanceGroups', u'related': [u'updateInstanceGroup', u'createInstanceGroup'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listInstanceGroups', u'updateInstanceGroup', u'createInstanceGroup'], u'length': 255, u'type': u'uuid', u'description': u'list instance groups by ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list instance groups by name'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists vm groups'}, u'physicalnetworks': {u'name': u'listPhysicalNetworks', u'related': [], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the physical network'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listPhysicalNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list physical network by id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'search by name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists physical networks'}, u'networks': {u'name': u'listNetworks', u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'issystem', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network is system, false otherwise'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'List networks by VPC'}, {u'name': u'acltype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list networks by ACL (access control list) type. Supported values are Account and Domain'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'specifyipranges', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only networks which support specifying ip ranges'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the network'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'restartrequired', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list networks by restartRequired'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the type of the network. Supported values are: Isolated and Shared'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'list networks by physical network id'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list networks supporting certain services'}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of the traffic'}, {u'name': u'id', u'required': False, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list networks by id'}, {u'name': u'canusefordeploy', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list networks available for vm deployment'}, {u'name': u'forvpc', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the network belongs to vpc'}], u'requiredparams': [], u'description': u'Lists all available networks.'}, u'capabilities': {u'name': u'listCapabilities', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'Lists capabilities'}, u'clusters': {u'name': u'listClusters', u'related': [u'updateCluster'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listClusters', u'updateCluster'], u'length': 255, u'type': u'uuid', u'description': u'lists clusters by the cluster ID'}, {u'name': u'managedstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'whether this cluster is managed by cloudstack'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by hypervisor type'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by allocation state'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'lists clusters by Zone ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by the cluster name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'clustertype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by cluster type'}, {u'name': u'showcapacities', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'flag to display the capacity of the clusters'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'lists clusters by Pod ID'}], u'requiredparams': [], u'description': u'Lists clusters.'}, u'resourcelimits': {u'name': u'listResourceLimits', u'related': [u'updateResourceLimit'], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'resourcetype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Type of resource to update. Values are 0, 1, 2, 3, and 4. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create.3 - Snapshot. Number of snapshots a user can create.4 - Template. Number of templates that a user can register/create.'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lists resource limits by ID.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists resource limits.'}, u'firewallrules': {u'name': u'listFirewallRules', u'related': [u'createEgressFirewallRule', u'createFirewallRule', u'listEgressFirewallRules'], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'ipaddressid', u'required': False, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the id of IP address of the firwall services'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists all firewall rules for an IP address.'}, u'supportednetworkservices': {u'name': u'listSupportedNetworkServices', u'related': [], u'isasync': False, u'params': [{u'name': u'service', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network service name to list providers and capabilities of'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'provider', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network service provider name'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists all network services provided by CloudStack or for the given Provider.'}, u'loadbalancerrules': {u'name': u'listLoadBalancerRules', u'related': [u'createLoadBalancerRule', u'updateLoadBalancerRule'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the availability zone ID'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine of the load balancer rule'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'id', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'publicipid', u'required': False, u'related': [u'restartNetwork', u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id of the load balancer rule '}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the load balancer rule'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists load balancer rules.'}, u'autoscalepolicies': {u'name': u'listAutoScalePolicies', u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy'], u'isasync': False, u'params': [{u'name': u'action', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the action to be executed if all the conditions evaluate to true for the specified duration.'}, {u'name': u'id', u'required': False, u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy', u'listAutoScalePolicies'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale policy'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'vmgroupid', u'required': False, u'related': [u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm group'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'conditionid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the condition of the policy'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists autoscale policies.'}, u'niciranvpdevices': {u'name': u'listNiciraNvpDevices', u'related': [u'addNiciraNvpDevice'], u'isasync': False, u'params': [{u'name': u'nvpdeviceid', u'required': False, u'related': [u'addNiciraNvpDevice', u'listNiciraNvpDevices'], u'length': 255, u'type': u'uuid', u'description': u'nicira nvp device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists Nicira NVP devices'}, u'f5loadbalancernetworks': {u'name': u'listF5LoadBalancerNetworks', u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'lbdeviceid', u'required': True, u'related': [u'configureF5LoadBalancer', u'addF5LoadBalancer', u'listF5LoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'f5 load balancer device ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'lbdeviceid'], u'description': u'lists network that are using a F5 load balancer device'}, u'templatepermissions': {u'name': u'listTemplatePermissions', u'related': [u'listIsoPermissions'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsoPermissions', u'listTemplatePermissions'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}], u'requiredparams': [u'id'], u'description': u'List template visibility and all accounts that have permissions to view this template.'}, u'projects': {u'name': u'listProjects', u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List projects by tags (key/value pairs)'}, {u'name': u'id', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list projects by project ID'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list projects by name'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list projects by state'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list projects by display text'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists projects and provides detailed information for listed projects'}, u'systemvms': {u'name': u'listSystemVms', u'related': [u'rebootSystemVm'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the system VM'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the host ID of the system VM'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the state of the system VM'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'storageid', u'required': False, u'related': [u'cancelStorageMaintenance'], u'length': 255, u'type': u'uuid', u'description': u"the storage ID where vm's volumes belong to"}, {u'name': u'systemvmtype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the system VM type. Possible types are "consoleproxy" and "secondarystoragevm".'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID of the system VM'}, {u'name': u'id', u'required': False, u'related': [u'rebootSystemVm', u'listSystemVms'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the system VM'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the system VM'}], u'requiredparams': [], u'description': u'List system virtual machines.'}, u'portforwardingrules': {u'name': u'listPortForwardingRules', u'related': [u'listIpForwardingRules', u'createPortForwardingRule'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'id', u'required': False, u'related': [u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'ipaddressid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of IP address of the port forwarding services'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists all port forwarding rules for an IP address.'}, u'hypervisors': {u'name': u'listHypervisors', u'related': [], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the zone id for listing hypervisors.'}], u'requiredparams': [], u'description': u'List hypervisors'}, u'publicipaddresses': {u'name': u'listPublicIpAddresses', u'related': [u'restartNetwork', u'associateIpAddress'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses by Zone ID'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'allocatedonly', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'limits search results to allocated public IP addresses'}, {u'name': u'id', u'required': False, u'related': [u'restartNetwork', u'listPublicIpAddresses', u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'lists ip address by id'}, {u'name': u'forloadbalancing', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list only ips used for load balancing'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isstaticnat', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list only static nat ip addresses'}, {u'name': u'issourcenat', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list only source nat ip addresses'}, {u'name': u'vlanid', u'required': False, u'related': [u'listVlanIpRanges'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses by VLAN ID'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists the specified IP address'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses by physical network id'}, {u'name': u'associatednetworkid', u'required': False, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses associated to the network specified'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the virtual network for the IP address'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'List ips belonging to the VPC'}], u'requiredparams': [], u'description': u'Lists all public ip addresses'}, u'vpngateways': {u'name': u'listVpnGateways', u'related': [u'createVpnGateway'], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'id', u'required': False, u'related': [u'createVpnGateway', u'listVpnGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the vpn gateway'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'id of vpc'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists site 2 site vpn gateways'}, u'loadbalancerruleinstances': {u'name': u'listLoadBalancerRuleInstances', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'applied', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if listing all virtual machines currently applied to the load balancer rule; default is true'}, {u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'id'], u'description': u'List all virtual machine instances that are assigned to a load balancer rule.'}, u'hosts': {u'name': u'listHosts', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the state of the host'}, {u'name': u'resourcestate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list hosts by resource state. Resource state represents current state determined by admin of host, valule can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the host'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the host'}, {u'name': u'virtualmachineid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'lists hosts existing in particular cluster'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host type'}, {u'name': u'id', u'required': False, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the id of the host'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]'}, {u'name': u'hahost', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, list only hosts dedicated to HA'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists hosts.'}, u'pools': {u'name': u'listPools', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'List Pool'}, u'counters': {u'name': u'listCounters', u'related': [], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'source', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Source of the counter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'listCounters'], u'length': 255, u'type': u'uuid', u'description': u'ID of the Counter.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the counter.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'List the counters'}, u'configurations': {u'name': u'listConfigurations', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists configuration by name'}, {u'name': u'category', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists configurations by category'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all configurations.'}, u'usagerecords': {u'name': u'listUsageRecords', u'related': [], u'isasync': False, u'params': [{u'name': u'enddate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'End date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.'}, {u'name': u'startdate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'Start date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'List usage records for the specified usage type'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'List usage records for specified project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List usage records for the specified user.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'List usage records for the specified domain.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'accountid', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'List usage records for the specified account'}], u'requiredparams': [u'enddate', u'startdate'], u'description': u'Lists usage records for accounts'}, u'storagepools': {u'name': u'listStoragePools', u'related': [u'cancelStorageMaintenance'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the storage pool'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'path', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the storage pool path'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list storage pools belongig to the specific cluster'}, {u'name': u'id', u'required': False, u'related': [u'cancelStorageMaintenance', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the storage pool'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the IP address for the storage pool'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the storage pool'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the storage pool'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists storage pools.'}, u'vpncustomergateways': {u'name': u'listVpnCustomerGateways', u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway', u'listVpnCustomerGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the customer gateway'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}], u'requiredparams': [], u'description': u'Lists site to site vpn customer gateways'}, u'zones': {u'name': u'listZones', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone'}, {u'name': u'available', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if you want to retrieve all available Zones. False if you only want to return the Zones from which you have at least one VM. Default is false.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the zone'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain associated with the zone'}, {u'name': u'showcapacities', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'flag to display the capacity of the zones'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists zones'}, u'serviceofferings': {u'name': u'listServiceOfferings', u'related': [u'updateHypervisorCapabilities'], u'isasync': False, u'params': [{u'name': u'systemvmtype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the system VM type. Possible types are "consoleproxy", "secondarystoragevm" or "domainrouter".'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain associated with the service offering'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the service offering'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine. Pass this in if you want to see the available service offering that a virtual machine can be changed to.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'issystem', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'is this a system vm offering'}, {u'name': u'id', u'required': False, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the service offering'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all available service offerings.'}, u'externalfirewalls': {u'name': u'listExternalFirewalls', u'related': [u'addExternalFirewall'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'zone Id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'zoneid'], u'description': u'List external firewall appliances.'}, u'networkserviceproviders': {u'name': u'listNetworkServiceProviders', u'related': [u'addNetworkServiceProvider', u'listTrafficTypes', u'updateNetworkServiceProvider'], u'isasync': False, u'params': [{u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list providers by state'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list providers by name'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists network serviceproviders for a given physical network.'}, u'capacity': {u'name': u'listCapacity', u'related': [], u'isasync': False, u'params': [{u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'lists capacity by type* CAPACITY_TYPE_MEMORY = 0* CAPACITY_TYPE_CPU = 1* CAPACITY_TYPE_STORAGE = 2* CAPACITY_TYPE_STORAGE_ALLOCATED = 3* CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4* CAPACITY_TYPE_PRIVATE_IP = 5* CAPACITY_TYPE_SECONDARY_STORAGE = 6* CAPACITY_TYPE_VLAN = 7* CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8* CAPACITY_TYPE_LOCAL_STORAGE = 9.'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'lists capacity by the Cluster ID'}, {u'name': u'sortby', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Sort the results. Available values: Usage'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'fetchlatest', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'recalculate capacities and fetch the latest'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'lists capacity by the Zone ID'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'lists capacity by the Pod ID'}], u'requiredparams': [], u'description': u'Lists all the system wide capacities.'}, u'diskofferings': {u'name': u'listDiskOfferings', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the disk offering'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the disk offering'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain of the disk offering.'}], u'requiredparams': [], u'description': u'Lists all available disk offerings.'}, u'lbstickinesspolicies': {u'name': u'listLBStickinessPolicies', u'related': [u'createLBStickinessPolicy'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'lbruleid', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [u'lbruleid'], u'description': u'Lists LBStickiness policies.'}, u'srxfirewallnetworks': {u'name': u'listSrxFirewallNetworks', u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'isasync': False, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'addSrxFirewall'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'lbdeviceid'], u'description': u'lists network that are using SRX firewall device'}, u'securitygroups': {u'name': u'listSecurityGroups', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'id', u'required': False, u'related': [u'listSecurityGroups'], u'length': 255, u'type': u'uuid', u'description': u'list the security group by the id provided'}, {u'name': u'securitygroupname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists security groups by name'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'lists security groups by virtual machine id'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists security groups'}, u'conditions': {u'name': u'listConditions', u'related': [u'listCounters', u'createCounter'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'ID of the Condition.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'counterid', u'required': False, u'related': [u'listConditions', u'listCounters', u'createCounter'], u'length': 255, u'type': u'uuid', u'description': u'Counter-id of the condition.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'policyid', u'required': False, u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the policy'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}], u'requiredparams': [], u'description': u'List Conditions for the specific user'}, u'swifts': {u'name': u'listSwifts', u'related': [u'addHost', u'updateHost', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the id of the swift'}], u'requiredparams': [], u'description': u'List Swift.'}, u'hypervisorcapabilities': {u'name': u'listHypervisorCapabilities', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listHypervisorCapabilities'], u'length': 255, u'type': u'uuid', u'description': u'ID of the hypervisor capability'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor for which to restrict the search'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists all hypervisor capabilities.'}, u'tags': {u'name': u'listTags', u'related': [], u'isasync': False, u'params': [{u'name': u'resourceid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by resource id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'resourcetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by resource type'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'key', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by key'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'customer', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by customer name'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'value', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by value'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'List resource tag(s)'}, u'routers': {u'name': u'listRouters', u'related': [u'changeServiceForRouter', u'stopRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the state of the router'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'List networks by VPC'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID of the router'}, {u'name': u'hostid', u'required': False, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the host ID of the router'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the router'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the router'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'addNicToVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk router'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'listNiciraNvpDeviceNetworks', u'updateNetwork', u'listF5LoadBalancerNetworks', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list by network id'}, {u'name': u'forvpc', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true is passed for this parameter, list only VPC routers'}], u'requiredparams': [], u'description': u'List routers.'}, u'traffictypes': {u'name': u'listTrafficTypes', u'related': [u'addNetworkServiceProvider', u'updateNetworkServiceProvider'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'physicalnetworkid'], u'description': u'Lists traffic types of a given physical network.'}, u'projectinvitations': {u'name': u'listProjectInvitations', u'related': [], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'activeonly', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, list only active invitations - having Pending state and ones that are not timed out yet'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list by project id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list invitations by state'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'listProjectInvitations'], u'length': 255, u'type': u'uuid', u'description': u'list invitations by id'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists projects and provides detailed information for listed projects'}, u'isos': {u'name': u'listIsos', u'related': [], u'isasync': False, u'params': [{u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the ISO is bootable, false otherwise'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list all isos by name'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'list ISO by id'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the ISO is publicly available to all users, false otherwise.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isofilter', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'possible values are "featured", "self", "selfexecutable","sharedexecutable","executable", and "community". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured. * all : all templates (only usable by admins).'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor for which to restrict the search'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'isready', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this ISO is ready to be deployed'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all available ISO files.'}, u'users': {u'name': u'listUsers', u'related': [], u'isasync': False, u'params': [{u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List user by the username'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'accounttype', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'List users by account type. Valid types include admin, domain-admin, read-only-admin, or user.'}, {u'name': u'id', u'required': False, u'related': [u'listUsers'], u'length': 255, u'type': u'uuid', u'description': u'List user by ID.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List users by state of the user account.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists user accounts'}, u'sshkeypairs': {u'name': u'listSSHKeyPairs', u'related': [], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'fingerprint', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'A public key fingerprint to look for'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'A key pair name to look for'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}], u'requiredparams': [], u'description': u'List registered keypairs'}, u'privategateways': {u'name': u'listPrivateGateways', u'related': [u'createPrivateGateway'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'createPrivateGateway', u'listPrivateGateways'], u'length': 255, u'type': u'uuid', u'description': u'list private gateway by id'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list gateways by ip address'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'list gateways by vpc'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list gateways by state'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list gateways by vlan'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}], u'requiredparams': [], u'description': u'List private gateways'}, u'usagetypes': {u'name': u'listUsageTypes', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'List Usage Types'}, u'domainchildren': {u'name': u'listDomainChildren', u'related': [u'createDomain'], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list children domains by name'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list children domain by parent domain ID.'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'to return the entire tree, use the value "true". To return the first level children, use the value "false".'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all children domains belonging to a specified domain'}, u'domains': {u'name': u'listDomains', u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'List domain by domain ID.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List domain by domain name.'}, {u'name': u'level', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'List domains by domain level.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}], u'requiredparams': [], u'description': u'Lists domains and provides detailed information for listed domains'}, u'externalloadbalancers': {u'name': u'listExternalLoadBalancers', u'related': [u'addHost', u'updateHost', u'listHosts'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'zone Id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists F5 external load balancer appliances added in a zone.'}, u'netscalerloadbalancers': {u'name': u'listNetscalerLoadBalancers', u'related': [], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'lbdeviceid', u'required': False, u'related': [u'listNetscalerLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'lists netscaler load balancer devices'}, u's3s': {u'name': u'listS3s', u'related': [u'addS3'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists S3s'}, u'bigswitchvnsdevices': {u'name': u'listBigSwitchVnsDevices', u'related': [u'addBigSwitchVnsDevice'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vnsdeviceid', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'bigswitch vns device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}], u'requiredparams': [], u'description': u'Lists BigSwitch Vns devices'}, u'accounts': {u'name': u'listAccounts', u'related': [u'markDefaultZoneForAccount', u'lockAccount'], u'isasync': False, u'params': [{u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list accounts by state. Valid states are enabled, disabled, and locked.'}, {u'name': u'iscleanuprequired', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list accounts by cleanuprequred attribute (values are true or false)'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'accounttype', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'list accounts by account type. Valid account types are 1 (admin), 2 (domain-admin), and 0 (user).'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'list account by account ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list account by account name'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists accounts and provides detailed account information for listed accounts'}, u'networkdevice': {u'name': u'listNetworkDevice', u'related': [u'addNetworkDevice'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'networkdevicetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall'}, {u'name': u'networkdeviceparameterlist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'parameters for network device'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'List network devices'}, u'vlanipranges': {u'name': u'listVlanIpRanges', u'related': [], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'networkid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'network id of the VLAN IP range'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID with which the VLAN IP range is associated. If used with the account parameter, returns all VLAN IP ranges for that account in the specified domain.'}, {u'name': u'id', u'required': False, u'related': [u'listVlanIpRanges'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VLAN IP range'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks'], u'length': 255, u'type': u'uuid', u'description': u'physical network id of the VLAN IP range'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'project who will own the VLAN'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account with which the VLAN IP range is associated. Must be used with the domainId parameter.'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ID or VID of the VLAN. Default is an "untagged" VLAN.'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID of the VLAN IP range'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the VLAN IP range'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if VLAN is of Virtual type, false if Direct'}], u'requiredparams': [], u'description': u'Lists all VLAN IP ranges.'}, u'traffictypeimplementors': {u'name': u'listTrafficTypeImplementors', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Optional. The network traffic type, if specified, return its implementor. Otherwise, return all traffic types with their implementor'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists implementors of implementor of a network traffic type or implementors of all network traffic types'}, u'storagenetworkiprange': {u'name': u'listStorageNetworkIpRange', u'related': [u'updateStorageNetworkIpRange'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Zone uuid, if specicied and both pod uuid and range uuid are absent, using it to search the range.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'listStorageNetworkIpRange', u'updateStorageNetworkIpRange'], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Storaget network IP range uuid, if specicied, using it to search the range.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Pod uuid, if specicied and range uuid is absent, using it to search the range.'}], u'requiredparams': [], u'description': u'List a storage network IP range.'}, u'isopermissions': {u'name': u'listIsoPermissions', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsoPermissions'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}], u'requiredparams': [u'id'], u'description': u'List iso visibility and all accounts that have permissions to view this iso.'}, u'snapshotpolicies': {u'name': u'listSnapshotPolicies', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'volumeid', u'required': True, u'related': [u'detachVolume', u'uploadVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [u'volumeid'], u'description': u'Lists snapshot policies.'}, u'autoscalevmgroups': {u'name': u'listAutoScaleVmGroups', u'related': [u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'isasync': False, u'params': [{u'name': u'policyid', u'required': False, u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy', u'listAutoScalePolicies'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the policy'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'vmprofileid', u'required': False, u'related': [u'updateAutoScaleVmProfile', u'createAutoScaleVmProfile', u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the profile'}, {u'name': u'lbruleid', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the loadbalancer'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the availability zone ID'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm group'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists autoscale vm groups.'}, u'projectaccounts': {u'name': u'listProjectAccounts', u'related': [u'createProject'], u'isasync': False, u'params': [{u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'id of the project'}, {u'name': u'role', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list accounts of the project by role'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list accounts of the project by account name'}], u'requiredparams': [u'projectid'], u'description': u"Lists project's accounts"}, u'autoscalevmprofiles': {u'name': u'listAutoScaleVmProfiles', u'related': [], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'id', u'required': False, u'related': [u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm profile'}, {u'name': u'templateid', u'required': False, u'related': [u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the templateid of the autoscale vm profile'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'otherdeployparams', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the otherdeployparameters of the autoscale vm profile'}], u'requiredparams': [], u'description': u'Lists autoscale vm profiles.'}, u'apis': {u'name': u'listApis', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'API name'}], u'requiredparams': [], u'description': u'lists all available apis on the server, provided by the Api Discovery plugin'}, u'vpcs': {u'name': u'listVPCs', u'related': [u'restartVPC'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by name of the VPC'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'cidr', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"list by cidr of the VPC. All VPC guest networks' cidrs should be within this CIDR"}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'restartrequired', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list VPCs by restartRequired option'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPCs by state'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by display text of the VPC'}, {u'name': u'id', u'required': False, u'related': [u'restartVPC', u'listVPCs'], u'length': 255, u'type': u'uuid', u'description': u'list VPC by id'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list by zone'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list VPC supporting certain services'}, {u'name': u'vpcofferingid', u'required': False, u'related': [u'listVPCOfferings', u'createVPCOffering'], u'length': 255, u'type': u'uuid', u'description': u'list by ID of the VPC offering'}], u'requiredparams': [], u'description': u'Lists VPCs'}, u'f5loadbalancers': {u'name': u'listF5LoadBalancers', u'related': [u'configureF5LoadBalancer'], u'isasync': False, u'params': [{u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'lbdeviceid', u'required': False, u'related': [u'configureF5LoadBalancer', u'listF5LoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'f5 load balancer device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'lists F5 load balancer devices'}, u'snapshots': {u'name': u'listSnapshots', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'id', u'required': False, u'related': [u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'lists snapshot by snapshot ID'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'intervaltype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'valid values are HOURLY, DAILY, WEEKLY, and MONTHLY.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'volumeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists snapshot by snapshot name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'snapshottype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'valid values are MANUAL or RECURRING.'}], u'requiredparams': [], u'description': u'Lists all available snapshots for the account.'}, u'networkofferings': {u'name': u'listNetworkOfferings', u'related': [u'createNetworkOffering', u'updateNetworkOffering'], u'isasync': False, u'params': [{u'name': u'isdefault', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only default network offerings. Default value is false'}, {u'name': u'sourcenatsupported', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only netwok offerings where source nat is supported, false otherwise'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list network offerings supporting certain services'}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network. Pass this in if you want to see the available network offering that a network can be changed to.'}, {u'name': u'specifyipranges', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only network offerings which support specifying ip ranges'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by name'}, {u'name': u'id', u'required': False, u'related': [u'listNetworkOfferings', u'createNetworkOffering', u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'list network offerings by id'}, {u'name': u'specifyvlan', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the tags for the network offering.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'list netowrk offerings available for network creation in specific zone'}, {u'name': u'forvpc', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the network offering can be used only for network creation inside the VPC'}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by traffic type'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'guestiptype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by guest type: Shared or Isolated'}, {u'name': u'istagged', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if offering has tags specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'list network offerings by tags'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by display text'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by state'}, {u'name': u'availability', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the availability of network offering. Default value is Required'}], u'requiredparams': [], u'description': u'Lists all available network offerings.'}, u'virtualmachines': {u'name': u'listVirtualMachines', u'related': [], u'isasync': False, u'params': [{u'name': u'templateid', u'required': False, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'list vms by template'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'networkid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list by network id'}, {u'name': u'storageid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u"the storage ID where vm's volumes belong to"}, {u'name': u'isoid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list vms by iso'}, {u'name': u'vpcid', u'required': False, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'list vms by vpc'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the pod ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the virtual machine'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of host details requested, value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min]. If no parameter is passed in, the details will be defaulted to all'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the target hypervisor for the template'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'groupid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the group ID'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the availability zone ID'}, {u'name': u'hostid', u'required': False, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}, {u'name': u'id', u'required': False, u'related': [u'listVirtualMachines'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list by network type; true if need to list vms using Virtual Network, false otherwise'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'state of the virtual machine'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'List the virtual machines owned by the account.'}, u'netscalerloadbalancernetworks': {u'name': u'listNetscalerLoadBalancerNetworks', u'related': [], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'lbdeviceid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}], u'requiredparams': [u'lbdeviceid'], u'description': u'lists network that are using a netscaler load balancer device'}, u'oscategories': {u'name': u'listOsCategories', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listOsCategories'], u'length': 255, u'type': u'uuid', u'description': u'list Os category by id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list os category by name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists all supported OS categories for this cloud.'}, u'virtualrouterelements': {u'name': u'listVirtualRouterElements', u'related': [u'createVirtualRouterElement', u'configureVirtualRouterElement'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'nspid', u'required': False, u'related': [u'addNetworkServiceProvider', u'listTrafficTypes', u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'list virtual router elements by network service provider id'}, {u'name': u'id', u'required': False, u'related': [u'createVirtualRouterElement', u'configureVirtualRouterElement', u'listVirtualRouterElements'], u'length': 255, u'type': u'uuid', u'description': u'list virtual router elements by id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'enabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list network offerings by enabled state'}], u'requiredparams': [], u'description': u'Lists all available virtual router elements.'}, u'lunsonfiler': {u'name': u'listLunsOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'poolname'], u'description': u'List LUN'}, u'asyncjobs': {u'name': u'listAsyncJobs', u'related': [u'queryAsyncJobResult'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'startdate', u'required': False, u'related': [], u'length': 255, u'type': u'tzdate', u'description': u'the start date of the async job'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists all pending asynchronous jobs for the account.'}, u'ostypes': {u'name': u'listOsTypes', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'list by Os type Id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'oscategoryid', u'required': False, u'related': [u'listOsCategories'], u'length': 255, u'type': u'uuid', u'description': u'list by Os Category id'}, {u'name': u'description', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list os by description'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all supported OS types for this cloud.'}, u'networkacls': {u'name': u'listNetworkACLs', u'related': [u'createNetworkACL'], u'isasync': False, u'params': [{u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network ACLs by traffic type - Ingress or Egress'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'Lists network ACL with the specified ID.'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'listNiciraNvpDeviceNetworks', u'updateNetwork', u'listF5LoadBalancerNetworks', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list network ACLs by network Id'}], u'requiredparams': [], u'description': u'Lists all network ACLs'}, u'volumesonfiler': {u'name': u'listVolumesOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'poolname'], u'description': u'List Volumes'}, u'eventtypes': {u'name': u'listEventTypes', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'List Event Types'}, u'remoteaccessvpns': {u'name': u'listRemoteAccessVpns', u'related': [u'createRemoteAccessVpn'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'publicipid', u'required': True, u'related': [u'restartNetwork', u'listPublicIpAddresses', u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn server'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [u'publicipid'], u'description': u'Lists remote access vpns'}, u'alerts': {u'name': u'listAlerts', u'related': [], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by alert type'}, {u'name': u'id', u'required': False, u'related': [u'listAlerts'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the alert'}], u'requiredparams': [], u'description': u'Lists all alerts.'}, u'regions': {u'name': u'listRegions', u'related': [u'addRegion'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'List Region by region ID.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List Region by region name.'}], u'requiredparams': [], u'description': u'Lists Regions'}, u'vpcofferings': {u'name': u'listVPCOfferings', u'related': [], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listVPCOfferings'], u'length': 255, u'type': u'uuid', u'description': u'list VPC offerings by id'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPC offerings by state'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list VPC offerings supporting certain services'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPC offerings by display text'}, {u'name': u'isdefault', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only default VPC offerings. Default value is false'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPC offerings by name'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists VPC offerings'}, u'niciranvpdevicenetworks': {u'name': u'listNiciraNvpDeviceNetworks', u'related': [u'createNetwork', u'updateNetwork', u'listF5LoadBalancerNetworks', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'isasync': False, u'params': [{u'name': u'nvpdeviceid', u'required': True, u'related': [u'addNiciraNvpDevice', u'listNiciraNvpDevices'], u'length': 255, u'type': u'uuid', u'description': u'nicira nvp device ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'nvpdeviceid'], u'description': u'lists network that are using a nicira nvp device'}, u'events': {u'name': u'listEvents', u'related': [], u'isasync': False, u'params': [{u'name': u'startdate', u'required': False, u'related': [], u'length': 255, u'type': u'date', u'description': u'the start date range of the list you want to retrieve (use format "yyyy-MM-dd" or the new format "yyyy-MM-dd HH:mm:ss")'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'enddate', u'required': False, u'related': [], u'length': 255, u'type': u'date', u'description': u'the end date range of the list you want to retrieve (use format "yyyy-MM-dd" or the new format "yyyy-MM-dd HH:mm:ss")'}, {u'name': u'duration', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the duration of the event'}, {u'name': u'id', u'required': False, u'related': [u'listEvents'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the event'}, {u'name': u'level', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the event level (INFO, WARN, ERROR)'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'entrytime', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the time the event was entered'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the event type (see event types)'}], u'requiredparams': [], u'description': u'A command to list events.'}, u'templates': {u'name': u'listTemplates', u'related': [u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'templatefilter', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'possible values are "featured", "self", "selfexecutable","sharedexecutable","executable", and "community". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured. * all : all templates (only usable by admins).'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the template name'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor for which to restrict the search'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'list templates by zoneId'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}], u'requiredparams': [u'templatefilter'], u'description': u'List all public, private, and privileged templates.'}, u'cisconexusvsms': {u'name': u'listCiscoNexusVSMs', u'related': [u'disableCiscoNexusVSM', u'enableCiscoNexusVSM'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.'}], u'requiredparams': [], u'description': u'Retrieves a Cisco Nexus 1000v Virtual Switch Manager device associated with a Cluster'}, u'ipforwardingrules': {u'name': u'listIpForwardingRules', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'listIpForwardingRules'], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'listVirtualMachines', u'destroyVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Lists all rules applied to the specified Vm.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'ipaddressid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list the rule belonging to this public ip address'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}], u'requiredparams': [], u'description': u'List the ip forwarding rules'}, u'srxfirewalls': {u'name': u'listSrxFirewalls', u'related': [u'addSrxFirewall'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'fwdeviceid', u'required': False, u'related': [u'listSrxFirewalls', u'addSrxFirewall'], u'length': 255, u'type': u'uuid', u'description': u'SRX firewall device ID'}], u'requiredparams': [], u'description': u'lists SRX firewall devices in a physical network'}, u'vpnconnections': {u'name': u'listVpnConnections', u'related': [], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'id of vpc'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'id', u'required': False, u'related': [u'listVpnConnections'], u'length': 255, u'type': u'uuid', u'description': u'id of the vpn connection'}], u'requiredparams': [], u'description': u'Lists site to site vpn connection gateways'}, u'trafficmonitors': {u'name': u'listTrafficMonitors', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'zone Id'}], u'requiredparams': [u'zoneid'], u'description': u'List traffic monitor Hosts.'}, u'vpnusers': {u'name': u'listVpnUsers', u'related': [], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listVpnUsers'], u'length': 255, u'type': u'uuid', u'description': u'The uuid of the Vpn user'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username of the vpn user.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists vpn users'}, u'egressfirewallrules': {u'name': u'listEgressFirewallRules', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'networkid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id network network for the egress firwall services'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'ipaddressid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of IP address of the firwall services'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}], u'requiredparams': [], u'description': u'Lists all egress firewall rules for network id.'}, u'staticroutes': {u'name': u'listStaticRoutes', u'related': [u'createStaticRoute'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'gatewayid', u'required': False, u'related': [u'createPrivateGateway'], u'length': 255, u'type': u'uuid', u'description': u'list static routes by gateway id'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'list static routes by vpc id'}, {u'name': u'id', u'required': False, u'related': [u'createStaticRoute', u'listStaticRoutes'], u'length': 255, u'type': u'uuid', u'description': u'list static route by id'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}], u'requiredparams': [], u'description': u'Lists all static routes'}, u'volumes': {u'name': u'listVolumes', u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the disk volume'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'hostid', u'required': False, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'list volumes on specified host'}, {u'name': u'id', u'required': False, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'listVolumes', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the type of disk volume'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the pod id the disk volume belongs to'}], u'requiredparams': [], u'description': u'Lists all volumes.'}, u'pods': {u'name': u'listPods', u'related': [u'updatePod'], u'isasync': False, u'params': [{u'name': u'showcapacities', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'flag to display the capacity of the pods'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list pods by allocation state'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list Pods by Zone ID'}, {u'name': u'id', u'required': False, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'list Pods by ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list Pods by name'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all Pods.'}}, u'upload': {u'volume': {u'name': u'uploadVolume', u'related': [u'detachVolume'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the volume'}, {u'name': u'format', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the volume. Possible values include QCOW2, OVA, and VHD.'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL of where the volume is hosted. Possible URL include http:// and https://'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional accountName. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId. If the account parameter is used, domainId must also be used.'}, {u'name': u'checksum', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the MD5 checksum value of this volume'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone the volume is to be hosted on'}], u'requiredparams': [u'name', u'format', u'url', u'zoneid'], u'description': u'Uploads a data disk.'}, u'customcertificate': {u'name': u'uploadCustomCertificate', u'related': [], u'isasync': True, u'params': [{u'name': u'domainsuffix', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'DNS domain suffix that the certificate is granted for.'}, {u'name': u'certificate', u'required': True, u'related': [], u'length': 65535, u'type': u'string', u'description': u'The certificate to be uploaded.'}, {u'name': u'privatekey', u'required': False, u'related': [], u'length': 65535, u'type': u'string', u'description': u'The private key for the attached certificate.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'A name / alias for the certificate.'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'An integer providing the location in a chain that the certificate will hold. Usually, this can be left empty. When creating a chain, the top level certificate should have an ID of 1, with each step in the chain incrementing by one. Example, CA with id = 1, Intermediate CA with id = 2, Site certificate with ID = 3'}], u'requiredparams': [u'domainsuffix', u'certificate'], u'description': u'Uploads a custom certificate for the console proxy VMs to use for SSL. Can be used to upload a single certificate signed by a known CA. Can also be used, through multiple calls, to upload a chain of certificates from CA to the custom certificate itself.'}}, u'remove': {u'region': {u'name': u'removeRegion', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'ID of the region to delete'}], u'requiredparams': [u'id'], u'description': u'Removes specified region'}, u'nicfromvirtualmachine': {u'name': u'removeNicFromVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'nicid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'NIC ID'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'nicid', u'virtualmachineid'], u'description': u'Removes VM from specified network by deleting a NIC'}, u'fromloadbalancerrule': {u'name': u'removeFromLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIpForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the load balancer rule'}, {u'name': u'virtualmachineids', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the virtual machines that are being removed from the load balancer rule (i.e. virtualMachineIds=1,2,3)'}], u'requiredparams': [u'id', u'virtualmachineids'], u'description': u'Removes a virtual machine or a list of virtual machines from a load balancer rule.'}, u'vpnuser': {u'name': u'removeVpnUser', u'related': [], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'remove vpn user from the project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the vpn user. Must be used with domainId.'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'username for the vpn user'}], u'requiredparams': [u'username'], u'description': u'Removes vpn user'}}, u'asyncapis': [u'createCondition', u'reconnectHost', u'copyTemplate', u'deleteBigSwitchVnsDevice', u'addNicToVirtualMachine', u'extractVolume', u'addAccountToProject', u'deleteEgressFirewallRule', u'deleteCiscoNexusVSM', u'createVpnConnection', u'suspendProject', u'addF5LoadBalancer', u'deleteAutoScaleVmGroup', u'authorizeSecurityGroupIngress', u'addNetscalerLoadBalancer', u'deleteDomain', u'configureNetscalerLoadBalancer', u'disableAutoScaleVmGroup', u'authorizeSecurityGroupEgress', u'createTemplate', u'migrateVolume', u'updatePhysicalNetwork', u'prepareHostForMaintenance', u'deletePrivateGateway', u'deleteStaticRoute', u'deleteTrafficType', u'deleteLoadBalancerRule', u'attachIso', u'destroySystemVm', u'deletePortForwardingRule', u'enableStorageMaintenance', u'stopRouter', u'configureSrxFirewall', u'attachVolume', u'updateVPCOffering', u'resetSSHKeyForVirtualMachine', u'updateProjectInvitation', u'createTags', u'enableAutoScaleVmGroup', u'deleteTags', u'deleteAccountFromProject', u'removeVpnUser', u'updateVpnCustomerGateway', u'stopSystemVm', u'uploadCustomCertificate', u'restartNetwork', u'createAutoScaleVmProfile', u'rebootVirtualMachine', u'enableCiscoNexusVSM', u'cancelHostMaintenance', u'deleteStorageNetworkIpRange', u'deleteFirewallRule', u'deleteVpnConnection', u'startSystemVm', u'deleteF5LoadBalancer', u'deleteNiciraNvpDevice', u'updateProject', u'deleteNetwork', u'deleteProject', u'deleteNetscalerLoadBalancer', u'deleteIpForwardingRule', u'addTrafficType', u'disableUser', u'resizeVolume', u'configureVirtualRouterElement', u'createStaticRoute', u'deleteProjectInvitation', u'migrateSystemVm', u'activateProject', u'removeNicFromVirtualMachine', u'revokeSecurityGroupIngress', u'updateDefaultNicForVirtualMachine', u'disableStaticNat', u'createNetworkACL', u'createVPC', u'configureF5LoadBalancer', u'disassociateIpAddress', u'createIpForwardingRule', u'createVolume', u'resetPasswordForVirtualMachine', u'assignToLoadBalancerRule', u'startRouter', u'extractIso', u'deleteRemoteAccessVpn', u'resetVpnConnection', u'createRemoteAccessVpn', u'extractTemplate', u'startVirtualMachine', u'detachIso', u'updateVPC', u'deleteAccount', u'associateIpAddress', u'updateAutoScaleVmProfile', u'disableAccount', u'updatePortForwardingRule', u'migrateVirtualMachine', u'createStorageNetworkIpRange', u'cancelStorageMaintenance', u'deployVirtualMachine', u'removeFromLoadBalancerRule', u'revokeSecurityGroupEgress', u'deleteCondition', u'createPortForwardingRule', u'addVpnUser', u'createVPCOffering', u'createEgressFirewallRule', u'deleteLBStickinessPolicy', u'destroyRouter', u'createPrivateGateway', u'disableCiscoNexusVSM', u'deleteAutoScaleVmProfile', u'updateTrafficType', u'deleteSnapshot', u'createProject', u'createLoadBalancerRule', u'addSrxFirewall', u'addNiciraNvpDevice', u'createAutoScalePolicy', u'restoreVirtualMachine', u'copyIso', u'uploadVolume', u'createLBStickinessPolicy', u'stopVirtualMachine', u'createCounter', u'createSnapshot', u'destroyVirtualMachine', u'updateNetwork', u'deleteVpnGateway', u'createAutoScaleVmGroup', u'rebootRouter', u'deleteNetworkServiceProvider', u'deleteIso', u'createVpnCustomerGateway', u'createFirewallRule', u'deleteAutoScalePolicy', u'deleteSrxFirewall', u'addNetworkServiceProvider', u'rebootSystemVm', u'detachVolume', u'deleteNetworkACL', u'markDefaultZoneForAccount', u'deleteVPC', u'restartVPC', u'updateAutoScaleVmGroup', u'updateLoadBalancerRule', u'createPhysicalNetwork', u'deleteTemplate', u'deletePhysicalNetwork', u'deleteVpnCustomerGateway', u'deleteVPCOffering', u'createVirtualRouterElement', u'updateAutoScalePolicy', u'addBigSwitchVnsDevice', u'createVpnGateway', u'updateNetworkServiceProvider', u'deleteCounter', u'updateStorageNetworkIpRange'], u'assign': {u'toloadbalancerrule': {u'name': u'assignToLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'virtualmachineids', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the virtual machine that are being assigned to the load balancer rule(i.e. virtualMachineIds=1,2,3)'}, {u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'virtualmachineids', u'id'], u'description': u'Assigns virtual machine or a list of virtual machines to a load balancer rule.'}, u'virtualmachine': {u'name': u'assignVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'networkids', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'list', u'description': u'list of new network ids in which the moved VM will participate. In case no network ids are provided the VM will be part of the default network for that zone. In case there is no network yet created for the new account the default network will be created.'}, {u'name': u'domainid', u'required': True, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain id of the new VM owner.'}, {u'name': u'securitygroupids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of security group ids to be applied on the virtual machine. In case no security groups are provided the VM is part of the default security group.'}, {u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'account name of the new VM owner.'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'id of the VM to be moved'}], u'requiredparams': [u'domainid', u'account', u'virtualmachineid'], u'description': u'Assign a VM from one account to another under the same domain. This API is available for Basic zones with security groups and Advance zones with guest networks. The VM is restricted to move between accounts under same domain.'}}, u'delete': {u'loadbalancerrule': {u'name': u'deleteLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a load balancer rule.'}, u'domain': {u'name': u'deleteDomain', u'related': [], u'isasync': True, u'params': [{u'name': u'cleanup', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if all domain resources (child domains, accounts) have to be cleaned up, false otherwise'}, {u'name': u'id', u'required': True, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'ID of domain to delete'}], u'requiredparams': [u'id'], u'description': u'Deletes a specified domain'}, u'instancegroup': {u'name': u'deleteInstanceGroup', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the instance group'}], u'requiredparams': [u'id'], u'description': u'Deletes a vm group'}, u'diskoffering': {u'name': u'deleteDiskOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the disk offering'}], u'requiredparams': [u'id'], u'description': u'Updates a disk offering.'}, u'externalloadbalancer': {u'name': u'deleteExternalLoadBalancer', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'Id of the external loadbalancer appliance.'}], u'requiredparams': [u'id'], u'description': u'Deletes a F5 external load balancer appliance added in a zone.'}, u'securitygroup': {u'name': u'deleteSecurityGroup', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID of account owning the security group'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The ID of the security group. Mutually exclusive with name parameter'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The ID of the security group. Mutually exclusive with id parameter'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account of the security group. Must be specified with domain ID'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the project of the security group'}], u'requiredparams': [], u'description': u'Deletes security group'}, u'portforwardingrule': {u'name': u'deletePortForwardingRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the port forwarding rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a port forwarding rule'}, u'cluster': {u'name': u'deleteCluster', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID'}], u'requiredparams': [u'id'], u'description': u'Deletes a cluster.'}, u'accountfromproject': {u'name': u'deleteAccountFromProject', u'related': [], u'isasync': True, u'params': [{u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to remove the account from'}, {u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the account to be removed from the project'}], u'requiredparams': [u'projectid', u'account'], u'description': u'Deletes account from the project'}, u'networkdevice': {u'name': u'deleteNetworkDevice', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Id of network device to delete'}], u'requiredparams': [u'id'], u'description': u'Deletes network device.'}, u'firewallrule': {u'name': u'deleteFirewallRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the firewall rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a firewall rule'}, u'pod': {u'name': u'deletePod', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Pod'}], u'requiredparams': [u'id'], u'description': u'Deletes a Pod.'}, u'ipforwardingrule': {u'name': u'deleteIpForwardingRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the id of the forwarding rule'}], u'requiredparams': [u'id'], u'description': u'Deletes an ip forwarding rule'}, u'vpnconnection': {u'name': u'deleteVpnConnection', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listVpnConnections', u'resetVpnConnection'], u'length': 255, u'type': u'uuid', u'description': u'id of vpn connection'}], u'requiredparams': [u'id'], u'description': u'Delete site to site vpn connection'}, u'lbstickinesspolicy': {u'name': u'deleteLBStickinessPolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createLBStickinessPolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the LB stickiness policy'}], u'requiredparams': [u'id'], u'description': u'Deletes a LB stickiness policy.'}, u'vpcoffering': {u'name': u'deleteVPCOffering', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VPC offering'}], u'requiredparams': [u'id'], u'description': u'Deletes VPC offering'}, u'network': {u'name': u'deleteNetwork', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network'}], u'requiredparams': [u'id'], u'description': u'Deletes a network'}, u'zone': {u'name': u'deleteZone', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Zone'}], u'requiredparams': [u'id'], u'description': u'Deletes a Zone.'}, u'remoteaccessvpn': {u'name': u'deleteRemoteAccessVpn', u'related': [], u'isasync': True, u'params': [{u'name': u'publicipid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn server'}], u'requiredparams': [u'publicipid'], u'description': u'Destroys a l2tp/ipsec remote access vpn'}, u'storagenetworkiprange': {u'name': u'deleteStorageNetworkIpRange', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listStorageNetworkIpRange', u'createStorageNetworkIpRange', u'updateStorageNetworkIpRange'], u'length': 255, u'type': u'uuid', u'description': u'the uuid of the storage network ip range'}], u'requiredparams': [u'id'], u'description': u'Deletes a storage network IP Range.'}, u'bigswitchvnsdevice': {u'name': u'deleteBigSwitchVnsDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'vnsdeviceid', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'BigSwitch device ID'}], u'requiredparams': [u'vnsdeviceid'], u'description': u' delete a bigswitch vns device'}, u'projectinvitation': {u'name': u'deleteProjectInvitation', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listProjectInvitations'], u'length': 255, u'type': u'uuid', u'description': u'id of the invitation'}], u'requiredparams': [u'id'], u'description': u'Accepts or declines project invitation'}, u'autoscalepolicy': {u'name': u'deleteAutoScalePolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale policy'}], u'requiredparams': [u'id'], u'description': u'Deletes a autoscale policy.'}, u'niciranvpdevice': {u'name': u'deleteNiciraNvpDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'nvpdeviceid', u'required': True, u'related': [u'addNiciraNvpDevice', u'listNiciraNvpDevices'], u'length': 255, u'type': u'uuid', u'description': u'Nicira device ID'}], u'requiredparams': [u'nvpdeviceid'], u'description': u' delete a nicira nvp device'}, u'serviceoffering': {u'name': u'deleteServiceOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the service offering'}], u'requiredparams': [u'id'], u'description': u'Deletes a service offering.'}, u'condition': {u'name': u'deleteCondition', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the condition.'}], u'requiredparams': [u'id'], u'description': u'Removes a condition'}, u'storagepool': {u'name': u'deleteStoragePool', u'related': [], u'isasync': False, u'params': [{u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force destroy storage pool (force expunge volumes in Destroyed state as a part of pool removal)'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Storage pool id'}], u'requiredparams': [u'id'], u'description': u'Deletes a storage pool.'}, u'vpngateway': {u'name': u'deleteVpnGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createVpnGateway'], u'length': 255, u'type': u'uuid', u'description': u'id of customer gateway'}], u'requiredparams': [u'id'], u'description': u'Delete site to site vpn gateway'}, u'snapshot': {u'name': u'deleteSnapshot', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createSnapshot', u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the snapshot'}], u'requiredparams': [u'id'], u'description': u'Deletes a snapshot of a disk volume.'}, u'autoscalevmgroup': {u'name': u'deleteAutoScaleVmGroup', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'disableAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}], u'requiredparams': [u'id'], u'description': u'Deletes a autoscale vm group.'}, u'trafficmonitor': {u'name': u'deleteTrafficMonitor', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Traffic Monitor Host.'}], u'requiredparams': [u'id'], u'description': u'Deletes an traffic monitor host.'}, u'networkacl': {u'name': u'deleteNetworkACL', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network ACL'}], u'requiredparams': [u'id'], u'description': u'Deletes a Network ACL'}, u'template': {u'name': u'deleteTemplate', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the template'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of zone of the template'}], u'requiredparams': [u'id'], u'description': u'Deletes a template from the system. All virtual machines using the deleted template will not be affected.'}, u'tags': {u'name': u'deleteTags', u'related': [], u'isasync': True, u'params': [{u'name': u'resourceids', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'Delete tags for resource id(s)'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'Delete tags matching key/value pairs'}, {u'name': u'resourcetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Delete tag by resource type'}], u'requiredparams': [u'resourceids', u'resourcetype'], u'description': u'Deleting resource tag(s)'}, u'snapshotpolicies': {u'name': u'deleteSnapshotPolicies', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Id of the snapshot policy'}, {u'name': u'ids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of snapshots policy IDs separated by comma'}], u'requiredparams': [], u'description': u'Deletes snapshot policies for the account.'}, u'privategateway': {u'name': u'deletePrivateGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createPrivateGateway', u'listPrivateGateways'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the private gateway'}], u'requiredparams': [u'id'], u'description': u'Deletes a Private gateway'}, u'traffictype': {u'name': u'deleteTrafficType', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'addTrafficType', u'updateTrafficType'], u'length': 255, u'type': u'uuid', u'description': u'traffic type id'}], u'requiredparams': [u'id'], u'description': u'Deletes traffic type of a physical network'}, u'host': {u'name': u'deleteHost', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}, {u'name': u'forcedestroylocalstorage', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force destroy local storage on this host. All VMs created on this local storage will be destroyed'}, {u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force delete the host. All HA enabled vms running on the host will be put to HA; HA disabled ones will be stopped'}], u'requiredparams': [u'id'], u'description': u'Deletes a host.'}, u'staticroute': {u'name': u'deleteStaticRoute', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createStaticRoute', u'listStaticRoutes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the static route'}], u'requiredparams': [u'id'], u'description': u'Deletes a static route'}, u'vpc': {u'name': u'deleteVPC', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VPC'}], u'requiredparams': [u'id'], u'description': u'Deletes a VPC'}, u'srxfirewall': {u'name': u'deleteSrxFirewall', u'related': [], u'isasync': True, u'params': [{u'name': u'fwdeviceid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'srx firewall device ID'}], u'requiredparams': [u'fwdeviceid'], u'description': u' delete a SRX firewall device'}, u'externalfirewall': {u'name': u'deleteExternalFirewall', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Id of the external firewall appliance.'}], u'requiredparams': [u'id'], u'description': u'Deletes an external firewall appliance.'}, u'pool': {u'name': u'deletePool', u'related': [], u'isasync': False, u'params': [{u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'poolname'], u'description': u'Delete a pool'}, u'autoscalevmprofile': {u'name': u'deleteAutoScaleVmProfile', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale profile'}], u'requiredparams': [u'id'], u'description': u'Deletes a autoscale vm profile.'}, u'volume': {u'name': u'deleteVolume', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'detachVolume', u'resizeVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the disk volume'}], u'requiredparams': [u'id'], u'description': u'Deletes a detached disk volume.'}, u'account': {u'name': u'deleteAccount', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'disableAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}], u'requiredparams': [u'id'], u'description': u'Deletes a account, and all users associated with this account'}, u'cisconexusvsm': {u'name': u'deleteCiscoNexusVSM', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableCiscoNexusVSM', u'listCiscoNexusVSMs', u'enableCiscoNexusVSM'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Cisco Nexus 1000v VSM device to be deleted'}], u'requiredparams': [u'id'], u'description': u' delete a Cisco Nexus VSM device'}, u'netscalerloadbalancer': {u'name': u'deleteNetscalerLoadBalancer', u'related': [], u'isasync': True, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'listNetscalerLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}], u'requiredparams': [u'lbdeviceid'], u'description': u' delete a netscaler load balancer device'}, u'networkoffering': {u'name': u'deleteNetworkOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'createNetworkOffering', u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network offering'}], u'requiredparams': [u'id'], u'description': u'Deletes a network offering.'}, u'vpncustomergateway': {u'name': u'deleteVpnCustomerGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'id of customer gateway'}], u'requiredparams': [u'id'], u'description': u'Delete site to site vpn customer gateway'}, u'counter': {u'name': u'deleteCounter', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the counter'}], u'requiredparams': [u'id'], u'description': u'Deletes a counter'}, u'physicalnetwork': {u'name': u'deletePhysicalNetwork', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Physical network'}], u'requiredparams': [u'id'], u'description': u'Deletes a Physical Network.'}, u'project': {u'name': u'deleteProject', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be deleted'}], u'requiredparams': [u'id'], u'description': u'Deletes a project'}, u'vlaniprange': {u'name': u'deleteVlanIpRange', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listVlanIpRanges'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VLAN IP range'}], u'requiredparams': [u'id'], u'description': u'Creates a VLAN IP range.'}, u'f5loadbalancer': {u'name': u'deleteF5LoadBalancer', u'related': [], u'isasync': True, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'configureF5LoadBalancer'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}], u'requiredparams': [u'lbdeviceid'], u'description': u' delete a F5 load balancer device'}, u'iso': {u'name': u'deleteIso', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the ISO file'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone of the ISO file. If not specified, the ISO will be deleted from all the zones'}], u'requiredparams': [u'id'], u'description': u'Deletes an ISO file.'}, u'egressfirewallrule': {u'name': u'deleteEgressFirewallRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the firewall rule'}], u'requiredparams': [u'id'], u'description': u'Deletes an ggress firewall rule'}, u'networkserviceprovider': {u'name': u'deleteNetworkServiceProvider', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'addNetworkServiceProvider', u'listTrafficTypes', u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network service provider'}], u'requiredparams': [u'id'], u'description': u'Deletes a Network Service Provider.'}, u'sshkeypair': {u'name': u'deleteSSHKeyPair', u'related': [], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the project associated with keypair'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the keypair'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the keypair'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the keypair. Must be used with the domainId parameter.'}], u'requiredparams': [u'name'], u'description': u'Deletes a keypair by name'}, u'user': {u'name': u'deleteUser', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers'], u'length': 255, u'type': u'uuid', u'description': u'id of the user to be deleted'}], u'requiredparams': [u'id'], u'description': u'Deletes a user for an account'}}} +apicache = {u'authorize': {u'securitygroupingress': {u'name': u'authorizeSecurityGroupIngress', u'related': [u'authorizeSecurityGroupEgress'], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the security group. If the account parameter is used, domainId must also be used.'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'start port for this ingress rule'}, {u'name': u'securitygroupid', u'required': False, u'related': [u'createSecurityGroup', u'listSecurityGroups'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list associated'}, {u'name': u'usersecuritygrouplist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'user to security group mapping'}, {u'name': u'securitygroupname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The name of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the security group. Must be used with domainId.'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'protocol', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'TCP is default. UDP is the other supported protocol'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'an optional project of the security group'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'end port for this ingress rule'}], u'requiredparams': [], u'description': u'Authorizes a particular ingress rule for this security group'}, u'securitygroupegress': {u'name': u'authorizeSecurityGroupEgress', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the security group. Must be used with domainId.'}, {u'name': u'securitygroupname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The name of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the security group. If the account parameter is used, domainId must also be used.'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'securitygroupid', u'required': False, u'related': [u'createSecurityGroup', u'listSecurityGroups'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the security group. Mutually exclusive with securityGroupName parameter'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'protocol', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'TCP is default. UDP is the other supported protocol'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'an optional project of the security group'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'end port for this egress rule'}, {u'name': u'usersecuritygrouplist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'user to security group mapping'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'start port for this egress rule'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list associated'}], u'requiredparams': [], u'description': u'Authorizes a particular egress rule for this security group'}}, u'restore': {u'virtualmachine': {u'name': u'restoreVirtualMachine', u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine'], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'virtualmachineid'], u'description': u'Restore a VM to original template or specific snapshot'}}, u'suspend': {u'project': {u'name': u'suspendProject', u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be suspended'}], u'requiredparams': [u'id'], u'description': u'Suspends a project'}}, u'revoke': {u'securitygroupingress': {u'name': u'revokeSecurityGroupIngress', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The ID of the ingress rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a particular ingress rule from this security group'}, u'securitygroupegress': {u'name': u'revokeSecurityGroupEgress', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The ID of the egress rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a particular egress rule from this security group'}}, u'disassociate': {u'ipaddress': {u'name': u'disassociateIpAddress', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the id of the public ip address to disassociate'}], u'requiredparams': [u'id'], u'description': u'Disassociates an ip address from the account.'}}, u'migrate': {u'volume': {u'name': u'migrateVolume', u'related': [u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'isasync': True, u'params': [{u'name': u'volumeid', u'required': True, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the volume'}, {u'name': u'storageid', u'required': True, u'related': [u'cancelStorageMaintenance', u'enableStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'destination storage pool ID to migrate the volume to'}], u'requiredparams': [u'volumeid', u'storageid'], u'description': u'Migrate volume'}, u'systemvm': {u'name': u'migrateSystemVm', u'related': [], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'rebootSystemVm', u'listSystemVms'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'hostid', u'required': True, u'related': [u'addHost', u'updateHost', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'destination Host ID to migrate VM to'}], u'requiredparams': [u'virtualmachineid', u'hostid'], u'description': u'Attempts Migration of a system virtual machine to the host specified.'}, u'virtualmachine': {u'name': u'migrateVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'storageid', u'required': False, u'related': [u'cancelStorageMaintenance'], u'length': 255, u'type': u'long', u'description': u'Destination storage pool ID to migrate VM volumes to. Required for migrating the root disk volume'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Destination Host ID to migrate VM to. Required for live migrating a VM from host to host'}], u'requiredparams': [u'virtualmachineid'], u'description': u'Attempts Migration of a VM to a different host or Root volume of the vm to a different storage pool'}}, u'lock': {u'account': {u'name': u'lockAccount', u'related': [u'markDefaultZoneForAccount'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Locks the specified account on this domain.'}, {u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Locks the specified account.'}], u'requiredparams': [u'domainid', u'account'], u'description': u'Locks an account'}, u'user': {u'name': u'lockUser', u'related': [u'listUsers'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers'], u'length': 255, u'type': u'uuid', u'description': u'Locks user by user ID.'}], u'requiredparams': [u'id'], u'description': u'Locks a user account'}}, u'dissociate': {u'lun': {u'name': u'dissociateLun', u'related': [], u'isasync': False, u'params': [{u'name': u'iqn', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Guest IQN.'}, {u'name': u'path', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'LUN path.'}], u'requiredparams': [u'iqn', u'path'], u'description': u'Dissociate a LUN'}}, u'activate': {u'project': {u'name': u'activateProject', u'related': [u'createProject', u'listProjectAccounts'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be modified'}], u'requiredparams': [u'id'], u'description': u'Activates a project'}}, u'reconnect': {u'host': {u'name': u'reconnectHost', u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'reconnectHost', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}], u'requiredparams': [u'id'], u'description': u'Reconnects a host.'}}, u'cancel': {u'hostmaintenance': {u'name': u'cancelHostMaintenance', u'related': [u'listSwifts', u'addHost', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}], u'requiredparams': [u'id'], u'description': u'Cancels host maintenance.'}, u'storagemaintenance': {u'name': u'cancelStorageMaintenance', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'cancelStorageMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the primary storage ID'}], u'requiredparams': [u'id'], u'description': u'Cancels maintenance for primary storage'}}, u'query': {u'asyncjobresult': {u'name': u'queryAsyncJobResult', u'related': [], u'isasync': False, u'params': [{u'name': u'jobid', u'required': True, u'related': [u'queryAsyncJobResult'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the asynchronous job'}], u'requiredparams': [u'jobid'], u'description': u'Retrieves the current status of asynchronous job.'}}, u'recover': {u'virtualmachine': {u'name': u'recoverVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Recovers a virtual machine.'}}, u'extract': {u'volume': {u'name': u'extractVolume', u'related': [u'extractTemplate', u'extractIso'], u'isasync': True, u'params': [{u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the url to which the volume would be extracted'}, {u'name': u'id', u'required': True, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'listVolumes', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the volume'}, {u'name': u'mode', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone where the volume is located'}], u'requiredparams': [u'id', u'mode', u'zoneid'], u'description': u'Extracts volume'}, u'iso': {u'name': u'extractIso', u'related': [u'extractTemplate'], u'isasync': True, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone where the ISO is originally located'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the url to which the ISO would be extracted'}, {u'name': u'mode', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD'}, {u'name': u'id', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the ISO file'}], u'requiredparams': [u'mode', u'id'], u'description': u'Extracts an ISO'}, u'template': {u'name': u'extractTemplate', u'related': [], u'isasync': True, u'params': [{u'name': u'mode', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD'}, {u'name': u'id', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the template'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the url to which the ISO would be extracted'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone where the ISO is originally located'}], u'requiredparams': [u'mode', u'id'], u'description': u'Extracts a template'}}, u'copy': {u'iso': {u'name': u'copyIso', u'related': [u'updateIso', u'listIsos'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'Template ID.'}, {u'name': u'destzoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is being copied to.'}, {u'name': u'sourcezoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is currently hosted on.'}], u'requiredparams': [u'id', u'destzoneid', u'sourcezoneid'], u'description': u'Copies an iso from one zone to another.'}, u'template': {u'name': u'copyTemplate', u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'registerTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'copyTemplate', u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'registerTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'Template ID.'}, {u'name': u'destzoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is being copied to.'}, {u'name': u'sourcezoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'ID of the zone the template is currently hosted on.'}], u'requiredparams': [u'id', u'destzoneid', u'sourcezoneid'], u'description': u'Copies a template from one zone to another.'}}, u'prepare': {u'hostformaintenance': {u'name': u'prepareHostForMaintenance', u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}], u'requiredparams': [u'id'], u'description': u'Prepares a host for maintenance.'}, u'template': {u'name': u'prepareTemplate', u'related': [u'registerIso', u'updateTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'zone ID of the template to be prepared in primary storage(s).'}, {u'name': u'templateid', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'template ID of the template to be prepared in primary storage(s).'}], u'requiredparams': [u'zoneid', u'templateid'], u'description': u'load template into primary storage'}}, u'attach': {u'volume': {u'name': u'attachVolume', u'related': [u'detachVolume', u'resizeVolume', u'uploadVolume', u'createVolume'], u'isasync': True, u'params': [{u'name': u'deviceid', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the ID of the device to map the volume to within the guest OS. If no deviceId is passed in, the next available deviceId will be chosen. Possible values for a Linux OS are:* 1 - /dev/xvdb* 2 - /dev/xvdc* 4 - /dev/xvde* 5 - /dev/xvdf* 6 - /dev/xvdg* 7 - /dev/xvdh* 8 - /dev/xvdi* 9 - /dev/xvdj'}, {u'name': u'id', u'required': True, u'related': [u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u' the ID of the virtual machine'}], u'requiredparams': [u'id', u'virtualmachineid'], u'description': u'Attaches a disk volume to a virtual machine.'}, u'iso': {u'name': u'attachIso', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'id', u'required': True, u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the ISO file'}], u'requiredparams': [u'virtualmachineid', u'id'], u'description': u'Attaches an ISO to a virtual machine.'}}, u'create': {u'loadbalancerrule': {u'name': u'createLoadBalancerRule', u'related': [u'updateLoadBalancerRule'], u'isasync': True, u'params': [{u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end public port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when LB rule is being created for VPC guest network 2) in all other cases defaulted to true'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the load balancer. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the load balancer'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'zone where the load balancer is going to be created. This parameter is required when LB service provider is ElasticLoadBalancerVm'}, {u'name': u'publicipid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'public ip address id from where the network traffic will be load balanced from'}, {u'name': u'algorithm', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'load balancer algorithm (source, roundrobin, leastconn)'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the load balancer rule'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'publicport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the public port from where the network traffic will be load balanced from'}, {u'name': u'description', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the description of the load balancer rule'}, {u'name': u'privateport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the private port of the private ip address/virtual machine where the network traffic will be load balanced to'}, {u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The guest network this rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)'}], u'requiredparams': [u'algorithm', u'name', u'publicport', u'privateport'], u'description': u'Creates a load balancer rule'}, u'domain': {u'name': u'createDomain', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'creates domain with this name'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Domain UUID, required for adding domain from another Region'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network domain for networks in the domain'}, {u'name': u'parentdomainid', u'required': False, u'related': [u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'assigns new domain a parent domain by domain ID of the parent. If no parent domain is specied, the ROOT domain is assumed.'}], u'requiredparams': [u'name'], u'description': u'Creates a domain'}, u'snapshotpolicy': {u'name': u'createSnapshotPolicy', u'related': [u'listSnapshotPolicies'], u'isasync': False, u'params': [{u'name': u'intervaltype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'valid values are HOURLY, DAILY, WEEKLY, and MONTHLY'}, {u'name': u'maxsnaps', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'maximum number of snapshots to retain'}, {u'name': u'schedule', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'time the snapshot is scheduled to be taken. Format is:* if HOURLY, MM* if DAILY, MM:HH* if WEEKLY, MM:HH:DD (1-7)* if MONTHLY, MM:HH:DD (1-28)'}, {u'name': u'timezone', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'volumeid', u'required': True, u'related': [u'detachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}], u'requiredparams': [u'intervaltype', u'maxsnaps', u'schedule', u'timezone', u'volumeid'], u'description': u'Creates a snapshot policy for the account.'}, u'diskoffering': {u'name': u'createDiskOffering', u'related': [u'listDiskOfferings'], u'isasync': False, u'params': [{u'name': u'customized', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'whether disk offering is custom or not'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'alternate display text of the disk offering'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the containing domain, null for public offerings'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the disk offering'}, {u'name': u'disksize', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'size of the disk offering in GB'}, {u'name': u'storagetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the storage type of the disk offering. Values are local and shared.'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'tags for the disk offering'}], u'requiredparams': [u'displaytext', u'name'], u'description': u'Creates a disk offering.'}, u'securitygroup': {u'name': u'createSecurityGroup', u'related': [u'listSecurityGroups'], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the security group. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the security group. If the account parameter is used, domainId must also be used.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the security group'}, {u'name': u'description', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the description of the security group'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Deploy vm for the project'}], u'requiredparams': [u'name'], u'description': u'Creates a security group'}, u'portforwardingrule': {u'name': u'createPortForwardingRule', u'related': [u'listIpForwardingRules'], u'isasync': True, u'params': [{u'name': u'privateport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the starting port of port forwarding rule's private port range"}, {u'name': u'ipaddressid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the IP address id of the port forwarding rule'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the port fowarding rule. Valid values are TCP or UDP.'}, {u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when PF rule is being created for VPC guest network 2) in all other cases defaulted to true'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine for the port forwarding rule'}, {u'name': u'privateendport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the ending port of port forwarding rule's private port range"}, {u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network of the vm the Port Forwarding rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)'}, {u'name': u'publicendport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the ending port of port forwarding rule's private port range"}, {u'name': u'publicport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u"the starting port of port forwarding rule's public port range"}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}], u'requiredparams': [u'privateport', u'ipaddressid', u'protocol', u'virtualmachineid', u'publicport'], u'description': u'Creates a port forwarding rule'}, u'pod': {u'name': u'createPod', u'related': [u'updatePod', u'listPods'], u'isasync': False, u'params': [{u'name': u'startip', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the starting IP address for the Pod'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Pod'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID in which the Pod will be created'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address for the Pod'}, {u'name': u'netmask', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask for the Pod'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Pod for allocation of new resources'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway for the Pod'}], u'requiredparams': [u'startip', u'name', u'zoneid', u'netmask', u'gateway'], u'description': u'Creates a new Pod.'}, u'ipforwardingrule': {u'name': u'createIpForwardingRule', u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'isasync': True, u'params': [{u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the end port for the rule'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'ipaddressid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id of the forwarding rule, already associated via associateIp'}, {u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default'}, {u'name': u'startport', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the start port for the rule'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the rule. Valid values are TCP or UDP.'}], u'requiredparams': [u'ipaddressid', u'startport', u'protocol'], u'description': u'Creates an ip forwarding rule'}, u'vpnconnection': {u'name': u'createVpnConnection', u'related': [u'listVpnConnections', u'resetVpnConnection'], u'isasync': True, u'params': [{u'name': u's2svpngatewayid', u'required': True, u'related': [u'createVpnGateway', u'listVpnGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the vpn gateway'}, {u'name': u's2scustomergatewayid', u'required': True, u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway', u'listVpnCustomerGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the customer gateway'}], u'requiredparams': [u's2svpngatewayid', u's2scustomergatewayid'], u'description': u'Create site to site vpn connection'}, u'vpncustomergateway': {u'name': u'createVpnCustomerGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the gateway. If used with the account parameter returns the gateway associated with the account for the specified domain.'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'public ip address id of the customer gateway'}, {u'name': u'esplifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 2 VPN connection to the customer gateway, in seconds'}, {u'name': u'esppolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ESP policy of the customer gateway'}, {u'name': u'ikepolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IKE policy of the customer gateway'}, {u'name': u'cidrlist', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'guest cidr list of the customer gateway'}, {u'name': u'dpd', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If DPD is enabled for VPN connection'}, {u'name': u'ipsecpsk', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IPsec Preshared-Key of the customer gateway'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the gateway. Must be used with the domainId parameter.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of this customer gateway'}, {u'name': u'ikelifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 1 VPN connection to the customer gateway, in seconds'}], u'requiredparams': [u'gateway', u'esppolicy', u'ikepolicy', u'cidrlist', u'ipsecpsk'], u'description': u'Creates site to site vpn customer gateway'}, u'lbstickinesspolicy': {u'name': u'createLBStickinessPolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'lbruleid', u'required': True, u'related': [u'listIpForwardingRules'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the LB Stickiness policy'}, {u'name': u'methodname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the LB Stickiness policy method, possible values can be obtained from ListNetworks API '}, {u'name': u'description', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the description of the LB Stickiness policy'}, {u'name': u'param', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'param list. Example: param[0].name=cookiename¶m[0].value=LBCookie '}], u'requiredparams': [u'lbruleid', u'name', u'methodname'], u'description': u'Creates a Load Balancer stickiness policy '}, u'vpcoffering': {u'name': u'createVPCOffering', u'related': [u'listVPCOfferings'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the vpc offering'}, {u'name': u'supportedservices', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'services supported by the vpc offering'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the vpc offering'}], u'requiredparams': [u'displaytext', u'supportedservices', u'name'], u'description': u'Creates VPC offering'}, u'network': {u'name': u'createNetwork', u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'isasync': False, u'params': [{u'name': u'endipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IPv6 address in the IPv6 network range'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'ip6cidr', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the CIDR of IPv6 network, must be at least /64'}, {u'name': u'acltype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Access control type; supported values are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network'}, {u'name': u'gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the network'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID the network belongs to'}, {u'name': u'subdomainaccess', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Defines whether to allow subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address in the network IP range'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a network'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network domain'}, {u'name': u'ip6gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the IPv6 network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account who will own the network'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the network'}, {u'name': u'startipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IPv6 address in the IPv6 network range'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the network'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'the VPC network belongs to'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address in the network IP range. If not specified, will be defaulted to startIP'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ID or VID of the network'}, {u'name': u'networkofferingid', u'required': True, u'related': [u'createNetworkOffering', u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'the network offering id'}], u'requiredparams': [u'displaytext', u'zoneid', u'name', u'networkofferingid'], u'description': u'Creates a network'}, u'zone': {u'name': u'createZone', u'related': [u'listZones'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the containing domain, null for public zones'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Zone'}, {u'name': u'ip6dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for IPv6 network in the Zone'}, {u'name': u'domain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network domain name for the networks in the zone'}, {u'name': u'internaldns1', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first internal DNS for the Zone'}, {u'name': u'localstorageenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if local storage offering enabled, false otherwise'}, {u'name': u'securitygroupenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network is security group enabled, false otherwise'}, {u'name': u'networktype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'network type of the zone, can be Basic or Advanced'}, {u'name': u'internaldns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second internal DNS for the Zone'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Zone for allocation of new resources'}, {u'name': u'guestcidraddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the guest CIDR address for the Zone'}, {u'name': u'dns1', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for the Zone'}, {u'name': u'ip6dns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for IPv6 network in the Zone'}, {u'name': u'dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for the Zone'}], u'requiredparams': [u'name', u'internaldns1', u'networktype', u'dns1'], u'description': u'Creates a Zone.'}, u'remoteaccessvpn': {u'name': u'createRemoteAccessVpn', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the VPN. Must be used with domainId.'}, {u'name': u'openfirewall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default'}, {u'name': u'publicipid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn server'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the VPN. If the account parameter is used, domainId must also be used.'}, {u'name': u'iprange', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the range of ip addresses to allocate to vpn clients. The first ip in the range will be taken by the vpn server'}], u'requiredparams': [u'publicipid'], u'description': u'Creates a l2tp/ipsec remote access vpn'}, u'instancegroup': {u'name': u'createInstanceGroup', u'related': [], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account of the instance group. The account parameter must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The project of the instance group'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the instance group'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID of account owning the instance group'}], u'requiredparams': [u'name'], u'description': u'Creates a vm group'}, u'autoscalepolicy': {u'name': u'createAutoScalePolicy', u'related': [u'updateAutoScalePolicy'], u'isasync': True, u'params': [{u'name': u'action', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the action to be executed if all the conditions evaluate to true for the specified duration.'}, {u'name': u'quiettime', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the cool down period for which the policy should not be evaluated after the action has been taken'}, {u'name': u'conditionids', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the conditions that are being evaluated on every interval'}, {u'name': u'duration', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the duration for which the conditions have to be true before action is taken'}], u'requiredparams': [u'action', u'conditionids', u'duration'], u'description': u'Creates an autoscale policy for a provision or deprovision action, the action is taken when the all the conditions evaluates to true for the specified duration. The policy is in effect once it is attached to a autscale vm group.'}, u'tags': {u'name': u'createTags', u'related': [], u'isasync': True, u'params': [{u'name': u'tags', u'required': True, u'related': [], u'length': 255, u'type': u'map', u'description': u'Map of tags (key/value pairs)'}, {u'name': u'resourcetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of the resource'}, {u'name': u'customer', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"identifies client specific tag. When the value is not null, the tag can't be used by cloudStack code internally"}, {u'name': u'resourceids', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of resources to create the tags for'}], u'requiredparams': [u'tags', u'resourcetype', u'resourceids'], u'description': u'Creates resource tag(s)'}, u'serviceoffering': {u'name': u'createServiceOffering', u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'isasync': False, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the service offering'}, {u'name': u'storagetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the storage type of the service offering. Values are local and shared.'}, {u'name': u'issystem', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'is this a system vm offering'}, {u'name': u'cpunumber', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'the CPU number of the service offering'}, {u'name': u'systemvmtype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the system VM type. Possible types are "domainrouter", "consoleproxy" and "secondarystoragevm".'}, {u'name': u'limitcpuuse', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'restrict the CPU usage to committed service offering'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host tag for this service offering.'}, {u'name': u'offerha', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the HA for the service offering'}, {u'name': u'memory', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'the total memory of the service offering in MB'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the containing domain, null for public offerings'}, {u'name': u'cpuspeed', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'the CPU speed of the service offering in MHz.'}, {u'name': u'networkrate', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'data transfer rate in megabits per second allowed. Supported only for non-System offering and system offerings having "domainrouter" systemvmtype'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the service offering'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tags for this service offering.'}], u'requiredparams': [u'name', u'cpunumber', u'memory', u'cpuspeed', u'displaytext'], u'description': u'Creates a service offering.'}, u'condition': {u'name': u'createCondition', u'related': [], u'isasync': True, u'params': [{u'name': u'threshold', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'Threshold value.'}, {u'name': u'counterid', u'required': True, u'related': [u'listConditions', u'listCounters', u'createCounter'], u'length': 255, u'type': u'uuid', u'description': u'ID of the Counter.'}, {u'name': u'relationaloperator', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Relational Operator to be used with threshold.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account of the condition. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID of the account.'}], u'requiredparams': [u'threshold', u'counterid', u'relationaloperator'], u'description': u'Creates a condition'}, u'storagepool': {u'name': u'createStoragePool', u'related': [u'cancelStorageMaintenance', u'listStoragePools'], u'isasync': False, u'params': [{u'name': u'clusterid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID for the storage pool'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the storage pool'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name for the storage pool'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tags for the storage pool'}, {u'name': u'podid', u'required': True, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the storage pool'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL of the storage pool'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'the details for the storage pool'}], u'requiredparams': [u'clusterid', u'zoneid', u'name', u'podid', u'url'], u'description': u'Creates a storage pool.'}, u'vpngateway': {u'name': u'createVpnGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'vpcid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn gateway'}], u'requiredparams': [u'vpcid'], u'description': u'Creates site to site vpn local gateway'}, u'autoscalevmgroup': {u'name': u'createAutoScaleVmGroup', u'related': [u'updateAutoScaleVmGroup'], u'isasync': True, u'params': [{u'name': u'vmprofileid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the autoscale profile that contains information about the vms in the vm group.'}, {u'name': u'scaledownpolicyids', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaledown autoscale policies'}, {u'name': u'scaleuppolicyids', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaleup autoscale policies'}, {u'name': u'interval', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the frequency at which the conditions have to be evaluated'}, {u'name': u'minmembers', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the minimum number of members in the vmgroup, the number of instances in the vm group will be equal to or more than this number.'}, {u'name': u'maxmembers', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the maximum number of members in the vmgroup, The number of instances in the vm group will be equal to or less than this number.'}, {u'name': u'lbruleid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'vmprofileid', u'scaledownpolicyids', u'scaleuppolicyids', u'minmembers', u'maxmembers', u'lbruleid'], u'description': u'Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.'}, u'networkacl': {u'name': u'createNetworkACL', u'related': [], u'isasync': True, u'params': [{u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the ending port of ACL'}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the traffic type for the ACL,can be Ingress or Egress, defaulted to Ingress if not specified'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to allow traffic from/to'}, {u'name': u'networkid', u'required': True, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network of the vm the ACL will be created for'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the ACL rule. Valid values are TCP/UDP/ICMP.'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the starting port of ACL'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}], u'requiredparams': [u'networkid', u'protocol'], u'description': u'Creates a ACL rule the given network (the network has to belong to VPC)'}, u'template': {u'name': u'createTemplate', u'related': [u'cancelStorageMaintenance', u'enableStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'isasync': True, u'params': [{u'name': u'ostypeid', u'required': True, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS Type that best represents the OS of this template.'}, {u'name': u'templatetag', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tag for this template.'}, {u'name': u'bits', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'32 or 64 bit'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template is a public template, false otherwise'}, {u'name': u'volumeid', u'required': False, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template supports the password reset feature; default is false'}, {u'name': u'snapshotid', u'required': False, u'related': [u'createSnapshot', u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the template. This is usually used for display purposes.'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'Template details in key/value pairs.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the template'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template is a featured template, false otherwise'}, {u'name': u'requireshvm', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template requires HVM, false otherwise'}], u'requiredparams': [u'ostypeid', u'displaytext', u'name'], u'description': u'Creates a template of a virtual machine. The virtual machine must be in a STOPPED state. A template created from this command is automatically designated as a private template visible to the account that created it.'}, u'privategateway': {u'name': u'createPrivateGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'vlan', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the Vlan for the private gateway'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the Private gateway'}, {u'name': u'netmask', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the Private gateway'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID the network belongs to'}, {u'name': u'vpcid', u'required': True, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'the VPC network belongs to'}, {u'name': u'ipaddress', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the IP address of the Private gateaway'}], u'requiredparams': [u'vlan', u'gateway', u'netmask', u'vpcid', u'ipaddress'], u'description': u'Creates a private gateway'}, u'volumeonfiler': {u'name': u'createVolumeOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'volumename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'volume name.'}, {u'name': u'aggregatename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'aggregate name.'}, {u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}, {u'name': u'snapshotpolicy', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'snapshot policy.'}, {u'name': u'ipaddress', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ip address.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'password.'}, {u'name': u'size', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'volume size.'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'user name.'}, {u'name': u'snapshotreservation', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'snapshot reservation.'}], u'requiredparams': [u'volumename', u'aggregatename', u'poolname', u'ipaddress', u'password', u'size', u'username'], u'description': u'Create a volume'}, u'staticroute': {u'name': u'createStaticRoute', u'related': [], u'isasync': True, u'params': [{u'name': u'gatewayid', u'required': True, u'related': [u'createPrivateGateway'], u'length': 255, u'type': u'uuid', u'description': u'the gateway id we are creating static route for'}, {u'name': u'cidr', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'static route cidr'}], u'requiredparams': [u'gatewayid', u'cidr'], u'description': u'Creates a static route'}, u'volume': {u'name': u'createVolume', u'related': [u'detachVolume', u'uploadVolume'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the disk volume'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'the project associated with the volume. Mutually exclusive with account parameter'}, {u'name': u'diskofferingid', u'required': False, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk offering. Either diskOfferingId or snapshotId must be passed in.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the disk volume. Must be used with the domainId parameter.'}, {u'name': u'size', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Arbitrary volume size'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the disk offering. If used with the account parameter returns the disk volume associated with the account for the specified domain.'}, {u'name': u'snapshotid', u'required': False, u'related': [u'createSnapshot', u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'the snapshot ID for the disk volume. Either diskOfferingId or snapshotId must be passed in.'}], u'requiredparams': [u'name'], u'description': u'Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.'}, u'user': {u'name': u'createUser', u'related': [u'lockUser', u'listUsers'], u'isasync': False, u'params': [{u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Creates the user under the specified account. If no account is specified, the username will be used as the account name.'}, {u'name': u'userid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'User UUID, required for adding account from external provisioning system'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Unique username.'}, {u'name': u'timezone', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Creates the user under the specified domain. Has to be accompanied with the account parameter'}, {u'name': u'email', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'email'}, {u'name': u'lastname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'lastname'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.'}, {u'name': u'firstname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'firstname'}], u'requiredparams': [u'account', u'username', u'email', u'lastname', u'password', u'firstname'], u'description': u'Creates a user for an account that already exists'}, u'vpc': {u'name': u'createVPC', u'related': [u'updateVPC', u'restartVPC', u'listVPCs'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the VPC'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the VPC'}, {u'name': u'vpcofferingid', u'required': True, u'related': [u'listVPCOfferings', u'createVPCOffering'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VPC offering'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'VPC network domain. All networks inside the VPC will belong to this domain'}, {u'name': u'cidr', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u"the cidr of the VPC. All VPC guest networks' cidrs should be within this CIDR"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the VPC. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the VPC. If used with the account parameter returns the VPC associated with the account for the specified domain.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'create VPC for the project'}], u'requiredparams': [u'displaytext', u'zoneid', u'name', u'vpcofferingid', u'cidr'], u'description': u'Creates a VPC'}, u'storagenetworkiprange': {u'name': u'createStorageNetworkIpRange', u'related': [u'listStorageNetworkIpRange', u'updateStorageNetworkIpRange'], u'isasync': True, u'params': [{u'name': u'startip', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Optional. The vlan the ip range sits on, default to Null when it is not specified which means you network is not on any Vlan. This is mainly for Vmware as other hypervisors can directly reterive bridge from pyhsical network traffic type table'}, {u'name': u'podid', u'required': True, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'UUID of pod where the ip range belongs to'}, {u'name': u'netmask', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask for storage network'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway for storage network'}], u'requiredparams': [u'startip', u'podid', u'netmask', u'gateway'], u'description': u'Creates a Storage network IP range.'}, u'pool': {u'name': u'createPool', u'related': [], u'isasync': False, u'params': [{u'name': u'algorithm', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'algorithm.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'algorithm', u'name'], u'description': u'Create a pool'}, u'autoscalevmprofile': {u'name': u'createAutoScaleVmProfile', u'related': [u'updateAutoScaleVmProfile', u'listAutoScaleVmProfiles'], u'isasync': True, u'params': [{u'name': u'otherdeployparams', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'parameters other than zoneId/serviceOfferringId/templateId of the auto deployed virtual machine'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'availability zone for the auto deployed virtual machine'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering', u'updateServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the service offering of the auto deployed virtual machine'}, {u'name': u'expungevmgraceperiod', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the time allowed for existing connections to get closed before a vm is destroyed'}, {u'name': u'counterparam', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161'}, {u'name': u'templateid', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template of the auto deployed virtual machine'}, {u'name': u'autoscaleuserid', u'required': False, u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'updateUser'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the user used to launch and destroy the VMs'}], u'requiredparams': [u'zoneid', u'serviceofferingid', u'templateid'], u'description': u'Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature.'}, u'account': {u'name': u'createAccount', u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'getUser', u'updateUser'], u'isasync': False, u'params': [{u'name': u'lastname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'lastname'}, {u'name': u'accounttype', u'required': True, u'related': [], u'length': 255, u'type': u'short', u'description': u'Type of the account. Specify 0 for user, 1 for root admin, and 2 for domain admin'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Unique username.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.'}, {u'name': u'firstname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'firstname'}, {u'name': u'userid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'User UUID, required for adding account from external provisioning system'}, {u'name': u'timezone', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Creates the user under the specified account. If no account is specified, the username will be used as the account name.'}, {u'name': u'accountdetails', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'details for account used to store specific parameters'}, {u'name': u'email', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'email'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"Network domain for the account's networks"}, {u'name': u'accountid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Account UUID, required for adding account from external provisioning system'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'Creates the user under the specified domain.'}], u'requiredparams': [u'lastname', u'accounttype', u'username', u'password', u'firstname', u'email'], u'description': u'Creates an account'}, u'firewallrule': {u'name': u'createFirewallRule', u'related': [u'listEgressFirewallRules'], u'isasync': True, u'params': [{u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the firewall rule. Valid values are TCP/UDP/ICMP.'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of firewallrule: system/user'}, {u'name': u'ipaddressid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the IP address id of the port forwarding rule'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the starting port of firewall rule'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the ending port of firewall rule'}], u'requiredparams': [u'protocol', u'ipaddressid'], u'description': u'Creates a firewall rule for a given ip address'}, u'networkoffering': {u'name': u'createNetworkOffering', u'related': [u'updateNetworkOffering'], u'isasync': False, u'params': [{u'name': u'serviceproviderlist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network'}, {u'name': u'serviceofferingid', u'required': False, u'related': [u'updateHypervisorCapabilities'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID used by virtual router provider'}, {u'name': u'supportedservices', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'services supported by the network offering'}, {u'name': u'networkrate', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'data transfer rate in megabits per second allowed'}, {u'name': u'ispersistent', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports persistent networks; defaulted to false if not specified'}, {u'name': u'servicecapabilitylist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'desired service capabilities as part of network offering'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the network offering'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the tags for the network offering.'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the network offering'}, {u'name': u'conservemode', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the network offering is IP conserve mode enabled'}, {u'name': u'guestiptype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'guest type of the network offering: Shared or Isolated'}, {u'name': u'traffictype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the traffic type for the network offering. Supported type in current release is GUEST only'}, {u'name': u'specifyvlan', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports vlans'}, {u'name': u'availability', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the availability of network offering. Default value is Optional'}, {u'name': u'specifyipranges', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports specifying ip ranges; defaulted to false if not specified'}], u'requiredparams': [u'supportedservices', u'name', u'displaytext', u'guestiptype', u'traffictype'], u'description': u'Creates a network offering.'}, u'vlaniprange': {u'name': u'createVlanIpRange', u'related': [u'listVlanIpRanges'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a VLAN'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'project who will own the VLAN. If VLAN is Zone wide, this parameter should be ommited'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ID or VID of the VLAN. If not specified, will be defaulted to the vlan of the network or if vlan of the network is null - to Untagged'}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the network id'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if VLAN is of Virtual type, false if Direct'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Have to be specified for Direct Untagged vlan only.'}, {u'name': u'ip6cidr', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the CIDR of IPv6 network, must be at least /64'}, {u'name': u'endipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IPv6 address in the IPv6 network range'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address in the VLAN IP range'}, {u'name': u'startipv6', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IPv6 address in the IPv6 network range'}, {u'name': u'gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the VLAN IP range'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the VLAN IP range'}, {u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address in the VLAN IP range'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account who will own the VLAN. If VLAN is Zone wide, this parameter should be ommited'}, {u'name': u'ip6gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway of the IPv6 network. Required for Shared networks and Isolated networks when it belongs to VPC'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the physical network id'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the VLAN IP range'}], u'requiredparams': [], u'description': u'Creates a VLAN IP range.'}, u'counter': {u'name': u'createCounter', u'related': [u'listCounters'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the counter.'}, {u'name': u'source', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Source of the counter.'}, {u'name': u'value', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Value of the counter e.g. oid in case of snmp.'}], u'requiredparams': [u'name', u'source', u'value'], u'description': u'Adds metric counter'}, u'lunonfiler': {u'name': u'createLunOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'size', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'LUN size.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'size', u'name'], u'description': u'Create a LUN from a pool'}, u'project': {u'name': u'createProject', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account who will be Admin for the project'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the project'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a project'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'display text of the project'}], u'requiredparams': [u'name', u'displaytext'], u'description': u'Creates a project'}, u'physicalnetwork': {u'name': u'createPhysicalNetwork', u'related': [u'listPhysicalNetworks'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the physical network'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the physical network'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'Tag the physical network'}, {u'name': u'networkspeed', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the speed for the physical network[1G/10G]'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the VLAN for the physical network'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'domain ID of the account owning a physical network'}, {u'name': u'broadcastdomainrange', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the broadcast domain range for the physical network[Pod or Zone]. In Acton release it can be Zone only in Advance zone, and Pod in Basic'}, {u'name': u'isolationmethods', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the isolation method for the physical network[VLAN/L3/GRE]'}], u'requiredparams': [u'name', u'zoneid'], u'description': u'Creates a physical network'}, u'snapshot': {u'name': u'createSnapshot', u'related': [u'listSnapshots'], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The account of the snapshot. The account parameter must be used with the domainId parameter.'}, {u'name': u'volumeid', u'required': True, u'related': [u'detachVolume'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the disk volume'}, {u'name': u'policyid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'policy id of the snapshot, if this is null, then use MANUAL_POLICY.'}], u'requiredparams': [u'volumeid'], u'description': u'Creates an instant snapshot of a volume.'}, u'virtualrouterelement': {u'name': u'createVirtualRouterElement', u'related': [], u'isasync': True, u'params': [{u'name': u'nspid', u'required': True, u'related': [u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'the network service provider ID of the virtual router element'}], u'requiredparams': [u'nspid'], u'description': u'Create a virtual router element.'}, u'egressfirewallrule': {u'name': u'createEgressFirewallRule', u'related': [u'createFirewallRule', u'listEgressFirewallRules'], u'isasync': True, u'params': [{u'name': u'networkid', u'required': True, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the network id of the port forwarding rule'}, {u'name': u'startport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the starting port of firewall rule'}, {u'name': u'icmpcode', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'error code for this icmp message'}, {u'name': u'icmptype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'type of the icmp message being sent'}, {u'name': u'cidrlist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the cidr list to forward traffic from'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of firewallrule: system/user'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the firewall rule. Valid values are TCP/UDP/ICMP.'}, {u'name': u'endport', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the ending port of firewall rule'}], u'requiredparams': [u'networkid', u'protocol'], u'description': u'Creates a egress firewall rule for a given network '}, u'sshkeypair': {u'name': u'createSSHKeyPair', u'related': [u'listSSHKeyPairs'], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the keypair'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the ssh key. Must be used with domainId.'}], u'requiredparams': [u'name'], u'description': u'Create a new keypair and returns the private key'}}, u'deploy': {u'virtualmachine': {u'name': u'deployVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'keypair', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the ssh key pair used to login to the virtual machine'}, {u'name': u'userdata', u'required': False, u'related': [], u'length': 2048, u'type': u'string', u'description': u'an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding.'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor on which to deploy the virtual machine'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.'}, {u'name': u'size', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId'}, {u'name': u'diskofferingid', u'required': False, u'related': [u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume. If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume created.'}, {u'name': u'securitygroupids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of security groups id that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupnames parameter'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the service offering for the virtual machine'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"the ip address for default vm's network"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the virtual machine. Must be used with domainId.'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'destination Host ID to deploy the VM to - parameter available for root admin only'}, {u'name': u'iptonetworklist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u"ip to network mapping. Can't be specified with networkIds parameter. Example: iptonetworklist[0].ip=10.10.10.11&iptonetworklist[0].ipv6=fc00:1234:5678::abcd&iptonetworklist[0].networkid=uuid - requests to use ip 10.10.10.11 in network id=uuid"}, {u'name': u'ip6address', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"the ipv6 address for default vm's network"}, {u'name': u'keyboard', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional keyboard device type for the virtual machine. valid value can be one of de,de-ch,es,fi,fr,fr-be,fr-ch,is,it,jp,nl-be,no,pt,uk,us'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'Deploy vm for the project'}, {u'name': u'networkids', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'list', u'description': u"list of network ids used by virtual machine. Can't be specified with ipToNetworkList parameter"}, {u'name': u'displayname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional user generated name for the virtual machine'}, {u'name': u'securitygroupnames', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of security groups names that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupids parameter'}, {u'name': u'templateid', u'required': True, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the template for the virtual machine'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'availability zone for the virtual machine'}, {u'name': u'group', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional group for the virtual machine'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'host name for the virtual machine'}, {u'name': u'startvm', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network offering supports specifying ip ranges; defaulted to true if not specified'}], u'requiredparams': [u'serviceofferingid', u'templateid', u'zoneid'], u'description': u'Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.'}}, u'restart': {u'network': {u'name': u'restartNetwork', u'related': [u'associateIpAddress'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The id of the network to restart.'}, {u'name': u'cleanup', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If cleanup old network elements'}], u'requiredparams': [u'id'], u'description': u'Restarts the network; includes 1) restarting network elements - virtual routers, dhcp servers 2) reapplying all public ips 3) reapplying loadBalancing/portForwarding rules'}, u'vpc': {u'name': u'restartVPC', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': False, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VPC'}], u'requiredparams': [], u'description': u'Restarts a VPC'}}, u'reboot': {u'systemvm': {u'name': u'rebootSystemVm', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'rebootSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Reboots a system VM.'}, u'router': {u'name': u'rebootRouter', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'rebootRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Starts a router.'}, u'virtualmachine': {u'name': u'rebootVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Reboots a virtual machine.'}}, u'mark': {u'defaultzoneforaccount': {u'name': u'markDefaultZoneForAccount', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': True, u'related': [u'markDefaultZoneForAccount'], u'length': 255, u'type': u'string', u'description': u'Name of the account that is to be marked.'}, {u'name': u'domainid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Marks the account that belongs to the specified domain.'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The Zone ID with which the account is to be marked.'}], u'requiredparams': [u'account', u'domainid', u'zoneid'], u'description': u'Marks a default zone for this account'}}, u'start': {u'systemvm': {u'name': u'startSystemVm', u'related': [u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Starts a system virtual machine.'}, u'router': {u'name': u'startRouter', u'related': [u'destroyRouter', u'rebootRouter'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'destroyRouter', u'rebootRouter', u'startRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Starts a router.'}, u'virtualmachine': {u'name': u'startVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'destination Host ID to deploy the VM to - parameter available for root admin only'}], u'requiredparams': [u'id'], u'description': u'Starts a virtual machine.'}}, u'add': {u'trafficmonitor': {u'name': u'addTrafficMonitor', u'related': [u'listTrafficMonitors'], u'isasync': False, u'params': [{u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the traffic monitor Host'}, {u'name': u'includezones', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Traffic going into the listed zones will be metered'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'Zone in which to add the external firewall appliance.'}, {u'name': u'excludezones', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Traffic going into the listed zones will not be metered'}], u'requiredparams': [u'url', u'zoneid'], u'description': u'Adds Traffic Monitor Host for Direct Network Usage'}, u'secondarystorage': {u'name': u'addSecondaryStorage', u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the secondary storage'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL for the secondary storage'}], u'requiredparams': [u'url'], u'description': u'Adds secondary storage.'}, u'nictovirtualmachine': {u'name': u'addNicToVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'networkid', u'required': True, u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'Network ID'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'IP Address for the new network'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'addNicToVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'networkid', u'virtualmachineid'], u'description': u'Adds VM to specified network by creating a NIC'}, u'netscalerloadbalancer': {u'name': u'addNetscalerLoadBalancer', u'related': [u'listNetscalerLoadBalancers', u'configureNetscalerLoadBalancer'], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach netscaler load balancer device'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach netscaler load balancer device'}, {u'name': u'networkdevicetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Netscaler device type supports NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the netscaler load balancer appliance.'}], u'requiredparams': [u'password', u'physicalnetworkid', u'username', u'networkdevicetype', u'url'], u'description': u'Adds a netscaler load balancer device'}, u'cluster': {u'name': u'addCluster', u'related': [u'listClusters', u'updateCluster'], u'isasync': False, u'params': [{u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'vsmpassword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the VSM associated with this cluster'}, {u'name': u'podid', u'required': True, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'vsmipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ipaddress of the VSM associated with this cluster'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the cluster: XenServer,KVM,VMware,Hyperv,BareMetal,Simulator'}, {u'name': u'vsmusername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the VSM associated with this cluster'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the cluster'}, {u'name': u'clustertype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of the cluster: CloudManaged, ExternalManaged'}, {u'name': u'clustername', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the cluster'}, {u'name': u'password', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the host'}], u'requiredparams': [u'podid', u'hypervisor', u'clustertype', u'clustername', u'zoneid'], u'description': u'Adds a new cluster'}, u's3': {u'name': u'addS3', u'related': [], u'isasync': False, u'params': [{u'name': u'connectiontimeout', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'connection timeout (milliseconds)'}, {u'name': u'accesskey', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'S3 access key'}, {u'name': u'bucket', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the template storage bucket'}, {u'name': u'endpoint', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'S3 host name'}, {u'name': u'secretkey', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'S3 secret key'}, {u'name': u'sockettimeout', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'socket timeout (milliseconds)'}, {u'name': u'maxerrorretry', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'maximum number of times to retry on error'}, {u'name': u'usehttps', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'connect to the S3 endpoint via HTTPS?'}], u'requiredparams': [u'accesskey', u'bucket', u'secretkey'], u'description': u'Adds S3'}, u'accounttoproject': {u'name': u'addAccountToProject', u'related': [], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the account to be added to the project'}, {u'name': u'email', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'email to which invitation to the project is going to be sent'}, {u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to add the account to'}], u'requiredparams': [u'projectid'], u'description': u'Adds account to a project'}, u'region': {u'name': u'addRegion', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the region'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Id of the Region'}, {u'name': u'endpoint', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Region service endpoint'}], u'requiredparams': [u'name', u'id', u'endpoint'], u'description': u'Adds a Region'}, u'externalloadbalancer': {u'name': u'addExternalLoadBalancer', u'related': [], u'isasync': False, u'params': [{u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Username of the external load balancer appliance.'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the external load balancer appliance.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Password of the external load balancer appliance.'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'Zone in which to add the external load balancer appliance.'}], u'requiredparams': [u'username', u'url', u'password', u'zoneid'], u'description': u'Adds F5 external load balancer appliance.'}, u'vpnuser': {u'name': u'addVpnUser', u'related': [u'listVpnUsers'], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'password for the username'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'username for the vpn user'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the vpn user. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'add vpn user to the specific project'}], u'requiredparams': [u'password', u'username'], u'description': u'Adds vpn users'}, u'baremetalhost': {u'name': u'addBaremetalHost', u'related': [u'listSwifts', u'addHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'ip address intentionally allocated to this host after provisioning'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of tags to be added to the host'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host URL'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the host'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the host'}, {u'name': u'clustername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name for the host'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID for the host'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the host'}, {u'name': u'podid', u'required': True, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the host'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Host for allocation of new resources'}], u'requiredparams': [u'url', u'username', u'zoneid', u'hypervisor', u'podid', u'password'], u'description': u'add a baremetal host'}, u'traffictype': {u'name': u'addTrafficType', u'related': [u'updateTrafficType'], u'isasync': True, u'params': [{u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The VLAN id to be used for Management traffic by VMware host'}, {u'name': u'kvmnetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a KVM host'}, {u'name': u'traffictype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the trafficType to be added to the physical network'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'vmwarenetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a VMware host'}, {u'name': u'xennetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a XenServer host'}], u'requiredparams': [u'traffictype', u'physicalnetworkid'], u'description': u'Adds traffic type to a physical network'}, u'niciranvpdevice': {u'name': u'addNiciraNvpDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'hostname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hostname of ip address of the Nicira NVP Controller.'}, {u'name': u'l3gatewayserviceuuid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The L3 Gateway Service UUID configured on the Nicira Controller'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to access the Nicira Controller API'}, {u'name': u'transportzoneuuid', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'The Transportzone UUID configured on the Nicira Controller'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to access the Nicira Controller API'}], u'requiredparams': [u'physicalnetworkid', u'hostname', u'username', u'transportzoneuuid', u'password'], u'description': u'Adds a Nicira NVP device'}, u'host': {u'name': u'addHost', u'related': [u'updateHost', u'listHosts'], u'isasync': False, u'params': [{u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the host'}, {u'name': u'podid', u'required': True, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'clustername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name for the host'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the host'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host URL'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID for the host'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the password for the host'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of tags to be added to the host'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this Host for allocation of new resources'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the host'}], u'requiredparams': [u'username', u'podid', u'zoneid', u'url', u'password', u'hypervisor'], u'description': u'Adds a new host.'}, u'f5loadbalancer': {u'name': u'addF5LoadBalancer', u'related': [u'configureF5LoadBalancer', u'listF5LoadBalancers'], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach F5 BigIP load balancer device'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach F5 BigIP load balancer device'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'networkdevicetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'supports only F5BigIpLoadBalancer'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the F5 load balancer appliance.'}], u'requiredparams': [u'password', u'username', u'physicalnetworkid', u'networkdevicetype', u'url'], u'description': u'Adds a F5 BigIP load balancer device'}, u'networkdevice': {u'name': u'addNetworkDevice', u'related': [], u'isasync': False, u'params': [{u'name': u'networkdevicetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall'}, {u'name': u'networkdeviceparameterlist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'parameters for network device'}], u'requiredparams': [], u'description': u'Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer'}, u'bigswitchvnsdevice': {u'name': u'addBigSwitchVnsDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'physicalnetworkid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'hostname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hostname of ip address of the BigSwitch VNS Controller.'}], u'requiredparams': [u'physicalnetworkid', u'hostname'], u'description': u'Adds a BigSwitch VNS device'}, u'srxfirewall': {u'name': u'addSrxFirewall', u'related': [], u'isasync': True, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach SRX firewall device'}, {u'name': u'networkdevicetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'supports only JuniperSRXFirewall'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Credentials to reach SRX firewall device'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the SRX appliance.'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}], u'requiredparams': [u'password', u'networkdevicetype', u'username', u'url', u'physicalnetworkid'], u'description': u'Adds a SRX firewall device'}, u'swift': {u'name': u'addSwift', u'related': [u'listSwifts', u'addHost', u'updateHost', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account for swift'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL for swift'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for swift'}, {u'name': u'key', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u' key for the user for swift'}], u'requiredparams': [u'url'], u'description': u'Adds Swift.'}, u'externalfirewall': {u'name': u'addExternalFirewall', u'related': [], u'isasync': False, u'params': [{u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'URL of the external firewall appliance.'}, {u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Password of the external firewall appliance.'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Zone in which to add the external firewall appliance.'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Username of the external firewall appliance.'}], u'requiredparams': [u'url', u'password', u'zoneid', u'username'], u'description': u'Adds an external firewall appliance'}, u'networkserviceprovider': {u'name': u'addNetworkServiceProvider', u'related': [u'updateNetworkServiceProvider'], u'isasync': True, u'params': [{u'name': u'destinationphysicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the destination Physical Network ID to bridge to'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name for the physical network service provider'}, {u'name': u'servicelist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of services to be enabled for this physical network service provider'}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID to add the provider to'}], u'requiredparams': [u'name', u'physicalnetworkid'], u'description': u'Adds a network serviceProvider to a physical network'}}, u'verbs': [u'authorize', u'restore', u'suspend', u'revoke', u'disassociate', u'migrate', u'lock', u'dissociate', u'activate', u'reconnect', u'cancel', u'query', u'recover', u'extract', u'detach', u'prepare', u'start', u'create', u'associate', u'reboot', u'mark', u'attach', u'add', u'change', u'deploy', u'ldap', u'destroy', u'enable', u'configure', u'get', u'modify', u'stop', u'update', u'disable', u'resize', u'copy', u'generate', u'restart', u'reset', u'register', u'list', u'upload', u'remove', u'assign', u'delete'], u'resize': {u'volume': {u'name': u'resizeVolume', u'related': [u'detachVolume', u'uploadVolume', u'createVolume'], u'isasync': True, u'params': [{u'name': u'diskofferingid', u'required': False, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'new disk offering id'}, {u'name': u'id', u'required': False, u'related': [u'detachVolume', u'resizeVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'shrinkok', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Verify OK to Shrink'}, {u'name': u'size', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'New volume size in G'}], u'requiredparams': [], u'description': u'Resizes a volume'}}, u'ldap': {u'config': {u'name': u'ldapConfig', u'related': [u'ldapRemove'], u'isasync': False, u'params': [{u'name': u'hostname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hostname or ip address of the ldap server eg: my.ldap.com'}, {u'name': u'ssl', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Check Use SSL if the external LDAP server is configured for LDAP over SSL.'}, {u'name': u'truststore', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enter the path to trust certificates store.'}, {u'name': u'queryfilter', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'You specify a query filter here, which narrows down the users, who can be part of this domain.'}, {u'name': u'searchbase', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.'}, {u'name': u'port', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Specify the LDAP port if required, default is 389.'}, {u'name': u'binddn', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specify the distinguished name of a user with the search permission on the directory.'}, {u'name': u'truststorepass', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enter the password for trust store.'}, {u'name': u'bindpass', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enter the password.'}], u'requiredparams': [u'hostname', u'queryfilter', u'searchbase'], u'description': u'Configure the LDAP context for this site.'}, u'remove': {u'name': u'ldapRemove', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'Remove the LDAP context for this site.'}}, u'destroy': {u'systemvm': {u'name': u'destroySystemVm', u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'stopSystemVm', u'changeServiceForSystemVm'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startSystemVm', u'destroySystemVm', u'rebootSystemVm', u'listSystemVms', u'stopSystemVm', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Destroyes a system virtual machine.'}, u'router': {u'name': u'destroyRouter', u'related': [u'rebootRouter'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'destroyRouter', u'rebootRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Destroys a router.'}, u'volumeonfiler': {u'name': u'destroyVolumeOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'volumename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'volume name.'}, {u'name': u'ipaddress', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ip address.'}, {u'name': u'aggregatename', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'aggregate name.'}], u'requiredparams': [u'volumename', u'ipaddress', u'aggregatename'], u'description': u'Destroy a Volume'}, u'lunonfiler': {u'name': u'destroyLunOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'path', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'LUN path.'}], u'requiredparams': [u'path'], u'description': u'Destroy a LUN'}, u'virtualmachine': {u'name': u'destroyVirtualMachine', u'related': [u'listVirtualMachines'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listVirtualMachines', u'destroyVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Destroys a virtual machine. Once destroyed, only the administrator can recover it.'}}, u'get': {u'apilimit': {u'name': u'getApiLimit', u'related': [u'resetApiLimit'], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'Get API limit count for the caller'}, u'vmpassword': {u'name': u'getVMPassword', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Returns an encrypted password for the VM'}, u'user': {u'name': u'getUser', u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'updateUser'], u'isasync': False, u'params': [{u'name': u'userapikey', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'API key of the user'}], u'requiredparams': [u'userapikey'], u'description': u'Find user account by API key'}, u'cloudidentifier': {u'name': u'getCloudIdentifier', u'related': [], u'isasync': False, u'params': [{u'name': u'userid', u'required': True, u'related': [u'lockUser', u'listUsers', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'the user ID for the cloud identifier'}], u'requiredparams': [u'userid'], u'description': u'Retrieves a cloud identifier.'}}, u'count': 355, u'enable': {u'account': {u'name': u'enableAccount', u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'disableAccount'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'Enables specified account in this domain.'}, {u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'enableAccount', u'disableAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enables specified account.'}], u'requiredparams': [], u'description': u'Enables an account'}, u'storagemaintenance': {u'name': u'enableStorageMaintenance', u'related': [u'cancelStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'cancelStorageMaintenance', u'enableStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'Primary storage ID'}], u'requiredparams': [u'id'], u'description': u'Puts storage pool into maintenance state'}, u'cisconexusvsm': {u'name': u'enableCiscoNexusVSM', u'related': [u'disableCiscoNexusVSM'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableCiscoNexusVSM', u'enableCiscoNexusVSM'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Cisco Nexus 1000v VSM device to be enabled'}], u'requiredparams': [u'id'], u'description': u'Enable a Cisco Nexus VSM device'}, u'staticnat': {u'name': u'enableStaticNat', u'related': [], u'isasync': False, u'params': [{u'name': u'ipaddressid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id for which static nat feature is being enabled'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine for enabling static nat feature'}, {u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network of the vm the static nat will be enabled for. Required when public Ip address is not associated with any Guest network yet (VPC case)'}], u'requiredparams': [u'ipaddressid', u'virtualmachineid'], u'description': u'Enables static nat for given ip address'}, u'user': {u'name': u'enableUser', u'related': [u'lockUser', u'listUsers', u'createUser'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'Enables user by user ID.'}], u'requiredparams': [u'id'], u'description': u'Enables a user account'}, u'autoscalevmgroup': {u'name': u'enableAutoScaleVmGroup', u'related': [u'createAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}], u'requiredparams': [u'id'], u'description': u'Enables an AutoScale Vm Group'}}, u'configure': {u'srxfirewall': {u'name': u'configureSrxFirewall', u'related': [u'listSrxFirewalls', u'addSrxFirewall'], u'isasync': True, u'params': [{u'name': u'fwdeviceid', u'required': True, u'related': [u'listSrxFirewalls', u'configureSrxFirewall', u'addSrxFirewall'], u'length': 255, u'type': u'uuid', u'description': u'SRX firewall device ID'}, {u'name': u'fwdevicecapacity', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'capacity of the firewall device, Capacity will be interpreted as number of networks device can handle'}], u'requiredparams': [u'fwdeviceid'], u'description': u'Configures a SRX firewall device'}, u'f5loadbalancer': {u'name': u'configureF5LoadBalancer', u'related': [], u'isasync': True, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'configureF5LoadBalancer'], u'length': 255, u'type': u'uuid', u'description': u'F5 load balancer device ID'}, {u'name': u'lbdevicecapacity', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'capacity of the device, Capacity will be interpreted as number of networks device can handle'}], u'requiredparams': [u'lbdeviceid'], u'description': u'configures a F5 load balancer device'}, u'netscalerloadbalancer': {u'name': u'configureNetscalerLoadBalancer', u'related': [u'listNetscalerLoadBalancers'], u'isasync': True, u'params': [{u'name': u'podids', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'list', u'description': u"Used when NetScaler device is provider of EIP service. This parameter represents the list of pod's, for which there exists a policy based route on datacenter L3 router to route pod's subnet IP to a NetScaler device."}, {u'name': u'lbdevicecapacity', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'capacity of the device, Capacity will be interpreted as number of networks device can handle'}, {u'name': u'lbdeviceid', u'required': True, u'related': [u'listNetscalerLoadBalancers', u'configureNetscalerLoadBalancer'], u'length': 255, u'type': u'uuid', u'description': u'Netscaler load balancer device ID'}, {u'name': u'inline', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if netscaler load balancer is intended to be used in in-line with firewall, false if netscaler load balancer will side-by-side with firewall'}, {u'name': u'lbdevicededicated', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this netscaler device to dedicated for a account, false if the netscaler device will be shared by multiple accounts'}], u'requiredparams': [u'lbdeviceid'], u'description': u'configures a netscaler load balancer device'}, u'virtualrouterelement': {u'name': u'configureVirtualRouterElement', u'related': [u'createVirtualRouterElement'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createVirtualRouterElement', u'configureVirtualRouterElement'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual router provider'}, {u'name': u'enabled', u'required': True, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Enabled/Disabled the service provider'}], u'requiredparams': [u'id', u'enabled'], u'description': u'Configures a virtual router element.'}}, u'associate': {u'ipaddress': {u'name': u'associateIpAddress', u'related': [], u'isasync': True, u'params': [{u'name': u'networkid', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'The network this ip address should be associated to.'}, {u'name': u'vpcid', u'required': False, u'related': [u'restartVPC', u'listVPCs'], u'length': 255, u'type': u'uuid', u'description': u'the VPC you want the ip address to be associated with'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account to associate with this IP address'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone you want to acquire an public IP address from'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'Deploy vm for the project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain to associate with this IP address'}], u'requiredparams': [], u'description': u'Acquires and associates a public IP to an account.'}, u'lun': {u'name': u'associateLun', u'related': [], u'isasync': False, u'params': [{u'name': u'iqn', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Guest IQN to which the LUN associate.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'LUN name.'}], u'requiredparams': [u'iqn', u'name'], u'description': u'Associate a LUN with a guest IQN'}}, u'stop': {u'systemvm': {u'name': u'stopSystemVm', u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'isasync': True, u'params': [{u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force stop the VM. The caller knows the VM is stopped.'}, {u'name': u'id', u'required': True, u'related': [u'startSystemVm', u'rebootSystemVm', u'listSystemVms', u'stopSystemVm', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system virtual machine'}], u'requiredparams': [u'id'], u'description': u'Stops a system VM.'}, u'router': {u'name': u'stopRouter', u'related': [u'changeServiceForRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'isasync': True, u'params': [{u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force stop the VM. The caller knows the VM is stopped.'}, {u'name': u'id', u'required': True, u'related': [u'changeServiceForRouter', u'stopRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the router'}], u'requiredparams': [u'id'], u'description': u'Stops a router.'}, u'virtualmachine': {u'name': u'stopVirtualMachine', u'related': [u'listVirtualMachines', u'destroyVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend). The caller knows the VM is stopped.'}], u'requiredparams': [u'id'], u'description': u'Stops a virtual machine.'}}, u'modify': {u'pool': {u'name': u'modifyPool', u'related': [], u'isasync': False, u'params': [{u'name': u'algorithm', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'algorithm.'}, {u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'algorithm', u'poolname'], u'description': u'Modify pool'}}, u'update': {u'loadbalancerrule': {u'name': u'updateLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'description', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the description of the load balancer rule'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of the load balancer rule to update'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the load balancer rule'}, {u'name': u'algorithm', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'load balancer algorithm (source, roundrobin, leastconn)'}], u'requiredparams': [u'id'], u'description': u'Updates load balancer'}, u'domain': {u'name': u'updateDomain', u'related': [u'listDomainChildren', u'createDomain'], u'isasync': False, u'params': [{u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"Network domain for the domain's networks; empty string will update domainName with NULL value"}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates domain with this name'}, {u'name': u'id', u'required': True, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'ID of domain to update'}], u'requiredparams': [u'id'], u'description': u'Updates a domain with a new name'}, u'projectinvitation': {u'name': u'updateProjectInvitation', u'related': [], u'isasync': True, u'params': [{u'name': u'accept', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, accept the invitation, decline if false. True by default'}, {u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to join'}, {u'name': u'token', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list invitations for specified account; this parameter has to be specified with domainId'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'account that is joining the project'}], u'requiredparams': [u'projectid'], u'description': u'Accepts or declines project invitation'}, u'diskoffering': {u'name': u'updateDiskOffering', u'related': [u'createDiskOffering', u'listDiskOfferings'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the disk offering'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'updates alternate display text of the disk offering with this value'}, {u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the disk offering, integer'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates name of the disk offering with this value'}], u'requiredparams': [u'id'], u'description': u'Updates a disk offering.'}, u'virtualmachine': {u'name': u'updateVirtualMachine', u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'displayname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'user generated name'}, {u'name': u'group', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'group of the virtual machine'}, {u'name': u'haenable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if high-availability is enabled for the virtual machine, false otherwise'}, {u'name': u'id', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'ostypeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS type that best represents this VM.'}, {u'name': u'userdata', u'required': False, u'related': [], u'length': 2048, u'type': u'string', u'description': u'an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding.'}], u'requiredparams': [u'id'], u'description': u'Updates properties of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. Therefore, stop the VM manually before issuing this call.'}, u'portforwardingrule': {u'name': u'updatePortForwardingRule', u'related': [u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'isasync': True, u'params': [{u'name': u'privateport', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the private port of the port forwarding rule'}, {u'name': u'publicport', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the public port of the port forwarding rule'}, {u'name': u'privateip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the private IP address of the port forwarding rule'}, {u'name': u'ipaddressid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the IP address id of the port forwarding rule'}, {u'name': u'protocol', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the protocol for the port fowarding rule. Valid values are TCP or UDP.'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine for the port forwarding rule'}], u'requiredparams': [u'privateport', u'publicport', u'ipaddressid', u'protocol'], u'description': u'Updates a port forwarding rule. Only the private port and the virtual machine can be updated.'}, u'cluster': {u'name': u'updateCluster', u'related': [], u'isasync': False, u'params': [{u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the cluster'}, {u'name': u'id', u'required': True, u'related': [u'updateCluster'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Cluster'}, {u'name': u'managedstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'whether this cluster is managed by cloudstack'}, {u'name': u'clustername', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the cluster name'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'clustertype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'hypervisor type of the cluster'}], u'requiredparams': [u'id'], u'description': u'Updates an existing cluster'}, u'hostpassword': {u'name': u'updateHostPassword', u'related': [], u'isasync': False, u'params': [{u'name': u'password', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new password for the host/cluster'}, {u'name': u'hostid', u'required': False, u'related': [u'listSwifts', u'addHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username for the host/cluster'}], u'requiredparams': [u'password', u'username'], u'description': u'Update password of a host/pool on management server.'}, u'pod': {u'name': u'updatePod', u'related': [], u'isasync': False, u'params': [{u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address for the Pod'}, {u'name': u'gateway', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the gateway for the Pod'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'id', u'required': True, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Pod'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Pod'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the starting IP address for the Pod'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask of the Pod'}], u'requiredparams': [u'id'], u'description': u'Updates a Pod.'}, u'isopermissions': {u'name': u'updateIsoPermissions', u'related': [], u'isasync': False, u'params': [{u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template/iso is extractable, false other wise. Can be set only by root admin'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for featured template/iso, false otherwise'}, {u'name': u'accounts', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of accounts. If specified, "op" parameter has to be passed in.'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for public template/iso, false for private templates/isos'}, {u'name': u'projectids', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of projects. If specified, "op" parameter has to be passed in.'}, {u'name': u'op', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'permission operator (add, remove, reset)'}, {u'name': u'id', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}], u'requiredparams': [u'id'], u'description': u'Updates iso permissions'}, u'resourcelimit': {u'name': u'updateResourceLimit', u'related': [], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Update resource for a specified account. Must be used with the domainId parameter.'}, {u'name': u'resourcetype', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Type of resource to update. Values are 0, 1, 2, 3, and 4. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create.3 - Snapshot. Number of snapshots a user can create.4 - Template. Number of templates that a user can register/create.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Update resource limits for all accounts in specified domain. If used with the account parameter, updates resource limits for a specified account in specified domain.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Update resource limits for project'}, {u'name': u'max', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u' Maximum resource limit.'}], u'requiredparams': [u'resourcetype'], u'description': u'Updates resource limits for an account or domain.'}, u'vpcoffering': {u'name': u'updateVPCOffering', u'related': [u'listVPCOfferings', u'createVPCOffering'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the VPC offering'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'update state for the VPC offering; supported states - Enabled/Disabled'}, {u'name': u'id', u'required': False, u'related': [u'listVPCOfferings', u'createVPCOffering', u'updateVPCOffering'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VPC offering'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the VPC offering'}], u'requiredparams': [], u'description': u'Updates VPC offering'}, u'network': {u'name': u'updateNetwork', u'related': [u'listNetscalerLoadBalancerNetworks'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network'}, {u'name': u'networkofferingid', u'required': False, u'related': [u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'network offering ID'}, {u'name': u'changecidr', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force update even if cidr type is different'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new name for the network'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new display text for the network'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network domain'}], u'requiredparams': [u'id'], u'description': u'Updates a network'}, u'zone': {u'name': u'updateZone', u'related': [u'listZones', u'createZone'], u'isasync': False, u'params': [{u'name': u'internaldns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first internal DNS for the Zone'}, {u'name': u'dnssearchorder', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the dns search order list'}, {u'name': u'internaldns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second internal DNS for the Zone'}, {u'name': u'domain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network domain name for the networks in the zone; empty string will update domain with NULL value'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'the details for the Zone'}, {u'name': u'ip6dns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for IPv6 network in the Zone'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Allocation state of this cluster for allocation of new resources'}, {u'name': u'ip6dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for IPv6 network in the Zone'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the Zone'}, {u'name': u'id', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Zone'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'updates a private zone to public if set, but not vice-versa'}, {u'name': u'dns2', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the second DNS for the Zone'}, {u'name': u'guestcidraddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the guest CIDR address for the Zone'}, {u'name': u'dhcpprovider', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the dhcp Provider for the Zone'}, {u'name': u'dns1', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the first DNS for the Zone'}, {u'name': u'localstorageenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if local storage offering enabled, false otherwise'}], u'requiredparams': [u'id'], u'description': u'Updates a Zone.'}, u'instancegroup': {u'name': u'updateInstanceGroup', u'related': [u'createInstanceGroup'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateInstanceGroup', u'createInstanceGroup'], u'length': 255, u'type': u'uuid', u'description': u'Instance group ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'new instance group name'}], u'requiredparams': [u'id'], u'description': u'Updates a vm group'}, u'autoscalepolicy': {u'name': u'updateAutoScalePolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'duration', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the duration for which the conditions have to be true before action is taken'}, {u'name': u'id', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale policy'}, {u'name': u'quiettime', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the cool down period for which the policy should not be evaluated after the action has been taken'}, {u'name': u'conditionids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the conditions that are being evaluated on every interval'}], u'requiredparams': [u'id'], u'description': u'Updates an existing autoscale policy.'}, u'serviceoffering': {u'name': u'updateServiceOffering', u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering'], u'isasync': False, u'params': [{u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the service offering, integer'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the service offering to be updated'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the service offering to be updated'}, {u'name': u'id', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering', u'updateServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the service offering to be updated'}], u'requiredparams': [u'id'], u'description': u'Updates a service offering.'}, u'storagepool': {u'name': u'updateStoragePool', u'related': [u'cancelStorageMaintenance', u'createStoragePool', u'listStoragePools'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'cancelStorageMaintenance', u'updateStoragePool', u'createStoragePool', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'the Id of the storage pool'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma-separated list of tags for the storage pool'}], u'requiredparams': [u'id'], u'description': u'Updates a storage pool.'}, u'hypervisorcapabilities': {u'name': u'updateHypervisorCapabilities', u'related': [], u'isasync': False, u'params': [{u'name': u'securitygroupenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'set true to enable security group for this hypervisor.'}, {u'name': u'maxguestslimit', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the max number of Guest VMs per host for this hypervisor.'}, {u'name': u'id', u'required': False, u'related': [u'listHypervisorCapabilities'], u'length': 255, u'type': u'uuid', u'description': u'ID of the hypervisor capability'}], u'requiredparams': [], u'description': u'Updates a hypervisor capabilities.'}, u'template': {u'name': u'updateTemplate', u'related': [u'registerIso', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if image is bootable, false otherwise'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the image supports the password reset feature; default is false'}, {u'name': u'format', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the image'}, {u'name': u'ostypeid', u'required': False, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS type that best represents the OS of this image.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the image file'}, {u'name': u'id', u'required': True, u'related': [u'registerIso', u'updateTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the image file'}, {u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the template, integer'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the image'}], u'requiredparams': [u'id'], u'description': u'Updates attributes of a template.'}, u'defaultnicforvirtualmachine': {u'name': u'updateDefaultNicForVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'nicid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'NIC ID'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'nicid', u'virtualmachineid'], u'description': u'Changes the default NIC on a VM'}, u'traffictype': {u'name': u'updateTrafficType', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateTrafficType'], u'length': 255, u'type': u'uuid', u'description': u'traffic type id'}, {u'name': u'xennetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a XenServer host'}, {u'name': u'vmwarenetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a VMware host'}, {u'name': u'kvmnetworklabel', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The network name label of the physical device dedicated to this traffic on a KVM host'}], u'requiredparams': [u'id'], u'description': u'Updates traffic type of a physical network'}, u'host': {u'name': u'updateHost', u'related': [u'listHosts'], u'isasync': False, u'params': [{u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Change resource state of host, valid values are [Enable, Disable]. Operation may failed if host in states not allowing Enable/Disable'}, {u'name': u'oscategoryid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of Os category to update the host with'}, {u'name': u'hosttags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of tags to be added to the host'}, {u'name': u'id', u'required': True, u'related': [u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the host to update'}, {u'name': u'url', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the new uri for the secondary storage: nfs://host/path'}], u'requiredparams': [u'id'], u'description': u'Updates a host.'}, u'user': {u'name': u'updateUser', u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser', u'updateUser'], u'length': 255, u'type': u'uuid', u'description': u'User uuid'}, {u'name': u'timezone', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.'}, {u'name': u'email', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'email'}, {u'name': u'usersecretkey', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The secret key for the user. Must be specified with userApiKey'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Unique username'}, {u'name': u'firstname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'first name'}, {u'name': u'lastname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'last name'}, {u'name': u'password', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Hashed password (default is MD5). If you wish to use any other hasing algorithm, you would need to write a custom authentication adapter'}, {u'name': u'userapikey', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The API key for the user. Must be specified with userSecretKey'}], u'requiredparams': [u'id'], u'description': u'Updates a user account'}, u'vpc': {u'name': u'updateVPC', u'related': [u'restartVPC', u'listVPCs'], u'isasync': True, u'params': [{u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the VPC'}, {u'name': u'id', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VPC'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the VPC'}], u'requiredparams': [], u'description': u'Updates a VPC'}, u'resourcecount': {u'name': u'updateResourceCount', u'related': [], u'isasync': False, u'params': [{u'name': u'resourcetype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Type of resource to update. If specifies valid values are 0, 1, 2, 3, and 4. If not specified will update all resource counts0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create.3 - Snapshot. Number of snapshots a user can create.4 - Template. Number of templates that a user can register/create.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Update resource limits for project'}, {u'name': u'domainid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'If account parameter specified then updates resource counts for a specified account in this domain else update resource counts for all accounts & child domains in specified domain.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Update resource count for a specified account. Must be used with the domainId parameter.'}], u'requiredparams': [u'domainid'], u'description': u'Recalculate and update resource count for an account or domain.'}, u'storagenetworkiprange': {u'name': u'updateStorageNetworkIpRange', u'related': [], u'isasync': True, u'params': [{u'name': u'endip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ending IP address'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Optional. the vlan the ip range sits on'}, {u'name': u'netmask', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the netmask for storage network'}, {u'name': u'id', u'required': True, u'related': [u'updateStorageNetworkIpRange'], u'length': 255, u'type': u'uuid', u'description': u'UUID of storage network ip range'}, {u'name': u'startip', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the beginning IP address'}], u'requiredparams': [u'id'], u'description': u'Update a Storage network IP range, only allowed when no IPs in this range have been allocated.'}, u'configuration': {u'name': u'updateConfiguration', u'related': [u'listConfigurations'], u'isasync': False, u'params': [{u'name': u'value', u'required': False, u'related': [], u'length': 4095, u'type': u'string', u'description': u'the value of the configuration'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the configuration'}], u'requiredparams': [u'name'], u'description': u'Updates a configuration.'}, u'templatepermissions': {u'name': u'updateTemplatePermissions', u'related': [], u'isasync': False, u'params': [{u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for featured template/iso, false otherwise'}, {u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template/iso is extractable, false other wise. Can be set only by root admin'}, {u'name': u'projectids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of projects. If specified, "op" parameter has to be passed in.'}, {u'name': u'op', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'permission operator (add, remove, reset)'}, {u'name': u'id', u'required': True, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true for public template/iso, false for private templates/isos'}, {u'name': u'accounts', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'a comma delimited list of accounts. If specified, "op" parameter has to be passed in.'}], u'requiredparams': [u'id'], u'description': u'Updates a template visibility permissions. A public template is visible to all accounts within the same domain. A private template is visible only to the owner of the template. A priviledged template is a private template with account permissions added. Only accounts specified under the template permissions are visible to them.'}, u'autoscalevmprofile': {u'name': u'updateAutoScaleVmProfile', u'related': [u'listAutoScaleVmProfiles'], u'isasync': True, u'params': [{u'name': u'expungevmgraceperiod', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the time allowed for existing connections to get closed before a vm is destroyed'}, {u'name': u'autoscaleuserid', u'required': False, u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the user used to launch and destroy the VMs'}, {u'name': u'templateid', u'required': False, u'related': [u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template of the auto deployed virtual machine'}, {u'name': u'id', u'required': True, u'related': [u'updateAutoScaleVmProfile', u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm profile'}, {u'name': u'counterparam', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161'}], u'requiredparams': [u'id'], u'description': u'Updates an existing autoscale vm profile.'}, u'account': {u'name': u'updateAccount', u'related': [u'markDefaultZoneForAccount', u'listAccounts', u'lockAccount'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain where the account exists'}, {u'name': u'networkdomain', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"Network domain for the account's networks; empty string will update domainName with NULL value"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the current account name'}, {u'name': u'accountdetails', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'details for account used to store specific parameters'}, {u'name': u'newname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'new name for the account'}], u'requiredparams': [u'newname'], u'description': u'Updates account information for the authenticated user'}, u'networkoffering': {u'name': u'updateNetworkOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the network offering, integer'}, {u'name': u'id', u'required': False, u'related': [u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'the id of the network offering'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the display text of the network offering'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the network offering'}, {u'name': u'availability', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the availability of network offering. Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'update state for the network offering'}], u'requiredparams': [], u'description': u'Updates a network offering.'}, u'vpncustomergateway': {u'name': u'updateVpnCustomerGateway', u'related': [u'createVpnCustomerGateway'], u'isasync': True, u'params': [{u'name': u'ikelifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 1 VPN connection to the customer gateway, in seconds'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the gateway. If used with the account parameter returns the gateway associated with the account for the specified domain.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of this customer gateway'}, {u'name': u'id', u'required': True, u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway'], u'length': 255, u'type': u'uuid', u'description': u'id of customer gateway'}, {u'name': u'esplifetime', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lifetime of phase 2 VPN connection to the customer gateway, in seconds'}, {u'name': u'ikepolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IKE policy of the customer gateway'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the gateway. Must be used with the domainId parameter.'}, {u'name': u'esppolicy', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'ESP policy of the customer gateway'}, {u'name': u'gateway', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'public ip address id of the customer gateway'}, {u'name': u'ipsecpsk', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'IPsec Preshared-Key of the customer gateway'}, {u'name': u'dpd', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If DPD is enabled for VPN connection'}, {u'name': u'cidrlist', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'guest cidr of the customer gateway'}], u'requiredparams': [u'id', u'ikepolicy', u'esppolicy', u'gateway', u'ipsecpsk', u'cidrlist'], u'description': u'Update site to site vpn customer gateway'}, u'region': {u'name': u'updateRegion', u'related': [u'addRegion', u'listRegions'], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates region with this name'}, {u'name': u'endpoint', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'updates region with this end point'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Id of region to update'}], u'requiredparams': [u'id'], u'description': u'Updates a region'}, u'project': {u'name': u'updateProject', u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be modified'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'display text of the project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'new Admin account for the project'}], u'requiredparams': [u'id'], u'description': u'Updates a project'}, u'physicalnetwork': {u'name': u'updatePhysicalNetwork', u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'isasync': True, u'params': [{u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the VLAN for the physical network'}, {u'name': u'id', u'required': True, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'physical network id'}, {u'name': u'networkspeed', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the speed for the physical network[1G/10G]'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'Tag the physical network'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enabled/Disabled'}], u'requiredparams': [u'id'], u'description': u'Updates a physical network'}, u'iso': {u'name': u'updateIso', u'related': [u'listIsos'], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the image file'}, {u'name': u'id', u'required': True, u'related': [u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the image file'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the image'}, {u'name': u'format', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the image'}, {u'name': u'sortkey', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'sort key of the template, integer'}, {u'name': u'ostypeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS type that best represents the OS of this image.'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the image supports the password reset feature; default is false'}, {u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if image is bootable, false otherwise'}], u'requiredparams': [u'id'], u'description': u'Updates an ISO file.'}, u'networkserviceprovider': {u'name': u'updateNetworkServiceProvider', u'related': [], u'isasync': True, u'params': [{u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Enabled/Disabled/Shutdown the physical network service provider'}, {u'name': u'id', u'required': True, u'related': [u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'network service provider id'}, {u'name': u'servicelist', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'the list of services to be enabled for this physical network service provider'}], u'requiredparams': [u'id'], u'description': u'Updates a network serviceProvider of a physical network'}, u'autoscalevmgroup': {u'name': u'updateAutoScaleVmGroup', u'related': [], u'isasync': True, u'params': [{u'name': u'scaledownpolicyids', u'required': False, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaledown autoscale policies'}, {u'name': u'interval', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the frequency at which the conditions have to be evaluated'}, {u'name': u'minmembers', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the minimum number of members in the vmgroup, the number of instances in the vm group will be equal to or more than this number.'}, {u'name': u'maxmembers', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the maximum number of members in the vmgroup, The number of instances in the vm group will be equal to or less than this number.'}, {u'name': u'id', u'required': True, u'related': [u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}, {u'name': u'scaleuppolicyids', u'required': False, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'list', u'description': u'list of scaleup autoscale policies'}], u'requiredparams': [u'id'], u'description': u'Updates an existing autoscale vm group.'}}, u'disable': {u'account': {u'name': u'disableAccount', u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'isasync': True, u'params': [{u'name': u'lock', u'required': True, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'If true, only lock the account; else disable the account'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Disables specified account.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'Disables specified account in this domain.'}, {u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'disableAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}], u'requiredparams': [u'lock'], u'description': u'Disables an account'}, u'autoscalevmgroup': {u'name': u'disableAutoScaleVmGroup', u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'disableAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}], u'requiredparams': [u'id'], u'description': u'Disables an AutoScale Vm Group'}, u'cisconexusvsm': {u'name': u'disableCiscoNexusVSM', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableCiscoNexusVSM'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Cisco Nexus 1000v VSM device to be deleted'}], u'requiredparams': [u'id'], u'description': u'disable a Cisco Nexus VSM device'}, u'staticnat': {u'name': u'disableStaticNat', u'related': [], u'isasync': True, u'params': [{u'name': u'ipaddressid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id for which static nat feature is being disableed'}], u'requiredparams': [u'ipaddressid'], u'description': u'Disables static rule for given ip address'}, u'user': {u'name': u'disableUser', u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableUser', u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'Disables user by user ID.'}], u'requiredparams': [u'id'], u'description': u'Disables a user account'}}, u'detach': {u'volume': {u'name': u'detachVolume', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': False, u'related': [u'detachVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'deviceid', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the device ID on the virtual machine where volume is detached from'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'listVirtualMachines'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine where the volume is detached from'}], u'requiredparams': [], u'description': u'Detaches a disk volume from a virtual machine.'}, u'iso': {u'name': u'detachIso', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'virtualmachineid'], u'description': u'Detaches any ISO file (if any) currently attached to a virtual machine.'}}, u'generate': {u'usagerecords': {u'name': u'generateUsageRecords', u'related': [], u'isasync': False, u'params': [{u'name': u'enddate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'End date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'List events for the specified domain.'}, {u'name': u'startdate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'Start date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.'}], u'requiredparams': [u'enddate', u'startdate'], u'description': u'Generates usage records. This will generate records only if there any records to be generated, i.e if the scheduled usage job was not run or failed'}}, u'change': {u'serviceforvirtualmachine': {u'name': u'changeServiceForVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID to apply to the virtual machine'}], u'requiredparams': [u'id', u'serviceofferingid'], u'description': u'Changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" state for this command to take effect.'}, u'serviceforsystemvm': {u'name': u'changeServiceForSystemVm', u'related': [u'rebootSystemVm', u'listSystemVms'], u'isasync': False, u'params': [{u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID to apply to the system vm'}, {u'name': u'id', u'required': True, u'related': [u'rebootSystemVm', u'listSystemVms', u'changeServiceForSystemVm'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the system vm'}], u'requiredparams': [u'serviceofferingid', u'id'], u'description': u'Changes the service offering for a system vm (console proxy or secondary storage). The system vm must be in a "Stopped" state for this command to take effect.'}, u'serviceforrouter': {u'name': u'changeServiceForRouter', u'related': [u'destroyRouter', u'rebootRouter', u'startRouter'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'changeServiceForRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the router'}, {u'name': u'serviceofferingid', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings', u'createServiceOffering', u'updateServiceOffering'], u'length': 255, u'type': u'uuid', u'description': u'the service offering ID to apply to the domain router'}], u'requiredparams': [u'id', u'serviceofferingid'], u'description': u'Upgrades domain router to a new service offering'}}, u'reset': {u'apilimit': {u'name': u'resetApiLimit', u'related': [], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the acount whose limit to be reset'}], u'requiredparams': [], u'description': u'Reset api count'}, u'sshkeyforvirtualmachine': {u'name': u'resetSSHKeyForVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'keypair', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the ssh key pair used to login to the virtual machine'}, {u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the ssh key. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.'}], u'requiredparams': [u'keypair', u'id'], u'description': u'Resets the SSH Key for virtual machine. The virtual machine must be in a "Stopped" state. [async]'}, u'passwordforvirtualmachine': {u'name': u'resetPasswordForVirtualMachine', u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the virtual machine'}], u'requiredparams': [u'id'], u'description': u'Resets the password for virtual machine. The virtual machine must be in a "Stopped" state and the template must already support this feature for this command to take effect. [async]'}, u'vpnconnection': {u'name': u'resetVpnConnection', u'related': [u'listVpnConnections'], u'isasync': True, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for connection. Must be used with domainId.'}, {u'name': u'id', u'required': True, u'related': [u'listVpnConnections', u'resetVpnConnection'], u'length': 255, u'type': u'uuid', u'description': u'id of vpn connection'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for connection. If the account parameter is used, domainId must also be used.'}], u'requiredparams': [u'id'], u'description': u'Reset site to site vpn connection'}}, u'register': {u'userkeys': {u'name': u'registerUserKeys', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers', u'enableUser', u'createUser'], u'length': 255, u'type': u'uuid', u'description': u'User id'}], u'requiredparams': [u'id'], u'description': u'This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user'}, u'iso': {u'name': u'registerIso', u'related': [u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'ostypeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS Type that best represents the OS of this ISO. If the iso is bootable this parameter needs to be passed'}, {u'name': u'checksum', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the MD5 checksum value of this ISO'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the ISO'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId. If the account parameter is used, domainId must also be used.'}, {u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this ISO is bootable. If not passed explicitly its assumed to be true'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'Register iso for the project'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if you want to register the ISO to be publicly available to all users, false otherwise.'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone you wish to register the ISO to.'}, {u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the iso or its derivatives are extractable; default is false'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the ISO. This is usually used for display purposes.'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if you want this ISO to be featured'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL to where the ISO is currently being hosted'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account name. Must be used with domainId.'}], u'requiredparams': [u'name', u'zoneid', u'displaytext', u'url'], u'description': u'Registers an existing ISO into the CloudStack Cloud.'}, u'sshkeypair': {u'name': u'registerSSHKeyPair', u'related': [u'createSSHKeyPair', u'listSSHKeyPairs'], u'isasync': False, u'params': [{u'name': u'publickey', u'required': True, u'related': [], u'length': 5120, u'type': u'string', u'description': u'Public key material of the keypair'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the keypair'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'an optional project for the ssh key'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the ssh key. Must be used with domainId.'}], u'requiredparams': [u'publickey', u'name'], u'description': u'Register a public key in a keypair under a certain name'}, u'template': {u'name': u'registerTemplate', u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'isextractable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template or its derivatives are extractable; default is false'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone the template is to be hosted on'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId. If the account parameter is used, domainId must also be used.'}, {u'name': u'checksum', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the MD5 checksum value of this template'}, {u'name': u'templatetag', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the tag for this template.'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template is available to all accounts; default is true'}, {u'name': u'passwordenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template supports the password reset feature; default is false'}, {u'name': u'displaytext', u'required': True, u'related': [], u'length': 4096, u'type': u'string', u'description': u'the display text of the template. This is usually used for display purposes.'}, {u'name': u'sshkeyenabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the template supports the sshkey upload feature; default is false'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'Register template for the project'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the template'}, {u'name': u'isfeatured', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template is a featured template, false otherwise'}, {u'name': u'format', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the template. Possible values include QCOW2, RAW, and VHD.'}, {u'name': u'requireshvm', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this template requires HVM'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional accountName. Must be used with domainId.'}, {u'name': u'ostypeid', u'required': True, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the OS Type that best represents the OS of this template.'}, {u'name': u'hypervisor', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the target hypervisor for the template'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL of where the template is hosted. Possible URL include http:// and https://'}, {u'name': u'bits', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'32 or 64 bits support. 64 by default'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'Template details in key/value pairs.'}], u'requiredparams': [u'zoneid', u'displaytext', u'name', u'format', u'ostypeid', u'hypervisor', u'url'], u'description': u'Registers an existing template into the CloudStack cloud. '}}, u'list': {u'instancegroups': {u'name': u'listInstanceGroups', u'related': [u'updateInstanceGroup', u'createInstanceGroup'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listInstanceGroups', u'updateInstanceGroup', u'createInstanceGroup'], u'length': 255, u'type': u'uuid', u'description': u'list instance groups by ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list instance groups by name'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists vm groups'}, u'physicalnetworks': {u'name': u'listPhysicalNetworks', u'related': [], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the physical network'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listPhysicalNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list physical network by id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'search by name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists physical networks'}, u'networks': {u'name': u'listNetworks', u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'issystem', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if network is system, false otherwise'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'List networks by VPC'}, {u'name': u'acltype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list networks by ACL (access control list) type. Supported values are Account and Domain'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'specifyipranges', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only networks which support specifying ip ranges'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the network'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'restartrequired', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list networks by restartRequired'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the type of the network. Supported values are: Isolated and Shared'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'list networks by physical network id'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list networks supporting certain services'}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'type of the traffic'}, {u'name': u'id', u'required': False, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list networks by id'}, {u'name': u'canusefordeploy', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list networks available for vm deployment'}, {u'name': u'forvpc', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the network belongs to vpc'}], u'requiredparams': [], u'description': u'Lists all available networks.'}, u'capabilities': {u'name': u'listCapabilities', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'Lists capabilities'}, u'clusters': {u'name': u'listClusters', u'related': [u'updateCluster'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listClusters', u'updateCluster'], u'length': 255, u'type': u'uuid', u'description': u'lists clusters by the cluster ID'}, {u'name': u'managedstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'whether this cluster is managed by cloudstack'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by hypervisor type'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by allocation state'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'lists clusters by Zone ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by the cluster name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'clustertype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists clusters by cluster type'}, {u'name': u'showcapacities', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'flag to display the capacity of the clusters'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'lists clusters by Pod ID'}], u'requiredparams': [], u'description': u'Lists clusters.'}, u'resourcelimits': {u'name': u'listResourceLimits', u'related': [u'updateResourceLimit'], u'isasync': False, u'params': [{u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'resourcetype', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'Type of resource to update. Values are 0, 1, 2, 3, and 4. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create.3 - Snapshot. Number of snapshots a user can create.4 - Template. Number of templates that a user can register/create.'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'Lists resource limits by ID.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists resource limits.'}, u'firewallrules': {u'name': u'listFirewallRules', u'related': [u'createEgressFirewallRule', u'createFirewallRule', u'listEgressFirewallRules'], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'ipaddressid', u'required': False, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the id of IP address of the firwall services'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists all firewall rules for an IP address.'}, u'supportednetworkservices': {u'name': u'listSupportedNetworkServices', u'related': [], u'isasync': False, u'params': [{u'name': u'service', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network service name to list providers and capabilities of'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'provider', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'network service provider name'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists all network services provided by CloudStack or for the given Provider.'}, u'loadbalancerrules': {u'name': u'listLoadBalancerRules', u'related': [u'createLoadBalancerRule', u'updateLoadBalancerRule'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the availability zone ID'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine of the load balancer rule'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'id', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'publicipid', u'required': False, u'related': [u'restartNetwork', u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'the public IP address id of the load balancer rule '}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the load balancer rule'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists load balancer rules.'}, u'autoscalepolicies': {u'name': u'listAutoScalePolicies', u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy'], u'isasync': False, u'params': [{u'name': u'action', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the action to be executed if all the conditions evaluate to true for the specified duration.'}, {u'name': u'id', u'required': False, u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy', u'listAutoScalePolicies'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale policy'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'vmgroupid', u'required': False, u'related': [u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm group'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'conditionid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the condition of the policy'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists autoscale policies.'}, u'niciranvpdevices': {u'name': u'listNiciraNvpDevices', u'related': [u'addNiciraNvpDevice'], u'isasync': False, u'params': [{u'name': u'nvpdeviceid', u'required': False, u'related': [u'addNiciraNvpDevice', u'listNiciraNvpDevices'], u'length': 255, u'type': u'uuid', u'description': u'nicira nvp device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists Nicira NVP devices'}, u'f5loadbalancernetworks': {u'name': u'listF5LoadBalancerNetworks', u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'lbdeviceid', u'required': True, u'related': [u'configureF5LoadBalancer', u'addF5LoadBalancer', u'listF5LoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'f5 load balancer device ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'lbdeviceid'], u'description': u'lists network that are using a F5 load balancer device'}, u'templatepermissions': {u'name': u'listTemplatePermissions', u'related': [u'listIsoPermissions'], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsoPermissions', u'listTemplatePermissions'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}], u'requiredparams': [u'id'], u'description': u'List template visibility and all accounts that have permissions to view this template.'}, u'projects': {u'name': u'listProjects', u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List projects by tags (key/value pairs)'}, {u'name': u'id', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list projects by project ID'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list projects by name'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list projects by state'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list projects by display text'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists projects and provides detailed information for listed projects'}, u'systemvms': {u'name': u'listSystemVms', u'related': [u'rebootSystemVm'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the system VM'}, {u'name': u'hostid', u'required': False, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the host ID of the system VM'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the state of the system VM'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'storageid', u'required': False, u'related': [u'cancelStorageMaintenance'], u'length': 255, u'type': u'uuid', u'description': u"the storage ID where vm's volumes belong to"}, {u'name': u'systemvmtype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the system VM type. Possible types are "consoleproxy" and "secondarystoragevm".'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID of the system VM'}, {u'name': u'id', u'required': False, u'related': [u'rebootSystemVm', u'listSystemVms'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the system VM'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the system VM'}], u'requiredparams': [], u'description': u'List system virtual machines.'}, u'portforwardingrules': {u'name': u'listPortForwardingRules', u'related': [u'listIpForwardingRules', u'createPortForwardingRule'], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'id', u'required': False, u'related': [u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'ipaddressid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of IP address of the port forwarding services'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists all port forwarding rules for an IP address.'}, u'hypervisors': {u'name': u'listHypervisors', u'related': [], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the zone id for listing hypervisors.'}], u'requiredparams': [], u'description': u'List hypervisors'}, u'publicipaddresses': {u'name': u'listPublicIpAddresses', u'related': [u'restartNetwork', u'associateIpAddress'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses by Zone ID'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'allocatedonly', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'limits search results to allocated public IP addresses'}, {u'name': u'id', u'required': False, u'related': [u'restartNetwork', u'listPublicIpAddresses', u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'lists ip address by id'}, {u'name': u'forloadbalancing', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list only ips used for load balancing'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isstaticnat', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list only static nat ip addresses'}, {u'name': u'issourcenat', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list only source nat ip addresses'}, {u'name': u'vlanid', u'required': False, u'related': [u'listVlanIpRanges'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses by VLAN ID'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists the specified IP address'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses by physical network id'}, {u'name': u'associatednetworkid', u'required': False, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'lists all public IP addresses associated to the network specified'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the virtual network for the IP address'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'List ips belonging to the VPC'}], u'requiredparams': [], u'description': u'Lists all public ip addresses'}, u'vpngateways': {u'name': u'listVpnGateways', u'related': [u'createVpnGateway'], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'id', u'required': False, u'related': [u'createVpnGateway', u'listVpnGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the vpn gateway'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'id of vpc'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists site 2 site vpn gateways'}, u'loadbalancerruleinstances': {u'name': u'listLoadBalancerRuleInstances', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'applied', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if listing all virtual machines currently applied to the load balancer rule; default is true'}, {u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'id'], u'description': u'List all virtual machine instances that are assigned to a load balancer rule.'}, u'hosts': {u'name': u'listHosts', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the host'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the state of the host'}, {u'name': u'resourcestate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list hosts by resource state. Resource state represents current state determined by admin of host, valule can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the host'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the host'}, {u'name': u'virtualmachineid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'lists hosts existing in particular cluster'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the host type'}, {u'name': u'id', u'required': False, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the id of the host'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]'}, {u'name': u'hahost', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, list only hosts dedicated to HA'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists hosts.'}, u'pools': {u'name': u'listPools', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'List Pool'}, u'counters': {u'name': u'listCounters', u'related': [], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'source', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Source of the counter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'listCounters'], u'length': 255, u'type': u'uuid', u'description': u'ID of the Counter.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the counter.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'List the counters'}, u'configurations': {u'name': u'listConfigurations', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists configuration by name'}, {u'name': u'category', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists configurations by category'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all configurations.'}, u'usagerecords': {u'name': u'listUsageRecords', u'related': [], u'isasync': False, u'params': [{u'name': u'enddate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'End date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.'}, {u'name': u'startdate', u'required': True, u'related': [], u'length': 255, u'type': u'date', u'description': u'Start date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'List usage records for the specified usage type'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'List usage records for specified project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List usage records for the specified user.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'List usage records for the specified domain.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'accountid', u'required': False, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'List usage records for the specified account'}], u'requiredparams': [u'enddate', u'startdate'], u'description': u'Lists usage records for accounts'}, u'storagepools': {u'name': u'listStoragePools', u'related': [u'cancelStorageMaintenance'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID for the storage pool'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'path', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the storage pool path'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list storage pools belongig to the specific cluster'}, {u'name': u'id', u'required': False, u'related': [u'cancelStorageMaintenance', u'listStoragePools'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the storage pool'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the IP address for the storage pool'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the storage pool'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID for the storage pool'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists storage pools.'}, u'vpncustomergateways': {u'name': u'listVpnCustomerGateways', u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'updateVpnCustomerGateway', u'createVpnCustomerGateway', u'listVpnCustomerGateways'], u'length': 255, u'type': u'uuid', u'description': u'id of the customer gateway'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}], u'requiredparams': [], u'description': u'Lists site to site vpn customer gateways'}, u'zones': {u'name': u'listZones', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone'}, {u'name': u'available', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if you want to retrieve all available Zones. False if you only want to return the Zones from which you have at least one VM. Default is false.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the zone'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain associated with the zone'}, {u'name': u'showcapacities', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'flag to display the capacity of the zones'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists zones'}, u'serviceofferings': {u'name': u'listServiceOfferings', u'related': [u'updateHypervisorCapabilities'], u'isasync': False, u'params': [{u'name': u'systemvmtype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the system VM type. Possible types are "consoleproxy", "secondarystoragevm" or "domainrouter".'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain associated with the service offering'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the service offering'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine. Pass this in if you want to see the available service offering that a virtual machine can be changed to.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'issystem', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'is this a system vm offering'}, {u'name': u'id', u'required': False, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the service offering'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all available service offerings.'}, u'externalfirewalls': {u'name': u'listExternalFirewalls', u'related': [u'addExternalFirewall'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'zoneid', u'required': True, u'related': [u'listZones'], u'length': 255, u'type': u'uuid', u'description': u'zone Id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'zoneid'], u'description': u'List external firewall appliances.'}, u'networkserviceproviders': {u'name': u'listNetworkServiceProviders', u'related': [u'addNetworkServiceProvider', u'listTrafficTypes', u'updateNetworkServiceProvider'], u'isasync': False, u'params': [{u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list providers by state'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list providers by name'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists network serviceproviders for a given physical network.'}, u'capacity': {u'name': u'listCapacity', u'related': [], u'isasync': False, u'params': [{u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'lists capacity by type* CAPACITY_TYPE_MEMORY = 0* CAPACITY_TYPE_CPU = 1* CAPACITY_TYPE_STORAGE = 2* CAPACITY_TYPE_STORAGE_ALLOCATED = 3* CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4* CAPACITY_TYPE_PRIVATE_IP = 5* CAPACITY_TYPE_SECONDARY_STORAGE = 6* CAPACITY_TYPE_VLAN = 7* CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8* CAPACITY_TYPE_LOCAL_STORAGE = 9.'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'lists capacity by the Cluster ID'}, {u'name': u'sortby', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Sort the results. Available values: Usage'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'fetchlatest', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'recalculate capacities and fetch the latest'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'lists capacity by the Zone ID'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'lists capacity by the Pod ID'}], u'requiredparams': [], u'description': u'Lists all the system wide capacities.'}, u'diskofferings': {u'name': u'listDiskOfferings', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the disk offering'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the disk offering'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the domain of the disk offering.'}], u'requiredparams': [], u'description': u'Lists all available disk offerings.'}, u'lbstickinesspolicies': {u'name': u'listLBStickinessPolicies', u'related': [u'createLBStickinessPolicy'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'lbruleid', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [u'lbruleid'], u'description': u'Lists LBStickiness policies.'}, u'srxfirewallnetworks': {u'name': u'listSrxFirewallNetworks', u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'isasync': False, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'addSrxFirewall'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'lbdeviceid'], u'description': u'lists network that are using SRX firewall device'}, u'securitygroups': {u'name': u'listSecurityGroups', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'id', u'required': False, u'related': [u'listSecurityGroups'], u'length': 255, u'type': u'uuid', u'description': u'list the security group by the id provided'}, {u'name': u'securitygroupname', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists security groups by name'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'lists security groups by virtual machine id'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists security groups'}, u'conditions': {u'name': u'listConditions', u'related': [u'listCounters', u'createCounter'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'ID of the Condition.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'counterid', u'required': False, u'related': [u'listConditions', u'listCounters', u'createCounter'], u'length': 255, u'type': u'uuid', u'description': u'Counter-id of the condition.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'policyid', u'required': False, u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the policy'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}], u'requiredparams': [], u'description': u'List Conditions for the specific user'}, u'swifts': {u'name': u'listSwifts', u'related': [u'addHost', u'updateHost', u'listHosts', u'listExternalLoadBalancers'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'the id of the swift'}], u'requiredparams': [], u'description': u'List Swift.'}, u'hypervisorcapabilities': {u'name': u'listHypervisorCapabilities', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listHypervisorCapabilities'], u'length': 255, u'type': u'uuid', u'description': u'ID of the hypervisor capability'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor for which to restrict the search'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists all hypervisor capabilities.'}, u'tags': {u'name': u'listTags', u'related': [], u'isasync': False, u'params': [{u'name': u'resourceid', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by resource id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'resourcetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by resource type'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'key', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by key'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'customer', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by customer name'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'value', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by value'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'List resource tag(s)'}, u'routers': {u'name': u'listRouters', u'related': [u'changeServiceForRouter', u'stopRouter', u'destroyRouter', u'rebootRouter', u'startRouter'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the state of the router'}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'List networks by VPC'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID of the router'}, {u'name': u'hostid', u'required': False, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'the host ID of the router'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the router'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the router'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'addNicToVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk router'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'listNiciraNvpDeviceNetworks', u'updateNetwork', u'listF5LoadBalancerNetworks', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list by network id'}, {u'name': u'forvpc', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true is passed for this parameter, list only VPC routers'}], u'requiredparams': [], u'description': u'List routers.'}, u'traffictypes': {u'name': u'listTrafficTypes', u'related': [u'addNetworkServiceProvider', u'updateNetworkServiceProvider'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': True, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'physicalnetworkid'], u'description': u'Lists traffic types of a given physical network.'}, u'projectinvitations': {u'name': u'listProjectInvitations', u'related': [], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'activeonly', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'if true, list only active invitations - having Pending state and ones that are not timed out yet'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list by project id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list invitations by state'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'listProjectInvitations'], u'length': 255, u'type': u'uuid', u'description': u'list invitations by id'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists projects and provides detailed information for listed projects'}, u'isos': {u'name': u'listIsos', u'related': [], u'isasync': False, u'params': [{u'name': u'bootable', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the ISO is bootable, false otherwise'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list all isos by name'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'list ISO by id'}, {u'name': u'ispublic', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if the ISO is publicly available to all users, false otherwise.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isofilter', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'possible values are "featured", "self", "selfexecutable","sharedexecutable","executable", and "community". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured. * all : all templates (only usable by admins).'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor for which to restrict the search'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'isready', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if this ISO is ready to be deployed'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all available ISO files.'}, u'users': {u'name': u'listUsers', u'related': [], u'isasync': False, u'params': [{u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List user by the username'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'accounttype', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'List users by account type. Valid types include admin, domain-admin, read-only-admin, or user.'}, {u'name': u'id', u'required': False, u'related': [u'listUsers'], u'length': 255, u'type': u'uuid', u'description': u'List user by ID.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List users by state of the user account.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists user accounts'}, u'sshkeypairs': {u'name': u'listSSHKeyPairs', u'related': [], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'fingerprint', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'A public key fingerprint to look for'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'A key pair name to look for'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}], u'requiredparams': [], u'description': u'List registered keypairs'}, u'privategateways': {u'name': u'listPrivateGateways', u'related': [u'createPrivateGateway'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'createPrivateGateway', u'listPrivateGateways'], u'length': 255, u'type': u'uuid', u'description': u'list private gateway by id'}, {u'name': u'ipaddress', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list gateways by ip address'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'list gateways by vpc'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list gateways by state'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list gateways by vlan'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}], u'requiredparams': [], u'description': u'List private gateways'}, u'usagetypes': {u'name': u'listUsageTypes', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'List Usage Types'}, u'domainchildren': {u'name': u'listDomainChildren', u'related': [u'createDomain'], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list children domains by name'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list children domain by parent domain ID.'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'to return the entire tree, use the value "true". To return the first level children, use the value "false".'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all children domains belonging to a specified domain'}, u'domains': {u'name': u'listDomains', u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'List domain by domain ID.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List domain by domain name.'}, {u'name': u'level', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'List domains by domain level.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}], u'requiredparams': [], u'description': u'Lists domains and provides detailed information for listed domains'}, u'externalloadbalancers': {u'name': u'listExternalLoadBalancers', u'related': [u'addHost', u'updateHost', u'listHosts'], u'isasync': False, u'params': [{u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'zone Id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists F5 external load balancer appliances added in a zone.'}, u'netscalerloadbalancers': {u'name': u'listNetscalerLoadBalancers', u'related': [], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'lbdeviceid', u'required': False, u'related': [u'listNetscalerLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'lists netscaler load balancer devices'}, u's3s': {u'name': u'listS3s', u'related': [u'addS3'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists S3s'}, u'bigswitchvnsdevices': {u'name': u'listBigSwitchVnsDevices', u'related': [u'addBigSwitchVnsDevice'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vnsdeviceid', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'bigswitch vns device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}], u'requiredparams': [], u'description': u'Lists BigSwitch Vns devices'}, u'accounts': {u'name': u'listAccounts', u'related': [u'markDefaultZoneForAccount', u'lockAccount'], u'isasync': False, u'params': [{u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list accounts by state. Valid states are enabled, disabled, and locked.'}, {u'name': u'iscleanuprequired', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list accounts by cleanuprequred attribute (values are true or false)'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'accounttype', u'required': False, u'related': [], u'length': 255, u'type': u'long', u'description': u'list accounts by account type. Valid account types are 1 (admin), 2 (domain-admin), and 0 (user).'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'markDefaultZoneForAccount', u'listAccounts', u'lockAccount'], u'length': 255, u'type': u'uuid', u'description': u'list account by account ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list account by account name'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [], u'description': u'Lists accounts and provides detailed account information for listed accounts'}, u'networkdevice': {u'name': u'listNetworkDevice', u'related': [u'addNetworkDevice'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'networkdevicetype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall'}, {u'name': u'networkdeviceparameterlist', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'parameters for network device'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'List network devices'}, u'vlanipranges': {u'name': u'listVlanIpRanges', u'related': [], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'networkid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'network id of the VLAN IP range'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID with which the VLAN IP range is associated. If used with the account parameter, returns all VLAN IP ranges for that account in the specified domain.'}, {u'name': u'id', u'required': False, u'related': [u'listVlanIpRanges'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VLAN IP range'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks'], u'length': 255, u'type': u'uuid', u'description': u'physical network id of the VLAN IP range'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'project who will own the VLAN'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account with which the VLAN IP range is associated. Must be used with the domainId parameter.'}, {u'name': u'vlan', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the ID or VID of the VLAN. Default is an "untagged" VLAN.'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the Pod ID of the VLAN IP range'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Zone ID of the VLAN IP range'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if VLAN is of Virtual type, false if Direct'}], u'requiredparams': [], u'description': u'Lists all VLAN IP ranges.'}, u'traffictypeimplementors': {u'name': u'listTrafficTypeImplementors', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'Optional. The network traffic type, if specified, return its implementor. Otherwise, return all traffic types with their implementor'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists implementors of implementor of a network traffic type or implementors of all network traffic types'}, u'storagenetworkiprange': {u'name': u'listStorageNetworkIpRange', u'related': [u'updateStorageNetworkIpRange'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Zone uuid, if specicied and both pod uuid and range uuid are absent, using it to search the range.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'listStorageNetworkIpRange', u'updateStorageNetworkIpRange'], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Storaget network IP range uuid, if specicied, using it to search the range.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'optional parameter. Pod uuid, if specicied and range uuid is absent, using it to search the range.'}], u'requiredparams': [], u'description': u'List a storage network IP range.'}, u'isopermissions': {u'name': u'listIsoPermissions', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsoPermissions'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}], u'requiredparams': [u'id'], u'description': u'List iso visibility and all accounts that have permissions to view this iso.'}, u'snapshotpolicies': {u'name': u'listSnapshotPolicies', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'volumeid', u'required': True, u'related': [u'detachVolume', u'uploadVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [u'volumeid'], u'description': u'Lists snapshot policies.'}, u'autoscalevmgroups': {u'name': u'listAutoScaleVmGroups', u'related': [u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'isasync': False, u'params': [{u'name': u'policyid', u'required': False, u'related': [u'createAutoScalePolicy', u'updateAutoScalePolicy', u'listAutoScalePolicies'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the policy'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'vmprofileid', u'required': False, u'related': [u'updateAutoScaleVmProfile', u'createAutoScaleVmProfile', u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the profile'}, {u'name': u'lbruleid', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the loadbalancer'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the availability zone ID'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'id', u'required': False, u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm group'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists autoscale vm groups.'}, u'projectaccounts': {u'name': u'listProjectAccounts', u'related': [u'createProject'], u'isasync': False, u'params': [{u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts'], u'length': 255, u'type': u'uuid', u'description': u'id of the project'}, {u'name': u'role', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list accounts of the project by role'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list accounts of the project by account name'}], u'requiredparams': [u'projectid'], u'description': u"Lists project's accounts"}, u'autoscalevmprofiles': {u'name': u'listAutoScaleVmProfiles', u'related': [], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'id', u'required': False, u'related': [u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale vm profile'}, {u'name': u'templateid', u'required': False, u'related': [u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the templateid of the autoscale vm profile'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'otherdeployparams', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the otherdeployparameters of the autoscale vm profile'}], u'requiredparams': [], u'description': u'Lists autoscale vm profiles.'}, u'apis': {u'name': u'listApis', u'related': [], u'isasync': False, u'params': [{u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'API name'}], u'requiredparams': [], u'description': u'lists all available apis on the server, provided by the Api Discovery plugin'}, u'vpcs': {u'name': u'listVPCs', u'related': [u'restartVPC'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'domainid', u'required': False, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by name of the VPC'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'cidr', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u"list by cidr of the VPC. All VPC guest networks' cidrs should be within this CIDR"}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'restartrequired', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list VPCs by restartRequired option'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPCs by state'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by display text of the VPC'}, {u'name': u'id', u'required': False, u'related': [u'restartVPC', u'listVPCs'], u'length': 255, u'type': u'uuid', u'description': u'list VPC by id'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list by zone'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list VPC supporting certain services'}, {u'name': u'vpcofferingid', u'required': False, u'related': [u'listVPCOfferings', u'createVPCOffering'], u'length': 255, u'type': u'uuid', u'description': u'list by ID of the VPC offering'}], u'requiredparams': [], u'description': u'Lists VPCs'}, u'f5loadbalancers': {u'name': u'listF5LoadBalancers', u'related': [u'configureF5LoadBalancer'], u'isasync': False, u'params': [{u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'updatePhysicalNetwork', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'lbdeviceid', u'required': False, u'related': [u'configureF5LoadBalancer', u'listF5LoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'f5 load balancer device ID'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'lists F5 load balancer devices'}, u'snapshots': {u'name': u'listSnapshots', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'id', u'required': False, u'related': [u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'lists snapshot by snapshot ID'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'intervaltype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'valid values are HOURLY, DAILY, WEEKLY, and MONTHLY.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'volumeid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'lists snapshot by snapshot name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'snapshottype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'valid values are MANUAL or RECURRING.'}], u'requiredparams': [], u'description': u'Lists all available snapshots for the account.'}, u'networkofferings': {u'name': u'listNetworkOfferings', u'related': [u'createNetworkOffering', u'updateNetworkOffering'], u'isasync': False, u'params': [{u'name': u'isdefault', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only default network offerings. Default value is false'}, {u'name': u'sourcenatsupported', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only netwok offerings where source nat is supported, false otherwise'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list network offerings supporting certain services'}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network. Pass this in if you want to see the available network offering that a network can be changed to.'}, {u'name': u'specifyipranges', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only network offerings which support specifying ip ranges'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by name'}, {u'name': u'id', u'required': False, u'related': [u'listNetworkOfferings', u'createNetworkOffering', u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'list network offerings by id'}, {u'name': u'specifyvlan', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the tags for the network offering.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'list netowrk offerings available for network creation in specific zone'}, {u'name': u'forvpc', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'the network offering can be used only for network creation inside the VPC'}, {u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by traffic type'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'guestiptype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by guest type: Shared or Isolated'}, {u'name': u'istagged', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if offering has tags specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 4096, u'type': u'string', u'description': u'list network offerings by tags'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by display text'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network offerings by state'}, {u'name': u'availability', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the availability of network offering. Default value is Required'}], u'requiredparams': [], u'description': u'Lists all available network offerings.'}, u'virtualmachines': {u'name': u'listVirtualMachines', u'related': [], u'isasync': False, u'params': [{u'name': u'templateid', u'required': False, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'list vms by template'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'networkid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list by network id'}, {u'name': u'storageid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u"the storage ID where vm's volumes belong to"}, {u'name': u'isoid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list vms by iso'}, {u'name': u'vpcid', u'required': False, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'list vms by vpc'}, {u'name': u'podid', u'required': False, u'related': [u'updatePod'], u'length': 255, u'type': u'uuid', u'description': u'the pod ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the virtual machine'}, {u'name': u'details', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'comma separated list of host details requested, value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min]. If no parameter is passed in, the details will be defaulted to all'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the target hypervisor for the template'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'groupid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the group ID'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the availability zone ID'}, {u'name': u'hostid', u'required': False, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}, {u'name': u'id', u'required': False, u'related': [u'listVirtualMachines'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'forvirtualnetwork', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list by network type; true if need to list vms using Virtual Network, false otherwise'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'state of the virtual machine'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'List the virtual machines owned by the account.'}, u'netscalerloadbalancernetworks': {u'name': u'listNetscalerLoadBalancerNetworks', u'related': [], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'lbdeviceid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}], u'requiredparams': [u'lbdeviceid'], u'description': u'lists network that are using a netscaler load balancer device'}, u'oscategories': {u'name': u'listOsCategories', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listOsCategories'], u'length': 255, u'type': u'uuid', u'description': u'list Os category by id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list os category by name'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists all supported OS categories for this cloud.'}, u'virtualrouterelements': {u'name': u'listVirtualRouterElements', u'related': [u'createVirtualRouterElement', u'configureVirtualRouterElement'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'nspid', u'required': False, u'related': [u'addNetworkServiceProvider', u'listTrafficTypes', u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'list virtual router elements by network service provider id'}, {u'name': u'id', u'required': False, u'related': [u'createVirtualRouterElement', u'configureVirtualRouterElement', u'listVirtualRouterElements'], u'length': 255, u'type': u'uuid', u'description': u'list virtual router elements by id'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'enabled', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'list network offerings by enabled state'}], u'requiredparams': [], u'description': u'Lists all available virtual router elements.'}, u'lunsonfiler': {u'name': u'listLunsOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'poolname'], u'description': u'List LUN'}, u'asyncjobs': {u'name': u'listAsyncJobs', u'related': [u'queryAsyncJobResult'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'startdate', u'required': False, u'related': [], u'length': 255, u'type': u'tzdate', u'description': u'the start date of the async job'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}], u'requiredparams': [], u'description': u'Lists all pending asynchronous jobs for the account.'}, u'ostypes': {u'name': u'listOsTypes', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [u'listOsTypes'], u'length': 255, u'type': u'uuid', u'description': u'list by Os type Id'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'oscategoryid', u'required': False, u'related': [u'listOsCategories'], u'length': 255, u'type': u'uuid', u'description': u'list by Os Category id'}, {u'name': u'description', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list os by description'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all supported OS types for this cloud.'}, u'networkacls': {u'name': u'listNetworkACLs', u'related': [u'createNetworkACL'], u'isasync': False, u'params': [{u'name': u'traffictype', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list network ACLs by traffic type - Ingress or Egress'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'Lists network ACL with the specified ID.'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'networkid', u'required': False, u'related': [u'createNetwork', u'listNiciraNvpDeviceNetworks', u'updateNetwork', u'listF5LoadBalancerNetworks', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'length': 255, u'type': u'uuid', u'description': u'list network ACLs by network Id'}], u'requiredparams': [], u'description': u'Lists all network ACLs'}, u'volumesonfiler': {u'name': u'listVolumesOnFiler', u'related': [], u'isasync': False, u'params': [{u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'poolname'], u'description': u'List Volumes'}, u'eventtypes': {u'name': u'listEventTypes', u'related': [], u'isasync': False, u'params': [], u'requiredparams': [], u'description': u'List Event Types'}, u'remoteaccessvpns': {u'name': u'listRemoteAccessVpns', u'related': [u'createRemoteAccessVpn'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'publicipid', u'required': True, u'related': [u'restartNetwork', u'listPublicIpAddresses', u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn server'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}], u'requiredparams': [u'publicipid'], u'description': u'Lists remote access vpns'}, u'alerts': {u'name': u'listAlerts', u'related': [], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list by alert type'}, {u'name': u'id', u'required': False, u'related': [u'listAlerts'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the alert'}], u'requiredparams': [], u'description': u'Lists all alerts.'}, u'regions': {u'name': u'listRegions', u'related': [u'addRegion'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'List Region by region ID.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List Region by region name.'}], u'requiredparams': [], u'description': u'Lists Regions'}, u'vpcofferings': {u'name': u'listVPCOfferings', u'related': [], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listVPCOfferings'], u'length': 255, u'type': u'uuid', u'description': u'list VPC offerings by id'}, {u'name': u'state', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPC offerings by state'}, {u'name': u'supportedservices', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list VPC offerings supporting certain services'}, {u'name': u'displaytext', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPC offerings by display text'}, {u'name': u'isdefault', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if need to list only default VPC offerings. Default value is false'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list VPC offerings by name'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists VPC offerings'}, u'niciranvpdevicenetworks': {u'name': u'listNiciraNvpDeviceNetworks', u'related': [u'createNetwork', u'updateNetwork', u'listF5LoadBalancerNetworks', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks', u'listNetworks'], u'isasync': False, u'params': [{u'name': u'nvpdeviceid', u'required': True, u'related': [u'addNiciraNvpDevice', u'listNiciraNvpDevices'], u'length': 255, u'type': u'uuid', u'description': u'nicira nvp device ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [u'nvpdeviceid'], u'description': u'lists network that are using a nicira nvp device'}, u'events': {u'name': u'listEvents', u'related': [], u'isasync': False, u'params': [{u'name': u'startdate', u'required': False, u'related': [], u'length': 255, u'type': u'date', u'description': u'the start date range of the list you want to retrieve (use format "yyyy-MM-dd" or the new format "yyyy-MM-dd HH:mm:ss")'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'enddate', u'required': False, u'related': [], u'length': 255, u'type': u'date', u'description': u'the end date range of the list you want to retrieve (use format "yyyy-MM-dd" or the new format "yyyy-MM-dd HH:mm:ss")'}, {u'name': u'duration', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the duration of the event'}, {u'name': u'id', u'required': False, u'related': [u'listEvents'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the event'}, {u'name': u'level', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the event level (INFO, WARN, ERROR)'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'entrytime', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'the time the event was entered'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the event type (see event types)'}], u'requiredparams': [], u'description': u'A command to list events.'}, u'templates': {u'name': u'listTemplates', u'related': [u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'isasync': False, u'params': [{u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'templatefilter', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'possible values are "featured", "self", "selfexecutable","sharedexecutable","executable", and "community". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured. * all : all templates (only usable by admins).'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listTemplates', u'registerIso', u'updateTemplate', u'prepareTemplate', u'copyIso', u'updateIso', u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the template ID'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the template name'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'hypervisor', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the hypervisor for which to restrict the search'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'list templates by zoneId'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}], u'requiredparams': [u'templatefilter'], u'description': u'List all public, private, and privileged templates.'}, u'cisconexusvsms': {u'name': u'listCiscoNexusVSMs', u'related': [u'disableCiscoNexusVSM', u'enableCiscoNexusVSM'], u'isasync': False, u'params': [{u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'clusterid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.'}], u'requiredparams': [], u'description': u'Retrieves a Cisco Nexus 1000v Virtual Switch Manager device associated with a Cluster'}, u'ipforwardingrules': {u'name': u'listIpForwardingRules', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'id', u'required': False, u'related': [u'listIpForwardingRules'], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'listVirtualMachines', u'destroyVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Lists all rules applied to the specified Vm.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'ipaddressid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list the rule belonging to this public ip address'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}], u'requiredparams': [], u'description': u'List the ip forwarding rules'}, u'srxfirewalls': {u'name': u'listSrxFirewalls', u'related': [u'addSrxFirewall'], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'physicalnetworkid', u'required': False, u'related': [u'listPhysicalNetworks', u'createPhysicalNetwork'], u'length': 255, u'type': u'uuid', u'description': u'the Physical Network ID'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'fwdeviceid', u'required': False, u'related': [u'listSrxFirewalls', u'addSrxFirewall'], u'length': 255, u'type': u'uuid', u'description': u'SRX firewall device ID'}], u'requiredparams': [], u'description': u'lists SRX firewall devices in a physical network'}, u'vpnconnections': {u'name': u'listVpnConnections', u'related': [], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'id of vpc'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'id', u'required': False, u'related': [u'listVpnConnections'], u'length': 255, u'type': u'uuid', u'description': u'id of the vpn connection'}], u'requiredparams': [], u'description': u'Lists site to site vpn connection gateways'}, u'trafficmonitors': {u'name': u'listTrafficMonitors', u'related': [], u'isasync': False, u'params': [{u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'zoneid', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'zone Id'}], u'requiredparams': [u'zoneid'], u'description': u'List traffic monitor Hosts.'}, u'vpnusers': {u'name': u'listVpnUsers', u'related': [], u'isasync': False, u'params': [{u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'id', u'required': False, u'related': [u'listVpnUsers'], u'length': 255, u'type': u'uuid', u'description': u'The uuid of the Vpn user'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'username', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the username of the vpn user.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}], u'requiredparams': [], u'description': u'Lists vpn users'}, u'egressfirewallrules': {u'name': u'listEgressFirewallRules', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'networkid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id network network for the egress firwall services'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Lists rule with the specified ID.'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'ipaddressid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the id of IP address of the firwall services'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}], u'requiredparams': [], u'description': u'Lists all egress firewall rules for network id.'}, u'staticroutes': {u'name': u'listStaticRoutes', u'related': [u'createStaticRoute'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'gatewayid', u'required': False, u'related': [u'createPrivateGateway'], u'length': 255, u'type': u'uuid', u'description': u'list static routes by gateway id'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'vpcid', u'required': False, u'related': [u'updateVPC', u'restartVPC', u'listVPCs', u'createVPC'], u'length': 255, u'type': u'uuid', u'description': u'list static routes by vpc id'}, {u'name': u'id', u'required': False, u'related': [u'createStaticRoute', u'listStaticRoutes'], u'length': 255, u'type': u'uuid', u'description': u'list static route by id'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}], u'requiredparams': [], u'description': u'Lists all static routes'}, u'volumes': {u'name': u'listVolumes', u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'uploadVolume', u'createVolume'], u'isasync': False, u'params': [{u'name': u'isrecursive', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the disk volume'}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'listProjects', u'suspendProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'list objects by project'}, {u'name': u'hostid', u'required': False, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addSecondaryStorage', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers', u'prepareHostForMaintenance'], u'length': 255, u'type': u'uuid', u'description': u'list volumes on specified host'}, {u'name': u'id', u'required': False, u'related': [u'migrateVolume', u'detachVolume', u'resizeVolume', u'attachVolume', u'listVolumes', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the disk volume'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'List resources by tags (key/value pairs)'}, {u'name': u'zoneid', u'required': False, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the availability zone'}, {u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'list only resources belonging to the domain specified'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list resources by account. Must be used with the domainId parameter.'}, {u'name': u'virtualmachineid', u'required': False, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'rebootVirtualMachine', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'attachIso', u'listLoadBalancerRuleInstances', u'deployVirtualMachine', u'detachIso', u'resetSSHKeyForVirtualMachine', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the virtual machine'}, {u'name': u'type', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the type of disk volume'}, {u'name': u'listall', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"}, {u'name': u'podid', u'required': False, u'related': [u'createPod', u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the pod id the disk volume belongs to'}], u'requiredparams': [], u'description': u'Lists all volumes.'}, u'pods': {u'name': u'listPods', u'related': [u'updatePod'], u'isasync': False, u'params': [{u'name': u'showcapacities', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'flag to display the capacity of the pods'}, {u'name': u'allocationstate', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list pods by allocation state'}, {u'name': u'pagesize', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'list Pods by Zone ID'}, {u'name': u'id', u'required': False, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'list Pods by ID'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'list Pods by name'}, {u'name': u'page', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u''}, {u'name': u'keyword', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'List by keyword'}], u'requiredparams': [], u'description': u'Lists all Pods.'}}, u'upload': {u'volume': {u'name': u'uploadVolume', u'related': [u'detachVolume'], u'isasync': True, u'params': [{u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the name of the volume'}, {u'name': u'format', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the format for the volume. Possible values include QCOW2, OVA, and VHD.'}, {u'name': u'url', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'the URL of where the volume is hosted. Possible URL include http:// and https://'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional accountName. Must be used with domainId.'}, {u'name': u'domainid', u'required': False, u'related': [u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId. If the account parameter is used, domainId must also be used.'}, {u'name': u'checksum', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the MD5 checksum value of this volume'}, {u'name': u'zoneid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone the volume is to be hosted on'}], u'requiredparams': [u'name', u'format', u'url', u'zoneid'], u'description': u'Uploads a data disk.'}, u'customcertificate': {u'name': u'uploadCustomCertificate', u'related': [], u'isasync': True, u'params': [{u'name': u'domainsuffix', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'DNS domain suffix that the certificate is granted for.'}, {u'name': u'certificate', u'required': True, u'related': [], u'length': 65535, u'type': u'string', u'description': u'The certificate to be uploaded.'}, {u'name': u'privatekey', u'required': False, u'related': [], u'length': 65535, u'type': u'string', u'description': u'The private key for the attached certificate.'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'A name / alias for the certificate.'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'integer', u'description': u'An integer providing the location in a chain that the certificate will hold. Usually, this can be left empty. When creating a chain, the top level certificate should have an ID of 1, with each step in the chain incrementing by one. Example, CA with id = 1, Intermediate CA with id = 2, Site certificate with ID = 3'}], u'requiredparams': [u'domainsuffix', u'certificate'], u'description': u'Uploads a custom certificate for the console proxy VMs to use for SSL. Can be used to upload a single certificate signed by a known CA. Can also be used, through multiple calls, to upload a chain of certificates from CA to the custom certificate itself.'}}, u'remove': {u'region': {u'name': u'removeRegion', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'integer', u'description': u'ID of the region to delete'}], u'requiredparams': [u'id'], u'description': u'Removes specified region'}, u'nicfromvirtualmachine': {u'name': u'removeNicFromVirtualMachine', u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': True, u'params': [{u'name': u'nicid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'NIC ID'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'startVirtualMachine', u'updateDefaultNicForVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'resetPasswordForVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'removeNicFromVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'Virtual Machine ID'}], u'requiredparams': [u'nicid', u'virtualmachineid'], u'description': u'Removes VM from specified network by deleting a NIC'}, u'fromloadbalancerrule': {u'name': u'removeFromLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIpForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the load balancer rule'}, {u'name': u'virtualmachineids', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the virtual machines that are being removed from the load balancer rule (i.e. virtualMachineIds=1,2,3)'}], u'requiredparams': [u'id', u'virtualmachineids'], u'description': u'Removes a virtual machine or a list of virtual machines from a load balancer rule.'}, u'vpnuser': {u'name': u'removeVpnUser', u'related': [], u'isasync': True, u'params': [{u'name': u'domainid', u'required': False, u'related': [u'updateDomain', u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.'}, {u'name': u'projectid', u'required': False, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'remove vpn user from the project'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'an optional account for the vpn user. Must be used with domainId.'}, {u'name': u'username', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'username for the vpn user'}], u'requiredparams': [u'username'], u'description': u'Removes vpn user'}}, u'asyncapis': [u'createCondition', u'reconnectHost', u'copyTemplate', u'deleteBigSwitchVnsDevice', u'addNicToVirtualMachine', u'extractVolume', u'addAccountToProject', u'deleteEgressFirewallRule', u'deleteCiscoNexusVSM', u'createVpnConnection', u'suspendProject', u'addF5LoadBalancer', u'deleteAutoScaleVmGroup', u'authorizeSecurityGroupIngress', u'addNetscalerLoadBalancer', u'deleteDomain', u'configureNetscalerLoadBalancer', u'disableAutoScaleVmGroup', u'authorizeSecurityGroupEgress', u'createTemplate', u'migrateVolume', u'updatePhysicalNetwork', u'prepareHostForMaintenance', u'deletePrivateGateway', u'deleteStaticRoute', u'deleteTrafficType', u'deleteLoadBalancerRule', u'attachIso', u'destroySystemVm', u'deletePortForwardingRule', u'enableStorageMaintenance', u'stopRouter', u'configureSrxFirewall', u'attachVolume', u'updateVPCOffering', u'resetSSHKeyForVirtualMachine', u'updateProjectInvitation', u'createTags', u'enableAutoScaleVmGroup', u'deleteTags', u'deleteAccountFromProject', u'removeVpnUser', u'updateVpnCustomerGateway', u'stopSystemVm', u'uploadCustomCertificate', u'restartNetwork', u'createAutoScaleVmProfile', u'rebootVirtualMachine', u'enableCiscoNexusVSM', u'cancelHostMaintenance', u'deleteStorageNetworkIpRange', u'deleteFirewallRule', u'deleteVpnConnection', u'startSystemVm', u'deleteF5LoadBalancer', u'deleteNiciraNvpDevice', u'updateProject', u'deleteNetwork', u'deleteProject', u'deleteNetscalerLoadBalancer', u'deleteIpForwardingRule', u'addTrafficType', u'disableUser', u'resizeVolume', u'configureVirtualRouterElement', u'createStaticRoute', u'deleteProjectInvitation', u'migrateSystemVm', u'activateProject', u'removeNicFromVirtualMachine', u'revokeSecurityGroupIngress', u'updateDefaultNicForVirtualMachine', u'disableStaticNat', u'createNetworkACL', u'createVPC', u'configureF5LoadBalancer', u'disassociateIpAddress', u'createIpForwardingRule', u'createVolume', u'resetPasswordForVirtualMachine', u'assignToLoadBalancerRule', u'startRouter', u'extractIso', u'deleteRemoteAccessVpn', u'resetVpnConnection', u'createRemoteAccessVpn', u'extractTemplate', u'startVirtualMachine', u'detachIso', u'updateVPC', u'deleteAccount', u'associateIpAddress', u'updateAutoScaleVmProfile', u'disableAccount', u'updatePortForwardingRule', u'migrateVirtualMachine', u'createStorageNetworkIpRange', u'cancelStorageMaintenance', u'deployVirtualMachine', u'removeFromLoadBalancerRule', u'revokeSecurityGroupEgress', u'deleteCondition', u'createPortForwardingRule', u'addVpnUser', u'createVPCOffering', u'createEgressFirewallRule', u'deleteLBStickinessPolicy', u'destroyRouter', u'createPrivateGateway', u'disableCiscoNexusVSM', u'deleteAutoScaleVmProfile', u'updateTrafficType', u'deleteSnapshot', u'createProject', u'createLoadBalancerRule', u'addSrxFirewall', u'addNiciraNvpDevice', u'createAutoScalePolicy', u'restoreVirtualMachine', u'copyIso', u'uploadVolume', u'createLBStickinessPolicy', u'stopVirtualMachine', u'createCounter', u'createSnapshot', u'destroyVirtualMachine', u'updateNetwork', u'deleteVpnGateway', u'createAutoScaleVmGroup', u'rebootRouter', u'deleteNetworkServiceProvider', u'deleteIso', u'createVpnCustomerGateway', u'createFirewallRule', u'deleteAutoScalePolicy', u'deleteSrxFirewall', u'addNetworkServiceProvider', u'rebootSystemVm', u'detachVolume', u'deleteNetworkACL', u'markDefaultZoneForAccount', u'deleteVPC', u'restartVPC', u'updateAutoScaleVmGroup', u'updateLoadBalancerRule', u'createPhysicalNetwork', u'deleteTemplate', u'deletePhysicalNetwork', u'deleteVpnCustomerGateway', u'deleteVPCOffering', u'createVirtualRouterElement', u'updateAutoScalePolicy', u'addBigSwitchVnsDevice', u'createVpnGateway', u'updateNetworkServiceProvider', u'deleteCounter', u'updateStorageNetworkIpRange'], u'assign': {u'toloadbalancerrule': {u'name': u'assignToLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'virtualmachineids', u'required': True, u'related': [u'startVirtualMachine', u'updateVirtualMachine', u'stopVirtualMachine', u'recoverVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'migrateVirtualMachine', u'changeServiceForVirtualMachine', u'deployVirtualMachine', u'detachIso', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'list', u'description': u'the list of IDs of the virtual machine that are being assigned to the load balancer rule(i.e. virtualMachineIds=1,2,3)'}, {u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'virtualmachineids', u'id'], u'description': u'Assigns virtual machine or a list of virtual machines to a load balancer rule.'}, u'virtualmachine': {u'name': u'assignVirtualMachine', u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'isasync': False, u'params': [{u'name': u'networkids', u'required': False, u'related': [u'updateNetwork', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'list', u'description': u'list of new network ids in which the moved VM will participate. In case no network ids are provided the VM will be part of the default network for that zone. In case there is no network yet created for the new account the default network will be created.'}, {u'name': u'domainid', u'required': True, u'related': [u'listDomainChildren', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'domain id of the new VM owner.'}, {u'name': u'securitygroupids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of security group ids to be applied on the virtual machine. In case no security groups are provided the VM is part of the default security group.'}, {u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'account name of the new VM owner.'}, {u'name': u'virtualmachineid', u'required': True, u'related': [u'updateVirtualMachine', u'stopVirtualMachine', u'assignVirtualMachine', u'listVirtualMachines', u'destroyVirtualMachine', u'restoreVirtualMachine'], u'length': 255, u'type': u'uuid', u'description': u'id of the VM to be moved'}], u'requiredparams': [u'domainid', u'account', u'virtualmachineid'], u'description': u'Assign a VM from one account to another under the same domain. This API is available for Basic zones with security groups and Advance zones with guest networks. The VM is restricted to move between accounts under same domain.'}}, u'delete': {u'loadbalancerrule': {u'name': u'deleteLoadBalancerRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the load balancer rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a load balancer rule.'}, u'domain': {u'name': u'deleteDomain', u'related': [], u'isasync': True, u'params': [{u'name': u'cleanup', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'true if all domain resources (child domains, accounts) have to be cleaned up, false otherwise'}, {u'name': u'id', u'required': True, u'related': [u'updateDomain', u'listDomainChildren', u'listDomains', u'createDomain'], u'length': 255, u'type': u'uuid', u'description': u'ID of domain to delete'}], u'requiredparams': [u'id'], u'description': u'Deletes a specified domain'}, u'instancegroup': {u'name': u'deleteInstanceGroup', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the instance group'}], u'requiredparams': [u'id'], u'description': u'Deletes a vm group'}, u'diskoffering': {u'name': u'deleteDiskOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateDiskOffering', u'createDiskOffering', u'listDiskOfferings'], u'length': 255, u'type': u'uuid', u'description': u'ID of the disk offering'}], u'requiredparams': [u'id'], u'description': u'Updates a disk offering.'}, u'externalloadbalancer': {u'name': u'deleteExternalLoadBalancer', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listSwifts', u'addHost', u'cancelHostMaintenance', u'addBaremetalHost', u'updateHost', u'addSwift', u'listHosts', u'listExternalLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'Id of the external loadbalancer appliance.'}], u'requiredparams': [u'id'], u'description': u'Deletes a F5 external load balancer appliance added in a zone.'}, u'securitygroup': {u'name': u'deleteSecurityGroup', u'related': [], u'isasync': False, u'params': [{u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID of account owning the security group'}, {u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'The ID of the security group. Mutually exclusive with name parameter'}, {u'name': u'name', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'The ID of the security group. Mutually exclusive with id parameter'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account of the security group. Must be specified with domain ID'}, {u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the project of the security group'}], u'requiredparams': [], u'description': u'Deletes security group'}, u'portforwardingrule': {u'name': u'deletePortForwardingRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the port forwarding rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a port forwarding rule'}, u'cluster': {u'name': u'deleteCluster', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the cluster ID'}], u'requiredparams': [u'id'], u'description': u'Deletes a cluster.'}, u'accountfromproject': {u'name': u'deleteAccountFromProject', u'related': [], u'isasync': True, u'params': [{u'name': u'projectid', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject', u'updateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to remove the account from'}, {u'name': u'account', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'name of the account to be removed from the project'}], u'requiredparams': [u'projectid', u'account'], u'description': u'Deletes account from the project'}, u'networkdevice': {u'name': u'deleteNetworkDevice', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'addHost', u'updateHost', u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Id of network device to delete'}], u'requiredparams': [u'id'], u'description': u'Deletes network device.'}, u'firewallrule': {u'name': u'deleteFirewallRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the firewall rule'}], u'requiredparams': [u'id'], u'description': u'Deletes a firewall rule'}, u'pod': {u'name': u'deletePod', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePod', u'listPods'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Pod'}], u'requiredparams': [u'id'], u'description': u'Deletes a Pod.'}, u'ipforwardingrule': {u'name': u'deleteIpForwardingRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the id of the forwarding rule'}], u'requiredparams': [u'id'], u'description': u'Deletes an ip forwarding rule'}, u'vpnconnection': {u'name': u'deleteVpnConnection', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listVpnConnections', u'resetVpnConnection'], u'length': 255, u'type': u'uuid', u'description': u'id of vpn connection'}], u'requiredparams': [u'id'], u'description': u'Delete site to site vpn connection'}, u'lbstickinesspolicy': {u'name': u'deleteLBStickinessPolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createLBStickinessPolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the LB stickiness policy'}], u'requiredparams': [u'id'], u'description': u'Deletes a LB stickiness policy.'}, u'vpcoffering': {u'name': u'deleteVPCOffering', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VPC offering'}], u'requiredparams': [u'id'], u'description': u'Deletes VPC offering'}, u'network': {u'name': u'deleteNetwork', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateNetwork', u'listSrxFirewallNetworks', u'listNetscalerLoadBalancerNetworks'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network'}], u'requiredparams': [u'id'], u'description': u'Deletes a network'}, u'zone': {u'name': u'deleteZone', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateZone', u'listZones', u'createZone'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Zone'}], u'requiredparams': [u'id'], u'description': u'Deletes a Zone.'}, u'remoteaccessvpn': {u'name': u'deleteRemoteAccessVpn', u'related': [], u'isasync': True, u'params': [{u'name': u'publicipid', u'required': True, u'related': [u'associateIpAddress'], u'length': 255, u'type': u'uuid', u'description': u'public ip address id of the vpn server'}], u'requiredparams': [u'publicipid'], u'description': u'Destroys a l2tp/ipsec remote access vpn'}, u'storagenetworkiprange': {u'name': u'deleteStorageNetworkIpRange', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listStorageNetworkIpRange', u'createStorageNetworkIpRange', u'updateStorageNetworkIpRange'], u'length': 255, u'type': u'uuid', u'description': u'the uuid of the storage network ip range'}], u'requiredparams': [u'id'], u'description': u'Deletes a storage network IP Range.'}, u'bigswitchvnsdevice': {u'name': u'deleteBigSwitchVnsDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'vnsdeviceid', u'required': True, u'related': [], u'length': 255, u'type': u'long', u'description': u'BigSwitch device ID'}], u'requiredparams': [u'vnsdeviceid'], u'description': u' delete a bigswitch vns device'}, u'projectinvitation': {u'name': u'deleteProjectInvitation', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listProjectInvitations'], u'length': 255, u'type': u'uuid', u'description': u'id of the invitation'}], u'requiredparams': [u'id'], u'description': u'Accepts or declines project invitation'}, u'autoscalepolicy': {u'name': u'deleteAutoScalePolicy', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateAutoScalePolicy'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale policy'}], u'requiredparams': [u'id'], u'description': u'Deletes a autoscale policy.'}, u'niciranvpdevice': {u'name': u'deleteNiciraNvpDevice', u'related': [], u'isasync': True, u'params': [{u'name': u'nvpdeviceid', u'required': True, u'related': [u'addNiciraNvpDevice', u'listNiciraNvpDevices'], u'length': 255, u'type': u'uuid', u'description': u'Nicira device ID'}], u'requiredparams': [u'nvpdeviceid'], u'description': u' delete a nicira nvp device'}, u'serviceoffering': {u'name': u'deleteServiceOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'updateHypervisorCapabilities', u'listServiceOfferings'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the service offering'}], u'requiredparams': [u'id'], u'description': u'Deletes a service offering.'}, u'condition': {u'name': u'deleteCondition', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the condition.'}], u'requiredparams': [u'id'], u'description': u'Removes a condition'}, u'storagepool': {u'name': u'deleteStoragePool', u'related': [], u'isasync': False, u'params': [{u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force destroy storage pool (force expunge volumes in Destroyed state as a part of pool removal)'}, {u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'Storage pool id'}], u'requiredparams': [u'id'], u'description': u'Deletes a storage pool.'}, u'vpngateway': {u'name': u'deleteVpnGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createVpnGateway'], u'length': 255, u'type': u'uuid', u'description': u'id of customer gateway'}], u'requiredparams': [u'id'], u'description': u'Delete site to site vpn gateway'}, u'snapshot': {u'name': u'deleteSnapshot', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createSnapshot', u'listSnapshots'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the snapshot'}], u'requiredparams': [u'id'], u'description': u'Deletes a snapshot of a disk volume.'}, u'autoscalevmgroup': {u'name': u'deleteAutoScaleVmGroup', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listAutoScaleVmGroups', u'createAutoScaleVmGroup', u'disableAutoScaleVmGroup', u'enableAutoScaleVmGroup', u'updateAutoScaleVmGroup'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale group'}], u'requiredparams': [u'id'], u'description': u'Deletes a autoscale vm group.'}, u'trafficmonitor': {u'name': u'deleteTrafficMonitor', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Traffic Monitor Host.'}], u'requiredparams': [u'id'], u'description': u'Deletes an traffic monitor host.'}, u'networkacl': {u'name': u'deleteNetworkACL', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network ACL'}], u'requiredparams': [u'id'], u'description': u'Deletes a Network ACL'}, u'template': {u'name': u'deleteTemplate', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the template'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of zone of the template'}], u'requiredparams': [u'id'], u'description': u'Deletes a template from the system. All virtual machines using the deleted template will not be affected.'}, u'tags': {u'name': u'deleteTags', u'related': [], u'isasync': True, u'params': [{u'name': u'resourceids', u'required': True, u'related': [], u'length': 255, u'type': u'list', u'description': u'Delete tags for resource id(s)'}, {u'name': u'tags', u'required': False, u'related': [], u'length': 255, u'type': u'map', u'description': u'Delete tags matching key/value pairs'}, {u'name': u'resourcetype', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Delete tag by resource type'}], u'requiredparams': [u'resourceids', u'resourcetype'], u'description': u'Deleting resource tag(s)'}, u'snapshotpolicies': {u'name': u'deleteSnapshotPolicies', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the Id of the snapshot policy'}, {u'name': u'ids', u'required': False, u'related': [], u'length': 255, u'type': u'list', u'description': u'list of snapshots policy IDs separated by comma'}], u'requiredparams': [], u'description': u'Deletes snapshot policies for the account.'}, u'privategateway': {u'name': u'deletePrivateGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createPrivateGateway', u'listPrivateGateways'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the private gateway'}], u'requiredparams': [u'id'], u'description': u'Deletes a Private gateway'}, u'traffictype': {u'name': u'deleteTrafficType', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'addTrafficType', u'updateTrafficType'], u'length': 255, u'type': u'uuid', u'description': u'traffic type id'}], u'requiredparams': [u'id'], u'description': u'Deletes traffic type of a physical network'}, u'host': {u'name': u'deleteHost', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the host ID'}, {u'name': u'forcedestroylocalstorage', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force destroy local storage on this host. All VMs created on this local storage will be destroyed'}, {u'name': u'forced', u'required': False, u'related': [], u'length': 255, u'type': u'boolean', u'description': u'Force delete the host. All HA enabled vms running on the host will be put to HA; HA disabled ones will be stopped'}], u'requiredparams': [u'id'], u'description': u'Deletes a host.'}, u'staticroute': {u'name': u'deleteStaticRoute', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createStaticRoute', u'listStaticRoutes'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the static route'}], u'requiredparams': [u'id'], u'description': u'Deletes a static route'}, u'vpc': {u'name': u'deleteVPC', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'restartVPC'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the VPC'}], u'requiredparams': [u'id'], u'description': u'Deletes a VPC'}, u'srxfirewall': {u'name': u'deleteSrxFirewall', u'related': [], u'isasync': True, u'params': [{u'name': u'fwdeviceid', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'srx firewall device ID'}], u'requiredparams': [u'fwdeviceid'], u'description': u' delete a SRX firewall device'}, u'externalfirewall': {u'name': u'deleteExternalFirewall', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listHosts'], u'length': 255, u'type': u'uuid', u'description': u'Id of the external firewall appliance.'}], u'requiredparams': [u'id'], u'description': u'Deletes an external firewall appliance.'}, u'pool': {u'name': u'deletePool', u'related': [], u'isasync': False, u'params': [{u'name': u'poolname', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'pool name.'}], u'requiredparams': [u'poolname'], u'description': u'Delete a pool'}, u'autoscalevmprofile': {u'name': u'deleteAutoScaleVmProfile', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listAutoScaleVmProfiles'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the autoscale profile'}], u'requiredparams': [u'id'], u'description': u'Deletes a autoscale vm profile.'}, u'volume': {u'name': u'deleteVolume', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'detachVolume', u'resizeVolume', u'uploadVolume', u'createVolume'], u'length': 255, u'type': u'uuid', u'description': u'The ID of the disk volume'}], u'requiredparams': [u'id'], u'description': u'Deletes a detached disk volume.'}, u'account': {u'name': u'deleteAccount', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'markDefaultZoneForAccount', u'updateAccount', u'listAccounts', u'lockAccount', u'disableAccount'], u'length': 255, u'type': u'uuid', u'description': u'Account id'}], u'requiredparams': [u'id'], u'description': u'Deletes a account, and all users associated with this account'}, u'cisconexusvsm': {u'name': u'deleteCiscoNexusVSM', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'disableCiscoNexusVSM', u'listCiscoNexusVSMs', u'enableCiscoNexusVSM'], u'length': 255, u'type': u'uuid', u'description': u'Id of the Cisco Nexus 1000v VSM device to be deleted'}], u'requiredparams': [u'id'], u'description': u' delete a Cisco Nexus VSM device'}, u'netscalerloadbalancer': {u'name': u'deleteNetscalerLoadBalancer', u'related': [], u'isasync': True, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'listNetscalerLoadBalancers'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}], u'requiredparams': [u'lbdeviceid'], u'description': u' delete a netscaler load balancer device'}, u'networkoffering': {u'name': u'deleteNetworkOffering', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'createNetworkOffering', u'updateNetworkOffering'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network offering'}], u'requiredparams': [u'id'], u'description': u'Deletes a network offering.'}, u'vpncustomergateway': {u'name': u'deleteVpnCustomerGateway', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'id of customer gateway'}], u'requiredparams': [u'id'], u'description': u'Delete site to site vpn customer gateway'}, u'counter': {u'name': u'deleteCounter', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the counter'}], u'requiredparams': [u'id'], u'description': u'Deletes a counter'}, u'physicalnetwork': {u'name': u'deletePhysicalNetwork', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the Physical network'}], u'requiredparams': [u'id'], u'description': u'Deletes a Physical Network.'}, u'project': {u'name': u'deleteProject', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'createProject', u'listProjectAccounts', u'activateProject'], u'length': 255, u'type': u'uuid', u'description': u'id of the project to be deleted'}], u'requiredparams': [u'id'], u'description': u'Deletes a project'}, u'vlaniprange': {u'name': u'deleteVlanIpRange', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'listVlanIpRanges'], u'length': 255, u'type': u'uuid', u'description': u'the id of the VLAN IP range'}], u'requiredparams': [u'id'], u'description': u'Creates a VLAN IP range.'}, u'f5loadbalancer': {u'name': u'deleteF5LoadBalancer', u'related': [], u'isasync': True, u'params': [{u'name': u'lbdeviceid', u'required': True, u'related': [u'configureF5LoadBalancer'], u'length': 255, u'type': u'uuid', u'description': u'netscaler load balancer device ID'}], u'requiredparams': [u'lbdeviceid'], u'description': u' delete a F5 load balancer device'}, u'iso': {u'name': u'deleteIso', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'listIsos'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the ISO file'}, {u'name': u'zoneid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the ID of the zone of the ISO file. If not specified, the ISO will be deleted from all the zones'}], u'requiredparams': [u'id'], u'description': u'Deletes an ISO file.'}, u'egressfirewallrule': {u'name': u'deleteEgressFirewallRule', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'updatePortForwardingRule', u'listIpForwardingRules', u'createIpForwardingRule', u'listPortForwardingRules', u'createPortForwardingRule'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the firewall rule'}], u'requiredparams': [u'id'], u'description': u'Deletes an ggress firewall rule'}, u'networkserviceprovider': {u'name': u'deleteNetworkServiceProvider', u'related': [], u'isasync': True, u'params': [{u'name': u'id', u'required': True, u'related': [u'addNetworkServiceProvider', u'listTrafficTypes', u'updateNetworkServiceProvider'], u'length': 255, u'type': u'uuid', u'description': u'the ID of the network service provider'}], u'requiredparams': [u'id'], u'description': u'Deletes a Network Service Provider.'}, u'sshkeypair': {u'name': u'deleteSSHKeyPair', u'related': [], u'isasync': False, u'params': [{u'name': u'projectid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the project associated with keypair'}, {u'name': u'domainid', u'required': False, u'related': [], u'length': 255, u'type': u'uuid', u'description': u'the domain ID associated with the keypair'}, {u'name': u'name', u'required': True, u'related': [], u'length': 255, u'type': u'string', u'description': u'Name of the keypair'}, {u'name': u'account', u'required': False, u'related': [], u'length': 255, u'type': u'string', u'description': u'the account associated with the keypair. Must be used with the domainId parameter.'}], u'requiredparams': [u'name'], u'description': u'Deletes a keypair by name'}, u'user': {u'name': u'deleteUser', u'related': [], u'isasync': False, u'params': [{u'name': u'id', u'required': True, u'related': [u'lockUser', u'listUsers'], u'length': 255, u'type': u'uuid', u'description': u'id of the user to be deleted'}], u'requiredparams': [u'id'], u'description': u'Deletes a user for an account'}}} diff --git a/tools/ngui/static/bootstrap/img/glyphicons-halflings-white.png b/tools/ngui/static/bootstrap/img/glyphicons-halflings-white.png index 3bf6484a29d..484e020c0ac 100644 Binary files a/tools/ngui/static/bootstrap/img/glyphicons-halflings-white.png and b/tools/ngui/static/bootstrap/img/glyphicons-halflings-white.png differ diff --git a/tools/ngui/static/bootstrap/img/glyphicons-halflings.png b/tools/ngui/static/bootstrap/img/glyphicons-halflings.png index a9969993201..b794a671407 100644 Binary files a/tools/ngui/static/bootstrap/img/glyphicons-halflings.png and b/tools/ngui/static/bootstrap/img/glyphicons-halflings.png differ diff --git a/tools/pom.xml b/tools/pom.xml index cda560bd94d..00f055a42d4 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.22.0.0-SNAPSHOT + 4.23.0.0-SNAPSHOT ../pom.xml diff --git a/ui/README.md b/ui/README.md index c794c22b182..170232b574e 100644 --- a/ui/README.md +++ b/ui/README.md @@ -1,3 +1,22 @@ + + # CloudStack UI A modern role-based progressive CloudStack UI based on Vue.js and Ant Design. diff --git a/ui/docs/customize.md b/ui/docs/customize.md index 1e0688e3370..5a3807e41d7 100644 --- a/ui/docs/customize.md +++ b/ui/docs/customize.md @@ -1,3 +1,22 @@ + + # UI customization Use a `public/config.json` (or `dist/config.json` after build) file for customizing theme, logos,... diff --git a/ui/docs/development.md b/ui/docs/development.md index 8b1f67b7c42..363c6a3795b 100644 --- a/ui/docs/development.md +++ b/ui/docs/development.md @@ -1,3 +1,22 @@ + + # UI Development The modern CloudStack UI is role-based progressive app that uses Vue.js and Ant Design. diff --git a/ui/docs/screenshot-dashboard.png b/ui/docs/screenshot-dashboard.png index 875bc2c5c13..a0143d5fc1e 100644 Binary files a/ui/docs/screenshot-dashboard.png and b/ui/docs/screenshot-dashboard.png differ diff --git a/ui/public/assets/403.png b/ui/public/assets/403.png index 5ce416c1e64..49e7daa8c43 100644 Binary files a/ui/public/assets/403.png and b/ui/public/assets/403.png differ diff --git a/ui/public/assets/404.png b/ui/public/assets/404.png index 4720b6840b0..36d5ee460c2 100644 Binary files a/ui/public/assets/404.png and b/ui/public/assets/404.png differ diff --git a/ui/public/assets/500.png b/ui/public/assets/500.png index bdb941817aa..d4c6c222dad 100644 Binary files a/ui/public/assets/500.png and b/ui/public/assets/500.png differ diff --git a/ui/public/assets/bg-what-is-cloudstack.png b/ui/public/assets/bg-what-is-cloudstack.png index db657dcf607..d4d7a03c0b3 100644 Binary files a/ui/public/assets/bg-what-is-cloudstack.png and b/ui/public/assets/bg-what-is-cloudstack.png differ diff --git a/ui/public/assets/error.png b/ui/public/assets/error.png index 25d69745eee..a1f39d4cc31 100644 Binary files a/ui/public/assets/error.png and b/ui/public/assets/error.png differ diff --git a/ui/public/assets/success.png b/ui/public/assets/success.png index fdfef8cd72b..613acfb344f 100644 Binary files a/ui/public/assets/success.png and b/ui/public/assets/success.png differ diff --git a/ui/public/config.json b/ui/public/config.json index 582f968ec0e..1a7beda654e 100644 --- a/ui/public/config.json +++ b/ui/public/config.json @@ -104,6 +104,7 @@ "showUserCategoryForModernImageSelection": true, "showAllCategoryForModernImageSelection": false, "docHelpMappings": {}, + "notifyLatestCSVersion": true, "announcementBanner": { "enabled": false, "showIcon": false, diff --git a/ui/public/locales/de_DE.json b/ui/public/locales/de_DE.json index d99ba4157df..2fee9202163 100644 --- a/ui/public/locales/de_DE.json +++ b/ui/public/locales/de_DE.json @@ -2078,7 +2078,7 @@ "message.success.create.internallb": "Interne LB erfolgreich erstellt", "message.success.create.isolated.network": "Isoliertes Netzwerk erfolgreich erstellt", "message.success.create.keypair": "SSH-Schlüsselpaar erfolgreich erstellt", -"message.success.create.kubernetes.cluter": "Kubernetes Cluster erfolgreich erstellt", +"message.success.create.kubernetes.cluster": "Kubernetes Cluster erfolgreich erstellt", "message.success.create.l2.network": "L2 Netzwerk erfolgreich erstellt", "message.success.create.volume": "Speicher erfolgreich erstellt", "message.success.delete": "Erfolgreich gelöscht", diff --git a/ui/public/locales/el_GR.json b/ui/public/locales/el_GR.json index 3c0cd6a1706..bb90661d9d3 100644 --- a/ui/public/locales/el_GR.json +++ b/ui/public/locales/el_GR.json @@ -2570,7 +2570,7 @@ "message.success.create.internallb": "Η εσωτερική lb ολοκληρώθηκε με επιτυχία", "message.success.create.isolated.network": "Δημιουργήθηκε με επιτυχία απομονωμένο δίκτυο", "message.success.create.keypair": "Δημιουργήθηκε με επιτυχία ζεύγος κλειδιών SSH", -"message.success.create.kubernetes.cluter": "Δημιουργήθηκε με επιτυχία την ομάδαΚυβερνητών", +"message.success.create.kubernetes.cluster": "Δημιουργήθηκε με επιτυχία την ομάδαΚυβερνητών", "message.success.create.l2.network": "Δημιουργήθηκε με επιτυχία το δίκτυο L2", "message.success.create.snapshot.from.vmsnapshot": "Επιτυχής δημιουργία στιγμιότυπου από στιγμιότυπο εικονικής μηχανής", "message.success.create.user": "Ο χρήστης δημιουργήθηκε με επιτυχία", diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index 3cd8e8335ba..028406bbc68 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -78,6 +78,8 @@ "label.action.copy.iso": "Copy ISO", "label.action.copy.snapshot": "Copy Snapshot", "label.action.copy.template": "Copy Template", +"label.action.create.backup.schedule": "Create Backup Schedule", +"label.action.create.recurring.snapshot": "Create Recurring Snapshot", "label.action.create.snapshot.from.vmsnapshot": "Create Snapshot from Instance Snapshot", "label.action.create.template.from.volume": "Create Template from volume", "label.action.create.volume": "Create Volume", @@ -455,6 +457,7 @@ "label.backup.restore": "Restore Instance backup", "label.backup.schedule.create.failed": "Failed to create Backup Schedule", "label.backuplimit": "Backup Limits", +"label.backup.schedules": "Backup Schedules", "label.backup.storage": "Backup Storage", "label.backupstoragelimit": "Backup Storage Limits (GiB)", "label.backupofferingid": "Backup Offering ID", @@ -632,6 +635,7 @@ "label.continue": "Continue", "label.continue.install": "Continue with installation", "label.controlnodes": "Control nodes", +"label.conversionhost": "Conversion Host", "label.copied.clipboard": "Copied to clipboard", "label.copy": "Copy", "label.copy.clipboard": "Copy to clipboard", @@ -694,8 +698,11 @@ "label.cron": "Cron expression", "label.cron.mode": "Cron mode", "label.crosszones": "Cross Zones", +"label.csienabled": "CSI Enabled", "label.currency": "Currency", "label.current": "Current", +"label.currentstep": "Current step", +"label.currentstep.duration": "Current step duration", "label.current.storage": "Current storage", "label.currentpassword": "Current password", "label.custom": "Custom", @@ -749,6 +756,7 @@ "label.delete.asnrange": "Delete AS Range", "label.delete.autoscale.vmgroup": "Delete AutoScaling Group", "label.delete.backup": "Delete backup", +"label.delete.backup.schedule": "Delete backup schedule", "label.delete.bgp.peer": "Delete BGP peer", "label.delete.bigswitchbcf": "Remove BigSwitch BCF controller", "label.delete.brocadevcs": "Remove Brocade Vcs switch", @@ -969,6 +977,7 @@ "label.elastic": "Elastic", "label.email": "Email", "label.enable.autoscale.vmgroup": "Enable AutoScaling Group", +"label.enable.csi": "Enable CloudStack CSI Driver", "label.enable.custom.action": "Enable Custom Action", "label.enable.extension": "Enable Extension", "label.enable.host": "Enable Host", @@ -1085,6 +1094,7 @@ "label.forcks": "For CKS", "label.forbidden": "Forbidden", "label.forced": "Force", +"label.force.convert.to.pool": "Force converting to storage pool directly (not using temporary storage for conversion)", "label.force.ms.to.import.vm.files": "Enable to force OVF Download via Management Server. Disable to use KVM Host ovftool (if installed)", "label.force.update.os.type": "Force update OS type", "label.force.stop": "Force stop", @@ -1211,6 +1221,7 @@ "label.hourly": "Hourly", "label.hypervisor": "Hypervisor", "label.hypervisor.capabilities": "Hypervisor Capabilities", +"label.hypervisor.default": "Hypervisor default", "label.hypervisor.type": "Hypervisor type", "label.hypervisors": "Hypervisors", "label.hypervisorsnapshotreserve": "Hypervisor Snapshot reserve", @@ -1238,6 +1249,7 @@ "label.import.instance": "Import Instance", "label.import.offering": "Import Offering", "label.import.role": "Import Role", +"label.import.vm.tasks": "Import VM Tasks", "label.import.volume": "Import Volume", "label.inactive": "Inactive", "label.inbuilt": "Inbuilt", @@ -1249,8 +1261,8 @@ "label.ingest.instance": "Ingest Instance", "label.ingress": "Ingress", "label.ingress.rule": "Ingress Rule", -"label.initial": "Inital", -"label.initialized": "Initalized", +"label.initial": "Initial", +"label.initialized": "Initialized", "label.insideportprofile": "Inside port profile", "label.installwizard.addzoneintro.title": "Let's add a Zone", "label.installwizard.subtitle": "This guide will aid you in setting up your CloudStack™ installation", @@ -1401,6 +1413,7 @@ "label.kubernetes.version.add": "Add Kubernetes version", "label.kubernetes.version.delete": "Delete Kubernetes version", "label.kubernetes.version.update": "Manage Kubernetes version", +"label.kubernetes.version.from.local": "Add Kubernetes version from local", "label.kubernetesversionid": "Kubernetes version", "label.kubernetesversionname": "Kubernetes version", "label.kvm": "KVM", @@ -1509,7 +1522,7 @@ "label.max.primary.storage": "Max. primary (GiB)", "label.max.secondary.storage": "Max. secondary (GiB)", "label.max.migrations": "Max. migrations", -"label.maxbackup": "Max. Backups", +"label.maxbackups": "Max. Backups", "label.maxbackupstorage": "Max. Backup Storage (GiB)", "label.maxbackups.to.retain": "Max. Backups to retain", "label.maxbucket": "Max. Buckets", @@ -1535,6 +1548,7 @@ "label.maxresolutiony": "Max. resolution Y", "label.maxsecondarystorage": "Max. secondary storage (GiB)", "label.maxsize": "Maximum size", +"label.maxsnaps": "Max. Snapshots", "label.maxsnapshot": "Max. Snapshots", "label.maxtemplate": "Max. Templates", "label.maxuservm": "Max. User Instances", @@ -1945,7 +1959,7 @@ "label.publicnetwork": "Public Network", "label.publicport": "Public port", "label.purgeresources": "Purge Resources", -"label.purge.usage.records.success": "Successfuly purged usage records", +"label.purge.usage.records.success": "Successfully purged usage records", "label.purge.usage.records.error": "Failed while purging usage records", "label.purpose": "Purpose", "label.qostype": "QoS type", @@ -2213,6 +2227,8 @@ "label.select.root.disk": "Select the ROOT disk", "label.select.source.vcenter.datacenter": "Select the source VMware vCenter Datacenter", "label.select.tier": "Select Network Tier", +"label.select.vm": "Select Instance", +"label.select.volume": "Select Volume", "label.select.zones": "Select zones", "label.select.storagepools": "Select storage pools", "label.select.2fa.provider": "Select the provider", @@ -2283,6 +2299,8 @@ "label.snapshot.name": "Snapshot name", "label.snapshotlimit": "Snapshot limits", "label.snapshotmemory": "Snapshot memory", +"label.snapshotpolicy": "Snapshot policy", +"label.snapshotpolicies": "Snapshot policies", "label.snapshots": "Volume Snapshots", "label.snapshottype": "Snapshot Type", "label.sockettimeout": "Socket timeout", @@ -2300,6 +2318,7 @@ "label.sourcenattype": "Supported source NAT type", "label.sourceport": "Source port", "label.sourcetype": "Source type", +"label.sourcevmname": "Source VM Name", "label.specifyasnumber": "Specify AS Number", "label.specifyipranges": "Specify IP ranges", "label.specifyvlan": "Specify VLAN", @@ -2604,7 +2623,7 @@ "label.upload.icon": "Upload icon", "label.upload.iso.from.local": "Upload ISO from local", "label.upload.resource.icon": "Upload icon", -"label.upload.ssl.certificate": "Upload SSL cerficicate", +"label.upload.ssl.certificate": "Upload SSL certificate", "label.upload.template.from.local": "Upload Template from local", "label.upload.volume": "Upload volume", "label.upload.volume.from.local": "Upload Volume from local", @@ -2813,7 +2832,7 @@ "label.windows": "Windows", "label.with.snapshotid": "with Snapshot ID", "label.write": "Write", -"label.writeback": "Write-back disk caching", +"label.writeback": "Write-back", "label.writecachetype": "Write-cache Type", "label.writeio": "Write (IO)", "label.writethrough": "Write-through", @@ -2867,6 +2886,7 @@ "label.leaseexpiryaction": "Lease expiry action", "label.remainingdays": "Lease", "label.leased": "Leased", +"label.totalduration": "Total duration", "label.usestoragereplication": "Use primary storage replication", "message.acquire.ip.failed": "Failed to acquire IP.", "message.action.acquire.ip": "Please confirm that you want to acquire new IP.", @@ -2875,10 +2895,13 @@ "message.action.create.snapshot.from.vmsnapshot": "Please confirm that you want to create Snapshot from Instance Snapshot", "message.action.create.instance.from.backup": "Please confirm that you want to create a new Instance from the given Backup.
Click on configure to edit the parameters for the new Instance before creation.", "message.create.instance.from.backup.different.zone": "Creating Instance from Backup on a different Zone. Please ensure that the backup repository is accessible in the selected Zone.", +"message.template.ostype.different.from.backup": "Selected Template has a different OS type than the Backup. Please proceed with caution.", +"message.iso.ostype.different.from.backup": "Selected ISO has a different OS type than the Backup. Please proceed with caution.", "message.action.delete.asnrange": "Please confirm the AS range that you want to delete", "message.action.delete.autoscale.vmgroup": "Please confirm that you want to delete this autoscaling group.", "message.action.delete.backup.offering": "Please confirm that you want to delete this backup offering?", "message.action.delete.backup.repository": "Please confirm that you want to delete this backup repository?", +"message.action.delete.backup.schedule": "Please confirm that you want to delete this backup schedule?", "message.action.delete.cluster": "Please confirm that you want to delete this Cluster.", "message.action.delete.custom.action": "Please confirm that you want to delete this custom action.", "message.action.delete.domain": "Please confirm that you want to delete this domain.", @@ -2904,6 +2927,7 @@ "message.action.delete.secondary.storage": "Please confirm that you want to delete this secondary storage.", "message.action.delete.security.group": "Please confirm that you want to delete this security group.", "message.action.delete.snapshot": "Please confirm that you want to delete this Snapshot.", +"message.action.delete.snapshot.policy": "Please confirm that you want to delete the selected Snapshot Policy.", "message.action.delete.template": "Please confirm that you want to delete this Template.", "message.action.delete.tungsten.router.table": "Please confirm that you want to remove Route Table from this Network?", "message.action.delete.vgpu.profile": "Please confirm that you want to delete this vGPU profile.", @@ -3097,7 +3121,7 @@ "message.change.offering.confirm": "Please confirm that you wish to change the service offering of this virtual Instance.", "message.change.offering.for.volume": "Successfully changed offering for the volume", "message.change.offering.for.volume.failed": "Change offering for the volume failed", -"message.change.offering.processing": "Changing offering for the volume...", +"message.change.offering.for.volume.processing": "Changing offering for the volume...", "message.change.password": "Please change your password.", "message.change.scope.failed": "Scope change failed", "message.change.scope.processing": "Scope change in progress", @@ -3506,6 +3530,7 @@ "message.host.dedication.released": "Host dedication released.", "message.host.external.datadisk": "Usage of data disks for the selected template is not applicable", "message.import.running.instance.warning": "The selected VM is powered-on on the VMware Datacenter. The recommended state to convert a VMware VM into KVM is powered-off after a graceful shutdown of the guest OS.", +"message.import.vm.tasks": "Import from VMware to KVM tasks", "message.import.volume": "Please specify the domain, account or project name.
If not set, the volume will be imported for the caller.", "message.info.cloudian.console": "Cloudian Management Console should open in another window.", "message.installwizard.cloudstack.helptext.website": " * Project website:\t ", @@ -3720,8 +3745,10 @@ "message.select.deselect.desired.options": "Please select / deselect the desired options", "message.select.deselect.to.sort": "Please select / deselect to sort the values", "message.select.destination.image.stores": "Please select Image Store(s) to which data is to be migrated to", +"message.select.destination.storage.instance.conversion": "(Optional) Select a Primary Storage destination for the converted disks", "message.select.disk.offering": "Please select a disk offering for disk", "message.select.end.date.and.time": "Select an end date & time.", +"message.select.extra.parameters.for.instance.conversion": "(Optional) Pass extra parameters to the virt-v2v command on the conversion host", "message.select.kvm.host.instance.conversion": "(Optional) Select a KVM host in the Zone to perform the instance conversion through virt-v2v", "message.select.kvm.host.instance.import": "(Optional) Select a KVM host in the Cluster to perform the importing of the converted instance", "message.select.load.balancer.rule": "Please select a load balancer rule for your AutoScale Instance group.", @@ -3729,7 +3756,9 @@ "message.select.nic.network": "Please select a Network for NIC", "message.select.security.groups": "Please select security group(s) for your new Instance.", "message.select.start.date.and.time": "Select a start date & time.", -"message.select.temporary.storage.instance.conversion": "(Optional) Select a Storage temporary destination for the converted disks through virt-v2v", +"message.select.temporary.storage.instance.conversion": "(Optional) Select a staging storage for the converted disks", +"message.select.volume.to.continue": "Please select a volume to continue.", +"message.select.vm.to.continue": "Please select an Instance to continue.", "message.select.zone.description": "Select type of Zone basic/advanced.", "message.select.zone.hint": "This is the type of Zone deployment that you want to use. Basic zone: provides a single Network where each Instance is assigned an IP directly from the Network. Guest isolation can be provided through layer-3 means such as security groups (IP address source filtering). Advanced zone: For more sophisticated Network topologies. This Network model provides the most flexibility in defining guest Networks and providing custom Network offerings such as firewall, VPN, or load balancer support.", "message.server": "Server : ", @@ -3792,7 +3821,6 @@ "message.success.assign.vm": "Successfully assigned Instance", "message.success.apply.network.policy": "Successfully applied Network Policy", "message.success.apply.tungsten.tag": "Successfully applied Tag", -"message.success.asign.vm": "Successfully assigned Instance", "message.success.assigned.vms": "Successfully assigned Instances", "message.success.certificate.upload": "Certificate successfully uploaded", "message.success.change.affinity.group": "Successfully changed affinity groups", @@ -3815,7 +3843,7 @@ "message.success.create.internallb": "Successfully created Internal Load Balancer", "message.success.create.isolated.network": "Successfully created isolated Network", "message.success.create.keypair": "Successfully created SSH key pair", -"message.success.create.kubernetes.cluter": "Successfully created Kubernetes Cluster", +"message.success.create.kubernetes.cluster": "Successfully created Kubernetes Cluster", "message.success.create.l2.network": "Successfully created L2 Network", "message.success.create.snapshot.from.vmsnapshot": "Successfully created Snapshot from Instance Snapshot", "message.success.create.template": "Successfully created Template", @@ -3891,7 +3919,7 @@ "message.success.unmanage.gpu.devices": "Successfully unmanaged GPU device(s)", "message.success.unmanage.instance": "Successfully unmanaged Instance", "message.success.unmanage.volume": "Successfully unmanaged Volume", -"message.success.unregister.extension": "Successfull unregistered Extension", +"message.success.unregister.extension": "Successfully unregistered Extension", "message.success.update.account": "Successfully updated Account", "message.success.update.bgp.peer": "Successfully updated BGP peer", "message.success.update.bucket": "Successfully updated bucket", diff --git a/ui/public/locales/ja_JP.json b/ui/public/locales/ja_JP.json index 734a0ea851d..850264fb341 100644 --- a/ui/public/locales/ja_JP.json +++ b/ui/public/locales/ja_JP.json @@ -3328,7 +3328,7 @@ "message.success.create.internallb": "正常に作成された内部LB", "message.success.create.isolated.network": "正常に作成された隔離ネットワーク", "message.success.create.keypair": "SSHキーペアが正常に作成されました", - "message.success.create.kubernetes.cluter": "正常に作成されたKubernetesクラスター", + "message.success.create.kubernetes.cluster": "正常に作成されたKubernetesクラスター", "message.success.create.l2.network": "正常に作成されたL2ネットワーク", "message.success.create.snapshot.from.vmsnapshot": "VMスナップショットからスナップショットを正常に作成しました", "message.success.create.user": "正常に作成されたユーザー", diff --git a/ui/public/locales/ko_KR.json b/ui/public/locales/ko_KR.json index 1f20c95438d..a951b859b48 100644 --- a/ui/public/locales/ko_KR.json +++ b/ui/public/locales/ko_KR.json @@ -2196,7 +2196,7 @@ "message.success.create.internallb": "\ub0b4\ubd80 LB\ub97c \uc0dd\uc131\ud588\uc2b5\ub2c8\ub2e4.", "message.success.create.isolated.network": "isolated \ub124\ud2b8\uc6cc\ud06c\ub97c \uc0dd\uc131\ud588\uc2b5\ub2c8\ub2e4.", "message.success.create.keypair": "SSH \ud0a4 \uc30d\uc744 \uc0dd\uc131\ud588\uc2b5\ub2c8\ub2e4.", -"message.success.create.kubernetes.cluter": "\ucfe0\ubc84\ub124\ud14c\uc2a4 \ud074\ub7ec\uc2a4\ud130\ub97c \uc0dd\uc131\ud588\uc2b5\ub2c8\ub2e4.", +"message.success.create.kubernetes.cluster": "\ucfe0\ubc84\ub124\ud14c\uc2a4 \ud074\ub7ec\uc2a4\ud130\ub97c \uc0dd\uc131\ud588\uc2b5\ub2c8\ub2e4.", "message.success.create.l2.network": "L2 \ub124\ud2b8\uc6cc\ud06c\ub97c \uc0dd\uc131\ud588\uc2b5\ub2c8\ub2e4.", "message.success.create.snapshot.from.vmsnapshot": "VM \uc2a4\ub0c5\uc0f7\uc5d0\uc11c \uc2a4\ub0c5\uc0f7\uc744 \uc0dd\uc131\ud588\uc2b5\ub2c8\ub2e4.", "message.success.create.user": "\uc0ac\uc6a9\uc790\uac00 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4.", diff --git a/ui/public/locales/pt_BR.json b/ui/public/locales/pt_BR.json index 711dd36deff..4346f1f0bb7 100644 --- a/ui/public/locales/pt_BR.json +++ b/ui/public/locales/pt_BR.json @@ -773,6 +773,7 @@ "label.hourly": "A cada hora", "label.hypervisor": "Virtualizador", "label.hypervisor.capabilities": "Recursos do virtualizador", +"label.hypervisor.default": "Padr\u00e3o do virtualizador", "label.hypervisor.type": "Tipo do virtualizador", "label.hypervisors": "Virtualizadores", "label.hypervisorsnapshotreserve": "Reserva de snapshot do virtualizador", @@ -1813,7 +1814,7 @@ "label.windows": "Windows", "label.with.snapshotid": "com o ID da snapshot", "label.write": "Escreva", -"label.writeback": "Cache de disco write-back", +"label.writeback": "Write-back", "label.writecachetype": "Tipo do cache de escrita", "label.writeio": "Escrita (IO)", "label.writethrough": "Write-through", @@ -2400,7 +2401,7 @@ "message.success.create.internallb": "LB interno criado com sucesso", "message.success.create.isolated.network": "Rede isolada criada com sucesso", "message.success.create.keypair": "Par de chaves SSH criado com sucesso", -"message.success.create.kubernetes.cluter": "Cluster Kubernetes criado com sucesso", +"message.success.create.kubernetes.cluster": "Cluster Kubernetes criado com sucesso", "message.success.create.l2.network": "Rede L2 criada com sucesso", "message.success.create.snapshot.from.vmsnapshot": "Snapshot de volume a partir da snapshot de VM criada com sucesso", "message.success.create.user": "Usu\u00e1rio criado com sucesso", diff --git a/ui/public/locales/te.json b/ui/public/locales/te.json index 5f89bbf7ed7..ed72626e0a6 100644 --- a/ui/public/locales/te.json +++ b/ui/public/locales/te.json @@ -3451,7 +3451,6 @@ "message.success.assign.vm": "విజయవంతంగా కేటాయించబడిన ఉదాహరణ", "message.success.apply.network.policy": "నెట్‌వర్క్ పాలసీ విజయవంతంగా వర్తింపజేయబడింది", "message.success.apply.tungsten.tag": "ట్యాగ్ విజయవంతంగా వర్తింపజేయబడింది", - "message.success.asign.vm": "విజయవంతంగా కేటాయించబడిన ఉదాహరణ", "message.success.assigned.vms": "సందర్భాలు విజయవంతంగా కేటాయించబడ్డాయి", "message.success.certificate.upload": "సర్టిఫికెట్ విజయవంతంగా అప్‌లోడ్ చేయబడింది", "message.success.change.affinity.group": "అనుబంధ సమూహాలు విజయవంతంగా మార్చబడ్డాయి", @@ -3472,7 +3471,7 @@ "message.success.create.internallb": "ఇంటర్నల్ లోడ్ బ్యాలెన్సర్ విజయవంతంగా సృష్టించబడింది", "message.success.create.isolated.network": "ఐసోలేటెడ్ నెట్‌వర్క్ విజయవంతంగా సృష్టించబడింది", "message.success.create.keypair": "SSH కీ జత విజయవంతంగా సృష్టించబడింది", - "message.success.create.kubernetes.cluter": "Kubernetes క్లస్టర్ విజయవంతంగా సృష్టించబడింది", + "message.success.create.kubernetes.cluster": "Kubernetes క్లస్టర్ విజయవంతంగా సృష్టించబడింది", "message.success.create.l2.network": "L2 నెట్‌వర్క్ విజయవంతంగా సృష్టించబడింది", "message.success.create.snapshot.from.vmsnapshot": "ఇన్‌స్టాన్స్ స్నాప్‌షాట్ నుండి స్నాప్‌షాట్ విజయవంతంగా సృష్టించబడింది", "message.success.create.template": "టెంప్లేట్ విజయవంతంగా సృష్టించబడింది", diff --git a/ui/public/locales/zh_CN.json b/ui/public/locales/zh_CN.json index 02149360841..4b68a2ef6d7 100644 --- a/ui/public/locales/zh_CN.json +++ b/ui/public/locales/zh_CN.json @@ -3792,7 +3792,7 @@ "message.success.create.internallb": "\u5DF2\u6210\u529F\u521B\u5EFA\u5185\u90E8LB", "message.success.create.isolated.network": "\u5DF2\u6210\u529F\u521B\u5EFA\u9694\u79BB\u7F51\u7EDC", "message.success.create.keypair": "\u5DF2\u6210\u529F\u521B\u5EFA SSH \u5BC6\u94A5\u5BF9", - "message.success.create.kubernetes.cluter": "\u5DF2\u6210\u529F\u521B\u5EFA Kubernetes \u96C6\u7FA4", + "message.success.create.kubernetes.cluster": "\u5DF2\u6210\u529F\u521B\u5EFA Kubernetes \u96C6\u7FA4", "message.success.create.l2.network": "\u5DF2\u6210\u529F\u521B\u5EFA L2 \u7F51\u7EDC", "message.success.create.snapshot.from.vmsnapshot": "\u5DF2\u6210\u529F\u4ECE\u865A\u62DF\u673A\u5FEB\u7167\u521B\u5EFA\u5FEB\u7167", "message.success.create.user": "\u5DF2\u6210\u529F\u521B\u5EFA\u7528\u6237", diff --git a/ui/src/assets/icons/kubernetes.svg b/ui/src/assets/icons/kubernetes.svg new file mode 100644 index 00000000000..51d8f490353 --- /dev/null +++ b/ui/src/assets/icons/kubernetes.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/src/components/header/CreateMenu.vue b/ui/src/components/header/CreateMenu.vue index 8c39ec5b8a0..aa1d020bdb6 100644 --- a/ui/src/components/header/CreateMenu.vue +++ b/ui/src/components/header/CreateMenu.vue @@ -26,7 +26,7 @@ @@ -50,6 +50,8 @@ + + diff --git a/ui/src/views/compute/wizard/OsBasedImageSelection.vue b/ui/src/views/compute/wizard/OsBasedImageSelection.vue index 6a52eea207b..680922752f7 100644 --- a/ui/src/views/compute/wizard/OsBasedImageSelection.vue +++ b/ui/src/views/compute/wizard/OsBasedImageSelection.vue @@ -47,7 +47,7 @@ @change="handleGuestOsCategoryChange">
- - {{ extenstionBasePath }} + + {{ extensionBasePath }} @@ -207,8 +208,9 @@ export default { this.fetchTimeZone = debounce(this.fetchTimeZone, 800) return { loading: false, - domain: { loading: false }, + domain: { id: null, loading: false }, domainsList: [], + dom: null, roleLoading: false, roles: [], timeZoneLoading: false, @@ -227,14 +229,35 @@ export default { computed: { samlAllowed () { return 'authorizeSamlSso' in this.$store.getters.apis + }, + selectedDomain () { + return this.domainsList.find(domain => domain.id === this.form.domainid) + }, + isNonRootDomain () { + if (!this.selectedDomain) return false + return this.selectedDomain.level > 0 && this.selectedDomain.path !== 'ROOT' + } + }, + watch: { + 'form.domainid': { + handler (newDomainId, oldDomainId) { + if (newDomainId && this.roles.length > 0) { + this.$nextTick(() => { + this.setDefaultRole() + }) + } + }, + immediate: false } }, methods: { initForm () { + var domId = this.$route.query.domainid || this.$store.getters.userInfo.domainid this.formRef = ref() this.form = reactive({ - domainid: this.$store.getters.userInfo.domainid + domainid: domId }) + this.domain.id = domId this.rules = reactive({ roleid: [{ required: true, message: this.$t('message.error.select') }], username: [{ required: true, message: this.$t('message.error.required.input') }], @@ -263,9 +286,36 @@ export default { isDomainAdmin () { return this.$store.getters.userInfo.roletype === 'DomainAdmin' }, + isAdmin () { + return this.$store.getters.userInfo.roletype === 'Admin' + }, isValidValueForKey (obj, key) { return key in obj && obj[key] != null }, + onDomainChange (newDomainId) { + if (newDomainId && this.roles.length > 0) { + this.$nextTick(() => { + this.setDefaultRole() + }) + } + }, + setDefaultRole () { + if (this.roles.length === 0) return + + let targetRoleType = null + + if (this.isAdmin()) { + targetRoleType = this.isNonRootDomain ? 'DomainAdmin' : 'Admin' + } else if (this.isDomainAdmin()) { + targetRoleType = 'User' + } + + const targetRole = targetRoleType + ? this.roles.find(role => role.type === targetRoleType) + : this.roles[0] + + this.form.roleid = (targetRole || this.roles[0]).id + }, async validateConfirmPassword (rule, value) { if (!value || value.length === 0) { return Promise.resolve() @@ -286,17 +336,22 @@ export default { this.loadMore('listDomains', 1, this.domain) }, loadMore (apiToCall, page, sema) { - console.log('sema.loading ' + sema.loading) - const params = {} - params.listAll = true - params.details = 'min' - params.pagesize = 100 - params.page = page + const params = { + listAll: true, + details: 'min', + pagesize: 100, + page: page + } var count getAPI(apiToCall, params).then(json => { const listDomains = json.listdomainsresponse.domain count = json.listdomainsresponse.count this.domainsList = this.domainsList.concat(listDomains) + this.dom = this.domainsList.find(domain => domain.id === this.domain.id) + + if (this.roles.length > 0) { + this.setDefaultRole() + } }).finally(() => { if (count <= this.domainsList.length) { sema.loading = false @@ -307,17 +362,13 @@ export default { }, fetchRoles () { this.roleLoading = true - const params = {} - params.state = 'enabled' + const params = { + state: 'enabled' + } + getAPI('listRoles', params).then(response => { this.roles = response.listrolesresponse.role || [] - this.form.roleid = this.roles[0].id - if (this.isDomainAdmin()) { - const userRole = this.roles.filter(role => role.type === 'User') - if (userRole.length > 0) { - this.form.roleid = userRole[0].id - } - } + this.setDefaultRole() }).finally(() => { this.roleLoading = false }) diff --git a/ui/src/views/iam/CreateRole.vue b/ui/src/views/iam/CreateRole.vue index 11cecf69efe..eac138fae78 100644 --- a/ui/src/views/iam/CreateRole.vue +++ b/ui/src/views/iam/CreateRole.vue @@ -202,7 +202,7 @@ export default { this.$emit('refresh-data') this.$notification.success({ message: 'Create Role', - description: 'Sucessfully created role ' + params.name + description: 'Successfully created role ' + params.name }) } this.closeAction() diff --git a/ui/src/views/iam/ImportRole.vue b/ui/src/views/iam/ImportRole.vue index c4dcf8f93b7..7a8e17c5691 100644 --- a/ui/src/views/iam/ImportRole.vue +++ b/ui/src/views/iam/ImportRole.vue @@ -213,7 +213,7 @@ export default { this.$emit('refresh-data') this.$notification.success({ message: 'Import Role', - description: 'Sucessfully imported role ' + params.name + description: 'Successfully imported role ' + params.name }) } this.closeAction() diff --git a/ui/src/views/image/AddKubernetesSupportedVersion.vue b/ui/src/views/image/AddKubernetesSupportedVersion.vue index f7b388d0a7f..d0fed0cc2bf 100644 --- a/ui/src/views/image/AddKubernetesSupportedVersion.vue +++ b/ui/src/views/image/AddKubernetesSupportedVersion.vue @@ -17,7 +17,12 @@