diff --git a/.build/BuildHelpFiles.ps1 b/.build/BuildHelpFiles.ps1 new file mode 100644 index 0000000..09a6efc --- /dev/null +++ b/.build/BuildHelpFiles.ps1 @@ -0,0 +1,35 @@ +param +( + [Parameter()] + [string] + $OutputDirectory = (property OutputDirectory (Join-Path $BuildRoot 'output')) +) +begin +{ + +} +process +{ + task 'BuildHelpFiles' { + $Script:OutputDirectory = Get-SamplerAbsolutePath -Path $OutputDirectory -RelativeTo $BuildRoot + $Script:psd = Get-ChildItem -Path "$($BuildRoot)/src" -include *.psd1 -File -Force -Recurse + $Script:ModuleInfo = Invoke-Expression "$(Get-Content $psd.FullName |Out-string)" + $Script:ModuleName = $psd.BaseName + $Script:ModuleDir = Join-Path "$($OutputDirectory)" -ChildPath "module" -AdditionalChildPath $ModuleName, $ModuleInfo.ModuleVersion + $Script:help = Join-Path $ModuleDir 'en-US' + $Script:docs = Join-Path $BuildRoot "docs" + $Script:index = $(Join-Path $docs "index.md") + Write-Build Magenta "Creating External Help" + if (Test-Path $help) + { + $null = Remove-Item $help -Recurse -Force + } + if (Test-Path $index) + { + $null = Remove-Item -Path $index -Force + } + Import-Module $(Join-Path $ModuleDir "$($ModuleName).psd1") -Force + + New-MarkdownHelp -Module $ModuleName -OutputFolder $docs -Force + } +} diff --git a/.build/Move-FormatsToOutput.ps1 b/.build/Move-FormatsToOutput.ps1 new file mode 100644 index 0000000..a1745bd --- /dev/null +++ b/.build/Move-FormatsToOutput.ps1 @@ -0,0 +1,68 @@ +param +( + [Parameter()] + [System.String] + $ProjectName = (property ProjectName ''), + + [Parameter()] + [System.String] + $SourcePath = (property SourcePath ''), + + [Parameter()] + [System.String] + $OutputDirectory = (property OutputDirectory (Join-Path $BuildRoot 'output')), + + [Parameter()] + [System.String] + $BuiltModuleSubdirectory = (property BuiltModuleSubdirectory ''), + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $VersionedOutputDirectory = (property VersionedOutputDirectory $true), + + [Parameter()] + [System.String] + $BuildModuleOutput = (property BuildModuleOutput (Join-Path $OutputDirectory $BuiltModuleSubdirectory)), + + [Parameter()] + [System.String] + $ReleaseNotesPath = (property ReleaseNotesPath (Join-Path $OutputDirectory 'ReleaseNotes.md')), + + [Parameter()] + [System.String] + $ModuleVersion = (property ModuleVersion ''), + + [Parameter()] + [System.Collections.Hashtable] + $BuildInfo = (property BuildInfo @{ }) +) + +task Move_Formats_To_Output { + $ErrorActionPreference = 'Stop' + $Script:psd = Get-ChildItem -Path "$($BuildRoot)/src" -include *.psd1 -File -Force -Recurse + $Script:ModuleInfo = Invoke-Expression "$(Get-Content $psd.FullName |Out-string)" + $Script:ModuleName = $psd.BaseName + $Script:ModuleDir = Join-Path "$($BuildModuleOutput)" -ChildPath $ModuleName -AdditionalChildPath $ModuleInfo.ModuleVersion + $formatsPath = Join-Path -Path $BuildRoot -ChildPath "src" -AdditionalChildPath "formats" + if (Test-Path $formatsPath) + { + try + { + + $null = Copy-Item -Path $formatsPath -Destination $Script:ModuleDir -Recurse -Force + } + catch + { + throw $_.Exception.Message + } + } + else + { + throw "Unable to find '$($formatsPath)'" + } + + if (-not (Test-Path $(Join-Path $Script:ModuleDir "formats"))) + { + throw "Formats folder was not copied to '$($Script:ModuleDir)'" + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..96c2e0d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Needed for publishing of examples, build worker defaults to core.autocrlf=input. +* text eol=autocrlf + +*.mof text eol=crlf +*.sh text eol=lf +*.svg eol=lf + +# Ensure any exe files are treated as binary +*.exe binary +*.jpg binary +*.xl* binary +*.pfx binary +*.png binary +*.dll binary +*.so binary diff --git a/.github/ISSUE_TEMPLATE/General.md b/.github/ISSUE_TEMPLATE/General.md new file mode 100644 index 0000000..fbcdf24 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/General.md @@ -0,0 +1,7 @@ +--- +name: General question or documentation update +about: If you have a general question or documentation update suggestion around the resource module. +--- + diff --git a/.github/ISSUE_TEMPLATE/Problem_with_module.yml b/.github/ISSUE_TEMPLATE/Problem_with_module.yml new file mode 100644 index 0000000..75e09b6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Problem_with_module.yml @@ -0,0 +1,103 @@ +name: Problem with the module +description: If you have a problem using this module, want to report a bug, or suggest an enhancement to this module. +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + TITLE: Please be descriptive not sensationalist. + + Your feedback and support is greatly appreciated, thanks for contributing! + + Please provide information regarding your issue under each section below. + **Write N/A in sections that do not apply, or if the information is not available.** + - type: textarea + id: description + attributes: + label: Problem description + description: Details of the scenario you tried and the problem that is occurring, or the enhancement you are suggesting. + validations: + required: true + - type: textarea + id: logs + attributes: + label: Verbose logs + description: | + Verbose logs showing the problem. **NOTE! Sensitive information should be obfuscated.** _Will be automatically formatted as plain text._ + placeholder: | + Paste verbose logs here + render: text + validations: + required: true + - type: textarea + id: reproducible + attributes: + label: How to reproduce + description: Provide the steps to reproduce the problem. + validations: + required: true + - type: textarea + id: expectedBehavior + attributes: + label: Expected behavior + description: Describe what you expected to happen. + validations: + required: true + - type: textarea + id: currentBehavior + attributes: + label: Current behavior + description: Describe what actually happens. + validations: + required: true + - type: textarea + id: suggestedSolution + attributes: + label: Suggested solution + description: Do you have any suggestions how to solve the issue? + validations: + required: true + - type: textarea + id: targetNodeOS + attributes: + label: Operating system the target node is running + description: | + Please provide as much as possible about the node running xo-powershell. _Will be automatically formatted as plain text._ + + To help with this information: + - On a Linux distribution, please provide the distribution name, version, and release. The following command can help get this information: `cat /etc/*-release && cat /proc/version` + - On macOS, please provide the product version and build version. The following command can help get this information: `sw_vers` + - On a Windows OS please provide edition, version, build, and language. The following command can help get this information: `Get-ComputerInfo -Property @('OsName','OsOperatingSystemSKU','OSArchitecture','WindowsVersion','WindowsBuildLabEx','OsLanguage','OsMuiLanguages')` + placeholder: | + Add operating system information here + render: text + validations: + required: true + - type: textarea + id: targetNodePS + attributes: + label: PowerShell version and build the target node is running + description: | + Please provide the version and build of PowerShell the target node is running. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `$PSVersionTable` + placeholder: | + Add PowerShell information here + render: text + validations: + required: true + - type: textarea + id: moduleVersion + attributes: + label: Module version used + description: | + Please provide the version of the xo-powershell module that was used. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `Get-Module -Name 'xo-powershell' -ListAvailable | ft Name,Version,Path` + placeholder: | + Add module information here + render: text + validations: + required: true + diff --git a/.github/ISSUE_TEMPLATE/Problem_with_resource.yml b/.github/ISSUE_TEMPLATE/Problem_with_resource.yml new file mode 100644 index 0000000..849cdb8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Problem_with_resource.yml @@ -0,0 +1,87 @@ +name: Problem with a resource +description: If you have a problem, bug, or enhancement with a resource in this resource module. +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + Please prefix the issue title (above) with the resource name, e.g. 'ResourceName: Short description of my issue'! + + Your feedback and support is greatly appreciated, thanks for contributing! + - type: textarea + id: description + attributes: + label: Problem description + description: Details of the scenario you tried and the problem that is occurring. + validations: + required: true + - type: textarea + id: logs + attributes: + label: Verbose logs + description: | + Verbose logs showing the problem. **NOTE! Sensitive information should be obfuscated.** _Will be automatically formatted as plain text._ + placeholder: | + Paste verbose logs here + render: text + validations: + required: true + - type: textarea + id: configuration + attributes: + label: DSC configuration + description: | + The DSC configuration that is used to reproduce the issue (as detailed as possible). **NOTE! Sensitive information should be obfuscated.** _Will be automatically formatted as PowerShell code._ + placeholder: | + Paste DSC configuration here + render: powershell + validations: + required: true + - type: textarea + id: suggestedSolution + attributes: + label: Suggested solution + description: Do you have any suggestions how to solve the issue? + validations: + required: true + - type: textarea + id: targetNodeOS + attributes: + label: Operating system the target node is running + description: | + Please provide as much as possible about the target node, for example edition, version, build, and language. _Will be automatically formatted as plain text._ + + On OS with WMF 5.1 the following command can help get this information: `Get-ComputerInfo -Property @('OsName','OsOperatingSystemSKU','OSArchitecture','WindowsVersion','WindowsBuildLabEx','OsLanguage','OsMuiLanguages')` + placeholder: | + Add operating system information here + render: text + validations: + required: true + - type: textarea + id: targetNodePS + attributes: + label: PowerShell version and build the target node is running + description: | + Please provide the version and build of PowerShell the target node is running. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `$PSVersionTable` + placeholder: | + Add PowerShell information here + render: text + validations: + required: true + - type: textarea + id: moduleVersion + attributes: + label: xo-powershell version + description: | + Please provide the version of the xo-powershell module that was used. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `Get-Module -Name 'xo-powershell' -ListAvailable | ft Name,Version,Path` + placeholder: | + Add module information here + render: text + validations: + required: true + diff --git a/.github/ISSUE_TEMPLATE/Resource_proposal.yml b/.github/ISSUE_TEMPLATE/Resource_proposal.yml new file mode 100644 index 0000000..2ddd098 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Resource_proposal.yml @@ -0,0 +1,39 @@ +name: New resource proposal +description: If you have a new resource proposal that you think should be added to this resource module. +title: "NewResourceName: New resource proposal" +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + Please replace `NewResourceName` in the issue title (above) with your proposed resource name. + + Thank you for contributing and making this resource module better! + - type: textarea + id: description + attributes: + label: Resource proposal + description: Provide information how this resource will/should work and how it will help users. + validations: + required: true + - type: textarea + id: proposedProperties + attributes: + label: Proposed properties + description: | + List all the proposed properties that the resource should have (key, required, write, and/or read). For each property provide a detailed description, the data type, if a default value should be used, and if the property is limited to a set of values. + value: | + Property | Type qualifier | Data type | Description | Default value | Allowed values + --- | --- | --- | --- | --- | --- + PropertyName | Key | String | Detailed description | None | None + validations: + required: true + - type: textarea + id: considerations + attributes: + label: Special considerations or limitations + description: | + Provide any considerations or limitations you can think of that a contributor should take in account when coding the proposed resource, and or what limitations a user will encounter or should consider when using the proposed resource. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..9917040 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,6 @@ +blank_issues_enabled: false +contact_links: + - name: "Virtual PowerShell User Group #DSC channel" + url: https://dsccommunity.org/community/contact/ + about: "To talk to the community and maintainers of DSC Community, please visit the #DSC channel." + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4b839df --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,63 @@ +# Pull Request + + + +## Pull Request (PR) description + + + +## Task list + + + +- [ ] The PR represents a single logical change. i.e. Cosmetic updates should go in different PRs. +- [ ] Added an entry under the Unreleased section of in the CHANGELOG.md as per [format](https://keepachangelog.com/en/1.0.0/). +- [ ] Local clean build passes without issue or fail tests (`build.ps1 -ResolveDependency`). +- [ ] Resource documentation added/updated in README.md. +- [ ] Resource parameter descriptions added/updated in README.md, schema.mof + and comment-based help. +- [ ] Comment-based help added/updated. +- [ ] Localization strings added/updated in all localization files as appropriate. +- [ ] Examples appropriately added/updated. +- [ ] Unit tests added/updated. See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). +- [ ] Integration tests added/updated (where possible). See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). +- [ ] New/changed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md). diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8589fad --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +output/ + +**.bak +*.local.* +!**/README.md +.kitchen/ + +*.nupkg +*.suo +*.user +*.coverage +.vs +.psproj +.sln +markdownissues.txt +node_modules +package-lock.json +test.ps1 diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..87b7da5 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,10 @@ +{ + "default": true, + "MD029": { + "style": "one" + }, + "MD013": true, + "MD024": false, + "MD034": false, + "no-hard-tabs": true +} diff --git a/.vscode/analyzersettings.psd1 b/.vscode/analyzersettings.psd1 new file mode 100644 index 0000000..78312d2 --- /dev/null +++ b/.vscode/analyzersettings.psd1 @@ -0,0 +1,44 @@ +@{ + CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules' + includeDefaultRules = $true + IncludeRules = @( + # DSC Resource Kit style guideline rules. + 'PSAvoidDefaultValueForMandatoryParameter', + 'PSAvoidDefaultValueSwitchParameter', + 'PSAvoidInvokingEmptyMembers', + 'PSAvoidNullOrEmptyHelpMessageAttribute', + 'PSAvoidUsingCmdletAliases', + 'PSAvoidUsingComputerNameHardcoded', + 'PSAvoidUsingDeprecatedManifestFields', + 'PSAvoidUsingEmptyCatchBlock', + 'PSAvoidUsingInvokeExpression', + 'PSAvoidUsingPositionalParameters', + 'PSAvoidShouldContinueWithoutForce', + 'PSAvoidUsingWMICmdlet', + 'PSAvoidUsingWriteHost', + 'PSDSCReturnCorrectTypesForDSCFunctions', + 'PSDSCStandardDSCFunctionsInResource', + 'PSDSCUseIdenticalMandatoryParametersForDSC', + 'PSDSCUseIdenticalParametersForDSC', + 'PSMisleadingBacktick', + 'PSMissingModuleManifestField', + 'PSPossibleIncorrectComparisonWithNull', + 'PSProvideCommentHelp', + 'PSReservedCmdletChar', + 'PSReservedParams', + 'PSUseApprovedVerbs', + 'PSUseCmdletCorrectly', + 'PSUseOutputTypeCorrectly', + 'PSAvoidGlobalVars', + 'PSAvoidUsingConvertToSecureStringWithPlainText', + 'PSAvoidUsingPlainTextForPassword', + 'PSAvoidUsingUsernameAndPasswordParams', + 'PSDSCUseVerboseMessageInDSCResource', + 'PSShouldProcess', + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSUsePSCredentialType', + + 'Measure-*' + ) + +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..bbd4a82 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "davidanson.vscode-markdownlint", + "ms-vscode.powershell", + "streetsidesoftware.code-spell-checker", + "redhat.vscode-yaml" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5e31941 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,42 @@ +{ + "powershell.codeFormatting.openBraceOnSameLine": false, + "powershell.codeFormatting.newLineAfterOpenBrace": true, + "powershell.codeFormatting.newLineAfterCloseBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenParen": true, + "powershell.codeFormatting.whitespaceAroundOperator": true, + "powershell.codeFormatting.whitespaceAfterSeparator": true, + "powershell.codeFormatting.ignoreOneLineBlock": false, + "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline", + "powershell.codeFormatting.preset": "Custom", + "powershell.codeFormatting.alignPropertyValuePairs": true, + "powershell.developer.bundledModulesPath": "${cwd}/output/RequiredModules", + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1", + "powershell.scriptAnalysis.enable": true, + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "files.insertFinalNewline": true, + "files.associations": { + "*.ps1xml": "xml" + }, + "cSpell.words": [ + "buildhelpers", + "Cmdletbinding", + "COMPANYNAME", + "endregion", + "gitversion", + "icontains", + "ICONURI", + "keepachangelog", + "LICENSEURI", + "notin", + "PROJECTURI", + "pscmdlet", + "RELEASENOTES", + "steppable" + ], + "[markdown]": { + "files.trimTrailingWhitespace": false, + "files.encoding": "utf8" + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..2991140 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,125 @@ +{ + "version": "2.0.0", + "_runner": "terminal", + "windows": { + "options": { + "shell": { + "executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-Command" + ] + } + } + }, + "linux": { + "options": { + "shell": { + "executable": "/usr/bin/pwsh", + "args": [ + "-NoProfile", + "-Command" + ] + } + } + }, + "osx": { + "options": { + "shell": { + "executable": "/usr/local/bin/pwsh", + "args": [ + "-NoProfile", + "-Command" + ] + } + } + }, + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "&${cwd}/build.ps1", + "args": [], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "new", + "clear": false + }, + "runOptions": { + "runOn": "default" + }, + "problemMatcher": [ + { + "owner": "powershell", + "fileLocation": [ + "absolute" + ], + "severity": "error", + "pattern": [ + { + "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", + "message": 1 + }, + { + "regexp": "(.*)", + "code": 1 + }, + { + "regexp": "" + }, + { + "regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*", + "file": 1, + "line": 2 + } + ] + } + ] + }, + { + "label": "test", + "type": "shell", + "command": "&${cwd}/build.ps1", + "args": ["-AutoRestore","-Tasks","test"], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [ + { + "owner": "powershell", + "fileLocation": [ + "absolute" + ], + "severity": "error", + "pattern": [ + { + "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", + "message": 1 + }, + { + "regexp": "(.*)", + "code": 1 + }, + { + "regexp": "" + }, + { + "regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*", + "file": 1, + "line": 2 + } + ] + } + ] + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..842458d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# Changelog for xo-powershell + +The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Testing + +### Changed + +- For changes in existing functionality. + +### Deprecated + +- For soon-to-be removed features. + +### Removed + +- For now removed features. + +### Fixed + +- For any bug fix. + +### Security + +- In case of vulnerabilities. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..d7589dd --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +This project has adopted the [DSC Community Code of Conduct](https://dsccommunity.org/code_of_conduct). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3544bcc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Contributing + +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). + +## Running the Tests + +If want to know how to run this module's tests you can look at the [Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines/#running-tests) diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..09f6489 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,39 @@ +mode: ContinuousDelivery +next-version: 0.0.1 +major-version-bump-message: '(breaking\schange|breaking|major)\b' +minor-version-bump-message: '(adds?|features?|minor)\b' +patch-version-bump-message: '\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}' +branches: + master: + tag: preview + regex: ^main$ + pull-request: + tag: PR + feature: + tag: useBranchName + increment: Minor + regex: f(eature(s)?)?[\/-] + source-branches: ['master'] + hotfix: + tag: fix + increment: Patch + regex: (hot)?fix(es)?[\/-] + source-branches: ['master'] + +ignore: + sha: [] +merge-message-formats: {} + + +# feature: +# tag: useBranchName +# increment: Minor +# regex: f(eature(s)?)?[/-] +# source-branches: ['master'] +# hotfix: +# tag: fix +# increment: Patch +# regex: (hot)?fix(es)?[/-] +# source-branches: ['master'] diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 new file mode 100644 index 0000000..863732b --- /dev/null +++ b/RequiredModules.psd1 @@ -0,0 +1,29 @@ +@{ + <# + This is only required if you need to use the method PowerShellGet & PSDepend + It is not required for PSResourceGet or ModuleFast (and will be ignored). + See Resolve-Dependency.psd1 on how to enable methods. + #> + #PSDependOptions = @{ + # AddToPath = $true + # Target = 'output\RequiredModules' + # Parameters = @{ + # Repository = 'PSGallery' + # } + #} + + InvokeBuild = 'latest' + PSScriptAnalyzer = 'latest' + Pester = 'latest' + ModuleBuilder = 'latest' + ChangelogManagement = 'latest' + Sampler = 'latest' + 'Sampler.GitHubTasks' = 'latest' + MarkdownLinkCheck = 'latest' + 'DscResource.Common' = 'latest' + 'DscResource.Test' = 'latest' + 'DscResource.AnalyzerRules' = 'latest' + xDscResourceDesigner = 'latest' + 'DscResource.DocGenerator' = 'latest' + PlatyPS = 'latest' +} diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 new file mode 100644 index 0000000..17cc98e --- /dev/null +++ b/Resolve-Dependency.ps1 @@ -0,0 +1,1060 @@ +<# + .DESCRIPTION + Bootstrap script for PSDepend. + + .PARAMETER DependencyFile + Specifies the configuration file for the this script. The default value is + 'RequiredModules.psd1' relative to this script's path. + + .PARAMETER PSDependTarget + Path for PSDepend to be bootstrapped and save other dependencies. + Can also be CurrentUser or AllUsers if you wish to install the modules in + such scope. The default value is 'output/RequiredModules' relative to + this script's path. + + .PARAMETER Proxy + Specifies the URI to use for Proxy when attempting to bootstrap + PackageProvider and PowerShellGet. + + .PARAMETER ProxyCredential + Specifies the credential to contact the Proxy when provided. + + .PARAMETER Scope + Specifies the scope to bootstrap the PackageProvider and PSGet if not available. + THe default value is 'CurrentUser'. + + .PARAMETER Gallery + Specifies the gallery to use when bootstrapping PackageProvider, PSGet and + when calling PSDepend (can be overridden in Dependency files). The default + value is 'PSGallery'. + + .PARAMETER GalleryCredential + Specifies the credentials to use with the Gallery specified above. + + .PARAMETER AllowOldPowerShellGetModule + Allow you to use a locally installed version of PowerShellGet older than + 1.6.0 (not recommended). Default it will install the latest PowerShellGet + if an older version than 2.0 is detected. + + .PARAMETER MinimumPSDependVersion + Allow you to specify a minimum version fo PSDepend, if you're after specific + features. + + .PARAMETER AllowPrerelease + Not yet written. + + .PARAMETER WithYAML + Not yet written. + + .PARAMETER UseModuleFast + Specifies to use ModuleFast instead of PowerShellGet to resolve dependencies + faster. + + .PARAMETER ModuleFastBleedingEdge + Specifies to use ModuleFast code that is in the ModuleFast's main branch + in its GitHub repository. The parameter UseModuleFast must also be set to + true. + + .PARAMETER UsePSResourceGet + Specifies to use the new PSResourceGet module instead of the (now legacy) PowerShellGet module. + + .PARAMETER PSResourceGetVersion + String specifying the module version for PSResourceGet if the `UsePSResourceGet` switch is utilized. + + .NOTES + Load defaults for parameters values from Resolve-Dependency.psd1 if not + provided as parameter. +#> +[CmdletBinding()] +param +( + [Parameter()] + [System.String] + $DependencyFile = 'RequiredModules.psd1', + + [Parameter()] + [System.String] + $PSDependTarget = (Join-Path -Path $PSScriptRoot -ChildPath 'output/RequiredModules'), + + [Parameter()] + [System.Uri] + $Proxy, + + [Parameter()] + [System.Management.Automation.PSCredential] + $ProxyCredential, + + [Parameter()] + [ValidateSet('CurrentUser', 'AllUsers')] + [System.String] + $Scope = 'CurrentUser', + + [Parameter()] + [System.String] + $Gallery = 'PSGallery', + + [Parameter()] + [System.Management.Automation.PSCredential] + $GalleryCredential, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $AllowOldPowerShellGetModule, + + [Parameter()] + [System.String] + $MinimumPSDependVersion, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $AllowPrerelease, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $WithYAML, + + [Parameter()] + [System.Collections.Hashtable] + $RegisterGallery, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $UseModuleFast, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $ModuleFastBleedingEdge, + + [Parameter()] + [System.String] + $ModuleFastVersion, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $UsePSResourceGet, + + [Parameter()] + [System.String] + $PSResourceGetVersion, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $UsePowerShellGetCompatibilityModule, + + [Parameter()] + [System.String] + $UsePowerShellGetCompatibilityModuleVersion +) + +try +{ + if ($PSVersionTable.PSVersion.Major -le 5) + { + if (-not (Get-Command -Name 'Import-PowerShellDataFile' -ErrorAction 'SilentlyContinue')) + { + Import-Module -Name Microsoft.PowerShell.Utility -RequiredVersion '3.1.0.0' + } + } + + Write-Verbose -Message 'Importing Bootstrap default parameters from ''$PSScriptRoot/Resolve-Dependency.psd1''.' + + $resolveDependencyConfigPath = Join-Path -Path $PSScriptRoot -ChildPath '.\Resolve-Dependency.psd1' -Resolve -ErrorAction 'Stop' + + $resolveDependencyDefaults = Import-PowerShellDataFile -Path $resolveDependencyConfigPath + + $parameterToDefault = $MyInvocation.MyCommand.ParameterSets.Where{ $_.Name -eq $PSCmdlet.ParameterSetName }.Parameters.Keys + + if ($parameterToDefault.Count -eq 0) + { + $parameterToDefault = $MyInvocation.MyCommand.Parameters.Keys + } + + # Set the parameters available in the Parameter Set, or it's not possible to choose yet, so all parameters are an option. + foreach ($parameterName in $parameterToDefault) + { + if (-not $PSBoundParameters.Keys.Contains($parameterName) -and $resolveDependencyDefaults.ContainsKey($parameterName)) + { + Write-Verbose -Message "Setting parameter '$parameterName' to value '$($resolveDependencyDefaults[$parameterName])'." + + try + { + $variableValue = $resolveDependencyDefaults[$parameterName] + + if ($variableValue -is [System.String]) + { + $variableValue = $ExecutionContext.InvokeCommand.ExpandString($variableValue) + } + + $PSBoundParameters.Add($parameterName, $variableValue) + + Set-Variable -Name $parameterName -Value $variableValue -Force -ErrorAction 'SilentlyContinue' + } + catch + { + Write-Verbose -Message "Error adding default for $parameterName : $($_.Exception.Message)." + } + } + } +} +catch +{ + Write-Warning -Message "Error attempting to import Bootstrap's default parameters from '$resolveDependencyConfigPath': $($_.Exception.Message)." +} + +# Handle when both ModuleFast and PSResourceGet is configured or/and passed as parameter. +if ($UseModuleFast -and $UsePSResourceGet) +{ + Write-Information -MessageData 'Both ModuleFast and PSResourceGet is configured or/and passed as parameter.' -InformationAction 'Continue' + + if ($PSVersionTable.PSVersion -ge '7.2') + { + $UsePSResourceGet = $false + + Write-Information -MessageData 'PowerShell 7.2 or higher being used, prefer ModuleFast over PSResourceGet.' -InformationAction 'Continue' + } + else + { + $UseModuleFast = $false + + Write-Information -MessageData 'Windows PowerShell or PowerShell <=7.1 is being used, prefer PSResourceGet since ModuleFast is not supported on this version of PowerShell.' -InformationAction 'Continue' + } +} + +# Only bootstrap ModuleFast if it is not already imported. +if ($UseModuleFast -and -not (Get-Module -Name 'ModuleFast')) +{ + try + { + $moduleFastBootstrapScriptBlockParameters = @{} + + if ($ModuleFastBleedingEdge) + { + Write-Information -MessageData 'ModuleFast is configured to use Bleeding Edge (directly from ModuleFast''s main branch).' -InformationAction 'Continue' + + $moduleFastBootstrapScriptBlockParameters.UseMain = $true + } + elseif($ModuleFastVersion) + { + if ($ModuleFastVersion -notmatch 'v') + { + $ModuleFastVersion = 'v{0}' -f $ModuleFastVersion + } + + Write-Information -MessageData ('ModuleFast is configured to use version {0}.' -f $ModuleFastVersion) -InformationAction 'Continue' + + $moduleFastBootstrapScriptBlockParameters.Release = $ModuleFastVersion + } + else + { + Write-Information -MessageData 'ModuleFast is configured to use latest released version.' -InformationAction 'Continue' + } + + $moduleFastBootstrapUri = 'bit.ly/modulefast' # cSpell: disable-line + + Write-Debug -Message ('Using bootstrap script at {0}' -f $moduleFastBootstrapUri) + + $invokeWebRequestParameters = @{ + Uri = $moduleFastBootstrapUri + ErrorAction = 'Stop' + } + + $moduleFastBootstrapScript = Invoke-WebRequest @invokeWebRequestParameters + + $moduleFastBootstrapScriptBlock = [ScriptBlock]::Create($moduleFastBootstrapScript) + + & $moduleFastBootstrapScriptBlock @moduleFastBootstrapScriptBlockParameters + } + catch + { + Write-Warning -Message ('ModuleFast could not be bootstrapped. Reverting to PSResourceGet. Error: {0}' -f $_.Exception.Message) + + $UseModuleFast = $false + $UsePSResourceGet = $true + } +} + +if ($UsePSResourceGet) +{ + $psResourceGetModuleName = 'Microsoft.PowerShell.PSResourceGet' + + # If PSResourceGet was used prior it will be locked and we can't replace it. + if ((Test-Path -Path "$PSDependTarget/$psResourceGetModuleName" -PathType 'Container') -and (Get-Module -Name $psResourceGetModuleName)) + { + Write-Information -MessageData ('{0} is already bootstrapped and imported into the session. If there is a need to refresh the module, open a new session and resolve dependencies again.' -f $psResourceGetModuleName) -InformationAction 'Continue' + } + else + { + Write-Debug -Message ('{0} do not exist, saving the module to RequiredModules.' -f $psResourceGetModuleName) + + $psResourceGetDownloaded = $false + + try + { + if (-not $PSResourceGetVersion) + { + # Default to latest version if no version is passed in parameter or specified in configuration. + $psResourceGetUri = "https://www.powershellgallery.com/api/v2/package/$psResourceGetModuleName" + } + else + { + $psResourceGetUri = "https://www.powershellgallery.com/api/v2/package/$psResourceGetModuleName/$PSResourceGetVersion" + } + + $invokeWebRequestParameters = @{ + # TODO: Should support proxy parameters passed to the script. + Uri = $psResourceGetUri + OutFile = "$PSDependTarget/$psResourceGetModuleName.nupkg" # cSpell: ignore nupkg + ErrorAction = 'Stop' + } + + $previousProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + + # Bootstrapping Microsoft.PowerShell.PSResourceGet. + Invoke-WebRequest @invokeWebRequestParameters + + $ProgressPreference = $previousProgressPreference + + $psResourceGetDownloaded = $true + } + catch + { + Write-Warning -Message ('{0} could not be bootstrapped. Reverting to PowerShellGet. Error: {1}' -f $psResourceGetModuleName, $_.Exception.Message) + } + + $UsePSResourceGet = $false + + if ($psResourceGetDownloaded) + { + # On Windows PowerShell the command Expand-Archive do not like .nupkg as a zip archive extension. + $zipFileName = ((Split-Path -Path $invokeWebRequestParameters.OutFile -Leaf) -replace 'nupkg', 'zip') + + $renameItemParameters = @{ + Path = $invokeWebRequestParameters.OutFile + NewName = $zipFileName + Force = $true + } + + Rename-Item @renameItemParameters + + $psResourceGetZipArchivePath = Join-Path -Path (Split-Path -Path $invokeWebRequestParameters.OutFile -Parent) -ChildPath $zipFileName + + $expandArchiveParameters = @{ + Path = $psResourceGetZipArchivePath + DestinationPath = "$PSDependTarget/$psResourceGetModuleName" + Force = $true + } + + Expand-Archive @expandArchiveParameters + + Remove-Item -Path $psResourceGetZipArchivePath + + Import-Module -Name $expandArchiveParameters.DestinationPath -Force + + # Successfully bootstrapped PSResourceGet, so let's use it. + $UsePSResourceGet = $true + } + } + + if ($UsePSResourceGet) + { + $psResourceGetModule = Get-Module -Name $psResourceGetModuleName + + $psResourceGetModuleVersion = $psResourceGetModule.Version.ToString() + + if ($psResourceGetModule.PrivateData.PSData.Prerelease) + { + $psResourceGetModuleVersion += '-{0}' -f $psResourceGetModule.PrivateData.PSData.Prerelease + } + + Write-Information -MessageData ('Using {0} v{1}.' -f $psResourceGetModuleName, $psResourceGetModuleVersion) -InformationAction 'Continue' + + if ($UsePowerShellGetCompatibilityModule) + { + $savePowerShellGetParameters = @{ + Name = 'PowerShellGet' + Path = $PSDependTarget + Repository = 'PSGallery' + TrustRepository = $true + } + + if ($UsePowerShellGetCompatibilityModuleVersion) + { + $savePowerShellGetParameters.Version = $UsePowerShellGetCompatibilityModuleVersion + + # Check if the version is a prerelease. + if ($UsePowerShellGetCompatibilityModuleVersion -match '\d+\.\d+\.\d+-.*') + { + $savePowerShellGetParameters.Prerelease = $true + } + } + + Save-PSResource @savePowerShellGetParameters + + Import-Module -Name "$PSDependTarget/PowerShellGet" + } + } +} + +# Check if legacy PowerShellGet and PSDepend must be bootstrapped. +if (-not ($UseModuleFast -or $UsePSResourceGet)) +{ + if ($PSVersionTable.PSVersion.Major -le 5) + { + <# + Making sure the imported PackageManagement module is not from PS7 module + path. The VSCode PS extension is changing the $env:PSModulePath and + prioritize the PS7 path. This is an issue with PowerShellGet because + it loads an old version if available (or fail to load latest). + #> + Get-Module -ListAvailable PackageManagement | + Where-Object -Property 'ModuleBase' -NotMatch 'powershell.7' | + Select-Object -First 1 | + Import-Module -Force + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 0 -CurrentOperation 'NuGet Bootstrap' + + $importModuleParameters = @{ + Name = 'PowerShellGet' + MinimumVersion = '2.0' + MaximumVersion = '2.8.999' + ErrorAction = 'SilentlyContinue' + PassThru = $true + } + + if ($AllowOldPowerShellGetModule) + { + $importModuleParameters.Remove('MinimumVersion') + } + + $powerShellGetModule = Import-Module @importModuleParameters + + # Install the package provider if it is not available. + $nuGetProvider = Get-PackageProvider -Name 'NuGet' -ListAvailable -ErrorAction 'SilentlyContinue' | + Select-Object -First 1 + + if (-not $powerShellGetModule -and -not $nuGetProvider) + { + $providerBootstrapParameters = @{ + Name = 'NuGet' + Force = $true + ForceBootstrap = $true + ErrorAction = 'Stop' + Scope = $Scope + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $providerBootstrapParameters.Add('Proxy', $Proxy) + } + + 'ProxyCredential' + { + $providerBootstrapParameters.Add('ProxyCredential', $ProxyCredential) + } + + 'AllowPrerelease' + { + $providerBootstrapParameters.Add('AllowPrerelease', $AllowPrerelease) + } + } + + Write-Information -MessageData 'Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed).' + + $null = Install-PackageProvider @providerBootstrapParameters + + $nuGetProvider = Get-PackageProvider -Name 'NuGet' -ListAvailable | Select-Object -First 1 + + $nuGetProviderVersion = $nuGetProvider.Version.ToString() + + Write-Information -MessageData "Bootstrap: Importing NuGet Package Provider version $nuGetProviderVersion to current session." + + $Null = Import-PackageProvider -Name 'NuGet' -RequiredVersion $nuGetProviderVersion -Force + } + + if ($RegisterGallery) + { + if ($RegisterGallery.ContainsKey('Name') -and -not [System.String]::IsNullOrEmpty($RegisterGallery.Name)) + { + $Gallery = $RegisterGallery.Name + } + else + { + $RegisterGallery.Name = $Gallery + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 7 -CurrentOperation "Verifying private package repository '$Gallery'" -Completed + + $previousRegisteredRepository = Get-PSRepository -Name $Gallery -ErrorAction 'SilentlyContinue' + + if ($previousRegisteredRepository.SourceLocation -ne $RegisterGallery.SourceLocation) + { + if ($previousRegisteredRepository) + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 9 -CurrentOperation "Re-registrering private package repository '$Gallery'" -Completed + + Unregister-PSRepository -Name $Gallery + + $unregisteredPreviousRepository = $true + } + else + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 9 -CurrentOperation "Registering private package repository '$Gallery'" -Completed + } + + Register-PSRepository @RegisterGallery + } + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 10 -CurrentOperation "Ensuring Gallery $Gallery is trusted" + + # Fail if the given PSGallery is not registered. + $previousGalleryInstallationPolicy = (Get-PSRepository -Name $Gallery -ErrorAction 'Stop').Trusted + + $updatedGalleryInstallationPolicy = $false + + if ($previousGalleryInstallationPolicy -ne $true) + { + $updatedGalleryInstallationPolicy = $true + + # Only change policy if the repository is not trusted + Set-PSRepository -Name $Gallery -InstallationPolicy 'Trusted' -ErrorAction 'Ignore' + } +} + +try +{ + # Check if legacy PowerShellGet and PSDepend must be used. + if (-not ($UseModuleFast -or $UsePSResourceGet)) + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 25 -CurrentOperation 'Checking PowerShellGet' + + # Ensure the module is loaded and retrieve the version you have. + $powerShellGetVersion = (Import-Module -Name 'PowerShellGet' -PassThru -ErrorAction 'SilentlyContinue').Version + + Write-Verbose -Message "Bootstrap: The PowerShellGet version is $powerShellGetVersion" + + # Versions below 2.0 are considered old, unreliable & not recommended + if (-not $powerShellGetVersion -or ($powerShellGetVersion -lt [System.Version] '2.0' -and -not $AllowOldPowerShellGetModule)) + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 40 -CurrentOperation 'Fetching newer version of PowerShellGet' + + # PowerShellGet module not found, installing or saving it. + if ($PSDependTarget -in 'CurrentUser', 'AllUsers') + { + Write-Debug -Message "PowerShellGet module not found. Attempting to install from Gallery $Gallery." + + Write-Warning -Message "Installing PowerShellGet in $PSDependTarget Scope." + + $installPowerShellGetParameters = @{ + Name = 'PowerShellGet' + Force = $true + SkipPublisherCheck = $true + AllowClobber = $true + Scope = $Scope + Repository = $Gallery + MaximumVersion = '2.8.999' + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $installPowerShellGetParameters.Add('Proxy', $Proxy) + } + + 'ProxyCredential' + { + $installPowerShellGetParameters.Add('ProxyCredential', $ProxyCredential) + } + + 'GalleryCredential' + { + $installPowerShellGetParameters.Add('Credential', $GalleryCredential) + } + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation 'Installing newer version of PowerShellGet' + + Install-Module @installPowerShellGetParameters + } + else + { + Write-Debug -Message "PowerShellGet module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + + $saveModuleParameters = @{ + Name = 'PowerShellGet' + Repository = $Gallery + Path = $PSDependTarget + Force = $true + MaximumVersion = '2.8.999' + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation "Saving PowerShellGet from $Gallery to $Scope" + + Save-Module @saveModuleParameters + } + + Write-Debug -Message 'Removing previous versions of PowerShellGet and PackageManagement from session' + + Get-Module -Name 'PowerShellGet' -All | Remove-Module -Force -ErrorAction 'SilentlyContinue' + Get-Module -Name 'PackageManagement' -All | Remove-Module -Force + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 65 -CurrentOperation 'Loading latest version of PowerShellGet' + + Write-Debug -Message 'Importing latest PowerShellGet and PackageManagement versions into session' + + if ($AllowOldPowerShellGetModule) + { + $powerShellGetModule = Import-Module -Name 'PowerShellGet' -Force -PassThru + } + else + { + Import-Module -Name 'PackageManagement' -MinimumVersion '1.4.8.1' -Force + + $powerShellGetModule = Import-Module -Name 'PowerShellGet' -MinimumVersion '2.2.5' -Force -PassThru + } + + $powerShellGetVersion = $powerShellGetModule.Version.ToString() + + Write-Information -MessageData "Bootstrap: PowerShellGet version loaded is $powerShellGetVersion" + } + + # Try to import the PSDepend module from the available modules. + $getModuleParameters = @{ + Name = 'PSDepend' + ListAvailable = $true + } + + $psDependModule = Get-Module @getModuleParameters + + if ($PSBoundParameters.ContainsKey('MinimumPSDependVersion')) + { + try + { + $psDependModule = $psDependModule | Where-Object -FilterScript { $_.Version -ge $MinimumPSDependVersion } + } + catch + { + throw ('There was a problem finding the minimum version of PSDepend. Error: {0}' -f $_) + } + } + + if (-not $psDependModule) + { + Write-Debug -Message 'PSDepend module not found.' + + # PSDepend module not found, installing or saving it. + if ($PSDependTarget -in 'CurrentUser', 'AllUsers') + { + Write-Debug -Message "Attempting to install from Gallery '$Gallery'." + + Write-Warning -Message "Installing PSDepend in $PSDependTarget Scope." + + $installPSDependParameters = @{ + Name = 'PSDepend' + Repository = $Gallery + Force = $true + Scope = $PSDependTarget + SkipPublisherCheck = $true + AllowClobber = $true + } + + if ($MinimumPSDependVersion) + { + $installPSDependParameters.Add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 75 -CurrentOperation "Installing PSDepend from $Gallery" + + Install-Module @installPSDependParameters + } + else + { + Write-Debug -Message "Attempting to Save from Gallery $Gallery to $PSDependTarget" + + $saveModuleParameters = @{ + Name = 'PSDepend' + Repository = $Gallery + Path = $PSDependTarget + Force = $true + } + + if ($MinimumPSDependVersion) + { + $saveModuleParameters.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 75 -CurrentOperation "Saving PSDepend from $Gallery to $PSDependTarget" + + Save-Module @saveModuleParameters + } + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 80 -CurrentOperation 'Importing PSDepend' + + $importModulePSDependParameters = @{ + Name = 'PSDepend' + ErrorAction = 'Stop' + Force = $true + } + + if ($PSBoundParameters.ContainsKey('MinimumPSDependVersion')) + { + $importModulePSDependParameters.Add('MinimumVersion', $MinimumPSDependVersion) + } + + # We should have successfully bootstrapped PSDepend. Fail if not available. + $null = Import-Module @importModulePSDependParameters + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 81 -CurrentOperation 'Invoke PSDepend' + + if ($WithYAML) + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 82 -CurrentOperation 'Verifying PowerShell module PowerShell-Yaml' + + if (-not (Get-Module -ListAvailable -Name 'PowerShell-Yaml')) + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 85 -CurrentOperation 'Installing PowerShell module PowerShell-Yaml' + + Write-Verbose -Message "PowerShell-Yaml module not found. Attempting to Save from Gallery '$Gallery' to '$PSDependTarget'." + + $SaveModuleParam = @{ + Name = 'PowerShell-Yaml' + Repository = $Gallery + Path = $PSDependTarget + Force = $true + } + + Save-Module @SaveModuleParam + } + else + { + Write-Verbose -Message 'PowerShell-Yaml is already available' + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 88 -CurrentOperation 'Importing PowerShell module PowerShell-Yaml' + } + } + + if (Test-Path -Path $DependencyFile) + { + if ($UseModuleFast -or $UsePSResourceGet) + { + $requiredModules = Import-PowerShellDataFile -Path $DependencyFile + + $requiredModules = $requiredModules.GetEnumerator() | + Where-Object -FilterScript { $_.Name -ne 'PSDependOptions' } + + if ($UseModuleFast) + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 90 -CurrentOperation 'Invoking ModuleFast' + + Write-Progress -Activity 'ModuleFast:' -PercentComplete 0 -CurrentOperation 'Restoring Build Dependencies' + + $modulesToSave = @( + 'PSDepend' # Always include PSDepend for backward compatibility. + ) + + if ($WithYAML) + { + $modulesToSave += 'PowerShell-Yaml' + } + + if ($UsePowerShellGetCompatibilityModule) + { + Write-Debug -Message 'PowerShellGet compatibility module is configured to be used.' + + # This is needed to ensure that the PowerShellGet compatibility module works. + $psResourceGetModuleName = 'Microsoft.PowerShell.PSResourceGet' + + if ($PSResourceGetVersion) + { + $modulesToSave += ('{0}:[{1}]' -f $psResourceGetModuleName, $PSResourceGetVersion) + } + else + { + $modulesToSave += $psResourceGetModuleName + } + + $powerShellGetCompatibilityModuleName = 'PowerShellGet' + + if ($UsePowerShellGetCompatibilityModuleVersion) + { + $modulesToSave += ('{0}:[{1}]' -f $powerShellGetCompatibilityModuleName, $UsePowerShellGetCompatibilityModuleVersion) + } + else + { + $modulesToSave += $powerShellGetCompatibilityModuleName + } + } + + foreach ($requiredModule in $requiredModules) + { + # If the RequiredModules.psd1 entry is an Hashtable then special handling is needed. + if ($requiredModule.Value -is [System.Collections.Hashtable]) + { + if (-not $requiredModule.Value.Version) + { + $requiredModuleVersion = 'latest' + } + else + { + $requiredModuleVersion = $requiredModule.Value.Version + } + + if ($requiredModuleVersion -eq 'latest') + { + $moduleNameSuffix = '' + + if ($requiredModule.Value.Parameters.AllowPrerelease -eq $true) + { + <# + Adding '!' to the module name indicate to ModuleFast + that is should also evaluate pre-releases. + #> + $moduleNameSuffix = '!' + } + + $modulesToSave += ('{0}{1}' -f $requiredModule.Name, $moduleNameSuffix) + } + else + { + $modulesToSave += ('{0}:[{1}]' -f $requiredModule.Name, $requiredModuleVersion) + } + } + else + { + if ($requiredModule.Value -eq 'latest') + { + $modulesToSave += $requiredModule.Name + } + else + { + # Handle different nuget version operators already present. + if ($requiredModule.Value -match '[!|:|[|(|,|>|<|=]') + { + $modulesToSave += ('{0}{1}' -f $requiredModule.Name, $requiredModule.Value) + } + else + { + # Assuming the version is a fixed version. + $modulesToSave += ('{0}:[{1}]' -f $requiredModule.Name, $requiredModule.Value) + } + } + } + } + + Write-Debug -Message ("Required modules to retrieve plan for:`n{0}" -f ($modulesToSave | Out-String)) + + $installModuleFastParameters = @{ + Destination = $PSDependTarget + DestinationOnly = $true + NoPSModulePathUpdate = $true + NoProfileUpdate = $true + Update = $true + Confirm = $false + } + + $moduleFastPlan = Install-ModuleFast -Specification $modulesToSave -Plan @installModuleFastParameters + + Write-Debug -Message ("Missing modules that need to be saved:`n{0}" -f ($moduleFastPlan | Out-String)) + + if ($moduleFastPlan) + { + # Clear all modules in plan from the current session so they can be fetched again. + $moduleFastPlan.Name | Get-Module | Remove-Module -Force + + $moduleFastPlan | Install-ModuleFast @installModuleFastParameters + } + else + { + Write-Verbose -Message 'All required modules were already up to date' + } + + Write-Progress -Activity 'ModuleFast:' -PercentComplete 100 -CurrentOperation 'Dependencies restored' -Completed + } + + if ($UsePSResourceGet) + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 90 -CurrentOperation 'Invoking PSResourceGet' + + $modulesToSave = @( + @{ + Name = 'PSDepend' # Always include PSDepend for backward compatibility. + } + ) + + if ($WithYAML) + { + $modulesToSave += @{ + Name = 'PowerShell-Yaml' + } + } + + # Prepare hashtable that can be concatenated to the Save-PSResource parameters. + foreach ($requiredModule in $requiredModules) + { + # If the RequiredModules.psd1 entry is an Hashtable then special handling is needed. + if ($requiredModule.Value -is [System.Collections.Hashtable]) + { + $saveModuleHashtable = @{ + Name = $requiredModule.Name + } + + if ($requiredModule.Value.Version -and $requiredModule.Value.Version -ne 'latest') + { + $saveModuleHashtable.Version = $requiredModule.Value.Version + } + + if ($requiredModule.Value.Parameters.AllowPrerelease -eq $true) + { + $saveModuleHashtable.Prerelease = $true + } + + $modulesToSave += $saveModuleHashtable + } + else + { + if ($requiredModule.Value -eq 'latest') + { + $modulesToSave += @{ + Name = $requiredModule.Name + } + } + else + { + $modulesToSave += @{ + Name = $requiredModule.Name + Version = $requiredModule.Value + } + } + } + } + + $percentagePerModule = [System.Math]::Floor(100 / $modulesToSave.Length) + + $progressPercentage = 0 + + Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercentage -CurrentOperation 'Restoring Build Dependencies' + + foreach ($currentModule in $modulesToSave) + { + Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercentage -CurrentOperation 'Restoring Build Dependencies' -Status ('Saving module {0}' -f $savePSResourceParameters.Name) + + $savePSResourceParameters = @{ + Path = $PSDependTarget + TrustRepository = $true + Confirm = $false + } + + # Concatenate the module parameters to the Save-PSResource parameters. + $savePSResourceParameters += $currentModule + + # Modules that Sampler depend on that cannot be refreshed without a new session. + $skipModule = @('PowerShell-Yaml') + + if ($savePSResourceParameters.Name -in $skipModule -and (Get-Module -Name $savePSResourceParameters.Name)) + { + Write-Progress -Activity 'PSResourceGet:' -PercentComplete $progressPercentage -CurrentOperation 'Restoring Build Dependencies' -Status ('Skipping module {0}' -f $savePSResourceParameters.Name) + + Write-Information -MessageData ('Skipping the module {0} since it cannot be refresh while loaded into the session. To refresh the module open a new session and resolve dependencies again.' -f $savePSResourceParameters.Name) -InformationAction 'Continue' + } + else + { + # Clear all module from the current session so any new version fetched will be re-imported. + Get-Module -Name $savePSResourceParameters.Name | Remove-Module -Force + + Save-PSResource @savePSResourceParameters -ErrorVariable 'savePSResourceError' + + if ($savePSResourceError) + { + Write-Warning -Message 'Save-PSResource could not save (replace) one or more dependencies. This can be due to the module is loaded into the session (and referencing assemblies). Close the current session and open a new session and try again.' + } + } + + $progressPercentage += $percentagePerModule + } + + Write-Progress -Activity 'PSResourceGet:' -PercentComplete 100 -CurrentOperation 'Dependencies restored' -Completed + } + } + else + { + Write-Progress -Activity 'Bootstrap:' -PercentComplete 90 -CurrentOperation 'Invoking PSDepend' + + Write-Progress -Activity 'PSDepend:' -PercentComplete 0 -CurrentOperation 'Restoring Build Dependencies' + + $psDependParameters = @{ + Force = $true + Path = $DependencyFile + } + + # TODO: Handle when the Dependency file is in YAML, and -WithYAML is specified. + Invoke-PSDepend @psDependParameters + + Write-Progress -Activity 'PSDepend:' -PercentComplete 100 -CurrentOperation 'Dependencies restored' -Completed + } + } + else + { + Write-Warning -Message "The dependency file '$DependencyFile' could not be found." + } + + Write-Progress -Activity 'Bootstrap:' -PercentComplete 100 -CurrentOperation 'Bootstrap complete' -Completed +} +finally +{ + if ($RegisterGallery) + { + Write-Verbose -Message "Removing private package repository '$Gallery'." + Unregister-PSRepository -Name $Gallery + } + + if ($unregisteredPreviousRepository) + { + Write-Verbose -Message "Reverting private package repository '$Gallery' to previous location URI:s." + + $registerPSRepositoryParameters = @{ + Name = $previousRegisteredRepository.Name + InstallationPolicy = $previousRegisteredRepository.InstallationPolicy + } + + if ($previousRegisteredRepository.SourceLocation) + { + $registerPSRepositoryParameters.SourceLocation = $previousRegisteredRepository.SourceLocation + } + + if ($previousRegisteredRepository.PublishLocation) + { + $registerPSRepositoryParameters.PublishLocation = $previousRegisteredRepository.PublishLocation + } + + if ($previousRegisteredRepository.ScriptSourceLocation) + { + $registerPSRepositoryParameters.ScriptSourceLocation = $previousRegisteredRepository.ScriptSourceLocation + } + + if ($previousRegisteredRepository.ScriptPublishLocation) + { + $registerPSRepositoryParameters.ScriptPublishLocation = $previousRegisteredRepository.ScriptPublishLocation + } + + Register-PSRepository @registerPSRepositoryParameters + } + + if ($updatedGalleryInstallationPolicy -eq $true -and $previousGalleryInstallationPolicy -ne $true) + { + # Only try to revert installation policy if the repository exist + if ((Get-PSRepository -Name $Gallery -ErrorAction 'SilentlyContinue')) + { + # Reverting the Installation Policy for the given gallery if it was not already trusted + Set-PSRepository -Name $Gallery -InstallationPolicy 'Untrusted' + } + } + + Write-Verbose -Message 'Project Bootstrapped, returning to Invoke-Build.' +} diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 new file mode 100644 index 0000000..a392279 --- /dev/null +++ b/Resolve-Dependency.psd1 @@ -0,0 +1,75 @@ +@{ + <# + Default parameter values to be loaded by the Resolve-Dependency.ps1 script (unless set in bound parameters + when calling the script). + #> + + #PSDependTarget = './output/modules' + #Proxy = '' + #ProxyCredential = '$MyCredentialVariable' #TODO: find a way to support credentials in build (resolve variable) + + Gallery = 'PSGallery' + + # To use a private nuget repository change the following to your own feed. The locations must be a Nuget v2 feed due + # to limitation in PowerShellGet v2.x. Example below is for a Azure DevOps Server project-scoped feed. While resolving + # dependencies it will be registered as a trusted repository with the name specified in the property 'Gallery' above, + # unless property 'Name' is provided in the hashtable below, if so it will override the property 'Gallery' above. The + # registered repository will be removed when dependencies has been resolved, unless it was already registered to begin + # with. If repository is registered already but with different URL:s the repository will be re-registered and reverted + # after dependencies has been resolved. Currently only Windows integrated security works with private Nuget v2 feeds + # (or if it is a public feed with no security), it is not possible yet to securely provide other credentials for the feed. + # Private repositories will currently only work using PowerShellGet. + #RegisterGallery = @{ + # #Name = 'MyPrivateFeedName' + # GallerySourceLocation = 'https://azdoserver.company.local///_packaging//nuget/v2' + # GalleryPublishLocation = 'https://azdoserver.company.local///_packaging//nuget/v2' + # GalleryScriptSourceLocation = 'https://azdoserver.company.local///_packaging//nuget/v2' + # GalleryScriptPublishLocation = 'https://azdoserver.company.local///_packaging//nuget/v2' + # #InstallationPolicy = 'Trusted' + #} + + #AllowOldPowerShellGetModule = $true + #MinimumPSDependVersion = '0.3.0' + AllowPrerelease = $false + WithYAML = $true # Will also bootstrap PowerShell-Yaml to read other config files + + <# + Enable ModuleFast to be the default method of resolving dependencies by setting + UseModuleFast to the value $true. ModuleFast requires PowerShell 7.2 or higher. + If UseModuleFast is not configured or set to $false then PowerShellGet (or + PSResourceGet if enabled) will be used to as the default method of resolving + dependencies. You can always use the parameter `-UseModuleFast` of the + Resolve-Dependency.ps1 or build.ps1 script even when this is not configured + or set to $false. + + You can use ModuleFastVersion to specify a specific version of ModuleFast to use. + This will also affect the use of parameter `-UseModuleFast` of the Resolve-Dependency.ps1 + or build.ps1 script. If ModuleFastVersion is not configured then the latest + (non-preview) released version is used. + + ModuleFastBleedingEdge will override ModuleFastVersion and use the absolute latest + code from the ModuleFast repository. This is useful if you want to test the absolute + latest changes in ModuleFast repository. This is not recommended for production use. + By enabling ModuleFastBleedingEdge the pipeline can encounter breaking changes or + problems by code that is merged in the ModuleFast repository, this could affect the + pipeline negatively. Make sure to use a clean PowerShell session after changing + the value of ModuleFastBleedingEdge so that ModuleFast uses the correct bootstrap + script and correct parameter values. This will also affect the use of parameter + `-UseModuleFast` of the Resolve-Dependency.ps1 or build.ps1 script. + #> + #UseModuleFast = $true + #ModuleFastVersion = '0.1.2' + #ModuleFastBleedingEdge = $true + + <# + Enable PSResourceGet to be the default method of resolving dependencies by setting + UsePSResourceGet to the value $true. If UsePSResourceGet is not configured or + set to $false then PowerShellGet will be used to resolve dependencies. + #> + UsePSResourceGet = $true + PSResourceGetVersion = '1.2.0' + + # PowerShellGet compatibility module only works when using PSResourceGet or ModuleFast. + UsePowerShellGetCompatibilityModule = $true + UsePowerShellGetCompatibilityModuleVersion = '3.0.23-beta23' +} diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..10e5bc5 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,43 @@ +## Security + +We take the security of our modules seriously, which includes all source +code repositories managed through our GitHub organization. + +If you believe you have found a security vulnerability in any of our +repository, please report it to us as described below. + +## Reporting Security Issues + +If the repository has enabled the ability to report a security vulnerability +through GitHub new issue (separate button called "Report a vulnerability") +then use that. See [Privately reporting a security vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability) +for more information. + +> [!CAUTION] +> Please do not report security vulnerabilities through a **public** GitHub issues +> or other public forum. + +If the repository does not have that option then please +report the security issue privately to one or several maintainers of the +repository. The easiest way to do so is to send us a direct message via +Twitter (X), Slack, Discord, or find us on some other social platform. + +You should receive a response within 48 hours. If for some reason you do not, +please follow up by other means or to other contributors. + +Please include the requested information listed below (as much as you can +provide) to help us better understand the nature and scope of the possible issue: + +* Type of issue +* Full paths of source file(s) related to the manifestation of the issue +* The location of the affected source code (tag/branch/commit or direct URL) +* Any special configuration required to reproduce the issue +* Step-by-step instructions to reproduce the issue +* Proof-of-concept or exploit code (if possible) +* Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +## Preferred Languages + +We prefer all communications to be in English. diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..f4a0fae --- /dev/null +++ b/build.ps1 @@ -0,0 +1,538 @@ +<# + .DESCRIPTION + Bootstrap and build script for PowerShell module CI/CD pipeline. + + .PARAMETER Tasks + The task or tasks to run. The default value is '.' (runs the default task). + + .PARAMETER CodeCoverageThreshold + The code coverage target threshold to uphold. Set to 0 to disable. + The default value is '' (empty string). + + .PARAMETER BuildConfig + Not yet written. + + .PARAMETER OutputDirectory + Specifies the folder to build the artefact into. The default value is 'output'. + + .PARAMETER BuiltModuleSubdirectory + Subdirectory name to build the module (under $OutputDirectory). The default + value is '' (empty string). + + .PARAMETER RequiredModulesDirectory + Can be a path (relative to $PSScriptRoot or absolute) to tell Resolve-Dependency + and PSDepend where to save the required modules. It is also possible to use + 'CurrentUser' och 'AllUsers' to install missing dependencies. You can override + the value for PSDepend in the Build.psd1 build manifest. The default value is + 'output/RequiredModules'. + + .PARAMETER PesterScript + One or more paths that will override the Pester configuration in build + configuration file when running the build task Invoke_Pester_Tests. + + If running Pester 5 test, use the alias PesterPath to be future-proof. + + .PARAMETER PesterTag + Filter which tags to run when invoking Pester tests. This is used in the + Invoke-Pester.pester.build.ps1 tasks. + + .PARAMETER PesterExcludeTag + Filter which tags to exclude when invoking Pester tests. This is used in + the Invoke-Pester.pester.build.ps1 tasks. + + .PARAMETER DscTestTag + Filter which tags to run when invoking DSC Resource tests. This is used + in the DscResource.Test.build.ps1 tasks. + + .PARAMETER DscTestExcludeTag + Filter which tags to exclude when invoking DSC Resource tests. This is + used in the DscResource.Test.build.ps1 tasks. + + .PARAMETER ResolveDependency + Not yet written. + + .PARAMETER BuildInfo + The build info object from ModuleBuilder. Defaults to an empty hashtable. + + .PARAMETER AutoRestore + Not yet written. + + .PARAMETER UseModuleFast + Specifies to use ModuleFast instead of PowerShellGet to resolve dependencies + faster. + + .PARAMETER UsePSResourceGet + Specifies to use PSResourceGet instead of PowerShellGet to resolve dependencies + faster. This can also be configured in Resolve-Dependency.psd1. + + .PARAMETER UsePowerShellGetCompatibilityModule + Specifies to use the compatibility module PowerShellGet. This parameter + only works then the method of downloading dependencies is PSResourceGet. + This can also be configured in Resolve-Dependency.psd1. +#> +[CmdletBinding()] +param +( + [Parameter(Position = 0)] + [System.String[]] + $Tasks = '.', + + [Parameter()] + [System.String] + $CodeCoverageThreshold = '', + + [Parameter()] + [System.String] + [ValidateScript( + { Test-Path -Path $_ } + )] + $BuildConfig, + + [Parameter()] + [System.String] + $OutputDirectory = 'output', + + [Parameter()] + [System.String] + $BuiltModuleSubdirectory = '', + + [Parameter()] + [System.String] + $RequiredModulesDirectory = $(Join-Path 'output' 'RequiredModules'), + + [Parameter()] + # This alias is to prepare for the rename of this parameter to PesterPath when Pester 4 support is removed + [Alias('PesterPath')] + [System.Object[]] + $PesterScript, + + [Parameter()] + [System.String[]] + $PesterTag, + + [Parameter()] + [System.String[]] + $PesterExcludeTag, + + [Parameter()] + [System.String[]] + $DscTestTag, + + [Parameter()] + [System.String[]] + $DscTestExcludeTag, + + [Parameter()] + [Alias('bootstrap')] + [System.Management.Automation.SwitchParameter] + $ResolveDependency, + + [Parameter(DontShow)] + [AllowNull()] + [System.Collections.Hashtable] + $BuildInfo, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $AutoRestore, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $UseModuleFast, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $UsePSResourceGet, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $UsePowerShellGetCompatibilityModule +) + +<# + The BEGIN block (at the end of this file) handles the Bootstrap of the Environment + before Invoke-Build can run the tasks if the parameter ResolveDependency (or + parameter alias Bootstrap) is specified. +#> + +process +{ + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + # Only run the process block through InvokeBuild (look at the Begin block at the bottom of this script). + return + } + + # Execute the Build process from the .build.ps1 path. + Push-Location -Path $PSScriptRoot -StackName 'BeforeBuild' + + try + { + Write-Host -Object "[build] Parsing defined tasks" -ForeGroundColor Magenta + + # Load the default BuildInfo if the parameter BuildInfo is not set. + if (-not $PSBoundParameters.ContainsKey('BuildInfo')) + { + try + { + if (Test-Path -Path $BuildConfig) + { + $configFile = Get-Item -Path $BuildConfig + + Write-Host -Object "[build] Loading Configuration from $configFile" + + $BuildInfo = switch -Regex ($configFile.Extension) + { + # Native Support for PSD1 + '\.psd1' + { + if (-not (Get-Command -Name Import-PowerShellDataFile -ErrorAction SilentlyContinue)) + { + Import-Module -Name Microsoft.PowerShell.Utility -RequiredVersion 3.1.0.0 + } + + Import-PowerShellDataFile -Path $BuildConfig + } + + # Support for yaml when module PowerShell-Yaml is available + '\.[yaml|yml]' + { + Import-Module -Name 'powershell-yaml' -ErrorAction Stop + + ConvertFrom-Yaml -Yaml (Get-Content -Raw $configFile) + } + + # Support for JSON and JSONC (by Removing comments) when module PowerShell-Yaml is available + '\.[json|jsonc]' + { + $jsonFile = Get-Content -Raw -Path $configFile + + $jsonContent = $jsonFile -replace '(?m)\s*//.*?$' -replace '(?ms)/\*.*?\*/' + + # Yaml is superset of JSON. + ConvertFrom-Yaml -Yaml $jsonContent + } + + # Unknown extension, return empty hashtable. + default + { + Write-Error -Message "Extension '$_' not supported. using @{}" + + @{ } + } + } + } + else + { + Write-Host -Object "Configuration file '$($BuildConfig.FullName)' not found" -ForegroundColor Red + + # No config file was found, return empty hashtable. + $BuildInfo = @{ } + } + } + catch + { + $logMessage = "Error loading Config '$($BuildConfig.FullName)'.`r`nAre you missing dependencies?`r`nMake sure you run './build.ps1 -ResolveDependency -tasks noop' before running build to restore the required modules." + + Write-Host -Object $logMessage -ForegroundColor Yellow + + $BuildInfo = @{ } + + Write-Error -Message $_.Exception.Message + } + } + + # If the Invoke-Build Task Header is specified in the Build Info, set it. + if ($BuildInfo.TaskHeader) + { + Set-BuildHeader -Script ([scriptblock]::Create($BuildInfo.TaskHeader)) + } + + <# + Add BuildModuleOutput to PSModule Path environment variable. + Moved here (not in begin block) because build file can contains BuiltSubModuleDirectory value. + #> + if ($BuiltModuleSubdirectory) + { + if (-not (Split-Path -IsAbsolute -Path $BuiltModuleSubdirectory)) + { + $BuildModuleOutput = Join-Path -Path $OutputDirectory -ChildPath $BuiltModuleSubdirectory + } + else + { + $BuildModuleOutput = $BuiltModuleSubdirectory + } + } # test if BuiltModuleSubDirectory set in build config file + elseif ($BuildInfo.ContainsKey('BuiltModuleSubDirectory')) + { + $BuildModuleOutput = Join-Path -Path $OutputDirectory -ChildPath $BuildInfo['BuiltModuleSubdirectory'] + } + else + { + $BuildModuleOutput = $OutputDirectory + } + + # Pre-pending $BuildModuleOutput folder to PSModulePath to resolve built module from this folder. + if ($powerShellModulePaths -notcontains $BuildModuleOutput) + { + Write-Host -Object "[build] Pre-pending '$BuildModuleOutput' folder to PSModulePath" -ForegroundColor Green + + $env:PSModulePath = $BuildModuleOutput + [System.IO.Path]::PathSeparator + $env:PSModulePath + } + + <# + Import Tasks from modules via their exported aliases when defined in Build Manifest. + https://github.com/nightroman/Invoke-Build/tree/master/Tasks/Import#example-2-import-from-a-module-with-tasks + #> + if ($BuildInfo.ContainsKey('ModuleBuildTasks')) + { + foreach ($module in $BuildInfo['ModuleBuildTasks'].Keys) + { + try + { + Write-Host -Object "Importing tasks from module $module" -ForegroundColor DarkGray + + $loadedModule = Import-Module -Name $module -PassThru -ErrorAction Stop + + foreach ($TaskToExport in $BuildInfo['ModuleBuildTasks'].($module)) + { + $loadedModule.ExportedAliases.GetEnumerator().Where{ + Write-Host -Object "`t Loading $($_.Key)..." -ForegroundColor DarkGray + + # Using -like to support wildcard. + $_.Key -like $TaskToExport + }.ForEach{ + # Dot-sourcing the Tasks via their exported aliases. + . (Get-Alias $_.Key) + } + } + } + catch + { + Write-Host -Object "Could not load tasks for module $module." -ForegroundColor Red + + Write-Error -Message $_ + } + } + } + + # Loading Build Tasks defined in the .build/ folder (will override the ones imported above if same task name). + Get-ChildItem -Path '.build/' -Recurse -Include '*.ps1' -ErrorAction Ignore | + ForEach-Object { + "Importing file $($_.BaseName)" | Write-Verbose + + . $_.FullName + } + + # Synopsis: Empty task, useful to test the bootstrap process. + task noop { } + + # Define default task sequence ("."), can be overridden in the $BuildInfo. + task . { + Write-Build -Object 'No sequence currently defined for the default task' -ForegroundColor Yellow + } + + Write-Host -Object 'Adding Workflow from configuration:' -ForegroundColor DarkGray + + # Load Invoke-Build task sequences/workflows from $BuildInfo. + foreach ($workflow in $BuildInfo.BuildWorkflow.keys) + { + Write-Verbose -Message "Creating Build Workflow '$Workflow' with tasks $($BuildInfo.BuildWorkflow.($Workflow) -join ', ')." + + $workflowItem = $BuildInfo.BuildWorkflow.($workflow) + + if ($workflowItem.Trim() -match '^\{(?[\w\W]*)\}$') + { + $workflowItem = [ScriptBlock]::Create($Matches['sb']) + } + + Write-Host -Object " +-> $workflow" -ForegroundColor DarkGray + + task $workflow $workflowItem + } + + Write-Host -Object "[build] Executing requested workflow: $($Tasks -join ', ')" -ForeGroundColor Magenta + + } + finally + { + Pop-Location -StackName 'BeforeBuild' + } +} + +begin +{ + # Find build config if not specified. + if (-not $BuildConfig) + { + $config = Get-ChildItem -Path "$PSScriptRoot\*" -Include 'build.y*ml', 'build.psd1', 'build.json*' -ErrorAction Ignore + + if (-not $config -or ($config -is [System.Array] -and $config.Length -le 0)) + { + throw 'No build configuration found. Specify path via parameter BuildConfig.' + } + elseif ($config -is [System.Array]) + { + if ($config.Length -gt 1) + { + throw 'More than one build configuration found. Specify which path to use via parameter BuildConfig.' + } + + $BuildConfig = $config[0] + } + else + { + $BuildConfig = $config + } + } + + # Bootstrapping the environment before using Invoke-Build as task runner + + if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') + { + Write-Host -Object "[pre-build] Starting Build Init" -ForegroundColor Green + + Push-Location $PSScriptRoot -StackName 'BuildModule' + } + + if ($RequiredModulesDirectory -in @('CurrentUser', 'AllUsers')) + { + # Installing modules instead of saving them. + Write-Host -Object "[pre-build] Required Modules will be installed to the PowerShell module path that is used for $RequiredModulesDirectory." -ForegroundColor Green + + <# + The variable $PSDependTarget will be used below when building the splatting + variable before calling Resolve-Dependency.ps1, unless overridden in the + file Resolve-Dependency.psd1. + #> + $PSDependTarget = $RequiredModulesDirectory + } + else + { + if (-not (Split-Path -IsAbsolute -Path $OutputDirectory)) + { + $OutputDirectory = Join-Path -Path $PSScriptRoot -ChildPath $OutputDirectory + } + + # Resolving the absolute path to save the required modules to. + if (-not (Split-Path -IsAbsolute -Path $RequiredModulesDirectory)) + { + $RequiredModulesDirectory = Join-Path -Path $PSScriptRoot -ChildPath $RequiredModulesDirectory + } + + # Create the output/modules folder if not exists, or resolve the Absolute path otherwise. + if (Resolve-Path -Path $RequiredModulesDirectory -ErrorAction SilentlyContinue) + { + Write-Debug -Message "[pre-build] Required Modules path already exist at $RequiredModulesDirectory" + + $requiredModulesPath = Convert-Path -Path $RequiredModulesDirectory + } + else + { + Write-Host -Object "[pre-build] Creating required modules directory $RequiredModulesDirectory." -ForegroundColor Green + + $requiredModulesPath = (New-Item -ItemType Directory -Force -Path $RequiredModulesDirectory).FullName + } + + $powerShellModulePaths = $env:PSModulePath -split [System.IO.Path]::PathSeparator + + # Pre-pending $requiredModulesPath folder to PSModulePath to resolve from this folder FIRST. + if ($RequiredModulesDirectory -notin @('CurrentUser', 'AllUsers') -and + ($powerShellModulePaths -notcontains $RequiredModulesDirectory)) + { + Write-Host -Object "[pre-build] Pre-pending '$RequiredModulesDirectory' folder to PSModulePath" -ForegroundColor Green + + $env:PSModulePath = $RequiredModulesDirectory + [System.IO.Path]::PathSeparator + $env:PSModulePath + } + + $powerShellYamlModule = Get-Module -Name 'powershell-yaml' -ListAvailable + $invokeBuildModule = Get-Module -Name 'InvokeBuild' -ListAvailable + $psDependModule = Get-Module -Name 'PSDepend' -ListAvailable + + # Checking if the user should -ResolveDependency. + if (-not ($powerShellYamlModule -and $invokeBuildModule -and $psDependModule) -and -not $ResolveDependency) + { + if ($AutoRestore -or -not $PSBoundParameters.ContainsKey('Tasks') -or $Tasks -contains 'build') + { + Write-Host -Object "[pre-build] Dependency missing, running './build.ps1 -ResolveDependency -Tasks noop' for you `r`n" -ForegroundColor Yellow + + $ResolveDependency = $true + } + else + { + Write-Warning -Message "Some required Modules are missing, make sure you first run with the '-ResolveDependency' parameter. Running 'build.ps1 -ResolveDependency -Tasks noop' will pull required modules without running the build task." + } + } + + <# + The variable $PSDependTarget will be used below when building the splatting + variable before calling Resolve-Dependency.ps1, unless overridden in the + file Resolve-Dependency.psd1. + #> + $PSDependTarget = $requiredModulesPath + } + + if ($ResolveDependency) + { + Write-Host -Object "[pre-build] Resolving dependencies using preferred method." -ForegroundColor Green + + $resolveDependencyParams = @{ } + + # If BuildConfig is a Yaml file, bootstrap powershell-yaml via ResolveDependency. + if ($BuildConfig -match '\.[yaml|yml]$') + { + $resolveDependencyParams.Add('WithYaml', $true) + } + + $resolveDependencyAvailableParams = (Get-Command -Name '.\Resolve-Dependency.ps1').Parameters.Keys + + foreach ($cmdParameter in $resolveDependencyAvailableParams) + { + # The parameter has been explicitly used for calling the .build.ps1 + if ($MyInvocation.BoundParameters.ContainsKey($cmdParameter)) + { + $paramValue = $MyInvocation.BoundParameters.Item($cmdParameter) + + Write-Debug " adding $cmdParameter :: $paramValue [from user-provided parameters to Build.ps1]" + + $resolveDependencyParams.Add($cmdParameter, $paramValue) + } + # Use defaults parameter value from Build.ps1, if any + else + { + $paramValue = Get-Variable -Name $cmdParameter -ValueOnly -ErrorAction Ignore + + if ($paramValue) + { + Write-Debug " adding $cmdParameter :: $paramValue [from default Build.ps1 variable]" + + $resolveDependencyParams.Add($cmdParameter, $paramValue) + } + } + } + + Write-Host -Object "[pre-build] Starting bootstrap process." -ForegroundColor Green + + .\Resolve-Dependency.ps1 @resolveDependencyParams + } + + if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') + { + Write-Verbose -Message "Bootstrap completed. Handing back to InvokeBuild." + + if ($PSBoundParameters.ContainsKey('ResolveDependency')) + { + Write-Verbose -Message "Dependency already resolved. Removing task." + + $null = $PSBoundParameters.Remove('ResolveDependency') + } + + Write-Host -Object "[build] Starting build with InvokeBuild." -ForegroundColor Green + + Invoke-Build @PSBoundParameters -Task $Tasks -File $MyInvocation.MyCommand.Path + + Pop-Location -StackName 'BuildModule' + + return + } +} diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..06a7545 --- /dev/null +++ b/build.yaml @@ -0,0 +1,158 @@ +--- +#################################################### +# ModuleBuilder Configuration # +#################################################### +# Path to the Module Manifest to build (where path will be resolved from) +# SourcePath: ./Sampler/Sampler.psd1 +# Output Directory where ModuleBuilder will build the Module, relative to module manifest +# OutputDirectory: ../output/Sampler +BuiltModuleSubdirectory: module +CopyPaths: + - en-US +# - DSCResources + # - Modules +Encoding: UTF8 +# Can be used to manually specify module's semantic version if the preferred method of +# using GitVersion is not available, and it is not possible to set the session environment +# variable `$env:ModuleVersion`, nor setting the variable `$ModuleVersion`, in the +# PowerShell session (parent scope) before running the task `build`. +#SemVer: '99.0.0-preview1' + +# Suffix to add to Root module PSM1 after merge (here, the Set-Alias exporting IB tasks) +# suffix: suffix.ps1 +# prefix: prefix.ps1 +VersionedOutputDirectory: true + +#################################################### +# ModuleBuilder Submodules Configuration # +#################################################### + +NestedModule: +# HelperSubmodule: # This is the first submodule to build into the output +# Path: ./*/Modules/HelperSubmodule/HelperSubmodule.psd1 +# # is trimmed (remove metadata & Prerelease tag) and OutputDirectory expanded (the only one) +# OutputDirectory: ///Modules/HelperSubmodule +# VersionedOutputDirectory: false +# AddToManifest: false +# SemVer: +# # suffix: +# # prefix: + +#################################################### +# Sampler Pipeline Configuration # +#################################################### +# Defining 'Workflows' (suite of InvokeBuild tasks) to be run using their alias +BuildWorkflow: + '.': # "." is the default Invoke-Build workflow. It is called when no -Tasks is specified to the build.ps1 + - build + - test + + build: + - Clean + - Build_Module_ModuleBuilder + - Move_Formats_To_Output + - Build_NestedModules_ModuleBuilder + - Create_changelog_release_output + - BuildHelpFiles + + + + pack: + - build + - package_module_nupkg + + + + # Defining test task to be run when invoking `./build.ps1 -Tasks test` + test: + # Uncomment to modify the PSModulePath in the test pipeline (also requires the build configuration section SetPSModulePath). + #- Set_PSModulePath + - Pester_Tests_Stop_On_Fail + # Use this task if pipeline uses code coverage and the module is using the + # pattern of Public, Private, Enum, Classes. + #- Convert_Pester_Coverage + - Pester_if_Code_Coverage_Under_Threshold + + # Use this task when you have multiple parallel tests, which produce multiple + # code coverage files and needs to get merged into one file. + #merge: + #- Merge_CodeCoverage_Files + + publish: + - Publish_Release_To_GitHub # Runs first, if token is expired it will fail early + - Publish_GitHub_Wiki_Content + + - publish_module_to_gallery + +#################################################### +# PESTER Configuration # +#################################################### + +Pester: + OutputFormat: NUnitXML + # Excludes one or more paths from being used to calculate code coverage. + ExcludeFromCodeCoverage: + + # If no scripts are defined the default is to use all the tests under the project's + # tests folder or source folder (if present). Test script paths can be defined to + # only run tests in certain folders, or run specific test files, or can be use to + # specify the order tests are run. + Script: + # - tests/QA/module.tests.ps1 + # - tests/QA + # - tests/Unit + # - tests/Integration + ExcludeTag: + # - helpQuality + # - FunctionalQuality + # - TestQuality + Tag: + CodeCoverageThreshold: 0 # Set to 0 to bypass + #CodeCoverageOutputFile: JaCoCo_$OsShortName.xml + #CodeCoverageOutputFileEncoding: ascii + # Use this if code coverage should be merged from several pipeline test jobs. + # Any existing keys above should be replaced. See also CodeCoverage below. + # CodeCoverageOutputFile is the file that is created for each pipeline test job. + #CodeCoverageOutputFile: JaCoCo_Merge.xml + +# Use this to merged code coverage from several pipeline test jobs. +# CodeCoverageFilePattern - the pattern used to search all pipeline test job artifacts +# after the file specified in CodeCoverageOutputFile. +# CodeCoverageMergedOutputFile - the file that is created by the merge build task and +# is the file that should be uploaded to code coverage services. +#CodeCoverage: + #CodeCoverageFilePattern: JaCoCo_Merge.xml # the pattern used to search all pipeline test job artifacts + #CodeCoverageMergedOutputFile: JaCoCo_coverage.xml # the file that is created for the merged code coverage + +DscTest: + ExcludeTag: + - "Common Tests - New Error-Level Script Analyzer Rules" + Tag: + ExcludeSourceFile: + - output + ExcludeModuleFile: + - Modules/DscResource.Common + # - Templates + +# Import ModuleBuilder tasks from a specific PowerShell module using the build +# task's alias. Wildcard * can be used to specify all tasks that has a similar +# prefix and or suffix. The module contain the task must be added as a required +# module in the file RequiredModules.psd1. +ModuleBuildTasks: + Sampler: + - '*.build.Sampler.ib.tasks' + Sampler.GitHubTasks: + - '*.ib.tasks' + + +# Invoke-Build Header to be used to 'decorate' the terminal output of the tasks. +TaskHeader: | + param($Path) + "" + "=" * 79 + Write-Build Cyan "`t`t`t$($Task.Name.replace("_"," ").ToUpper())" + Write-Build DarkGray "$(Get-BuildSynopsis $Task)" + "-" * 79 + Write-Build DarkGray " $Path" + Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)" + "" diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..269e924 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,31 @@ +codecov: + require_ci_to_pass: no + # master should be the baseline for reporting + branch: main + +comment: + layout: "reach, diff, flags, files" + behavior: default + +coverage: + range: 50..80 + round: down + precision: 0 + + status: + project: + default: + # Set the overall project code coverage requirement to 70% + target: 70 + patch: + default: + # Set the pull request requirement to not regress overall coverage by more than 5% + # and let codecov.io set the goal for the code changed in the patch. + target: auto + threshold: 5 + +# Use this if there are paths that should not be part of the code coverage, for +# example a deprecated function where tests has been removed. +#ignore: +# - 'source/Public/Get-Deprecated.ps1' + diff --git a/docs/Add-XoGroupUser.md b/docs/Add-XoGroupUser.md new file mode 100644 index 0000000..db6e020 --- /dev/null +++ b/docs/Add-XoGroupUser.md @@ -0,0 +1,119 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Add-XoGroupUser + +## SYNOPSIS +Add an existing user to a Xen Orchestra group. + +## SYNTAX + +``` +Add-XoGroupUser [-GroupId] [-UserId] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Associates a user with a group via PUT /groups/{id}/users/{userId}. +The user must already exist (see New-XoUser). +This is an idempotent operation - re-adding an already-member user is a no-op on the server. + +## EXAMPLES + +### EXAMPLE 1 +``` +Add-XoGroupUser -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" +``` + +## PARAMETERS + +### -GroupId +The UUID of the group the user will be added to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -UserId +The UUID of the user to add to the group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Add-XoVmStatDataSource.md b/docs/Add-XoVmStatDataSource.md new file mode 100644 index 0000000..68e3606 --- /dev/null +++ b/docs/Add-XoVmStatDataSource.md @@ -0,0 +1,118 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Add-XoVmStatDataSource + +## SYNOPSIS +Add a stats data source on a VM. + +## SYNTAX + +``` +Add-XoVmStatDataSource [-VmUuid] [-DataSource] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Calls PUT /vms/{id}/stats/data_source/{data_source} to add stat data source. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -DataSource "cpu0" +``` + +## PARAMETERS + +### -VmUuid +The UUID of the target VM. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DataSource +The name of the stats data source (e.g. +'cpu0', 'memory'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Clear-XoTask.md b/docs/Clear-XoTask.md new file mode 100644 index 0000000..9e80790 --- /dev/null +++ b/docs/Clear-XoTask.md @@ -0,0 +1,104 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Clear-XoTask + +## SYNOPSIS +Delete all Xen Orchestra tasks (bulk cleanup). + +## SYNTAX + +``` +Clear-XoTask [[-Filter] ] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /tasks. +Used to purge the task log. +Typically invoked with -Filter to scope to completed/failed tasks only; check the XO REST documentation for the exact filter semantics supported on this endpoint. + +## EXAMPLES + +### EXAMPLE 1 +``` +Clear-XoTask -Filter 'status:success' +``` + +## PARAMETERS + +### -Filter +Optional filter expression forwarded to the server. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Connect-XoPbd.md b/docs/Connect-XoPbd.md new file mode 100644 index 0000000..f61951f --- /dev/null +++ b/docs/Connect-XoPbd.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Connect-XoPbd + +## SYNOPSIS +Plug one or more Xen Orchestra PBDs. + +## SYNTAX + +``` +Connect-XoPbd [-PbdUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Attaches the PBD to its host, making the underlying SR available. +Returns a task that can be passed to Wait-XoTask. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -PbdUuid +The UUID(s) of the PBD to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Connect-XoServer.md b/docs/Connect-XoServer.md new file mode 100644 index 0000000..a5c6b71 --- /dev/null +++ b/docs/Connect-XoServer.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Connect-XoServer + +## SYNOPSIS +Connect one or more Xen Orchestra XO servers. + +## SYNTAX + +``` +Connect-XoServer [-ServerUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Establishes the XAPI connection for the registered XO server. +Returns a task object. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -ServerUuid +The UUID(s) of the XO server to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Connect-XoSession.md b/docs/Connect-XoSession.md new file mode 100644 index 0000000..68a952f --- /dev/null +++ b/docs/Connect-XoSession.md @@ -0,0 +1,161 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Connect-XoSession + +## SYNOPSIS +Connect to a Xen Orchestra instance. + +## SYNTAX + +### Token (Default) +``` +Connect-XoSession [-HostName] [-Token ] [-Limit ] [-SaveCredentials] + [-SkipCertificateCheck] [-ProgressAction ] [] +``` + +### Credential +``` +Connect-XoSession [-HostName] -Credential [-Limit ] [-SaveCredentials] + [-SkipCertificateCheck] [-ProgressAction ] [] +``` + +## DESCRIPTION +Establishes a connection to a Xen Orchestra instance using either token-based or credential-based authentication. + +## EXAMPLES + +### EXAMPLE 1 +``` +Connect-XoSession -HostName "https://xo.example.com" -Token "your-api-token" +Connects to the specified Xen Orchestra instance using a token. +``` + +### EXAMPLE 2 +``` +Connect-XoSession -HostName "https://xo.example.com" +Prompts for a token and connects to the specified Xen Orchestra instance. +``` + +## PARAMETERS + +### -HostName +The URL of the Xen Orchestra instance. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Credential +Credentials for authentication (not currently implemented). + +```yaml +Type: PSCredential +Parameter Sets: Credential +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Token +API token for authentication. + +```yaml +Type: String +Parameter Sets: Token +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Default page size limit for query cmdlets. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SaveCredentials +Save credentials for future sessions. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SkipCertificateCheck +Skips certificate validation (not recommended for production). + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### System.Boolean +## NOTES + +## RELATED LINKS diff --git a/docs/Connect-XoVbd.md b/docs/Connect-XoVbd.md new file mode 100644 index 0000000..183fd13 --- /dev/null +++ b/docs/Connect-XoVbd.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Connect-XoVbd + +## SYNOPSIS +Plug one or more Xen Orchestra VBDs. + +## SYNTAX + +``` +Connect-XoVbd [-VbdUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Plugs the VBD into its VM so the guest can see the backing VDI (hot-plug if the VM is running). +Returns a task. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -VbdUuid +The UUID(s) of the VBD to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Copy-XoVm.md b/docs/Copy-XoVm.md new file mode 100644 index 0000000..7ad31f7 --- /dev/null +++ b/docs/Copy-XoVm.md @@ -0,0 +1,122 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Copy-XoVm + +## SYNOPSIS +Clone a Xen Orchestra VM. + +## SYNTAX + +``` +Copy-XoVm [-VmUuid] [-Parameters ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Clones the specified VM. +Use -Parameters to pass optional clone options (e.g. +\`\`@{ name = "copy"; full_copy = $true }\`\`). +Returns a task object. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Parameters @{ } +``` + +## PARAMETERS + +### -VmUuid +The UUID of the VM to act on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Parameters +Hashtable of action body parameters. +See the linked XO REST documentation for the expected fields. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Disable-XoHost.md b/docs/Disable-XoHost.md new file mode 100644 index 0000000..e321c7e --- /dev/null +++ b/docs/Disable-XoHost.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Disable-XoHost + +## SYNOPSIS +Disable one or more Xen Orchestra hosts. + +## SYNTAX + +``` +Disable-XoHost [-HostUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Marks the host as disabled so the pool scheduler stops placing new VMs on it. +Existing VMs keep running until migrated or shut down. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Disconnect-XoPbd.md b/docs/Disconnect-XoPbd.md new file mode 100644 index 0000000..e3b28c1 --- /dev/null +++ b/docs/Disconnect-XoPbd.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Disconnect-XoPbd + +## SYNOPSIS +Unplug one or more Xen Orchestra PBDs. + +## SYNTAX + +``` +Disconnect-XoPbd [-PbdUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Detaches the PBD from its host, taking the SR offline on that host. +All VMs/VDIs using the SR from this host must be detached or migrated first. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -PbdUuid +The UUID(s) of the PBD to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Disconnect-XoServer.md b/docs/Disconnect-XoServer.md new file mode 100644 index 0000000..9dedf18 --- /dev/null +++ b/docs/Disconnect-XoServer.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Disconnect-XoServer + +## SYNOPSIS +Disconnect one or more Xen Orchestra XO servers. + +## SYNTAX + +``` +Disconnect-XoServer [-ServerUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Drops the XAPI connection for the registered XO server. +The server stays registered but its pool stops syncing until reconnected. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -ServerUuid +The UUID(s) of the XO server to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Disconnect-XoSession.md b/docs/Disconnect-XoSession.md new file mode 100644 index 0000000..ab0a5f7 --- /dev/null +++ b/docs/Disconnect-XoSession.md @@ -0,0 +1,77 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Disconnect-XoSession + +## SYNOPSIS +Disconnect from a Xen Orchestra instance. + +## SYNTAX + +``` +Disconnect-XoSession [-ClearCredentials] [-ProgressAction ] [] +``` + +## DESCRIPTION +Disconnects from the current Xen Orchestra session and optionally clears saved credentials. + +## EXAMPLES + +### EXAMPLE 1 +``` +Disconnect-XoSession +Disconnects from the current session. +``` + +### EXAMPLE 2 +``` +Disconnect-XoSession -ClearCredentials +Disconnects from the current session and clears saved credentials. +``` + +## PARAMETERS + +### -ClearCredentials +Clears any saved credentials for the current session. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Disconnect-XoVbd.md b/docs/Disconnect-XoVbd.md new file mode 100644 index 0000000..37f2494 --- /dev/null +++ b/docs/Disconnect-XoVbd.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Disconnect-XoVbd + +## SYNOPSIS +Unplug one or more Xen Orchestra VBDs. + +## SYNTAX + +``` +Disconnect-XoVbd [-VbdUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Unplugs the VBD from its VM. +Any guest I/O to the disk is cut off. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -VbdUuid +The UUID(s) of the VBD to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Enable-XoHost.md b/docs/Enable-XoHost.md new file mode 100644 index 0000000..a630a96 --- /dev/null +++ b/docs/Enable-XoHost.md @@ -0,0 +1,109 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Enable-XoHost + +## SYNOPSIS +Enable one or more Xen Orchestra hosts. + +## SYNTAX + +``` +Enable-XoHost [-HostUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Marks the host as enabled so the pool scheduler will place new VMs on it. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Export-XoVdi.md b/docs/Export-XoVdi.md new file mode 100644 index 0000000..aa94d9e --- /dev/null +++ b/docs/Export-XoVdi.md @@ -0,0 +1,156 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Export-XoVdi + +## SYNOPSIS +Export a VDI. + +## SYNTAX + +``` +Export-XoVdi [-VdiUuid] [-Format] [-OutFile] [-PassThru] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Export a VDI from Xen Orchestra. +Downloads the VDI to a local file. + +## EXAMPLES + +### EXAMPLE 1 +``` +Export-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" -Format vhd -OutFile "C:\Exports\disk.vhd" +Exports the VDI in VHD format to the specified file. +``` + +### EXAMPLE 2 +``` +Get-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" | Export-XoVdi -Format vhd -OutFile "C:\Exports\disk.vhd" +Exports the VDI in VHD format to the specified file, piping from Get-XoVdi. +``` + +## PARAMETERS + +### -VdiUuid +The UUID of the VDI to export. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: VdiId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Format +The format to export the VDI in. +Valid values: raw, vhd. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -OutFile +The path to save the exported VDI to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +If specified, returns the exported file info as a FileInfo object. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Export-XoVdiSnapshot.md b/docs/Export-XoVdiSnapshot.md new file mode 100644 index 0000000..f3f671c --- /dev/null +++ b/docs/Export-XoVdiSnapshot.md @@ -0,0 +1,156 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Export-XoVdiSnapshot + +## SYNOPSIS +Export a VDI snapshot. + +## SYNTAX + +``` +Export-XoVdiSnapshot [-VdiSnapshotUuid] [-Format] [-OutFile] [-PassThru] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Export a VDI snapshot from Xen Orchestra. +Downloads the snapshot to a local file. + +## EXAMPLES + +### EXAMPLE 1 +``` +Export-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" -Format vhd -OutFile "C:\Exports\snapshot.vhd" +Exports the VDI snapshot in VHD format to the specified file. +``` + +### EXAMPLE 2 +``` +Get-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" | Export-XoVdiSnapshot -Format vhd -OutFile "C:\Exports\snapshot.vhd" +Exports the VDI snapshot in VHD format to the specified file, piping from Get-XoVdiSnapshot. +``` + +## PARAMETERS + +### -VdiSnapshotUuid +The UUID of the VDI snapshot to export. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: VdiSnapshotId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Format +The format to export the VDI snapshot in. +Valid values: raw, vhd. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -OutFile +The path to save the exported VDI snapshot to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +If specified, returns the exported file info as a FileInfo object. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Export-XoVm.md b/docs/Export-XoVm.md new file mode 100644 index 0000000..e8f98ed --- /dev/null +++ b/docs/Export-XoVm.md @@ -0,0 +1,150 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Export-XoVm + +## SYNOPSIS +Export a Xen Orchestra VM to a local file. + +## SYNTAX + +``` +Export-XoVm [-VmUuid] -Format -OutFile [-PassThru] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Downloads the specified VM in either xva (XenServer native) or ova format. +The download is streamed to -OutFile; nothing is returned unless -PassThru is specified. +For large VMs the export can take a while - consider running it as a background job. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Format xva -OutFile "./export.xva" +``` + +## PARAMETERS + +### -VmUuid +The UUID of the VM to export. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Format +Export format: 'xva' (XenServer native, fastest) or 'ova' (portable OVF). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -OutFile +Local path to write the exported file to. +Parent directory must exist. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +Return the written file as a FileInfo object. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Export-XoVmSnapshot.md b/docs/Export-XoVmSnapshot.md new file mode 100644 index 0000000..eeca8ec --- /dev/null +++ b/docs/Export-XoVmSnapshot.md @@ -0,0 +1,150 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Export-XoVmSnapshot + +## SYNOPSIS +Export a Xen Orchestra VM snapshot to a local file. + +## SYNTAX + +``` +Export-XoVmSnapshot [-VmSnapshotUuid] -Format -OutFile [-PassThru] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Downloads the specified VM snapshot in either xva (XenServer native) or ova format. +The download is streamed to -OutFile; nothing is returned unless -PassThru is specified. +For large VM snapshots the export can take a while - consider running it as a background job. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Format xva -OutFile "./export.xva" +``` + +## PARAMETERS + +### -VmSnapshotUuid +The UUID of the VM snapshot to export. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Format +Export format: 'xva' (XenServer native, fastest) or 'ova' (portable OVF). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -OutFile +Local path to write the exported file to. +Parent directory must exist. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +Return the written file as a FileInfo object. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Export-XoVmTemplate.md b/docs/Export-XoVmTemplate.md new file mode 100644 index 0000000..0aa80da --- /dev/null +++ b/docs/Export-XoVmTemplate.md @@ -0,0 +1,150 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Export-XoVmTemplate + +## SYNOPSIS +Export a Xen Orchestra VM template to a local file. + +## SYNTAX + +``` +Export-XoVmTemplate [-VmTemplateUuid] -Format -OutFile [-PassThru] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Downloads the specified VM template in either xva (XenServer native) or ova format. +The download is streamed to -OutFile; nothing is returned unless -PassThru is specified. +For large VM templates the export can take a while - consider running it as a background job. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Format xva -OutFile "./export.xva" +``` + +## PARAMETERS + +### -VmTemplateUuid +The UUID of the VM template to export. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Format +Export format: 'xva' (XenServer native, fastest) or 'ova' (portable OVF). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -OutFile +Local path to write the exported file to. +Parent directory must exist. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +Return the written file as a FileInfo object. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoAlarm.md b/docs/Get-XoAlarm.md new file mode 100644 index 0000000..90b5d19 --- /dev/null +++ b/docs/Get-XoAlarm.md @@ -0,0 +1,142 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoAlarm + +## SYNOPSIS +List or query alarms. + +## SYNTAX + +### Filter (Default) +``` +Get-XoAlarm [-BodyName ] [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### AlarmUuid +``` +Get-XoAlarm [-AlarmUuid] [-Limit ] [-ProgressAction ] [] +``` + +### PoolUuid +``` +Get-XoAlarm [-PoolUuid] [-Limit ] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get Xen Orchestra alarms by UUID or list all existing alarms. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoAlarm -AlarmUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -AlarmUuid +The UUID(s) of the alarm(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: AlarmUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -BodyName +Filter alarms matching the specified body name. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the alarm query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PoolUuid +UUID of the pool whose alarms to retrieve. + +```yaml +Type: String +Parameter Sets: PoolUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Limit +Maximum number of alarms to return. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupArchive.md b/docs/Get-XoBackupArchive.md new file mode 100644 index 0000000..09fc661 --- /dev/null +++ b/docs/Get-XoBackupArchive.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupArchive + +## SYNOPSIS +List or query Xen Orchestra backup archives. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupArchive [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### BackupArchiveId +``` +Get-XoBackupArchive [-BackupArchiveId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves Xen Orchestra backup archives - restorable snapshots stored in a backup repository. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupArchiveId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupArchive -Filter 'type:xo-vm-backup' +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -BackupArchiveId +One or more IDs of the backup archives to retrieve. +When omitted, the cmdlet enumerates backup archives using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: BackupArchiveId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of backup archives to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupArchive +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupJob.md b/docs/Get-XoBackupJob.md new file mode 100644 index 0000000..fa767b7 --- /dev/null +++ b/docs/Get-XoBackupJob.md @@ -0,0 +1,107 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupJob + +## SYNOPSIS +List or query backup jobs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupJob [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### BackupJobId +``` +Get-XoBackupJob [-BackupJobId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get Xen Orchestra backup jobs by ID or list all existing backup jobs. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupJob -BackupJobId "d33f3dc1-92b4-469c-ad58-4c2a106a4721" +``` + +## PARAMETERS + +### -BackupJobId +The ID(s) of the backup job(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: BackupJobId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the backup job query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of backup jobs to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupJob +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupJobLog.md b/docs/Get-XoBackupJobLog.md new file mode 100644 index 0000000..34b1465 --- /dev/null +++ b/docs/Get-XoBackupJobLog.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupJobLog + +## SYNOPSIS +List or query Xen Orchestra backup job logs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupJobLog [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### BackupLogId +``` +Get-XoBackupJobLog [-BackupLogId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves run logs for Xen Orchestra backup jobs via the /backup/logs endpoint (alias of Get-XoBackupLog using the alternative path). +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupLogId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupJobLog -Limit 50 +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -BackupLogId +One or more IDs of the backup job logs to retrieve. +When omitted, the cmdlet enumerates backup job logs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: BackupLogId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of backup job logs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupLog +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupJobMetadata.md b/docs/Get-XoBackupJobMetadata.md new file mode 100644 index 0000000..9573219 --- /dev/null +++ b/docs/Get-XoBackupJobMetadata.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupJobMetadata + +## SYNOPSIS +List or query Xen Orchestra metadata backup jobs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupJobMetadata [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### BackupJobId +``` +Get-XoBackupJobMetadata [-BackupJobId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves metadata backup jobs - jobs that back up XO/XCP-ng metadata rather than VM disks. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupJobId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupJobMetadata +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -BackupJobId +One or more IDs of the metadata backup jobs to retrieve. +When omitted, the cmdlet enumerates metadata backup jobs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: BackupJobId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of metadata backup jobs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupJob +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupJobMirror.md b/docs/Get-XoBackupJobMirror.md new file mode 100644 index 0000000..e7057df --- /dev/null +++ b/docs/Get-XoBackupJobMirror.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupJobMirror + +## SYNOPSIS +List or query Xen Orchestra mirror backup jobs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupJobMirror [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### BackupJobId +``` +Get-XoBackupJobMirror [-BackupJobId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves mirror backup jobs - jobs that replicate backups between remotes. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupJobId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupJobMirror +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -BackupJobId +One or more IDs of the mirror backup jobs to retrieve. +When omitted, the cmdlet enumerates mirror backup jobs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: BackupJobId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of mirror backup jobs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupJob +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupJobVm.md b/docs/Get-XoBackupJobVm.md new file mode 100644 index 0000000..e7ad0a2 --- /dev/null +++ b/docs/Get-XoBackupJobVm.md @@ -0,0 +1,116 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupJobVm + +## SYNOPSIS +List or query Xen Orchestra VM backup jobs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupJobVm [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### BackupJobId +``` +Get-XoBackupJobVm [-BackupJobId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves VM backup jobs - the jobs that snapshot and archive VMs to a backup repository. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupJobId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupJobVm +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -BackupJobId +One or more IDs of the VM backup jobs to retrieve. +When omitted, the cmdlet enumerates VM backup jobs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: BackupJobId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of VM backup jobs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupJob +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupLog.md b/docs/Get-XoBackupLog.md new file mode 100644 index 0000000..f85135e --- /dev/null +++ b/docs/Get-XoBackupLog.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupLog + +## SYNOPSIS +List or query Xen Orchestra backup logs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupLog [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### BackupLogId +``` +Get-XoBackupLog [-BackupLogId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves run logs for Xen Orchestra backup jobs. +Each log captures the status, start time, and nested tasks of one backup run. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupLogId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupLog -Filter 'status:failure' +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -BackupLogId +One or more IDs of the backup logs to retrieve. +When omitted, the cmdlet enumerates backup logs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: BackupLogId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of backup logs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupLog +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoBackupRepository.md b/docs/Get-XoBackupRepository.md new file mode 100644 index 0000000..62e62ac --- /dev/null +++ b/docs/Get-XoBackupRepository.md @@ -0,0 +1,118 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoBackupRepository + +## SYNOPSIS +List or query Xen Orchestra backup repositories. + +## SYNTAX + +### Filter (Default) +``` +Get-XoBackupRepository [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### BackupRepositoryId +``` +Get-XoBackupRepository [-BackupRepositoryId] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Retrieves backup repositories (remotes) configured in Xen Orchestra - the destinations where backup archives are stored. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupRepositoryId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoBackupRepository | Where-Object enabled +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -BackupRepositoryId +One or more IDs of the backup repositories to retrieve. +When omitted, the cmdlet enumerates backup repositories using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: BackupRepositoryId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of backup repositories to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupRepository +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoDashboard.md b/docs/Get-XoDashboard.md new file mode 100644 index 0000000..c8e922e --- /dev/null +++ b/docs/Get-XoDashboard.md @@ -0,0 +1,62 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoDashboard + +## SYNOPSIS +Get the Xen Orchestra global dashboard summary. + +## SYNTAX + +``` +Get-XoDashboard [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves the global dashboard object exposed at /dashboard: aggregate counters (nHosts, nPools), resource overview (cpus, memory, storage), pool connectivity status, and repository totals. +Useful for a one-shot health snapshot of the XO deployment. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoDashboard +``` + +### EXAMPLE 2 +``` +(Get-XoDashboard).resourcesOverview +``` + +## PARAMETERS + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Dashboard +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoEvent.md b/docs/Get-XoEvent.md new file mode 100644 index 0000000..0432a2f --- /dev/null +++ b/docs/Get-XoEvent.md @@ -0,0 +1,96 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoEvent + +## SYNOPSIS +List Xen Orchestra events. + +## SYNTAX + +``` +Get-XoEvent [[-Filter] ] [[-Limit] ] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves entries from the Xen Orchestra event log. +Events represent system-level occurrences (object changes, connection events, user actions). +Useful for audit/troubleshooting. +Supports XO filter expressions and paging. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoEvent -Limit 100 +``` + +### EXAMPLE 2 +``` +Get-XoEvent -Filter 'type:connection-lost' +``` + +## PARAMETERS + +### -Filter +XO filter expression applied server-side (e.g. +\`type:host\`). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of events to return. +Defaults to the session limit. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Event +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoEventSubscription.md b/docs/Get-XoEventSubscription.md new file mode 100644 index 0000000..c142c38 --- /dev/null +++ b/docs/Get-XoEventSubscription.md @@ -0,0 +1,99 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoEventSubscription + +## SYNOPSIS +List or query subscriptions for a specific Xen Orchestra event. + +## SYNTAX + +### All (Default) +``` +Get-XoEventSubscription [-EventId] [-ProgressAction ] [] +``` + +### Single +``` +Get-XoEventSubscription [-EventId] [-SubscriptionId ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Retrieves webhook/API subscriptions attached to a given event. +A subscription describes where and how Xen Orchestra should notify an external endpoint when the event fires. +Supply -SubscriptionId to fetch a single subscription. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoEventSubscription -EventId 'vm-started' +``` + +### EXAMPLE 2 +``` +Get-XoEventSubscription -EventId 'vm-started' -SubscriptionId 'sub-123' +``` + +## PARAMETERS + +### -EventId +The ID of the event whose subscriptions to retrieve. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SubscriptionId +Optional ID of a specific subscription to retrieve instead of listing them all. + +```yaml +Type: String +Parameter Sets: Single +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoGroup.md b/docs/Get-XoGroup.md new file mode 100644 index 0000000..2469bee --- /dev/null +++ b/docs/Get-XoGroup.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoGroup + +## SYNOPSIS +List or query Xen Orchestra groups. + +## SYNTAX + +### Filter (Default) +``` +Get-XoGroup [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### GroupId +``` +Get-XoGroup [-GroupId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves user groups configured in Xen Orchestra. +Groups are used to grant permissions to collections of users. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -GroupId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoGroup +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -GroupId +One or more IDs of the groups to retrieve. +When omitted, the cmdlet enumerates groups using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: GroupId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of groups to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Group +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoGroupTask.md b/docs/Get-XoGroupTask.md new file mode 100644 index 0000000..c130dda --- /dev/null +++ b/docs/Get-XoGroupTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoGroupTask + +## SYNOPSIS +Get tasks scoped to a specific group. + +## SYNTAX + +``` +Get-XoGroupTask [-GroupId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra group. +Accepts one or more group UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoGroupTask -GroupId "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoGroup | Get-XoGroupTask +``` + +## PARAMETERS + +### -GroupId +The UUID(s) of the group whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoGroupUser.md b/docs/Get-XoGroupUser.md new file mode 100644 index 0000000..a2218e8 --- /dev/null +++ b/docs/Get-XoGroupUser.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoGroupUser + +## SYNOPSIS +Get user scoped to a specific group. + +## SYNTAX + +``` +Get-XoGroupUser [-GroupId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves user attached to the specified Xen Orchestra group. +Accepts one or more group UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoGroupUser -GroupId "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoGroup | Get-XoGroupUser +``` + +## PARAMETERS + +### -GroupId +The UUID(s) of the group whose user should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.User +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoGuiRoute.md b/docs/Get-XoGuiRoute.md new file mode 100644 index 0000000..6a013d0 --- /dev/null +++ b/docs/Get-XoGuiRoute.md @@ -0,0 +1,58 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoGuiRoute + +## SYNOPSIS +Get the Xen Orchestra GUI route table. + +## SYNTAX + +``` +Get-XoGuiRoute [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves the /gui-routes resource which maps GUI generation names (e.g. +xo5, xo6) to their URL prefixes. +This is mainly useful for tooling that needs to construct GUI deep links. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoGuiRoute +``` + +## PARAMETERS + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.GuiRoute +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHost.md b/docs/Get-XoHost.md new file mode 100644 index 0000000..2736d19 --- /dev/null +++ b/docs/Get-XoHost.md @@ -0,0 +1,143 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHost + +## SYNOPSIS +Get physical hosts from Xen Orchestra. + +## SYNTAX + +### Filter (Default) +``` +Get-XoHost [-Filter ] [-PoolUuid ] [-Limit ] [-ProgressAction ] + [] +``` + +### HostUuid +``` +Get-XoHost [-HostUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves physical XCP-ng/XenServer hosts from Xen Orchestra. +Can retrieve specific hosts by their UUID or filter hosts by various criteria. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHost +Returns up to 25 hosts. +``` + +### EXAMPLE 2 +``` +Get-XoHost -Limit 0 +Returns all hosts without limit. +``` + +### EXAMPLE 3 +``` +Get-XoHost -HostUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns the host with the specified UUID. +``` + +### EXAMPLE 4 +``` +Get-XoHost -Filter "power_state:running" +Returns running hosts (up to default limit). +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: HostUuid +Aliases: HostId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +Filter to apply to the host query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PoolUuid +UUID of the pool whose hosts to retrieve. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostAlarm.md b/docs/Get-XoHostAlarm.md new file mode 100644 index 0000000..befb084 --- /dev/null +++ b/docs/Get-XoHostAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostAlarm + +## SYNOPSIS +Get alarms scoped to a specific host. + +## SYNTAX + +``` +Get-XoHostAlarm [-HostUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra host. +Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostAlarm -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" +``` + +### EXAMPLE 2 +``` +Get-XoHost | Get-XoHostAlarm +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostAudit.md b/docs/Get-XoHostAudit.md new file mode 100644 index 0000000..440e487 --- /dev/null +++ b/docs/Get-XoHostAudit.md @@ -0,0 +1,94 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostAudit + +## SYNOPSIS +Download the audit log for a Xen Orchestra host. + +## SYNTAX + +``` +Get-XoHostAudit [-HostUuid] [-OutFile ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Downloads the plain-text XAPI audit log from /hosts/{id}/audit.txt. +When -OutFile is supplied the file is written to disk; otherwise the content is returned as a string. +Useful for compliance reporting and forensic investigation. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostAudit -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" -OutFile "./host-audit.txt" +``` + +### EXAMPLE 2 +``` +Get-XoHost | ForEach-Object { Get-XoHostAudit -HostUuid $_.HostUuid -OutFile "./audit-$($_.Name).txt" } +``` + +## PARAMETERS + +### -HostUuid +The UUID of the host whose audit log to download. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -OutFile +Path to save the downloaded content to. +If omitted, content is returned as a string. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostLogBundle.md b/docs/Get-XoHostLogBundle.md new file mode 100644 index 0000000..821dcb6 --- /dev/null +++ b/docs/Get-XoHostLogBundle.md @@ -0,0 +1,89 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostLogBundle + +## SYNOPSIS +Download the diagnostic log bundle for a Xen Orchestra host. + +## SYNTAX + +``` +Get-XoHostLogBundle [-HostUuid] [-OutFile ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Downloads the compressed .tgz log bundle from /hosts/{id}/logs.tgz. +The bundle contains xensource.log, messages, xapi database dumps and other data that support engineers typically ask for. +When -OutFile is supplied the file is written to disk. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostLogBundle -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" -OutFile "./host-logs.tgz" +``` + +## PARAMETERS + +### -HostUuid +The UUID of the host whose log bundle to download. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -OutFile +Path to save the downloaded .tgz to. +If omitted, content is streamed back as bytes. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostMessage.md b/docs/Get-XoHostMessage.md new file mode 100644 index 0000000..304fbce --- /dev/null +++ b/docs/Get-XoHostMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostMessage + +## SYNOPSIS +Get messages scoped to a specific host. + +## SYNTAX + +``` +Get-XoHostMessage [-HostUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra host. +Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostMessage -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" +``` + +### EXAMPLE 2 +``` +Get-XoHost | Get-XoHostMessage +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostPatch.md b/docs/Get-XoHostPatch.md new file mode 100644 index 0000000..0ae8b24 --- /dev/null +++ b/docs/Get-XoHostPatch.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostPatch + +## SYNOPSIS +Get missing patches scoped to a specific host. + +## SYNTAX + +``` +Get-XoHostPatch [-HostUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves missing patches attached to the specified Xen Orchestra host. +Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostPatch -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" +``` + +### EXAMPLE 2 +``` +Get-XoHost | Get-XoHostPatch +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host whose missing patches should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.PoolPatch +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostSmt.md b/docs/Get-XoHostSmt.md new file mode 100644 index 0000000..fb2be88 --- /dev/null +++ b/docs/Get-XoHostSmt.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostSmt + +## SYNOPSIS +Get SMT status scoped to a specific host. + +## SYNTAX + +``` +Get-XoHostSmt [-HostUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves SMT status attached to the specified Xen Orchestra host. +Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostSmt -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" +``` + +### EXAMPLE 2 +``` +Get-XoHost | Get-XoHostSmt +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host whose SMT status should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### System.Management.Automation.PSCustomObject +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostStat.md b/docs/Get-XoHostStat.md new file mode 100644 index 0000000..91c3236 --- /dev/null +++ b/docs/Get-XoHostStat.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostStat + +## SYNOPSIS +Get performance statistics scoped to a specific host. + +## SYNTAX + +``` +Get-XoHostStat [-HostUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves performance statistics attached to the specified Xen Orchestra host. +Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostStat -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" +``` + +### EXAMPLE 2 +``` +Get-XoHost | Get-XoHostStat +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host whose performance statistics should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Stat +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoHostTask.md b/docs/Get-XoHostTask.md new file mode 100644 index 0000000..3ceb10f --- /dev/null +++ b/docs/Get-XoHostTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoHostTask + +## SYNOPSIS +Get tasks scoped to a specific host. + +## SYNTAX + +``` +Get-XoHostTask [-HostUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra host. +Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoHostTask -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" +``` + +### EXAMPLE 2 +``` +Get-XoHost | Get-XoHostTask +``` + +## PARAMETERS + +### -HostUuid +The UUID(s) of the host whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoMessage.md b/docs/Get-XoMessage.md new file mode 100644 index 0000000..fa1c203 --- /dev/null +++ b/docs/Get-XoMessage.md @@ -0,0 +1,163 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoMessage + +## SYNOPSIS +List or query messages. + +## SYNTAX + +### Filter (Default) +``` +Get-XoMessage [-Name ] [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### MessageUuid +``` +Get-XoMessage [-MessageUuid] [-Limit ] [-ProgressAction ] + [] +``` + +### PoolUuid +``` +Get-XoMessage [-PoolUuid] [-Limit ] [-ProgressAction ] [] +``` + +### VmUuid +``` +Get-XoMessage [-VmUuid] [-Limit ] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get Xen Orchestra messages by UUID or list all existing messages. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoMessage -MessageUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -MessageUuid +The UUID(s) of the message(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: MessageUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Filter messages matching the specified name. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the message query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PoolUuid +UUID of the pool whose messages to retrieve. + +```yaml +Type: String +Parameter Sets: PoolUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -VmUuid +UUID of the VM whose messages to retrieve. + +```yaml +Type: String +Parameter Sets: VmUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Limit +Maximum number of messages to return. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoNetwork.md b/docs/Get-XoNetwork.md new file mode 100644 index 0000000..cef9f00 --- /dev/null +++ b/docs/Get-XoNetwork.md @@ -0,0 +1,138 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoNetwork + +## SYNOPSIS +Query networks by UUID or condition. + +## SYNTAX + +### Filter (Default) +``` +Get-XoNetwork [-Name ] [-Filter ] [-Tag ] [-Limit ] + [-ProgressAction ] [] +``` + +### NetworkUuid +``` +Get-XoNetwork [-NetworkUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get network details. +You can specify networks by their UUIDs or properties. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoNetwork -NetworkUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -NetworkUuid +The UUID(s) of the network(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: NetworkUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Filter networks matching the specified name. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the network query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Filter networks matching any of the specified tags. + +```yaml +Type: String[] +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of networks to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoNetworkAlarm.md b/docs/Get-XoNetworkAlarm.md new file mode 100644 index 0000000..d715bd9 --- /dev/null +++ b/docs/Get-XoNetworkAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoNetworkAlarm + +## SYNOPSIS +Get alarms scoped to a specific network. + +## SYNTAX + +``` +Get-XoNetworkAlarm [-NetworkUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra network. +Accepts one or more network UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoNetworkAlarm -NetworkUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoNetwork | Get-XoNetworkAlarm +``` + +## PARAMETERS + +### -NetworkUuid +The UUID(s) of the network whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoNetworkMessage.md b/docs/Get-XoNetworkMessage.md new file mode 100644 index 0000000..5c009eb --- /dev/null +++ b/docs/Get-XoNetworkMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoNetworkMessage + +## SYNOPSIS +Get messages scoped to a specific network. + +## SYNTAX + +``` +Get-XoNetworkMessage [-NetworkUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra network. +Accepts one or more network UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoNetworkMessage -NetworkUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoNetwork | Get-XoNetworkMessage +``` + +## PARAMETERS + +### -NetworkUuid +The UUID(s) of the network whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoNetworkTask.md b/docs/Get-XoNetworkTask.md new file mode 100644 index 0000000..a74e432 --- /dev/null +++ b/docs/Get-XoNetworkTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoNetworkTask + +## SYNOPSIS +Get tasks scoped to a specific network. + +## SYNTAX + +``` +Get-XoNetworkTask [-NetworkUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra network. +Accepts one or more network UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoNetworkTask -NetworkUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoNetwork | Get-XoNetworkTask +``` + +## PARAMETERS + +### -NetworkUuid +The UUID(s) of the network whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPbd.md b/docs/Get-XoPbd.md new file mode 100644 index 0000000..1336a07 --- /dev/null +++ b/docs/Get-XoPbd.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPbd + +## SYNOPSIS +List or query Xen Orchestra PBDs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoPbd [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### PbdUuid +``` +Get-XoPbd [-PbdUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves physical block devices (PBDs). +A PBD is the XAPI object that connects a host to a storage repository. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -PbdUuid to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPbd | Where-Object attached -eq $false +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -PbdUuid +One or more IDs of the PBDs to retrieve. +When omitted, the cmdlet enumerates PBDs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: PbdUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of PBDs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Pbd +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPci.md b/docs/Get-XoPci.md new file mode 100644 index 0000000..6b146e3 --- /dev/null +++ b/docs/Get-XoPci.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPci + +## SYNOPSIS +List or query Xen Orchestra PCI devices. + +## SYNTAX + +### Filter (Default) +``` +Get-XoPci [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### PciUuid +``` +Get-XoPci [-PciUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves PCI devices visible to pool hosts. +Useful for discovering devices available for passthrough. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -PciUuid to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPci -Limit 0 +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -PciUuid +One or more IDs of the PCI devices to retrieve. +When omitted, the cmdlet enumerates PCI devices using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: PciUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of PCI devices to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Pci +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPgpu.md b/docs/Get-XoPgpu.md new file mode 100644 index 0000000..6641791 --- /dev/null +++ b/docs/Get-XoPgpu.md @@ -0,0 +1,116 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPgpu + +## SYNOPSIS +List or query Xen Orchestra physical GPUs (PGPUs). + +## SYNTAX + +### Filter (Default) +``` +Get-XoPgpu [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### PgpuUuid +``` +Get-XoPgpu [-PgpuUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves physical GPUs attached to pool hosts, including their GPU group membership and dom0 access status. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -PgpuUuid to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPgpu +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -PgpuUuid +One or more IDs of the physical GPUs (PGPUs) to retrieve. +When omitted, the cmdlet enumerates physical GPUs (PGPUs) using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: PgpuUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of physical GPUs (PGPUs) to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Pgpu +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPif.md b/docs/Get-XoPif.md new file mode 100644 index 0000000..9a23fbb --- /dev/null +++ b/docs/Get-XoPif.md @@ -0,0 +1,138 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPif + +## SYNOPSIS +Query PIFs by UUID or condition. + +## SYNTAX + +### Filter (Default) +``` +Get-XoPif [-Name ] [-Filter ] [-Tag ] [-Limit ] + [-ProgressAction ] [] +``` + +### PifUuid +``` +Get-XoPif [-PifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get PIF details. +You can specify PIFs by their UUIDs or properties. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPif -PifUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -PifUuid +The UUID(s) of the PIF(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: PifUuid +Aliases: PIFs + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Filter PIFs matching the specified name. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the PIF query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Filter PIFs matching any of the specified tags. + +```yaml +Type: String[] +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of PIFs to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPifAlarm.md b/docs/Get-XoPifAlarm.md new file mode 100644 index 0000000..95fe87f --- /dev/null +++ b/docs/Get-XoPifAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPifAlarm + +## SYNOPSIS +Get alarms scoped to a specific PIF. + +## SYNTAX + +``` +Get-XoPifAlarm [-PifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra PIF. +Accepts one or more PIF UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPifAlarm -PifUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoPif | Get-XoPifAlarm +``` + +## PARAMETERS + +### -PifUuid +The UUID(s) of the PIF whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPifMessage.md b/docs/Get-XoPifMessage.md new file mode 100644 index 0000000..8a3a526 --- /dev/null +++ b/docs/Get-XoPifMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPifMessage + +## SYNOPSIS +Get messages scoped to a specific PIF. + +## SYNTAX + +``` +Get-XoPifMessage [-PifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra PIF. +Accepts one or more PIF UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPifMessage -PifUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoPif | Get-XoPifMessage +``` + +## PARAMETERS + +### -PifUuid +The UUID(s) of the PIF whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPifTask.md b/docs/Get-XoPifTask.md new file mode 100644 index 0000000..a36b355 --- /dev/null +++ b/docs/Get-XoPifTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPifTask + +## SYNOPSIS +Get tasks scoped to a specific PIF. + +## SYNTAX + +``` +Get-XoPifTask [-PifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra PIF. +Accepts one or more PIF UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPifTask -PifUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoPif | Get-XoPifTask +``` + +## PARAMETERS + +### -PifUuid +The UUID(s) of the PIF whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPool.md b/docs/Get-XoPool.md new file mode 100644 index 0000000..bb83afc --- /dev/null +++ b/docs/Get-XoPool.md @@ -0,0 +1,138 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPool + +## SYNOPSIS +Query pools by UUID or condition. + +## SYNTAX + +### Filter (Default) +``` +Get-XoPool [-Name ] [-Filter ] [-Tag ] [-Limit ] + [-ProgressAction ] [] +``` + +### PoolUuid +``` +Get-XoPool [-PoolUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get pool details. +You can specify pools by their UUIDs or properties. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pool(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: PoolUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Filter pools matching the specified name. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the pool query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Filter pools matching any of the specified tags. + +```yaml +Type: String[] +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of pools to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPoolDashboard.md b/docs/Get-XoPoolDashboard.md new file mode 100644 index 0000000..0e69faf --- /dev/null +++ b/docs/Get-XoPoolDashboard.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPoolDashboard + +## SYNOPSIS +Get dashboard summary scoped to a specific pool. + +## SYNTAX + +``` +Get-XoPoolDashboard [-PoolUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves dashboard summary attached to the specified Xen Orchestra pool. +Accepts one or more pool UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPoolDashboard -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" +``` + +### EXAMPLE 2 +``` +Get-XoPool | Get-XoPoolDashboard +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pool whose dashboard summary should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Dashboard +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPoolMessage.md b/docs/Get-XoPoolMessage.md new file mode 100644 index 0000000..3ad07f9 --- /dev/null +++ b/docs/Get-XoPoolMessage.md @@ -0,0 +1,70 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPoolMessage + +## SYNOPSIS +Get Pool message + +## SYNTAX + +``` +Get-XoPoolMessage [-PoolUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages associated with a Xen Orchestra pool. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPoolMessage -PoolUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' +``` + +## PARAMETERS + +### -PoolUuid +Target Xen Orchestra pool UUID. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPoolPatch.md b/docs/Get-XoPoolPatch.md new file mode 100644 index 0000000..2db498c --- /dev/null +++ b/docs/Get-XoPoolPatch.md @@ -0,0 +1,70 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPoolPatch + +## SYNOPSIS +Query pending patches for a Xen Orchestra pool. + +## SYNTAX + +``` +Get-XoPoolPatch [-PoolUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Query pending patches for a Xen Orchestra pool. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPoolPatch -PoolUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' +``` + +## PARAMETERS + +### -PoolUuid +Target Xen Orchestra pool UUID. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPoolStat.md b/docs/Get-XoPoolStat.md new file mode 100644 index 0000000..a21805d --- /dev/null +++ b/docs/Get-XoPoolStat.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPoolStat + +## SYNOPSIS +Get performance statistics scoped to a specific pool. + +## SYNTAX + +``` +Get-XoPoolStat [-PoolUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves performance statistics attached to the specified Xen Orchestra pool. +Accepts one or more pool UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPoolStat -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" +``` + +### EXAMPLE 2 +``` +Get-XoPool | Get-XoPoolStat +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pool whose performance statistics should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Stat +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPoolTask.md b/docs/Get-XoPoolTask.md new file mode 100644 index 0000000..73973c9 --- /dev/null +++ b/docs/Get-XoPoolTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPoolTask + +## SYNOPSIS +Get tasks scoped to a specific pool. + +## SYNTAX + +``` +Get-XoPoolTask [-PoolUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra pool. +Accepts one or more pool UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPoolTask -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" +``` + +### EXAMPLE 2 +``` +Get-XoPool | Get-XoPoolTask +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pool whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoPoolVm.md b/docs/Get-XoPoolVm.md new file mode 100644 index 0000000..25fd766 --- /dev/null +++ b/docs/Get-XoPoolVm.md @@ -0,0 +1,79 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoPoolVm + +## SYNOPSIS +Get VMs scoped to a specific pool. + +## SYNTAX + +``` +Get-XoPoolVm [-PoolUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Returns the VMs that belong to the specified pool(s). +The XO REST API does not expose a dedicated GET /pools/{id}/vms endpoint (only POST for imports), so this cmdlet delegates to Get-XoVm with a $pool filter. +Accepts one or more pool UUIDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoPoolVm -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" +``` + +### EXAMPLE 2 +``` +Get-XoPool | Get-XoPoolVm +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pool whose VMs should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoProxy.md b/docs/Get-XoProxy.md new file mode 100644 index 0000000..0144902 --- /dev/null +++ b/docs/Get-XoProxy.md @@ -0,0 +1,116 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoProxy + +## SYNOPSIS +List or query Xen Orchestra XO proxies. + +## SYNTAX + +### Filter (Default) +``` +Get-XoProxy [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### ProxyId +``` +Get-XoProxy [-ProxyId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves Xen Orchestra proxies - lightweight VMs that relay backup/migration traffic between XO and a pool. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -ProxyId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoProxy +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -ProxyId +One or more IDs of the XO proxies to retrieve. +When omitted, the cmdlet enumerates XO proxies using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: ProxyId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of XO proxies to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Proxy +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoRestoreJobLog.md b/docs/Get-XoRestoreJobLog.md new file mode 100644 index 0000000..cdaa67b --- /dev/null +++ b/docs/Get-XoRestoreJobLog.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoRestoreJobLog + +## SYNOPSIS +List or query Xen Orchestra restore logs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoRestoreJobLog [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### RestoreLogId +``` +Get-XoRestoreJobLog [-RestoreLogId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves restore logs via the /restore/logs endpoint (alias of Get-XoRestoreLog using the alternative path). +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -RestoreLogId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoRestoreJobLog -Limit 50 +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -RestoreLogId +One or more IDs of the restore logs to retrieve. +When omitted, the cmdlet enumerates restore logs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: RestoreLogId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of restore logs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.RestoreLog +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoRestoreLog.md b/docs/Get-XoRestoreLog.md new file mode 100644 index 0000000..c24f6d0 --- /dev/null +++ b/docs/Get-XoRestoreLog.md @@ -0,0 +1,116 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoRestoreLog + +## SYNOPSIS +List or query Xen Orchestra restore logs. + +## SYNTAX + +### Filter (Default) +``` +Get-XoRestoreLog [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### RestoreLogId +``` +Get-XoRestoreLog [-RestoreLogId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves restore logs - the per-run records produced when a backup archive is restored to a VM or SR. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -RestoreLogId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoRestoreLog -Filter 'status:failure' +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -RestoreLogId +One or more IDs of the restore logs to retrieve. +When omitted, the cmdlet enumerates restore logs using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: RestoreLogId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of restore logs to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.RestoreLog +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSchedule.md b/docs/Get-XoSchedule.md new file mode 100644 index 0000000..a75981f --- /dev/null +++ b/docs/Get-XoSchedule.md @@ -0,0 +1,106 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSchedule + +## SYNOPSIS +List or query schedules. + +## SYNTAX + +### Filter (Default) +``` +Get-XoSchedule [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### ScheduleUuid +``` +Get-XoSchedule [-ScheduleUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get Xen Orchestra schedules by UUID or list all existing schedules. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSchedule -ScheduleUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -ScheduleUuid +The UUID(s) of the schedule(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: ScheduleUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the schedule query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of schedules to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoServer.md b/docs/Get-XoServer.md new file mode 100644 index 0000000..58ba060 --- /dev/null +++ b/docs/Get-XoServer.md @@ -0,0 +1,128 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoServer + +## SYNOPSIS +Get servers from Xen Orchestra. + +## SYNTAX + +### Filter (Default) +``` +Get-XoServer [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### ServerUuid +``` +Get-XoServer [-ServerUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves servers from Xen Orchestra. +Can retrieve specific servers by their ID +or filter servers by various criteria. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoServer +Returns up to 25 servers. +``` + +### EXAMPLE 2 +``` +Get-XoServer -Limit 0 +Returns all servers without limit. +``` + +### EXAMPLE 3 +``` +Get-XoServer -ServerUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns the server with the specified ID. +``` + +### EXAMPLE 4 +``` +Get-XoServer -Filter "status:connected" +Returns connected servers (up to default limit). +``` + +## PARAMETERS + +### -ServerUuid +The ID(s) of the server(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: ServerUuid +Aliases: ServerId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +Filter to apply to the server query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoServerTask.md b/docs/Get-XoServerTask.md new file mode 100644 index 0000000..91901bd --- /dev/null +++ b/docs/Get-XoServerTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoServerTask + +## SYNOPSIS +Get tasks scoped to a specific XO server. + +## SYNTAX + +``` +Get-XoServerTask [-ServerUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra XO server. +Accepts one or more XO server UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoServerTask -ServerUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoServer | Get-XoServerTask +``` + +## PARAMETERS + +### -ServerUuid +The UUID(s) of the XO server whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSession.md b/docs/Get-XoSession.md new file mode 100644 index 0000000..41933e6 --- /dev/null +++ b/docs/Get-XoSession.md @@ -0,0 +1,55 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSession + +## SYNOPSIS +Get the current XO session settings. + +## SYNTAX + +``` +Get-XoSession [-ProgressAction ] [] +``` + +## DESCRIPTION +Get the current Xen Orchestra session settings. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSession +``` + +## PARAMETERS + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSingleHostById.md b/docs/Get-XoSingleHostById.md new file mode 100644 index 0000000..2d95ebc --- /dev/null +++ b/docs/Get-XoSingleHostById.md @@ -0,0 +1,87 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSingleHostById + +## SYNOPSIS +Get a single host by ID + +## SYNTAX + +``` +Get-XoSingleHostById [[-HostUuid] ] [[-Params] ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Get a single host from Xen Orchestra by its UUID. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSingleHostById -HostUuid '812b59e1-2682-43ef-acd4-808d3551b907' +``` + +## PARAMETERS + +### -HostUuid +Target host UUID to retrieve. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Params +Hashtable with request parameters. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Host +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSingleServerById.md b/docs/Get-XoSingleServerById.md new file mode 100644 index 0000000..a255caa --- /dev/null +++ b/docs/Get-XoSingleServerById.md @@ -0,0 +1,87 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSingleServerById + +## SYNOPSIS +Get single server by ID + +## SYNTAX + +``` +Get-XoSingleServerById [[-ServerUuid] ] [[-Params] ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Get a single server from Xen Orchestra by its ID. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSingleServerById -ServerUuid '812b59e1-2682-43ef-acd4-808d3551b907' +``` + +## PARAMETERS + +### -ServerUuid +Target server UUID to retrieve. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Params +Target server query parameters. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Server +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSingleSrById.md b/docs/Get-XoSingleSrById.md new file mode 100644 index 0000000..d47337b --- /dev/null +++ b/docs/Get-XoSingleSrById.md @@ -0,0 +1,87 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSingleSrById + +## SYNOPSIS +Get single SR by ID + +## SYNTAX + +``` +Get-XoSingleSrById [[-SrUuid] ] [[-Params] ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Get a single storage repository by its UUID. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSingleSrById -SrUuid '812b59e1-2682-43ef-acd4-808d3551b907' +``` + +## PARAMETERS + +### -SrUuid +Target storage repository UUID. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Params +Target SR request parameters hash. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Sr +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSingleTaskById.md b/docs/Get-XoSingleTaskById.md new file mode 100644 index 0000000..314c5c4 --- /dev/null +++ b/docs/Get-XoSingleTaskById.md @@ -0,0 +1,87 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSingleTaskById + +## SYNOPSIS +Get a single task by ID + +## SYNTAX + +``` +Get-XoSingleTaskById [[-TaskId] ] [[-Params] ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Retrieves a single task from the API by its ID + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSingleTaskById -TaskId "0m8k2zkzi" +``` + +## PARAMETERS + +### -TaskId +The ID of the task to retrieve + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Params +Additional parameters to pass to the API + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSingleVdiById.md b/docs/Get-XoSingleVdiById.md new file mode 100644 index 0000000..1d6daaa --- /dev/null +++ b/docs/Get-XoSingleVdiById.md @@ -0,0 +1,87 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSingleVdiById + +## SYNOPSIS +Get VDI by ID + +## SYNTAX + +``` +Get-XoSingleVdiById [[-VdiUuid] ] [[-Params] ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Get a single VDI from Xen Orchestra by UUID. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSingleVdiById -VdiUuid '812b59e1-2682-43ef-acd4-808d3551b907' +``` + +## PARAMETERS + +### -VdiUuid +Target VDI UUID to retrieve. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Params +Target VDI request parameters hash. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vdi +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSingleVdiSnapshotById.md b/docs/Get-XoSingleVdiSnapshotById.md new file mode 100644 index 0000000..36206b4 --- /dev/null +++ b/docs/Get-XoSingleVdiSnapshotById.md @@ -0,0 +1,87 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSingleVdiSnapshotById + +## SYNOPSIS +Get a VDI Snapshot by ID + +## SYNTAX + +``` +Get-XoSingleVdiSnapshotById [[-VdiSnapshotUuid] ] [[-Params] ] + [-ProgressAction ] [] +``` + +## DESCRIPTION +Get a single VDI Snapshot from Xen Orchestra by UUID. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSingleVdiSnapshotById -VdiSnapshotUuid '812b59e1-2682-43ef-acd4-808d3551b907' +``` + +## PARAMETERS + +### -VdiSnapshotUuid +Target VDI Snapshot UUID to retrieve. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Params +Target VDI Snapshot request parameters hash. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.VdiSnapshot +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSingleVmById.md b/docs/Get-XoSingleVmById.md new file mode 100644 index 0000000..c8454a5 --- /dev/null +++ b/docs/Get-XoSingleVmById.md @@ -0,0 +1,71 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSingleVmById + +## SYNOPSIS +Get a VM by ID + +## SYNTAX + +``` +Get-XoSingleVmById [[-VmUuid] ] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get a single VM from Xen Orchestra by UUID. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSingleVmById -VmUuid '812b59e1-2682-43ef-acd4-808d3551b907' +``` + +## PARAMETERS + +### -VmUuid +Target VM UUID to retrieve. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSm.md b/docs/Get-XoSm.md new file mode 100644 index 0000000..6a070d5 --- /dev/null +++ b/docs/Get-XoSm.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSm + +## SYNOPSIS +List or query Xen Orchestra storage managers (SMs). + +## SYNTAX + +### Filter (Default) +``` +Get-XoSm [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### SmUuid +``` +Get-XoSm [-SmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves XAPI storage manager plugins installed on pool hosts. +Each SM corresponds to a supported SR type (ext, lvm, nfs, ...). +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -SmUuid to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSm | Sort-Object -Property SM_type +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -SmUuid +One or more IDs of the storage managers (SMs) to retrieve. +When omitted, the cmdlet enumerates storage managers (SMs) using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: SmUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of storage managers (SMs) to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Sm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSr.md b/docs/Get-XoSr.md new file mode 100644 index 0000000..15c1cb9 --- /dev/null +++ b/docs/Get-XoSr.md @@ -0,0 +1,115 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSr + +## SYNOPSIS +Get storage repositories from Xen Orchestra. + +## SYNTAX + +### Filter (Default) +``` +Get-XoSr [-Limit ] [-ProgressAction ] [] +``` + +### SrUuid +``` +Get-XoSr [-SrUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves storage repositories from Xen Orchestra. +Can retrieve specific SRs by their UUID +or all SRs. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSr +Returns up to 25 SRs. +``` + +### EXAMPLE 2 +``` +Get-XoSr -Limit 0 +Returns all SRs without limit. +``` + +### EXAMPLE 3 +``` +Get-XoSr -SrUuid "a1b2c3d4" +Returns the SR with the specified UUID. +``` + +### EXAMPLE 4 +``` +Get-XoSr -Limit 5 +Returns the first 5 SRs. +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the SR(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: SrUuid +Aliases: SrId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. +Use -Limit 0 to return all results without limitation. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Sr +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSrAlarm.md b/docs/Get-XoSrAlarm.md new file mode 100644 index 0000000..535bee3 --- /dev/null +++ b/docs/Get-XoSrAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSrAlarm + +## SYNOPSIS +Get alarms scoped to a specific storage repository. + +## SYNTAX + +``` +Get-XoSrAlarm [-SrUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra storage repository. +Accepts one or more storage repository UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSrAlarm -SrUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoSr | Get-XoSrAlarm +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the storage repository whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSrMessage.md b/docs/Get-XoSrMessage.md new file mode 100644 index 0000000..92c92b2 --- /dev/null +++ b/docs/Get-XoSrMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSrMessage + +## SYNOPSIS +Get messages scoped to a specific storage repository. + +## SYNTAX + +``` +Get-XoSrMessage [-SrUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra storage repository. +Accepts one or more storage repository UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSrMessage -SrUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoSr | Get-XoSrMessage +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the storage repository whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSrTask.md b/docs/Get-XoSrTask.md new file mode 100644 index 0000000..30c56ac --- /dev/null +++ b/docs/Get-XoSrTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSrTask + +## SYNOPSIS +Get tasks scoped to a specific storage repository. + +## SYNTAX + +``` +Get-XoSrTask [-SrUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra storage repository. +Accepts one or more storage repository UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSrTask -SrUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoSr | Get-XoSrTask +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the storage repository whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoSrVdi.md b/docs/Get-XoSrVdi.md new file mode 100644 index 0000000..c9dd0e9 --- /dev/null +++ b/docs/Get-XoSrVdi.md @@ -0,0 +1,79 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoSrVdi + +## SYNOPSIS +Get virtual disks (VDIs) scoped to a specific storage repository. + +## SYNTAX + +``` +Get-XoSrVdi [-SrUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Returns the VDIs that live on the specified storage repository. +The XO REST API does not expose a dedicated GET /srs/{id}/vdis endpoint (only POST for VDI uploads), so this cmdlet delegates to Get-XoVdi with the $SR filter. +Accepts one or more SR UUIDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoSrVdi -SrUuid "c787b75c-3e0d-70fa-d0c3-cbfd382d7e33" +``` + +### EXAMPLE 2 +``` +Get-XoSr | Get-XoSrVdi +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the storage repository whose virtual disks (VDIs) should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vdi +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoTask.md b/docs/Get-XoTask.md new file mode 100644 index 0000000..86df588 --- /dev/null +++ b/docs/Get-XoTask.md @@ -0,0 +1,129 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoTask + +## SYNOPSIS +Get tasks from Xen Orchestra. + +## SYNTAX + +### Filter (Default) +``` +Get-XoTask [-Status ] [-Limit ] [-ProgressAction ] [] +``` + +### TaskId +``` +Get-XoTask [-TaskId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks from Xen Orchestra. +Can retrieve specific tasks by their ID +or filter tasks by status. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoTask +Returns up to 25 tasks of any status. +``` + +### EXAMPLE 2 +``` +Get-XoTask -Status failure +Returns failed tasks. +``` + +### EXAMPLE 3 +``` +Get-XoTask -TaskId "0m8k2zkzi" +Returns the task with the specified ID. +``` + +### EXAMPLE 4 +``` +Get-XoTask -Limit 5 +Returns the first 5 tasks. +``` + +## PARAMETERS + +### -TaskId +The ID(s) of the task(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: TaskId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Status +Filter tasks by status. +Valid values: pending, success, failure. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoUser.md b/docs/Get-XoUser.md new file mode 100644 index 0000000..7c6aaf6 --- /dev/null +++ b/docs/Get-XoUser.md @@ -0,0 +1,116 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoUser + +## SYNOPSIS +List or query Xen Orchestra users. + +## SYNTAX + +### Filter (Default) +``` +Get-XoUser [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### UserId +``` +Get-XoUser [-UserId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves Xen Orchestra users, including their permission level, email and group membership. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -UserId to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoUser | Where-Object permission -eq 'admin' +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -UserId +One or more IDs of the users to retrieve. +When omitted, the cmdlet enumerates users using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: UserId +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of users to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.User +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoUserAuthenticationToken.md b/docs/Get-XoUserAuthenticationToken.md new file mode 100644 index 0000000..c2c2c15 --- /dev/null +++ b/docs/Get-XoUserAuthenticationToken.md @@ -0,0 +1,79 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoUserAuthenticationToken + +## SYNOPSIS +List authentication tokens for a specific user. + +## SYNTAX + +``` +Get-XoUserAuthenticationToken [-UserId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves the API authentication tokens owned by a user via GET /users/{id}/authentication_tokens. +Each token includes the client id, description, creation/expiration timestamps and most recent use. +Useful for auditing long-lived tokens created via xo-cli. +The REST API does not expose a "self" variant for listing (only for creation), so a UserId is required. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoUserAuthenticationToken -UserId '722d17b9-699b-49d2-8193-be1ac573d3de' +``` + +### EXAMPLE 2 +``` +Get-XoUser | Get-XoUserAuthenticationToken +``` + +## PARAMETERS + +### -UserId +The UUID of the user whose authentication tokens should be returned. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.UserAuthenticationToken +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoUserGroup.md b/docs/Get-XoUserGroup.md new file mode 100644 index 0000000..6c9a66b --- /dev/null +++ b/docs/Get-XoUserGroup.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoUserGroup + +## SYNOPSIS +Get group scoped to a specific user. + +## SYNTAX + +``` +Get-XoUserGroup [-UserId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves group attached to the specified Xen Orchestra user. +Accepts one or more user UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoUserGroup -UserId "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoUser | Get-XoUserGroup +``` + +## PARAMETERS + +### -UserId +The UUID(s) of the user whose group should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Group +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoUserTask.md b/docs/Get-XoUserTask.md new file mode 100644 index 0000000..3a937bc --- /dev/null +++ b/docs/Get-XoUserTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoUserTask + +## SYNOPSIS +Get tasks scoped to a specific user. + +## SYNTAX + +``` +Get-XoUserTask [-UserId] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra user. +Accepts one or more user UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoUserTask -UserId "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoUser | Get-XoUserTask +``` + +## PARAMETERS + +### -UserId +The UUID(s) of the user whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVbd.md b/docs/Get-XoVbd.md new file mode 100644 index 0000000..4fb3fef --- /dev/null +++ b/docs/Get-XoVbd.md @@ -0,0 +1,138 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVbd + +## SYNOPSIS +Query VBDs by UUID or condition. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVbd [-Name ] [-Filter ] [-Tag ] [-Limit ] + [-ProgressAction ] [] +``` + +### VbdUuid +``` +Get-XoVbd [-VbdUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get VBD details. +You can specify VBDs by their UUIDs or properties. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVbd -VbdUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -VbdUuid +The UUID(s) of the VBD(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: VbdUuid +Aliases: $VBDs + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Filter VBDs matching the specified name. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the VBD query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Filter VBDs matching any of the specified tags. + +```yaml +Type: String[] +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of VBDs to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVbdAlarm.md b/docs/Get-XoVbdAlarm.md new file mode 100644 index 0000000..5469263 --- /dev/null +++ b/docs/Get-XoVbdAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVbdAlarm + +## SYNOPSIS +Get alarms scoped to a specific VBD. + +## SYNTAX + +``` +Get-XoVbdAlarm [-VbdUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VBD. +Accepts one or more VBD UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVbdAlarm -VbdUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVbd | Get-XoVbdAlarm +``` + +## PARAMETERS + +### -VbdUuid +The UUID(s) of the VBD whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVbdMessage.md b/docs/Get-XoVbdMessage.md new file mode 100644 index 0000000..655c3aa --- /dev/null +++ b/docs/Get-XoVbdMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVbdMessage + +## SYNOPSIS +Get messages scoped to a specific VBD. + +## SYNTAX + +``` +Get-XoVbdMessage [-VbdUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra VBD. +Accepts one or more VBD UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVbdMessage -VbdUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVbd | Get-XoVbdMessage +``` + +## PARAMETERS + +### -VbdUuid +The UUID(s) of the VBD whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVbdTask.md b/docs/Get-XoVbdTask.md new file mode 100644 index 0000000..e04a2a8 --- /dev/null +++ b/docs/Get-XoVbdTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVbdTask + +## SYNOPSIS +Get tasks scoped to a specific VBD. + +## SYNTAX + +``` +Get-XoVbdTask [-VbdUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VBD. +Accepts one or more VBD UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVbdTask -VbdUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVbd | Get-XoVbdTask +``` + +## PARAMETERS + +### -VbdUuid +The UUID(s) of the VBD whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdi.md b/docs/Get-XoVdi.md new file mode 100644 index 0000000..3cb7299 --- /dev/null +++ b/docs/Get-XoVdi.md @@ -0,0 +1,150 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdi + +## SYNOPSIS +Get VDIs from Xen Orchestra. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVdi [-SrUuid ] [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### VdiUuid +``` +Get-XoVdi [-VdiUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves VDIs from Xen Orchestra. +Can retrieve specific VDIs by their UUID +or filter VDIs by various criteria. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdi +Returns up to 25 VDIs. +``` + +### EXAMPLE 2 +``` +Get-XoVdi -Limit 0 +Returns all VDIs without limit. +``` + +### EXAMPLE 3 +``` +Get-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns the VDI with the specified UUID. +``` + +### EXAMPLE 4 +``` +Get-XoVdi -SrUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns VDIs on the specified storage repository (up to default limit). +``` + +### EXAMPLE 5 +``` +Get-XoVdi -Filter "name_label:backup*" +Returns VDIs with names starting with "backup" (up to default limit). +``` + +## PARAMETERS + +### -VdiUuid +The UUID(s) of the VDI(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: VdiUuid +Aliases: VdiId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SrUuid +Filter VDIs by storage repository UUID. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter to apply to the VDI query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdiAlarm.md b/docs/Get-XoVdiAlarm.md new file mode 100644 index 0000000..43787ae --- /dev/null +++ b/docs/Get-XoVdiAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdiAlarm + +## SYNOPSIS +Get alarms scoped to a specific VDI. + +## SYNTAX + +``` +Get-XoVdiAlarm [-VdiUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VDI. +Accepts one or more VDI UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdiAlarm -VdiUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVdi | Get-XoVdiAlarm +``` + +## PARAMETERS + +### -VdiUuid +The UUID(s) of the VDI whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdiMessage.md b/docs/Get-XoVdiMessage.md new file mode 100644 index 0000000..a799b3c --- /dev/null +++ b/docs/Get-XoVdiMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdiMessage + +## SYNOPSIS +Get messages scoped to a specific VDI. + +## SYNTAX + +``` +Get-XoVdiMessage [-VdiUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra VDI. +Accepts one or more VDI UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdiMessage -VdiUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVdi | Get-XoVdiMessage +``` + +## PARAMETERS + +### -VdiUuid +The UUID(s) of the VDI whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdiSnapshot.md b/docs/Get-XoVdiSnapshot.md new file mode 100644 index 0000000..ed43f27 --- /dev/null +++ b/docs/Get-XoVdiSnapshot.md @@ -0,0 +1,128 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdiSnapshot + +## SYNOPSIS +Get VDI snapshots from Xen Orchestra. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVdiSnapshot [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### VdiSnapshotUuid +``` +Get-XoVdiSnapshot [-VdiSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves VDI snapshots from Xen Orchestra. +Can retrieve specific snapshots by their UUID +or filter snapshots by various criteria. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdiSnapshot +Returns up to 25 VDI snapshots. +``` + +### EXAMPLE 2 +``` +Get-XoVdiSnapshot -Limit 0 +Returns all VDI snapshots without limit. +``` + +### EXAMPLE 3 +``` +Get-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns the VDI snapshot with the specified UUID. +``` + +### EXAMPLE 4 +``` +Get-XoVdiSnapshot -Filter "name_label:backup*" +Returns VDI snapshots with names starting with "backup" (up to default limit). +``` + +## PARAMETERS + +### -VdiSnapshotUuid +The UUID(s) of the VDI snapshot(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: VdiSnapshotUuid +Aliases: VdiSnapshotId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +Filter to apply to the snapshot query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdiSnapshotAlarm.md b/docs/Get-XoVdiSnapshotAlarm.md new file mode 100644 index 0000000..e8640f2 --- /dev/null +++ b/docs/Get-XoVdiSnapshotAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdiSnapshotAlarm + +## SYNOPSIS +Get alarms scoped to a specific VDI snapshot. + +## SYNTAX + +``` +Get-XoVdiSnapshotAlarm [-VdiSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VDI snapshot. +Accepts one or more VDI snapshot UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdiSnapshotAlarm -VdiSnapshotUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVdiSnapshot | Get-XoVdiSnapshotAlarm +``` + +## PARAMETERS + +### -VdiSnapshotUuid +The UUID(s) of the VDI snapshot whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdiSnapshotMessage.md b/docs/Get-XoVdiSnapshotMessage.md new file mode 100644 index 0000000..60ef062 --- /dev/null +++ b/docs/Get-XoVdiSnapshotMessage.md @@ -0,0 +1,79 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdiSnapshotMessage + +## SYNOPSIS +Get messages scoped to a specific VDI snapshot. + +## SYNTAX + +``` +Get-XoVdiSnapshotMessage [-VdiSnapshotUuid] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra VDI snapshot. +Accepts one or more VDI snapshot UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdiSnapshotMessage -VdiSnapshotUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVdiSnapshot | Get-XoVdiSnapshotMessage +``` + +## PARAMETERS + +### -VdiSnapshotUuid +The UUID(s) of the VDI snapshot whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdiSnapshotTask.md b/docs/Get-XoVdiSnapshotTask.md new file mode 100644 index 0000000..089ad9a --- /dev/null +++ b/docs/Get-XoVdiSnapshotTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdiSnapshotTask + +## SYNOPSIS +Get tasks scoped to a specific VDI snapshot. + +## SYNTAX + +``` +Get-XoVdiSnapshotTask [-VdiSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VDI snapshot. +Accepts one or more VDI snapshot UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdiSnapshotTask -VdiSnapshotUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVdiSnapshot | Get-XoVdiSnapshotTask +``` + +## PARAMETERS + +### -VdiSnapshotUuid +The UUID(s) of the VDI snapshot whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVdiTask.md b/docs/Get-XoVdiTask.md new file mode 100644 index 0000000..c1548e3 --- /dev/null +++ b/docs/Get-XoVdiTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVdiTask + +## SYNOPSIS +Get tasks scoped to a specific VDI. + +## SYNTAX + +``` +Get-XoVdiTask [-VdiUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VDI. +Accepts one or more VDI UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVdiTask -VdiUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVdi | Get-XoVdiTask +``` + +## PARAMETERS + +### -VdiUuid +The UUID(s) of the VDI whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVif.md b/docs/Get-XoVif.md new file mode 100644 index 0000000..0ad8bc2 --- /dev/null +++ b/docs/Get-XoVif.md @@ -0,0 +1,138 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVif + +## SYNOPSIS +Query VIFs by UUID or condition. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVif [-Name ] [-Filter ] [-Tag ] [-Limit ] + [-ProgressAction ] [] +``` + +### VifUuid +``` +Get-XoVif [-VifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get VIF details. +You can specify VIFs by their UUIDs or properties. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVif -VifUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -VifUuid +The UUID(s) of the VIF(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: VifUuid +Aliases: VIFs + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Filter VIFs matching the specified name. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the VIF query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Filter VIFs matching any of the specified tags. + +```yaml +Type: String[] +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of VIFs to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVifAlarm.md b/docs/Get-XoVifAlarm.md new file mode 100644 index 0000000..67232ac --- /dev/null +++ b/docs/Get-XoVifAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVifAlarm + +## SYNOPSIS +Get alarms scoped to a specific VIF. + +## SYNTAX + +``` +Get-XoVifAlarm [-VifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VIF. +Accepts one or more VIF UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVifAlarm -VifUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVif | Get-XoVifAlarm +``` + +## PARAMETERS + +### -VifUuid +The UUID(s) of the VIF whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVifMessage.md b/docs/Get-XoVifMessage.md new file mode 100644 index 0000000..9ab752b --- /dev/null +++ b/docs/Get-XoVifMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVifMessage + +## SYNOPSIS +Get messages scoped to a specific VIF. + +## SYNTAX + +``` +Get-XoVifMessage [-VifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra VIF. +Accepts one or more VIF UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVifMessage -VifUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVif | Get-XoVifMessage +``` + +## PARAMETERS + +### -VifUuid +The UUID(s) of the VIF whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVifTask.md b/docs/Get-XoVifTask.md new file mode 100644 index 0000000..2f7122a --- /dev/null +++ b/docs/Get-XoVifTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVifTask + +## SYNOPSIS +Get tasks scoped to a specific VIF. + +## SYNTAX + +``` +Get-XoVifTask [-VifUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VIF. +Accepts one or more VIF UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVifTask -VifUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVif | Get-XoVifTask +``` + +## PARAMETERS + +### -VifUuid +The UUID(s) of the VIF whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVm.md b/docs/Get-XoVm.md new file mode 100644 index 0000000..b0d3fa0 --- /dev/null +++ b/docs/Get-XoVm.md @@ -0,0 +1,202 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVm + +## SYNOPSIS +Get VMs from Xen Orchestra. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVm [-PowerState ] [-Tag ] [-Filter ] [-PoolUuid ] + [-HostUuid ] [-Limit ] [-ProgressAction ] [] +``` + +### VmUuid +``` +Get-XoVm [-VmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves VMs from Xen Orchestra. +Can retrieve specific VMs by their UUID +or filter VMs by power state, tags, or custom filters. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVm +Returns up to 25 VMs. +``` + +### EXAMPLE 2 +``` +Get-XoVm -Limit 0 +Returns all VMs without limit. +``` + +### EXAMPLE 3 +``` +Get-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns the VM with the specified UUID. +``` + +### EXAMPLE 4 +``` +Get-XoVm -PowerState Running +Returns running VMs (up to default limit). +``` + +### EXAMPLE 5 +``` +Get-XoVm -Tag "Production" +Returns VMs tagged with "Production" (up to default limit). +``` + +### EXAMPLE 6 +``` +Get-XoVm -Filter "name_label:test*" +Returns VMs with names starting with "test" (up to default limit). +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: VmUuid +Aliases: VmId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -PowerState +Filter VMs by power state. +Valid values: Running, Halted, Suspended. + +```yaml +Type: String[] +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Filter VMs by one or more tags. + +```yaml +Type: String[] +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +Custom filter to apply to the VM query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PoolUuid +UUID of the pool whose VMs to retrieve. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -HostUuid +UUID of the host whose VMs to retrieve. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmAlarm.md b/docs/Get-XoVmAlarm.md new file mode 100644 index 0000000..faf38cb --- /dev/null +++ b/docs/Get-XoVmAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmAlarm + +## SYNOPSIS +Get alarms scoped to a specific VM. + +## SYNTAX + +``` +Get-XoVmAlarm [-VmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VM. +Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmAlarm -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" +``` + +### EXAMPLE 2 +``` +Get-XoVm | Get-XoVmAlarm +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmBackupJob.md b/docs/Get-XoVmBackupJob.md new file mode 100644 index 0000000..a8e48ea --- /dev/null +++ b/docs/Get-XoVmBackupJob.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmBackupJob + +## SYNOPSIS +Get backup jobs scoped to a specific VM. + +## SYNTAX + +``` +Get-XoVmBackupJob [-VmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves backup jobs attached to the specified Xen Orchestra VM. +Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmBackupJob -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" +``` + +### EXAMPLE 2 +``` +Get-XoVm | Get-XoVmBackupJob +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM whose backup jobs should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.BackupJob +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmController.md b/docs/Get-XoVmController.md new file mode 100644 index 0000000..282695a --- /dev/null +++ b/docs/Get-XoVmController.md @@ -0,0 +1,118 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmController + +## SYNOPSIS +List or query Xen Orchestra VM controllers. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVmController [-Filter ] [-Limit ] [-ProgressAction ] + [] +``` + +### VmControllerUuid +``` +Get-XoVmController [-VmControllerUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves VM controllers (dom0 control-domain VMs) from Xen Orchestra. +These are the privileged VMs that run on each host to manage guest VMs. +When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -VmControllerUuid to fetch specific entries or -Filter / -Limit to scope a list query. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmController +``` + +### EXAMPLE 2 +``` +" +``` + +## PARAMETERS + +### -VmControllerUuid +One or more IDs of the VM controllers to retrieve. +When omitted, the cmdlet enumerates VM controllers using Filter and Limit. + +```yaml +Type: String[] +Parameter Sets: VmControllerUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +XO filter expression applied server-side (same syntax as the REST \`filter\` query parameter, e.g. +\`status:success\`). + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of VM controllers to return when listing. +Defaults to the session limit set by Connect-XoSession or Set-XoSession. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.VmController +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmControllerAlarm.md b/docs/Get-XoVmControllerAlarm.md new file mode 100644 index 0000000..22ab34f --- /dev/null +++ b/docs/Get-XoVmControllerAlarm.md @@ -0,0 +1,79 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmControllerAlarm + +## SYNOPSIS +Get alarms scoped to a specific VM controller. + +## SYNTAX + +``` +Get-XoVmControllerAlarm [-VmControllerUuid] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VM controller. +Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmControllerAlarm -VmControllerUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmController | Get-XoVmControllerAlarm +``` + +## PARAMETERS + +### -VmControllerUuid +The UUID(s) of the VM controller whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmControllerMessage.md b/docs/Get-XoVmControllerMessage.md new file mode 100644 index 0000000..4babac4 --- /dev/null +++ b/docs/Get-XoVmControllerMessage.md @@ -0,0 +1,79 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmControllerMessage + +## SYNOPSIS +Get messages scoped to a specific VM controller. + +## SYNTAX + +``` +Get-XoVmControllerMessage [-VmControllerUuid] [-ProgressAction ] + [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra VM controller. +Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmControllerMessage -VmControllerUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmController | Get-XoVmControllerMessage +``` + +## PARAMETERS + +### -VmControllerUuid +The UUID(s) of the VM controller whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmControllerTask.md b/docs/Get-XoVmControllerTask.md new file mode 100644 index 0000000..31a542f --- /dev/null +++ b/docs/Get-XoVmControllerTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmControllerTask + +## SYNOPSIS +Get tasks scoped to a specific VM controller. + +## SYNTAX + +``` +Get-XoVmControllerTask [-VmControllerUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VM controller. +Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmControllerTask -VmControllerUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmController | Get-XoVmControllerTask +``` + +## PARAMETERS + +### -VmControllerUuid +The UUID(s) of the VM controller whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmControllerVdi.md b/docs/Get-XoVmControllerVdi.md new file mode 100644 index 0000000..6572e62 --- /dev/null +++ b/docs/Get-XoVmControllerVdi.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmControllerVdi + +## SYNOPSIS +Get virtual disks (VDIs) scoped to a specific VM controller. + +## SYNTAX + +``` +Get-XoVmControllerVdi [-VmControllerUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves virtual disks (VDIs) attached to the specified Xen Orchestra VM controller. +Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmControllerVdi -VmControllerUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmController | Get-XoVmControllerVdi +``` + +## PARAMETERS + +### -VmControllerUuid +The UUID(s) of the VM controller whose virtual disks (VDIs) should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vdi +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmDashboard.md b/docs/Get-XoVmDashboard.md new file mode 100644 index 0000000..8b59734 --- /dev/null +++ b/docs/Get-XoVmDashboard.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmDashboard + +## SYNOPSIS +Get dashboard summary scoped to a specific VM. + +## SYNTAX + +``` +Get-XoVmDashboard [-VmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves dashboard summary attached to the specified Xen Orchestra VM. +Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmDashboard -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" +``` + +### EXAMPLE 2 +``` +Get-XoVm | Get-XoVmDashboard +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM whose dashboard summary should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Dashboard +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmSnapshot.md b/docs/Get-XoVmSnapshot.md new file mode 100644 index 0000000..d1a5b29 --- /dev/null +++ b/docs/Get-XoVmSnapshot.md @@ -0,0 +1,129 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmSnapshot + +## SYNOPSIS +Get VM snapshots. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVmSnapshot [-Filter ] [-Limit ] [-ProgressAction ] [] +``` + +### VmSnapshotUuid +``` +Get-XoVmSnapshot [-VmSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves VM snapshots from Xen Orchestra. +Can retrieve specific snapshots by their UUID +or filter snapshots by various criteria. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmSnapshot +Returns up to 25 VM snapshots. +``` + +### EXAMPLE 2 +``` +Get-XoVmSnapshot -Limit 0 +Returns all VM snapshots without limit. +``` + +### EXAMPLE 3 +``` +Get-XoVmSnapshot -VmSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns the VM snapshot with the specified UUID. +``` + +### EXAMPLE 4 +``` +Get-XoVmSnapshot -Filter "name_label:backup" +Returns VM snapshots with "backup" in their name (up to default limit). +``` + +## PARAMETERS + +### -VmSnapshotUuid +The UUID(s) of the VM snapshot(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: VmSnapshotUuid +Aliases: Snapshot + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +Filter to apply to the snapshot query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of results to return. +Default is 25 if not specified. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.VmSnapshot +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmSnapshotAlarm.md b/docs/Get-XoVmSnapshotAlarm.md new file mode 100644 index 0000000..94b5468 --- /dev/null +++ b/docs/Get-XoVmSnapshotAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmSnapshotAlarm + +## SYNOPSIS +Get alarms scoped to a specific VM snapshot. + +## SYNTAX + +``` +Get-XoVmSnapshotAlarm [-VmSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VM snapshot. +Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmSnapshotAlarm -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmSnapshot | Get-XoVmSnapshotAlarm +``` + +## PARAMETERS + +### -VmSnapshotUuid +The UUID(s) of the VM snapshot whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmSnapshotMessage.md b/docs/Get-XoVmSnapshotMessage.md new file mode 100644 index 0000000..2e09244 --- /dev/null +++ b/docs/Get-XoVmSnapshotMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmSnapshotMessage + +## SYNOPSIS +Get messages scoped to a specific VM snapshot. + +## SYNTAX + +``` +Get-XoVmSnapshotMessage [-VmSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra VM snapshot. +Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmSnapshotMessage -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmSnapshot | Get-XoVmSnapshotMessage +``` + +## PARAMETERS + +### -VmSnapshotUuid +The UUID(s) of the VM snapshot whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmSnapshotTask.md b/docs/Get-XoVmSnapshotTask.md new file mode 100644 index 0000000..7778914 --- /dev/null +++ b/docs/Get-XoVmSnapshotTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmSnapshotTask + +## SYNOPSIS +Get tasks scoped to a specific VM snapshot. + +## SYNTAX + +``` +Get-XoVmSnapshotTask [-VmSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VM snapshot. +Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmSnapshotTask -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmSnapshot | Get-XoVmSnapshotTask +``` + +## PARAMETERS + +### -VmSnapshotUuid +The UUID(s) of the VM snapshot whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmSnapshotVdi.md b/docs/Get-XoVmSnapshotVdi.md new file mode 100644 index 0000000..486add5 --- /dev/null +++ b/docs/Get-XoVmSnapshotVdi.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmSnapshotVdi + +## SYNOPSIS +Get virtual disks (VDIs) scoped to a specific VM snapshot. + +## SYNTAX + +``` +Get-XoVmSnapshotVdi [-VmSnapshotUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves virtual disks (VDIs) attached to the specified Xen Orchestra VM snapshot. +Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmSnapshotVdi -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmSnapshot | Get-XoVmSnapshotVdi +``` + +## PARAMETERS + +### -VmSnapshotUuid +The UUID(s) of the VM snapshot whose virtual disks (VDIs) should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vdi +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmStat.md b/docs/Get-XoVmStat.md new file mode 100644 index 0000000..4c352c6 --- /dev/null +++ b/docs/Get-XoVmStat.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmStat + +## SYNOPSIS +Get performance statistics scoped to a specific VM. + +## SYNTAX + +``` +Get-XoVmStat [-VmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves performance statistics attached to the specified Xen Orchestra VM. +Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmStat -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" +``` + +### EXAMPLE 2 +``` +Get-XoVm | Get-XoVmStat +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM whose performance statistics should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Stat +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmTask.md b/docs/Get-XoVmTask.md new file mode 100644 index 0000000..f38ca80 --- /dev/null +++ b/docs/Get-XoVmTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmTask + +## SYNOPSIS +Get tasks scoped to a specific VM. + +## SYNTAX + +``` +Get-XoVmTask [-VmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VM. +Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmTask -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" +``` + +### EXAMPLE 2 +``` +Get-XoVm | Get-XoVmTask +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmTemplate.md b/docs/Get-XoVmTemplate.md new file mode 100644 index 0000000..453323b --- /dev/null +++ b/docs/Get-XoVmTemplate.md @@ -0,0 +1,138 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmTemplate + +## SYNOPSIS +List or query VM templates. + +## SYNTAX + +### Filter (Default) +``` +Get-XoVmTemplate [-Default] [-PoolUuid ] [-Filter ] [-Limit ] + [-ProgressAction ] [] +``` + +### VmTemplateUuid +``` +Get-XoVmTemplate [-VmTemplateUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Get Xen Orchestra VM templates by UUID or list all existing VM templates. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmTemplate -VmTemplateUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -VmTemplateUuid +The UUID(s) of the VM template(s) to retrieve. + +```yaml +Type: String[] +Parameter Sets: VmTemplateUuid +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Default +Only return default VM templates when set. + +```yaml +Type: SwitchParameter +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PoolUuid +UUID of the pool whose templates to retrieve. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Filter +Custom filter expression for the template query. + +```yaml +Type: String +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit +Maximum number of VM templates to return. + +```yaml +Type: Int32 +Parameter Sets: Filter +Aliases: + +Required: False +Position: Named +Default value: $script:XoSessionLimit +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.VmTemplate +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmTemplateAlarm.md b/docs/Get-XoVmTemplateAlarm.md new file mode 100644 index 0000000..f6f62aa --- /dev/null +++ b/docs/Get-XoVmTemplateAlarm.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmTemplateAlarm + +## SYNOPSIS +Get alarms scoped to a specific VM template. + +## SYNTAX + +``` +Get-XoVmTemplateAlarm [-VmTemplateUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves alarms attached to the specified Xen Orchestra VM template. +Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmTemplateAlarm -VmTemplateUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmTemplate | Get-XoVmTemplateAlarm +``` + +## PARAMETERS + +### -VmTemplateUuid +The UUID(s) of the VM template whose alarms should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Alarm +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmTemplateMessage.md b/docs/Get-XoVmTemplateMessage.md new file mode 100644 index 0000000..399c8a1 --- /dev/null +++ b/docs/Get-XoVmTemplateMessage.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmTemplateMessage + +## SYNOPSIS +Get messages scoped to a specific VM template. + +## SYNTAX + +``` +Get-XoVmTemplateMessage [-VmTemplateUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves messages attached to the specified Xen Orchestra VM template. +Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmTemplateMessage -VmTemplateUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmTemplate | Get-XoVmTemplateMessage +``` + +## PARAMETERS + +### -VmTemplateUuid +The UUID(s) of the VM template whose messages should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Message +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmTemplateTask.md b/docs/Get-XoVmTemplateTask.md new file mode 100644 index 0000000..51946c8 --- /dev/null +++ b/docs/Get-XoVmTemplateTask.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmTemplateTask + +## SYNOPSIS +Get tasks scoped to a specific VM template. + +## SYNTAX + +``` +Get-XoVmTemplateTask [-VmTemplateUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves tasks attached to the specified Xen Orchestra VM template. +Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmTemplateTask -VmTemplateUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmTemplate | Get-XoVmTemplateTask +``` + +## PARAMETERS + +### -VmTemplateUuid +The UUID(s) of the VM template whose tasks should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmTemplateVdi.md b/docs/Get-XoVmTemplateVdi.md new file mode 100644 index 0000000..c4526de --- /dev/null +++ b/docs/Get-XoVmTemplateVdi.md @@ -0,0 +1,78 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmTemplateVdi + +## SYNOPSIS +Get virtual disks (VDIs) scoped to a specific VM template. + +## SYNTAX + +``` +Get-XoVmTemplateVdi [-VmTemplateUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves virtual disks (VDIs) attached to the specified Xen Orchestra VM template. +Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmTemplateVdi -VmTemplateUuid "00000000-0000-0000-0000-000000000000" +``` + +### EXAMPLE 2 +``` +Get-XoVmTemplate | Get-XoVmTemplateVdi +``` + +## PARAMETERS + +### -VmTemplateUuid +The UUID(s) of the VM template whose virtual disks (VDIs) should be returned. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vdi +## NOTES + +## RELATED LINKS diff --git a/docs/Get-XoVmVdi.md b/docs/Get-XoVmVdi.md new file mode 100644 index 0000000..c4292f4 --- /dev/null +++ b/docs/Get-XoVmVdi.md @@ -0,0 +1,77 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Get-XoVmVdi + +## SYNOPSIS +Get virtual disks attached to a VM. + +## SYNTAX + +``` +Get-XoVmVdi [-VmUuid] [-ProgressAction ] [] +``` + +## DESCRIPTION +Retrieves all virtual disk images (VDIs) attached to a specified VM. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-XoVmVdi -VmUuid "12345678-abcd-1234-abcd-1234567890ab" +Returns all virtual disks attached to the specified VM. +``` + +### EXAMPLE 2 +``` +Get-XoVm -PowerState Running | Get-XoVmVdi +Returns all virtual disks attached to running VMs. +``` + +## PARAMETERS + +### -VmUuid +The UUID of the VM to get VDIs for. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Import-XoSrVdi.md b/docs/Import-XoSrVdi.md new file mode 100644 index 0000000..246cf56 --- /dev/null +++ b/docs/Import-XoSrVdi.md @@ -0,0 +1,120 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Import-XoSrVdi + +## SYNOPSIS +Import a VDI file into a Xen Orchestra storage repository. + +## SYNTAX + +``` +Import-XoSrVdi [-SrUuid] [-InFile] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Calls POST /srs/{id}/vdis with the file contents as an application/octet-stream body. +XO creates a VDI on the target SR and streams the uploaded content into it. +Returns a task object that can be passed to Wait-XoTask. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -InFile "./disk.vhd" +``` + +## PARAMETERS + +### -SrUuid +The UUID of the SR to import the VDI into. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -InFile +Path to the VDI file on disk (raw or vhd). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Import-XoVdi.md b/docs/Import-XoVdi.md new file mode 100644 index 0000000..0455a51 --- /dev/null +++ b/docs/Import-XoVdi.md @@ -0,0 +1,133 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Import-XoVdi + +## SYNOPSIS +Import content into an existing VDI. + +## SYNTAX + +``` +Import-XoVdi [-VdiUuid] [-Format] [-InFile] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls PUT /vdis/{id}.{format} to upload raw VDI content (raw or vhd) to a pre-existing VDI. +Use New-XoVdi first to create an empty VDI of the correct size. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Format vhd -InFile "./disk.vhd" +``` + +## PARAMETERS + +### -VdiUuid +The UUID of the target VDI. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Format +Upload format: 'raw' or 'vhd'. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InFile +Path to the file to upload. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Import-XoVm.md b/docs/Import-XoVm.md new file mode 100644 index 0000000..e3aa3e1 --- /dev/null +++ b/docs/Import-XoVm.md @@ -0,0 +1,120 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Import-XoVm + +## SYNOPSIS +Import a VM file (.xva/.ova) into a pool. + +## SYNTAX + +``` +Import-XoVm [-PoolUuid] [-InFile] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Calls POST /pools/{id}/vms with the file contents as an application/octet-stream body. +Large files are streamed from disk via Invoke-RestMethod's -InFile parameter. +Returns a task object that can be passed to Wait-XoTask. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -InFile "./mytemplate.xva" +``` + +## PARAMETERS + +### -PoolUuid +The UUID of the pool to import the VM into. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -InFile +Path to the .xva or .ova file on disk. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Invoke-XoHostManagementReconfigure.md b/docs/Invoke-XoHostManagementReconfigure.md new file mode 100644 index 0000000..58e3656 --- /dev/null +++ b/docs/Invoke-XoHostManagementReconfigure.md @@ -0,0 +1,122 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Invoke-XoHostManagementReconfigure + +## SYNOPSIS +Reconfigure the management network on a host. + +## SYNTAX + +``` +Invoke-XoHostManagementReconfigure [-HostUuid] [-Parameters ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Points the host management interface at a different network/PIF. +Pass the target as -Parameters (e.g. +\`\`@{ pif = \ }\`\`). +Returns a task. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Parameters @{ } +``` + +## PARAMETERS + +### -HostUuid +The UUID of the host to act on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Parameters +Hashtable of action body parameters. +See the linked XO REST documentation for the expected fields. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Invoke-XoPoolManagementReconfigure.md b/docs/Invoke-XoPoolManagementReconfigure.md new file mode 100644 index 0000000..a5cd216 --- /dev/null +++ b/docs/Invoke-XoPoolManagementReconfigure.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Invoke-XoPoolManagementReconfigure + +## SYNOPSIS +Reconfigure the management network of a Xen Orchestra pool. + +## SYNTAX + +``` +Invoke-XoPoolManagementReconfigure [-PoolUuid] [-NetworkUuid] + [-AdditionalParameters ] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Points the pool's management interface at a different network. +Thin wrapper +around the internal Invoke-XoPoolAction -Action management_reconfigure helper. +Returns a task object that can be passed to Wait-XoTask to monitor completion. + +## EXAMPLES + +### EXAMPLE 1 +``` +Invoke-XoPoolManagementReconfigure -PoolUuid $pool.PoolUuid -NetworkUuid $net.NetworkUuid +``` + +## PARAMETERS + +### -PoolUuid +The UUID of the pool whose management network is being reconfigured. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -NetworkUuid +The UUID of the network to use as the new management network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AdditionalParameters +Optional hashtable of extra body parameters to merge into the +management_reconfigure action payload. +Values here override NetworkUuid. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Invoke-XoSrForget.md b/docs/Invoke-XoSrForget.md new file mode 100644 index 0000000..810667b --- /dev/null +++ b/docs/Invoke-XoSrForget.md @@ -0,0 +1,109 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Invoke-XoSrForget + +## SYNOPSIS +Forget one or more Xen Orchestra SRs. + +## SYNTAX + +``` +Invoke-XoSrForget [-SrUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Detaches the SR from the pool without destroying the underlying storage (the data and VDIs remain on the remote; they can be re-introduced later). + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the SR to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Invoke-XoSrReclaimSpace.md b/docs/Invoke-XoSrReclaimSpace.md new file mode 100644 index 0000000..2970920 --- /dev/null +++ b/docs/Invoke-XoSrReclaimSpace.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Invoke-XoSrReclaimSpace + +## SYNOPSIS +Reclaim space on one or more Xen Orchestra SRs. + +## SYNTAX + +``` +Invoke-XoSrReclaimSpace [-SrUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Triggers space reclamation (TRIM/UNMAP) on the SR. +Useful on thin-provisioned storage to return freed blocks. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the SR to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Invoke-XoSrScan.md b/docs/Invoke-XoSrScan.md new file mode 100644 index 0000000..7164a25 --- /dev/null +++ b/docs/Invoke-XoSrScan.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Invoke-XoSrScan + +## SYNOPSIS +Rescan one or more Xen Orchestra SRs. + +## SYNTAX + +``` +Invoke-XoSrScan [-SrUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Forces XAPI to rescan the SR. +Reconciles newly appeared or disappeared VDIs with the database. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -SrUuid +The UUID(s) of the SR to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Invoke-XoVmPause.md b/docs/Invoke-XoVmPause.md new file mode 100644 index 0000000..472af15 --- /dev/null +++ b/docs/Invoke-XoVmPause.md @@ -0,0 +1,111 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Invoke-XoVmPause + +## SYNOPSIS +Pause one or more Xen Orchestra VMs. + +## SYNTAX + +``` +Invoke-XoVmPause [-VmUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Freezes CPU execution of the VM without saving RAM state. +Use Invoke-XoVmUnpause to resume. +Not to be confused with Suspend-XoVm, which writes memory to disk. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Invoke-XoVmUnpause.md b/docs/Invoke-XoVmUnpause.md new file mode 100644 index 0000000..4b34c75 --- /dev/null +++ b/docs/Invoke-XoVmUnpause.md @@ -0,0 +1,109 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Invoke-XoVmUnpause + +## SYNOPSIS +Unpause one or more Xen Orchestra VMs. + +## SYNTAX + +``` +Invoke-XoVmUnpause [-VmUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Resumes CPU execution of a paused VM (previously paused with Invoke-XoVmPause). + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Move-XoVdi.md b/docs/Move-XoVdi.md new file mode 100644 index 0000000..f25e674 --- /dev/null +++ b/docs/Move-XoVdi.md @@ -0,0 +1,122 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Move-XoVdi + +## SYNOPSIS +Migrate a Xen Orchestra VDI to another storage repository. + +## SYNTAX + +``` +Move-XoVdi [-VdiUuid] [-Parameters ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Triggers a live VDI migration to a different SR. +The destination SR UUID must be provided via -Parameters (e.g. +\`\`@{ sr_id = \ }\`\`); see the XO REST docs at /rest/v0/docs/#/vdis/MigrateVdi for the full schema. +Returns a task object. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Parameters @{ } +``` + +## PARAMETERS + +### -VdiUuid +The UUID of the VDI to act on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Parameters +Hashtable of action body parameters. +See the linked XO REST documentation for the expected fields. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Move-XoVm.md b/docs/Move-XoVm.md new file mode 100644 index 0000000..4ba46b4 --- /dev/null +++ b/docs/Move-XoVm.md @@ -0,0 +1,122 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Move-XoVm + +## SYNOPSIS +Live-migrate a Xen Orchestra VM to another host. + +## SYNTAX + +``` +Move-XoVm [-VmUuid] [-Parameters ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Triggers a live VM migration. +The destination host UUID (and optionally migration network / storage) must be provided via -Parameters. +See /rest/v0/docs/#/vms/MigrateVm for the expected body. +Returns a task object. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Parameters @{ } +``` + +## PARAMETERS + +### -VmUuid +The UUID of the VM to act on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Parameters +Hashtable of action body parameters. +See the linked XO REST documentation for the expected fields. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoBondedNetwork.md b/docs/New-XoBondedNetwork.md new file mode 100644 index 0000000..2e07657 --- /dev/null +++ b/docs/New-XoBondedNetwork.md @@ -0,0 +1,186 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoBondedNetwork + +## SYNOPSIS +Create a new bonded network on a Xen Orchestra pool. + +## SYNTAX + +``` +New-XoBondedNetwork [-PoolUuid] [-Name] -PifUuid -BondMode + [-Description ] [-AdditionalParameters ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Creates a bonded network from a set of PIFs on the specified pool. +Thin wrapper +around the internal Invoke-XoPoolAction -Action create_bonded_network helper. +Returns a task object that can be passed to Wait-XoTask to monitor completion. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoBondedNetwork -PoolUuid $pool.PoolUuid -Name "bond0" -PifUuid $p1,$p2 -BondMode lacp +``` + +## PARAMETERS + +### -PoolUuid +The UUID of the pool to create the bonded network on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The name of the new bonded network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PifUuid +The UUIDs of the PIFs to bond together. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: PifIds + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -BondMode +The bonding mode. +Typical values: balance-slb, active-backup, lacp. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +Optional description of the new bonded network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AdditionalParameters +Optional hashtable of extra body parameters to merge into the +create_bonded_network action payload. +Values here override the dedicated +parameters above. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoEventSubscription.md b/docs/New-XoEventSubscription.md new file mode 100644 index 0000000..90efdaa --- /dev/null +++ b/docs/New-XoEventSubscription.md @@ -0,0 +1,133 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoEventSubscription + +## SYNOPSIS +Create a new subscription on a Xen Orchestra event. + +## SYNTAX + +``` +New-XoEventSubscription [-EventId] [-Collection] [-Fields ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls POST /events/{id}/subscriptions to register a subscription that pushes filtered collection updates to the caller. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoEventSubscription -EventId "events" -Collection "VM" -Fields id,name_label +``` + +## PARAMETERS + +### -EventId +The ID of the event to subscribe to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Collection +XO collection to watch (e.g. +'VM'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Fields +Fields to include in notification payloads. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoGroup.md b/docs/New-XoGroup.md new file mode 100644 index 0000000..7d5f2c1 --- /dev/null +++ b/docs/New-XoGroup.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoGroup + +## SYNOPSIS +Create a new Xen Orchestra group. + +## SYNTAX + +``` +New-XoGroup [-Name] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Creates a new group via POST /groups. +Groups are used to grant permissions to collections of users. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoGroup -Name "ops" +``` + +## PARAMETERS + +### -Name +The name of the new group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Group +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoInternalNetwork.md b/docs/New-XoInternalNetwork.md new file mode 100644 index 0000000..be63034 --- /dev/null +++ b/docs/New-XoInternalNetwork.md @@ -0,0 +1,157 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoInternalNetwork + +## SYNOPSIS +Create a new internal network on a Xen Orchestra pool. + +## SYNTAX + +``` +New-XoInternalNetwork [-PoolUuid] [-Name] [-Description ] + [-AdditionalParameters ] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Creates an internal (host-local, no external uplink) network on the specified +pool. +Thin wrapper around the internal Invoke-XoPoolAction -Action +create_internal_network helper. +Returns a task object that can be passed to +Wait-XoTask to monitor completion. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoInternalNetwork -PoolUuid $pool.PoolUuid -Name "private-lab" +``` + +## PARAMETERS + +### -PoolUuid +The UUID of the pool to create the internal network on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The name of the new internal network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +Optional description of the new internal network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AdditionalParameters +Optional hashtable of extra body parameters to merge into the +create_internal_network action payload. +Values here override the dedicated +parameters above. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoNetwork.md b/docs/New-XoNetwork.md new file mode 100644 index 0000000..6f5580d --- /dev/null +++ b/docs/New-XoNetwork.md @@ -0,0 +1,186 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoNetwork + +## SYNOPSIS +Create a new network on a Xen Orchestra pool. + +## SYNTAX + +``` +New-XoNetwork [-PoolUuid] [-Name] [-Description ] [-PifUuid ] [-Vlan ] + [-AdditionalParameters ] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Creates a regular network on the specified pool. +Thin wrapper around the +internal Invoke-XoPoolAction -Action create_network helper. +Returns a task +object that can be passed to Wait-XoTask to monitor completion. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoNetwork -PoolUuid $pool.PoolUuid -Name "frontend" -PifUuid $pif.PifUuid -Vlan 100 +``` + +## PARAMETERS + +### -PoolUuid +The UUID of the pool to create the network on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The name of the new network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +Optional description of the new network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PifUuid +Optional UUID of the PIF to attach the network to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Vlan +Optional VLAN id for the new network. +Use 0 for untagged. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AdditionalParameters +Optional hashtable of extra body parameters to merge into the create_network +action payload. +Values here override the dedicated parameters above. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoServer.md b/docs/New-XoServer.md new file mode 100644 index 0000000..73bfc1e --- /dev/null +++ b/docs/New-XoServer.md @@ -0,0 +1,150 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoServer + +## SYNOPSIS +Register a new XCP-ng/XenServer pool master with Xen Orchestra. + +## SYNTAX + +``` +New-XoServer [-HostName] [-Credential] [-Label ] [-AllowUnauthorized] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls POST /servers to add a pool master. +The credentials are supplied as a PSCredential so the password is not exposed in plain text. +Label and connection flags are optional; host/username/password are mandatory. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoServer -Host "192.168.1.10" -Credential (Get-Credential root) -Label "lab pool" +``` + +## PARAMETERS + +### -HostName +The IP address or hostname of the pool master to register. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Credential +PSCredential with the XCP-ng root (or equivalent) username and password. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Label +Optional friendly label shown in the XO UI. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AllowUnauthorized +Accept self-signed certificates when connecting to the pool master. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Server +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoUser.md b/docs/New-XoUser.md new file mode 100644 index 0000000..e432af9 --- /dev/null +++ b/docs/New-XoUser.md @@ -0,0 +1,127 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoUser + +## SYNOPSIS +Create a new Xen Orchestra user. + +## SYNTAX + +``` +New-XoUser [-Credential] [-Permission ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Creates a new user via POST /users. +The name and password are supplied together as a PSCredential so the password never has to sit in a plain-text variable. +Permission defaults to 'none' (read-only). + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoUser -Credential (Get-Credential) -Permission viewer +``` + +### EXAMPLE 2 +``` +$cred = [pscredential]::new("alice@example.com", (ConvertTo-SecureString "s3cret" -AsPlainText -Force)) +New-XoUser -Credential $cred +``` + +## PARAMETERS + +### -Credential +PSCredential whose UserName becomes the XO user name and whose Password is sent to XO as the initial password. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Permission +Permission level for the new user: 'none', 'viewer' (read-only), or 'admin'. +Defaults to 'none'. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.User +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoUserAuthenticationToken.md b/docs/New-XoUserAuthenticationToken.md new file mode 100644 index 0000000..e94f205 --- /dev/null +++ b/docs/New-XoUserAuthenticationToken.md @@ -0,0 +1,149 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoUserAuthenticationToken + +## SYNOPSIS +Create a new API authentication token for a user. + +## SYNTAX + +``` +New-XoUserAuthenticationToken [-UserId] [-Description ] [-ClientId ] + [-ExpiresIn ] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls POST /users/{id}/authentication_tokens to mint a new XO API token. +The token value is returned once; store it securely. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Description "ci pipeline" -ExpiresIn "30 days" +``` + +## PARAMETERS + +### -UserId +The UUID of the user the token is minted for. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Description +Human-readable description of what the token is for. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ClientId +Optional stable client identifier to associate with the token. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ExpiresIn +Optional expiration expressed as an XO duration string (e.g. +'1 hour', '30 days'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoVbd.md b/docs/New-XoVbd.md new file mode 100644 index 0000000..42df593 --- /dev/null +++ b/docs/New-XoVbd.md @@ -0,0 +1,149 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoVbd + +## SYNOPSIS +Create a new Xen Orchestra VBD linking a VDI to a VM. + +## SYNTAX + +``` +New-XoVbd [-VmUuid] [-VdiUuid] [-Bootable] [-Mode ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls POST /vbds to attach a VDI to a VM. +The resulting VBD controls whether the VM boots from the VDI and whether it is read-only or read/write. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -VdiUuid "" -Bootable +``` + +## PARAMETERS + +### -VmUuid +The UUID of the VM to attach the VDI to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -VdiUuid +The UUID of the VDI to attach. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Bootable +Mark the VBD as bootable. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Mode +Access mode: 'RW' (read/write, default) or 'RO' (read-only). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: RW +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vbd +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoVdi.md b/docs/New-XoVdi.md new file mode 100644 index 0000000..998fab4 --- /dev/null +++ b/docs/New-XoVdi.md @@ -0,0 +1,149 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoVdi + +## SYNOPSIS +Create a new Xen Orchestra VDI on a storage repository. + +## SYNTAX + +``` +New-XoVdi [-SrUuid] [-Name] [-SizeBytes] [-Description ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls POST /vdis to create an empty VDI of the specified size on the given SR. +Returns the created VDI (resolved via Get-XoVdi) or the raw server response. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Name "scratch" -SizeBytes 10737418240 +``` + +## PARAMETERS + +### -SrUuid +The UUID of the SR to create the VDI on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Name label for the new VDI. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SizeBytes +Virtual size of the VDI, in bytes. + +```yaml +Type: Int64 +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +Optional name_description for the new VDI. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vdi +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoVif.md b/docs/New-XoVif.md new file mode 100644 index 0000000..db256de --- /dev/null +++ b/docs/New-XoVif.md @@ -0,0 +1,134 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoVif + +## SYNOPSIS +Create a new Xen Orchestra VIF attaching a VM to a network. + +## SYNTAX + +``` +New-XoVif [-VmUuid] [-NetworkUuid] [-Mac ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls POST /vifs to add a new virtual network interface to the specified VM on the specified network. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -NetworkUuid "" +``` + +## PARAMETERS + +### -VmUuid +The UUID of the VM to attach the VIF to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -NetworkUuid +The UUID of the network to connect the VIF to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Mac +Optional MAC address. +If omitted, XO generates one. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Vif +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoVm.md b/docs/New-XoVm.md new file mode 100644 index 0000000..fa7f815 --- /dev/null +++ b/docs/New-XoVm.md @@ -0,0 +1,222 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoVm + +## SYNOPSIS +Create a new VM on a Xen Orchestra pool. + +## SYNTAX + +``` +New-XoVm [-PoolUuid] [-Name] -TemplateUuid [-Description ] + [-HostUuid ] [-CPUs ] [-MemoryBytes ] [-AdditionalParameters ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Creates a new VM on the specified pool from a VM template. +Thin wrapper around the +internal Invoke-XoPoolAction -Action create_vm helper. +Returns a task object that +can be passed to Wait-XoTask to monitor completion. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoVm -PoolUuid $pool.PoolUuid -Name "web-01" -TemplateUuid $tpl.VmTemplateUuid +``` + +### EXAMPLE 2 +``` +New-XoVm -PoolUuid $pool.PoolUuid -Name "web-01" -TemplateUuid $tpl.VmTemplateUuid -HostUuid $host.HostUuid -CPUs 2 -MemoryBytes 2147483648 +``` + +## PARAMETERS + +### -PoolUuid +The UUID of the pool to create the VM on. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The name_label to assign to the new VM. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TemplateUuid +The UUID of the VM template to clone from. +See Get-XoVmTemplate. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: TemplateId + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +Optional name_description for the new VM. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -HostUuid +Optional UUID of the host the VM should prefer (affinity). +See Get-XoHost. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: AffinityHost + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -CPUs +Optional number of virtual CPUs to assign to the new VM. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MemoryBytes +Optional amount of memory, in bytes, to assign to the new VM. + +```yaml +Type: Int64 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AdditionalParameters +Optional hashtable of extra body parameters to merge into the create_vm action +payload. +Values in this hashtable override any of the dedicated parameters above. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/New-XoVmSnapshot.md b/docs/New-XoVmSnapshot.md new file mode 100644 index 0000000..d468c76 --- /dev/null +++ b/docs/New-XoVmSnapshot.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# New-XoVmSnapshot + +## SYNOPSIS +Create a snapshot of one or more VMs. + +## SYNTAX + +``` +New-XoVmSnapshot [-VmUuid] [[-SnapshotName] ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Creates a snapshot of the specified VMs. +Optionally, you can specify a custom name +for the snapshot. + +## EXAMPLES + +### EXAMPLE 1 +``` +New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" +Creates a snapshot of the VM with the specified UUID. +``` + +### EXAMPLE 2 +``` +New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" -SnapshotName "Before Update" +Creates a snapshot named "Before Update" of the VM with the specified UUID. +``` + +### EXAMPLE 3 +``` +New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" -NameLabel "Before Update" +Creates a snapshot named "Before Update" of the VM with the specified UUID. +``` + +### EXAMPLE 4 +``` +Get-XoVm -PowerState Running | New-XoVmSnapshot -SnapshotName "Backup $(Get-Date -Format 'yyyy-MM-dd')" +Creates a dated snapshot of all running VMs. +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM(s) to snapshot. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SnapshotName +The name to give to the snapshot. +If not specified, a default name will be used. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: NameLabel + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoEmptyValue.md b/docs/Remove-XoEmptyValue.md new file mode 100644 index 0000000..2da1a14 --- /dev/null +++ b/docs/Remove-XoEmptyValue.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoEmptyValue + +## SYNOPSIS +Removes XO empty values + +## SYNTAX + +``` +Remove-XoEmptyValue [-InputObject] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Removes null or empty entries from a hashtable. + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-XoEmptyValue -InputObject $MyObject +``` + +## PARAMETERS + +### -InputObject +Target hashtable to filter entries. + +```yaml +Type: IDictionary +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### System.Collections.Hashtable +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoEventSubscription.md b/docs/Remove-XoEventSubscription.md new file mode 100644 index 0000000..26cf3a6 --- /dev/null +++ b/docs/Remove-XoEventSubscription.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoEventSubscription + +## SYNOPSIS +Remove a subscription from a Xen Orchestra event. + +## SYNTAX + +``` +Remove-XoEventSubscription [-EventId] [-SubscriptionId] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls DELETE /events/{id}/subscriptions/{subscriptionId} to detach a subscription previously registered with New-XoEventSubscription. + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-XoEventSubscription -EventId "events" -SubscriptionId "sub-123" +``` + +## PARAMETERS + +### -EventId +The ID of the event that the subscription belongs to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SubscriptionId +The ID of the subscription to remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoGroup.md b/docs/Remove-XoGroup.md new file mode 100644 index 0000000..0f678da --- /dev/null +++ b/docs/Remove-XoGroup.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoGroup + +## SYNOPSIS +Delete one or more Xen Orchestra groups. + +## SYNTAX + +``` +Remove-XoGroup [-GroupId] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /groups/{id}. +Members are not deleted - only the group itself is removed. + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-XoGroup -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" +``` + +## PARAMETERS + +### -GroupId +The UUID(s) of the group(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoGroupUser.md b/docs/Remove-XoGroupUser.md new file mode 100644 index 0000000..177bf8d --- /dev/null +++ b/docs/Remove-XoGroupUser.md @@ -0,0 +1,118 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoGroupUser + +## SYNOPSIS +Remove a user from a Xen Orchestra group. + +## SYNTAX + +``` +Remove-XoGroupUser [-GroupId] [-UserId] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Disassociates a user from a group via DELETE /groups/{id}/users/{userId}. +The user itself is not deleted - only the membership is removed. + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-XoGroupUser -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" +``` + +## PARAMETERS + +### -GroupId +The UUID of the group to remove the user from. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -UserId +The UUID of the user to remove from the group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoNetwork.md b/docs/Remove-XoNetwork.md new file mode 100644 index 0000000..8626d9f --- /dev/null +++ b/docs/Remove-XoNetwork.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoNetwork + +## SYNOPSIS +Delete one or more Xen Orchestra networks. + +## SYNTAX + +``` +Remove-XoNetwork [-NetworkUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /networks/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -NetworkUuid +The ID(s) of the network(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoServer.md b/docs/Remove-XoServer.md new file mode 100644 index 0000000..42343a7 --- /dev/null +++ b/docs/Remove-XoServer.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoServer + +## SYNOPSIS +Delete one or more Xen Orchestra XO servers. + +## SYNTAX + +``` +Remove-XoServer [-ServerUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /servers/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -ServerUuid +The ID(s) of the XO server(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoTask.md b/docs/Remove-XoTask.md new file mode 100644 index 0000000..21e5869 --- /dev/null +++ b/docs/Remove-XoTask.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoTask + +## SYNOPSIS +Delete one or more Xen Orchestra tasks. + +## SYNTAX + +``` +Remove-XoTask [-TaskId] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /tasks/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -TaskId +The ID(s) of the task(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoUser.md b/docs/Remove-XoUser.md new file mode 100644 index 0000000..a7a5399 --- /dev/null +++ b/docs/Remove-XoUser.md @@ -0,0 +1,108 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoUser + +## SYNOPSIS +Delete one or more Xen Orchestra users. + +## SYNTAX + +``` +Remove-XoUser [-UserId] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /users/{id}. +Accepts multiple UUIDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-XoUser -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" +``` + +### EXAMPLE 2 +``` +Get-XoUser | Where-Object permission -eq 'none' | Remove-XoUser +``` + +## PARAMETERS + +### -UserId +The UUID(s) of the user(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVbd.md b/docs/Remove-XoVbd.md new file mode 100644 index 0000000..1091b38 --- /dev/null +++ b/docs/Remove-XoVbd.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVbd + +## SYNOPSIS +Delete one or more Xen Orchestra VBDs. + +## SYNTAX + +``` +Remove-XoVbd [-VbdUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /vbds/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -VbdUuid +The ID(s) of the VBD(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVdi.md b/docs/Remove-XoVdi.md new file mode 100644 index 0000000..68ee488 --- /dev/null +++ b/docs/Remove-XoVdi.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVdi + +## SYNOPSIS +Delete one or more Xen Orchestra VDIs. + +## SYNTAX + +``` +Remove-XoVdi [-VdiUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /vdis/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -VdiUuid +The ID(s) of the VDI(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVdiSnapshot.md b/docs/Remove-XoVdiSnapshot.md new file mode 100644 index 0000000..7f9561e --- /dev/null +++ b/docs/Remove-XoVdiSnapshot.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVdiSnapshot + +## SYNOPSIS +Delete one or more Xen Orchestra VDI snapshots. + +## SYNTAX + +``` +Remove-XoVdiSnapshot [-VdiSnapshotUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /vdi-snapshots/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -VdiSnapshotUuid +The ID(s) of the VDI snapshot(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVif.md b/docs/Remove-XoVif.md new file mode 100644 index 0000000..3c44268 --- /dev/null +++ b/docs/Remove-XoVif.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVif + +## SYNOPSIS +Delete one or more Xen Orchestra VIFs. + +## SYNTAX + +``` +Remove-XoVif [-VifUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /vifs/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -VifUuid +The ID(s) of the VIF(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVm.md b/docs/Remove-XoVm.md new file mode 100644 index 0000000..b7b8e4f --- /dev/null +++ b/docs/Remove-XoVm.md @@ -0,0 +1,109 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVm + +## SYNOPSIS +Delete one or more Xen Orchestra VMs. + +## SYNTAX + +``` +Remove-XoVm [-VmUuid] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Issues DELETE /vms/{id}. +The VM must be shut down before it can be deleted. +Associated VDIs are destroyed along with the VM unless detached first. +Accepts multiple UUIDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-XoVm -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" +``` + +### EXAMPLE 2 +``` +Get-XoVm -PowerState Halted | Where-Object Name -like 'tmp-*' | Remove-XoVm +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVmSnapshot.md b/docs/Remove-XoVmSnapshot.md new file mode 100644 index 0000000..3337278 --- /dev/null +++ b/docs/Remove-XoVmSnapshot.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVmSnapshot + +## SYNOPSIS +Delete one or more Xen Orchestra VM snapshots. + +## SYNTAX + +``` +Remove-XoVmSnapshot [-VmSnapshotUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /vm-snapshots/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -VmSnapshotUuid +The ID(s) of the VM snapshot(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVmStatDataSource.md b/docs/Remove-XoVmStatDataSource.md new file mode 100644 index 0000000..5ffdd0e --- /dev/null +++ b/docs/Remove-XoVmStatDataSource.md @@ -0,0 +1,118 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVmStatDataSource + +## SYNOPSIS +Remove a stats data source on a VM. + +## SYNTAX + +``` +Remove-XoVmStatDataSource [-VmUuid] [-DataSource] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls DELETE /vms/{id}/stats/data_source/{data_source} to remove stat data source. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -DataSource "cpu0" +``` + +## PARAMETERS + +### -VmUuid +The UUID of the target VM. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DataSource +The name of the stats data source (e.g. +'cpu0', 'memory'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-XoVmTemplate.md b/docs/Remove-XoVmTemplate.md new file mode 100644 index 0000000..17ad734 --- /dev/null +++ b/docs/Remove-XoVmTemplate.md @@ -0,0 +1,103 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Remove-XoVmTemplate + +## SYNOPSIS +Delete one or more Xen Orchestra VM templates. + +## SYNTAX + +``` +Remove-XoVmTemplate [-VmTemplateUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Issues DELETE /vm-templates/{id}. +Accepts multiple IDs and pipeline input by property name. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +## PARAMETERS + +### -VmTemplateUuid +The ID(s) of the VM template(s) to delete. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Restart-XoPool.md b/docs/Restart-XoPool.md new file mode 100644 index 0000000..bbe963b --- /dev/null +++ b/docs/Restart-XoPool.md @@ -0,0 +1,102 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Restart-XoPool + +## SYNOPSIS +Restart a running pool. + +## SYNTAX + +``` +Restart-XoPool [-PoolUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Restart the specified pools using a rolling pool reboot. + +## EXAMPLES + +### EXAMPLE 1 +``` +Restart-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pools(s) to restart. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Restart-XoVm.md b/docs/Restart-XoVm.md new file mode 100644 index 0000000..7192f3b --- /dev/null +++ b/docs/Restart-XoVm.md @@ -0,0 +1,126 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Restart-XoVm + +## SYNOPSIS +Restart one or more VMs. + +## SYNTAX + +``` +Restart-XoVm [-VmUuid] [-Force] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Restarts the specified VMs. +By default, performs a clean reboot. +Use -Force to perform a hard reboot. + +## EXAMPLES + +### EXAMPLE 1 +``` +Restart-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" +Performs a clean reboot of the VM with the specified UUID. +``` + +### EXAMPLE 2 +``` +Get-XoVm -PowerState Running | Restart-XoVm -Force +Performs a hard reboot of all running VMs. +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM(s) to restart. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Force +If specified, performs a hard reboot instead of a clean reboot. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Resume-XoVm.md b/docs/Resume-XoVm.md new file mode 100644 index 0000000..2840173 --- /dev/null +++ b/docs/Resume-XoVm.md @@ -0,0 +1,108 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Resume-XoVm + +## SYNOPSIS +Resume one or more Xen Orchestra VMs. + +## SYNTAX + +``` +Resume-XoVm [-VmUuid] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Resumes a suspended VM, restoring its memory from disk and returning it to the Running state. + +## EXAMPLES + +### EXAMPLE 1 +``` +" +``` + +### EXAMPLE 2 +``` +" | Wait-XoTask -PassThru +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM to act on. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### XoPowershell.Task +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoGroup.md b/docs/Set-XoGroup.md new file mode 100644 index 0000000..33a6b34 --- /dev/null +++ b/docs/Set-XoGroup.md @@ -0,0 +1,117 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoGroup + +## SYNOPSIS +Update a Xen Orchestra group. + +## SYNTAX + +``` +Set-XoGroup [-GroupId] [-Name] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Renames an existing group via PATCH /groups/{id}. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoGroup -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" -Name "ops-team" +``` + +## PARAMETERS + +### -GroupId +The UUID of the group to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The new name for the group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoHost.md b/docs/Set-XoHost.md new file mode 100644 index 0000000..502df1d --- /dev/null +++ b/docs/Set-XoHost.md @@ -0,0 +1,147 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoHost + +## SYNOPSIS +Set Host + +## SYNTAX + +``` +Set-XoHost [-HostUuid] [-Name ] [-Description ] [-Tags ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a host in Xen Orchestra. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoHost -HostUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'MyHost' -Description 'First Host' -Tags @('Critical','Backups') +``` + +## PARAMETERS + +### -HostUuid +UUID of the host to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: HostId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the host. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +New description for the host. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tags +Tags to assign to the target host. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoHostTag.md b/docs/Set-XoHostTag.md new file mode 100644 index 0000000..5cb6be8 --- /dev/null +++ b/docs/Set-XoHostTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoHostTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra host. + +## SYNTAX + +``` +Set-XoHostTag [-HostUuid] [-Tag] [-Remove] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified host using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -HostUuid +The UUID of the host to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoNetwork.md b/docs/Set-XoNetwork.md new file mode 100644 index 0000000..7f16fab --- /dev/null +++ b/docs/Set-XoNetwork.md @@ -0,0 +1,153 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoNetwork + +## SYNOPSIS +Set XO Network + +## SYNTAX + +``` +Set-XoNetwork [-NetworkUuid] [-Name ] [-Description ] [-Tags ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a network in Xen Orchestra. + +## EXAMPLES + +### EXAMPLE 1 +``` +$params = @{ + NetworkUuid = '011ccf6a-c5ad-48ec-a255-d056584686f0' + Name = 'MyNetwork' + Description = "My awesome network" + Tags = @('Important', 'MainNetwork') +} +Set-XoNetwork @params +``` + +## PARAMETERS + +### -NetworkUuid +UUID of the network to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: NetworkId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the network. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +Target network description + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tags +Tags to assign to the target network. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoNetworkTag.md b/docs/Set-XoNetworkTag.md new file mode 100644 index 0000000..3346271 --- /dev/null +++ b/docs/Set-XoNetworkTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoNetworkTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra network. + +## SYNTAX + +``` +Set-XoNetworkTag [-NetworkUuid] [-Tag] [-Remove] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified network using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -NetworkUuid +The UUID of the network to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoPif.md b/docs/Set-XoPif.md new file mode 100644 index 0000000..c1b2cad --- /dev/null +++ b/docs/Set-XoPif.md @@ -0,0 +1,147 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoPif + +## SYNOPSIS +Set Pif + +## SYNTAX + +``` +Set-XoPif [-PifUuid] [-Name ] [-Description ] [-Tags ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a PIF in Xen Orchestra. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoPif -PifUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'New Name' +``` + +## PARAMETERS + +### -PifUuid +UUID of the PIF to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: PifId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the PIF. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +New description for the PIF. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tags +Tags to assign to the target PIF. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoPool.md b/docs/Set-XoPool.md new file mode 100644 index 0000000..e45e3a7 --- /dev/null +++ b/docs/Set-XoPool.md @@ -0,0 +1,147 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoPool + +## SYNOPSIS +Set XO pool + +## SYNTAX + +``` +Set-XoPool [-PoolUuid] [-Name ] [-Description ] [-Tags ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a pool in Xen Orchestra. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoPool -PoolUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'New Pool Name' +``` + +## PARAMETERS + +### -PoolUuid +UUID of the pool to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: PoolId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the pool. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +New description for the pool. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tags +Tags to assign to the target pool. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoPoolTag.md b/docs/Set-XoPoolTag.md new file mode 100644 index 0000000..cd2aa05 --- /dev/null +++ b/docs/Set-XoPoolTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoPoolTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra pool. + +## SYNTAX + +``` +Set-XoPoolTag [-PoolUuid] [-Tag] [-Remove] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified pool using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -PoolUuid +The UUID of the pool to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoSession.md b/docs/Set-XoSession.md new file mode 100644 index 0000000..22234a2 --- /dev/null +++ b/docs/Set-XoSession.md @@ -0,0 +1,108 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoSession + +## SYNOPSIS +Set the current XO session settings. + +## SYNTAX + +``` +Set-XoSession [[-Limit] ] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Set the current Xen Orchestra session settings. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoSession -Limit 50 +Sets the current session-wide limit to 50 items for all query cmdlets. +``` + +### EXAMPLE 2 +``` +Set-XoSession -Limit 0 +Sets cmdlets to return all items by default. +``` + +## PARAMETERS + +### -Limit +Sets the current XO query limit for all Get-Xo* cmdlets that support a -Limit parameter. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoSr.md b/docs/Set-XoSr.md new file mode 100644 index 0000000..c0a8897 --- /dev/null +++ b/docs/Set-XoSr.md @@ -0,0 +1,147 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoSr + +## SYNOPSIS +Set XO sr + +## SYNTAX + +``` +Set-XoSr [-SrUuid] [-Name ] [-Description ] [-Tags ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a storage repository in XO. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoSr -SrUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name "MySR" +``` + +## PARAMETERS + +### -SrUuid +UUID of the storage repository to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: SrId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the SR. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +New description for the SR. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tags +Tags to assign to the target SR. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoSrTag.md b/docs/Set-XoSrTag.md new file mode 100644 index 0000000..80477c3 --- /dev/null +++ b/docs/Set-XoSrTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoSrTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra storage repository. + +## SYNTAX + +``` +Set-XoSrTag [-SrUuid] [-Tag] [-Remove] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified storage repository using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -SrUuid +The UUID of the storage repository to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoUser.md b/docs/Set-XoUser.md new file mode 100644 index 0000000..700068b --- /dev/null +++ b/docs/Set-XoUser.md @@ -0,0 +1,155 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoUser + +## SYNOPSIS +Update a Xen Orchestra user. + +## SYNTAX + +``` +Set-XoUser [-UserId] [-Credential ] [-Permission ] [-Preferences ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Edits an existing user via PATCH /users/{id}. +Any combination of Credential, Permission, or Preferences may be supplied; omitted fields are left unchanged. +When Credential is supplied, both the user name and password are sent (XO treats them as a pair on update). + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoUser -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" -Permission admin +``` + +### EXAMPLE 2 +``` +Set-XoUser -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" -Credential (Get-Credential) +``` + +## PARAMETERS + +### -UserId +The UUID of the user to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Credential +PSCredential holding the new user name and password to assign. +The UserName is sent as 'name' and the password is sent in the request body. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Permission +New permission level: 'none', 'viewer', or 'admin'. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Preferences +Hashtable of preference key/values to store on the user. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVdi.md b/docs/Set-XoVdi.md new file mode 100644 index 0000000..dc8b053 --- /dev/null +++ b/docs/Set-XoVdi.md @@ -0,0 +1,132 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVdi + +## SYNOPSIS +Set XO VDI + +## SYNTAX + +``` +Set-XoVdi [-VdiUuid] [-Name ] [-Description ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a VDI in Xen Orchestra. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoVdi -VdiUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'MyVdi' +``` + +## PARAMETERS + +### -VdiUuid +UUID of the VDI to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: VdiId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the VDI. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +New description for the target VDI. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVdiSnapshotTag.md b/docs/Set-XoVdiSnapshotTag.md new file mode 100644 index 0000000..2811508 --- /dev/null +++ b/docs/Set-XoVdiSnapshotTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVdiSnapshotTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra VDI snapshot. + +## SYNTAX + +``` +Set-XoVdiSnapshotTag [-VdiSnapshotUuid] [-Tag] [-Remove] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified VDI snapshot using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -VdiSnapshotUuid +The UUID of the VDI snapshot to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVdiTag.md b/docs/Set-XoVdiTag.md new file mode 100644 index 0000000..c0b0c34 --- /dev/null +++ b/docs/Set-XoVdiTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVdiTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra VDI. + +## SYNTAX + +``` +Set-XoVdiTag [-VdiUuid] [-Tag] [-Remove] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified VDI using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -VdiUuid +The UUID of the VDI to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVif.md b/docs/Set-XoVif.md new file mode 100644 index 0000000..624a902 --- /dev/null +++ b/docs/Set-XoVif.md @@ -0,0 +1,147 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVif + +## SYNOPSIS +Set Vif + +## SYNTAX + +``` +Set-XoVif [-VifUuid] [-Name ] [-Description ] [-Tags ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a VIF in Xen Orchestra. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoVif -VifUuid '812b59e1-2682-43ef-acd4-808d3551b907' -Name 'MyVif' +``` + +## PARAMETERS + +### -VifUuid +UUID of the VIF to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: VifId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the VIF. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +New description for the VIF. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tags +Tags to assign to the target VIF. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVm.md b/docs/Set-XoVm.md new file mode 100644 index 0000000..2343466 --- /dev/null +++ b/docs/Set-XoVm.md @@ -0,0 +1,147 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVm + +## SYNOPSIS +Set Vm + +## SYNTAX + +``` +Set-XoVm [-VmUuid] [-Name ] [-Description ] [-Tags ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Update properties of a VM in Xen Orchestra. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-XoVm -VmUuid '812b59e1-2682-43ef-acd4-808d3551b907' -Name 'MyVm' +``` + +## PARAMETERS + +### -VmUuid +UUID of the target VM to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: VmId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +New name label for the VM. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +New description for the VM. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tags +Tags to assign to the target VM. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVmControllerTag.md b/docs/Set-XoVmControllerTag.md new file mode 100644 index 0000000..af598fe --- /dev/null +++ b/docs/Set-XoVmControllerTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVmControllerTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra VM controller. + +## SYNTAX + +``` +Set-XoVmControllerTag [-VmControllerUuid] [-Tag] [-Remove] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified VM controller using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -VmControllerUuid +The UUID of the VM controller to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVmSnapshotTag.md b/docs/Set-XoVmSnapshotTag.md new file mode 100644 index 0000000..e4c5cf4 --- /dev/null +++ b/docs/Set-XoVmSnapshotTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVmSnapshotTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra VM snapshot. + +## SYNTAX + +``` +Set-XoVmSnapshotTag [-VmSnapshotUuid] [-Tag] [-Remove] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified VM snapshot using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -VmSnapshotUuid +The UUID of the VM snapshot to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVmTag.md b/docs/Set-XoVmTag.md new file mode 100644 index 0000000..4b16840 --- /dev/null +++ b/docs/Set-XoVmTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVmTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra VM. + +## SYNTAX + +``` +Set-XoVmTag [-VmUuid] [-Tag] [-Remove] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified VM using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -VmUuid +The UUID of the VM to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-XoVmTemplateTag.md b/docs/Set-XoVmTemplateTag.md new file mode 100644 index 0000000..f514ee5 --- /dev/null +++ b/docs/Set-XoVmTemplateTag.md @@ -0,0 +1,139 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Set-XoVmTemplateTag + +## SYNOPSIS +Attach or detach a single tag on a Xen Orchestra VM template. + +## SYNTAX + +``` +Set-XoVmTemplateTag [-VmTemplateUuid] [-Tag] [-Remove] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Manages individual tags on the specified VM template using the /tags/{tag} endpoint. +By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). +Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + +## EXAMPLES + +### EXAMPLE 1 +``` +" -Tag "production" +``` + +### EXAMPLE 2 +``` +" -Tag "production" -Remove +``` + +## PARAMETERS + +### -VmTemplateUuid +The UUID of the VM template to tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +The tag value to add or remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Remove +Detach the tag instead of attaching it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Start-XoSchedule.md b/docs/Start-XoSchedule.md new file mode 100644 index 0000000..b59ba29 --- /dev/null +++ b/docs/Start-XoSchedule.md @@ -0,0 +1,105 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Start-XoSchedule + +## SYNOPSIS +Start one or more schedules. + +## SYNTAX + +``` +Start-XoSchedule [-ScheduleId] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Starts the specified schedules. +Returns a task object that can be used to monitor +the startup operation. + +## EXAMPLES + +### EXAMPLE 1 +``` +Start-XoSchedule -ScheduleId "12345678-abcd-1234-abcd-1234567890ab" +Starts the schedule with the specified ID. +``` + +## PARAMETERS + +### -ScheduleId +The ID(s) of the schedule(s) to start. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Start-XoVm.md b/docs/Start-XoVm.md new file mode 100644 index 0000000..7eea686 --- /dev/null +++ b/docs/Start-XoVm.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Start-XoVm + +## SYNOPSIS +Start one or more VMs. + +## SYNTAX + +``` +Start-XoVm [-VmUuid] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Starts the specified VMs. +Returns a task object that can be used to monitor +the startup operation. + +## EXAMPLES + +### EXAMPLE 1 +``` +Start-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" +Starts the VM with the specified UUID. +``` + +### EXAMPLE 2 +``` +Get-XoVm -PowerState Halted | Start-XoVm +Starts all halted VMs. +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM(s) to start. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Stop-XoPool.md b/docs/Stop-XoPool.md new file mode 100644 index 0000000..db04602 --- /dev/null +++ b/docs/Stop-XoPool.md @@ -0,0 +1,118 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Stop-XoPool + +## SYNOPSIS +Stop a running pool. + +## SYNTAX + +``` +Stop-XoPool [-PoolUuid] [-Force] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Stop the specified pools. +Currently only supports emergency shutdown. + +## EXAMPLES + +### EXAMPLE 1 +``` +Stop-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" -Force +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pools(s) to stop. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Force +Perform an emergency shutdown. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Stop-XoTask.md b/docs/Stop-XoTask.md new file mode 100644 index 0000000..1293356 --- /dev/null +++ b/docs/Stop-XoTask.md @@ -0,0 +1,110 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Stop-XoTask + +## SYNOPSIS +Abort one or more running Xen Orchestra tasks. + +## SYNTAX + +``` +Stop-XoTask [-TaskId] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +POSTs to /tasks/{id}/actions/abort to request cancellation of the specified task. +Some XAPI tasks cannot be aborted; those will return an error. +Aborting a task can leave partial state behind (e.g. +a half-migrated VM) - use with care. + +## EXAMPLES + +### EXAMPLE 1 +``` +Stop-XoTask -TaskId "0m8k2zkzi" +``` + +### EXAMPLE 2 +``` +Get-XoTask -Status pending | Stop-XoTask +``` + +## PARAMETERS + +### -TaskId +The ID(s) of the task(s) to abort. +Accepts pipeline input by property name. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Stop-XoVm.md b/docs/Stop-XoVm.md new file mode 100644 index 0000000..ec413a9 --- /dev/null +++ b/docs/Stop-XoVm.md @@ -0,0 +1,126 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Stop-XoVm + +## SYNOPSIS +Stop one or more VMs. + +## SYNTAX + +``` +Stop-XoVm [-VmUuid] [-Force] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Stops the specified VMs. +By default, performs a clean shutdown. +Use -Force to perform a hard shutdown. + +## EXAMPLES + +### EXAMPLE 1 +``` +Stop-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" +Performs a clean shutdown of the VM with the specified UUID. +``` + +### EXAMPLE 2 +``` +Get-XoVm -PowerState Running | Stop-XoVm -Force +Performs a hard shutdown of all running VMs. +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM(s) to stop. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Force +If specified, performs a hard shutdown instead of a clean shutdown. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Suspend-XoVm.md b/docs/Suspend-XoVm.md new file mode 100644 index 0000000..82c2c18 --- /dev/null +++ b/docs/Suspend-XoVm.md @@ -0,0 +1,109 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Suspend-XoVm + +## SYNOPSIS +Suspend one or more VMs. + +## SYNTAX + +``` +Suspend-XoVm [-VmUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Suspends the specified Xen Orchestra VMs. + +## EXAMPLES + +### EXAMPLE 1 +``` +Suspend-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" +Suspends the VM with the specified UUID. +``` + +### EXAMPLE 2 +``` +Get-XoVm -PowerState Running | Suspend-XoVm +Suspends all running VMs. +``` + +## PARAMETERS + +### -VmUuid +The UUID(s) of the VM(s) to suspend. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Test-XoPing.md b/docs/Test-XoPing.md new file mode 100644 index 0000000..10ad17b --- /dev/null +++ b/docs/Test-XoPing.md @@ -0,0 +1,59 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Test-XoPing + +## SYNOPSIS +Test the reachability of the Xen Orchestra REST API. + +## SYNTAX + +``` +Test-XoPing [-ProgressAction ] [] +``` + +## DESCRIPTION +Sends a GET to the /ping endpoint using the current session credentials. +Returns $true on success (2xx) or $false on any failure (network error, auth error, non-2xx). +Does not throw. +Useful for quick health probes in monitoring scripts. + +## EXAMPLES + +### EXAMPLE 1 +``` +if (-not (Test-XoPing)) { throw "XO API unreachable" } +``` + +## PARAMETERS + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### System.Boolean +## NOTES + +## RELATED LINKS diff --git a/docs/Test-XoSession.md b/docs/Test-XoSession.md new file mode 100644 index 0000000..5fbaf3b --- /dev/null +++ b/docs/Test-XoSession.md @@ -0,0 +1,57 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Test-XoSession + +## SYNOPSIS +Check the connection to Xen Orchestra. + +## SYNTAX + +``` +Test-XoSession [-ProgressAction ] [] +``` + +## DESCRIPTION +Tests if the current session is connected to a Xen Orchestra instance. + +## EXAMPLES + +### EXAMPLE 1 +``` +Test-XoSession +Returns $true if connected, $false otherwise. +``` + +## PARAMETERS + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### System.Boolean +## NOTES + +## RELATED LINKS diff --git a/docs/Update-XoPool.md b/docs/Update-XoPool.md new file mode 100644 index 0000000..10f61b2 --- /dev/null +++ b/docs/Update-XoPool.md @@ -0,0 +1,102 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Update-XoPool + +## SYNOPSIS +Update a running pool. + +## SYNTAX + +``` +Update-XoPool [-PoolUuid] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Update the specified pools using a rolling pool update. + +## EXAMPLES + +### EXAMPLE 1 +``` +Update-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" +``` + +## PARAMETERS + +### -PoolUuid +The UUID(s) of the pools(s) to update. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Wait-XoTask.md b/docs/Wait-XoTask.md new file mode 100644 index 0000000..169bee7 --- /dev/null +++ b/docs/Wait-XoTask.md @@ -0,0 +1,92 @@ +--- +external help file: xo-powershell-help.xml +Module Name: xo-powershell +online version: +schema: 2.0.0 +--- + +# Wait-XoTask + +## SYNOPSIS +Wait for task completion. + +## SYNTAX + +``` +Wait-XoTask [-TaskId] [-PassThru] [-ProgressAction ] [] +``` + +## DESCRIPTION +Waits for the specified tasks to complete and optionally returns the result. + +## EXAMPLES + +### EXAMPLE 1 +``` +Wait-XoTask -TaskId "0m8k2zkzi" +Waits for the task to complete. +``` + +### EXAMPLE 2 +``` +Wait-XoTask -TaskId "0m8k2zkzi" -PassThru +Waits for the task to complete and returns the task object. +``` + +## PARAMETERS + +### -TaskId +The ID(s) of the task(s) to wait for. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -PassThru +If specified, returns the task objects after completion. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/src/Private/ConvertFrom-XoSecureString.ps1 b/src/Private/ConvertFrom-XoSecureString.ps1 new file mode 100644 index 0000000..b56def3 --- /dev/null +++ b/src/Private/ConvertFrom-XoSecureString.ps1 @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 + +function ConvertFrom-XoSecureString +{ + <# + .SYNOPSIS + Convert secure string into string + + .DESCRIPTION + Convert a SecureString to a plain string value. + + .PARAMETER SecureString + SecureString to convert to plain text. + + .EXAMPLE + ConvertFrom-XoSecureString -SecureString 'MySecretString' + #> + [CmdletBinding()] + [OutputType([string])] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [securestring]$SecureString + ) + + process + { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString) + try + { + return [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + } + finally + { + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) + } + } +} diff --git a/src/Private/ConvertFrom-XoTaskHref.ps1 b/src/Private/ConvertFrom-XoTaskHref.ps1 new file mode 100644 index 0000000..7f5bd6d --- /dev/null +++ b/src/Private/ConvertFrom-XoTaskHref.ps1 @@ -0,0 +1,38 @@ +function ConvertFrom-XoTaskHref +{ + <# + .SYNOPSIS + Convert a task URL to a task object + .DESCRIPTION + Extracts the task ID from a URL and retrieves the task from the API + .PARAMETER Uri + The task href URL to convert to an object. + .EXAMPLE + ConvertFrom-XoTaskHref -Uri $uri + #> + [CmdletBinding()] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [string]$Uri + ) + + process + { + if ($Uri -imatch "\/rest\/v0\/tasks\/([0-9a-z]+)") + { + $taskId = $matches[1] + } + elseif ($Uri -imatch "^@\{taskId=.*\}") + { + $data = ConvertFrom-StringData -StringData "$($Uri -replace '(@|\{|\})','')" + $taskId = ([pscustomobject]$data).taskId + } + else + { + throw "Bad task href format: {0}", $Uri + } + + + Get-XoTask -TaskId $taskId + } +} diff --git a/src/Private/ConvertFrom-XoUuidHref.ps1 b/src/Private/ConvertFrom-XoUuidHref.ps1 new file mode 100644 index 0000000..c8d9b78 --- /dev/null +++ b/src/Private/ConvertFrom-XoUuidHref.ps1 @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: Apache-2.0 + +function ConvertFrom-XoUuidHref +{ + <# + .SYNOPSIS + Convert Href to URI + + .DESCRIPTION + Convert an API href into a UUID segment value. + + .PARAMETER Uri + Target href URI to convert to UUID. + + .EXAMPLE + ConvertFrom-XoUuidHref -Uri $uri + #> + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)][string]$Uri + ) + + process + { + if ($Uri -notmatch "\/rest\/v0\/[0-9a-z-_]+\/[0-9a-z-]+") + { + throw "Bad href format" + } + [uri]::new([uri]$script:XoHost, $Uri).Segments[-1] + } +} diff --git a/src/Private/ConvertTo-XoAlarmObject.ps1 b/src/Private/ConvertTo-XoAlarmObject.ps1 new file mode 100644 index 0000000..fa1fa44 --- /dev/null +++ b/src/Private/ConvertTo-XoAlarmObject.ps1 @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_ALARM_FIELDS = "body,name,time,type,uuid,`$pool" + +function ConvertTo-XoAlarmObject +{ + <# + .SYNOPSIS + Convert object to Alarm Object + + .DESCRIPTION + Convert an API response to an XO alarm object. + + .PARAMETER InputObject + Alarm object returned from the API. + + .EXAMPLE + ConvertTo-XoAlarmObject -InputObject $Object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + AlarmTime = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.time).ToLocalTime() + BodyName = $InputObject.body.name + BodyValue = $InputObject.body.value + } + Set-XoObject $InputObject -TypeName XoPowershell.Alarm -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoBackupArchiveObject.ps1 b/src/Private/ConvertTo-XoBackupArchiveObject.ps1 new file mode 100644 index 0000000..81be8fe --- /dev/null +++ b/src/Private/ConvertTo-XoBackupArchiveObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_BACKUP_ARCHIVE_FIELDS = "id,backupRepository,disks,type" + +function ConvertTo-XoBackupArchiveObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo BackupArchive object + + .DESCRIPTION + Convert an API response to an XO BackupArchive object. + + .PARAMETER InputObject + BackupArchive input object from the API. + + .EXAMPLE + ConvertTo-XoBackupArchiveObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.BackupArchive")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + BackupArchiveId = $InputObject.id + } + Set-XoObject $InputObject -TypeName XoPowershell.BackupArchive -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoBackupJobObject.ps1 b/src/Private/ConvertTo-XoBackupJobObject.ps1 new file mode 100644 index 0000000..f5d722a --- /dev/null +++ b/src/Private/ConvertTo-XoBackupJobObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_BACKUP_JOB_FIELDS = "id,name,mode,type" + +function ConvertTo-XoBackupJobObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo BackupJob object + + .DESCRIPTION + Convert an API response to an XO backup job object. + + .PARAMETER InputObject + Backup job input object from the API. + + .EXAMPLE + ConvertTo-XoBackupJobObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.BackupJob")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + BackupJobId = $InputObject.id + } + Set-XoObject $InputObject -TypeName XoPowershell.BackupJob -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoBackupLogObject.ps1 b/src/Private/ConvertTo-XoBackupLogObject.ps1 new file mode 100644 index 0000000..0472c9c --- /dev/null +++ b/src/Private/ConvertTo-XoBackupLogObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_BACKUP_LOG_FIELDS = "id,jobId,jobName,message,scheduleId,start,status" + +function ConvertTo-XoBackupLogObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo BackupLog object + + .DESCRIPTION + Convert an API response to an XO BackupLog object. + + .PARAMETER InputObject + BackupLog input object from the API. + + .EXAMPLE + ConvertTo-XoBackupLogObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.BackupLog")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + BackupLogId = $InputObject.id + } + Set-XoObject $InputObject -TypeName XoPowershell.BackupLog -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoBackupRepositoryObject.ps1 b/src/Private/ConvertTo-XoBackupRepositoryObject.ps1 new file mode 100644 index 0000000..689d24d --- /dev/null +++ b/src/Private/ConvertTo-XoBackupRepositoryObject.ps1 @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_BACKUP_REPOSITORY_FIELDS = "id,name,enabled,url" + +function ConvertTo-XoBackupRepositoryObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo BackupRepository object + + .DESCRIPTION + Convert an API response to an XO BackupRepository object. + + .PARAMETER InputObject + BackupRepository input object from the API. + + .EXAMPLE + ConvertTo-XoBackupRepositoryObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.BackupRepository")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + BackupRepositoryId = $InputObject.id + Name = $InputObject.name + } + Set-XoObject $InputObject -TypeName XoPowershell.BackupRepository -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoDashboardObject.ps1 b/src/Private/ConvertTo-XoDashboardObject.ps1 new file mode 100644 index 0000000..34569b6 --- /dev/null +++ b/src/Private/ConvertTo-XoDashboardObject.ps1 @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 + +function ConvertTo-XoDashboardObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Dashboard object + + .DESCRIPTION + Convert an API response to an XO Dashboard object. + + .PARAMETER InputObject + Dashboard input object from the API. + + .EXAMPLE + ConvertTo-XoDashboardObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Dashboard")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + Set-XoObject $InputObject -TypeName XoPowershell.Dashboard + } +} diff --git a/src/Private/ConvertTo-XoEventObject.ps1 b/src/Private/ConvertTo-XoEventObject.ps1 new file mode 100644 index 0000000..c0e432f --- /dev/null +++ b/src/Private/ConvertTo-XoEventObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_EVENT_FIELDS = "id,name,type,time" + +function ConvertTo-XoEventObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Event object + + .DESCRIPTION + Convert an API response to an XO Event object. + + .PARAMETER InputObject + Event input object from the API. + + .EXAMPLE + ConvertTo-XoEventObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Event")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + EventId = $InputObject.id + } + Set-XoObject $InputObject -TypeName XoPowershell.Event -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoGroupObject.ps1 b/src/Private/ConvertTo-XoGroupObject.ps1 new file mode 100644 index 0000000..9c147a8 --- /dev/null +++ b/src/Private/ConvertTo-XoGroupObject.ps1 @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_GROUP_FIELDS = "id,name,users" + +function ConvertTo-XoGroupObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Group object + + .DESCRIPTION + Convert an API response to an XO Group object. + + .PARAMETER InputObject + Group input object from the API. + + .EXAMPLE + ConvertTo-XoGroupObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Group")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + GroupId = $InputObject.id + Name = $InputObject.name + } + Set-XoObject $InputObject -TypeName XoPowershell.Group -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoGuiRouteObject.ps1 b/src/Private/ConvertTo-XoGuiRouteObject.ps1 new file mode 100644 index 0000000..ccece9e --- /dev/null +++ b/src/Private/ConvertTo-XoGuiRouteObject.ps1 @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 + +function ConvertTo-XoGuiRouteObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo GuiRoute object + + .DESCRIPTION + Convert an API response to an XO GuiRoute object. + + .PARAMETER InputObject + GuiRoute input object from the API. + + .EXAMPLE + ConvertTo-XoGuiRouteObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.GuiRoute")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + Set-XoObject $InputObject -TypeName XoPowershell.GuiRoute + } +} diff --git a/src/Private/ConvertTo-XoHostObject.ps1 b/src/Private/ConvertTo-XoHostObject.ps1 new file mode 100644 index 0000000..dc61dcb --- /dev/null +++ b/src/Private/ConvertTo-XoHostObject.ps1 @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_HOST_FIELDS = "uuid,name_label,name_description,power_state,memory,address,hostname,version,productBrand,build,startTime,tags,bios_strings,license_params,license_server,license_expiry,residentVms,PIFs,PCIs,PGPUs,poolId,CPUs" + +function ConvertTo-XoHostObject +{ + <# + .SYNOPSIS + Convert a host object from the API to a PowerShell object. + .DESCRIPTION + Convert a host object from the API to a PowerShell object with proper properties and types. + This function creates a flat object using the raw values from the API response. + .PARAMETER InputObject + The host object from the API. + .EXAMPLE + ConvertTo-XoHostObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Host")] + param ( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + HostUuid = $InputObject.uuid + Name = $InputObject.name_label + PowerState = $InputObject.power_state + Description = $InputObject.name_description + BiosStrings = $InputObject.bios_strings + LicenseParams = $InputObject.license_params + LicenseServer = $InputObject.license_server + LicenseExpiry = $InputObject.license_expiry + } + Set-XoObject $InputObject -TypeName XoPowershell.Host -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoMessageObject.ps1 b/src/Private/ConvertTo-XoMessageObject.ps1 new file mode 100644 index 0000000..794d4fc --- /dev/null +++ b/src/Private/ConvertTo-XoMessageObject.ps1 @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_MESSAGE_FIELDS = "body,name,time,type,uuid" + +function ConvertTo-XoMessageObject +{ + <# + .SYNOPSIS + Convert Message object into powershell object + + .DESCRIPTION + Convert Message object into powershell object + + .PARAMETER InputObject + Message object returned from the API. + + .EXAMPLE + ConvertTo-XoMessageObject -InputObject $object + + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + MessageUuid = $InputObject.uuid + MessageTime = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.time).ToLocalTime() + } + Set-XoObject $InputObject -TypeName XoPowershell.Message -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoNetworkObject.ps1 b/src/Private/ConvertTo-XoNetworkObject.ps1 new file mode 100644 index 0000000..e1d7900 --- /dev/null +++ b/src/Private/ConvertTo-XoNetworkObject.ps1 @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_NETWORK_FIELDS = "automatic,defaultIsLocked,MTU,name_description,name_label,tags,PIFs,VIFs,nbd,uuid,`$pool" + +function ConvertTo-XoNetworkObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo network object + + .DESCRIPTION + Convert api object to powershell xo network object + + .PARAMETER InputObject + Network input object from the API. + + .EXAMPLE + ConvertTo-XoNetworkObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.Network")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + NetworkUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + PifUuid = $InputObject.PIFs + VifUuid = $InputObject.VIFs + } + Set-XoObject $InputObject -TypeName XoPowershell.Network -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoPbdObject.ps1 b/src/Private/ConvertTo-XoPbdObject.ps1 new file mode 100644 index 0000000..7e1f466 --- /dev/null +++ b/src/Private/ConvertTo-XoPbdObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_PBD_FIELDS = "attached,id,uuid,device_config,host,SR" + +function ConvertTo-XoPbdObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Pbd object + + .DESCRIPTION + Convert an API response to an XO Pbd object. + + .PARAMETER InputObject + Pbd input object from the API. + + .EXAMPLE + ConvertTo-XoPbdObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Pbd")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + PbdUuid = $InputObject.uuid + } + Set-XoObject $InputObject -TypeName XoPowershell.Pbd -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoPciObject.ps1 b/src/Private/ConvertTo-XoPciObject.ps1 new file mode 100644 index 0000000..d1bc64d --- /dev/null +++ b/src/Private/ConvertTo-XoPciObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_PCI_FIELDS = "class_name,device_name,id,uuid,pci_id" + +function ConvertTo-XoPciObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Pci object + + .DESCRIPTION + Convert an API response to an XO Pci object. + + .PARAMETER InputObject + Pci input object from the API. + + .EXAMPLE + ConvertTo-XoPciObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Pci")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + PciUuid = $InputObject.uuid + } + Set-XoObject $InputObject -TypeName XoPowershell.Pci -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoPgpuObject.ps1 b/src/Private/ConvertTo-XoPgpuObject.ps1 new file mode 100644 index 0000000..cb53edc --- /dev/null +++ b/src/Private/ConvertTo-XoPgpuObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_PGPU_FIELDS = "id,uuid,dom0Access,gpuGroup,host" + +function ConvertTo-XoPgpuObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Pgpu object + + .DESCRIPTION + Convert an API response to an XO Pgpu object. + + .PARAMETER InputObject + Pgpu input object from the API. + + .EXAMPLE + ConvertTo-XoPgpuObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Pgpu")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + PgpuUuid = $InputObject.uuid + } + Set-XoObject $InputObject -TypeName XoPowershell.Pgpu -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoPifObject.ps1 b/src/Private/ConvertTo-XoPifObject.ps1 new file mode 100644 index 0000000..cc8ed95 --- /dev/null +++ b/src/Private/ConvertTo-XoPifObject.ps1 @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_PIF_FIELDS = "attached,isBondMaster,isBondSlave,device,deviceName,dns,disallowUnplug,gateway,ip,ipv6,mac,management,carrier,mode,ipv6Mode,mtu,netmask,physical,primaryAddressType,vlan,speed,uuid,`$network,`$pool" + +function ConvertTo-XoPifObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Pif object + + .DESCRIPTION + Convert api object to powershell xo Pif object + + .PARAMETER InputObject + PIF input object returned from the API. + + .EXAMPLE + ConvertTo-XoPifObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.Pif")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + PifUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + } + Set-XoObject $InputObject -TypeName XoPowershell.Pif -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoPoolObject.ps1 b/src/Private/ConvertTo-XoPoolObject.ps1 new file mode 100644 index 0000000..0715680 --- /dev/null +++ b/src/Private/ConvertTo-XoPoolObject.ps1 @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_POOL_FIELDS = "auto_poweron,default_SR,HA_enabled,haSrs,master,tags,name_description,name_label,migrationCompression,cpus,zstdSupported,vtpmSupported,platform_version,type,uuid" + +function ConvertTo-XoPoolObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Pool object + + .DESCRIPTION + Convert api object to powershell xo Pool object + + .PARAMETER InputObject + Pool input object returned from the API. + + .EXAMPLE + ConvertTo-XoPoolObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.Pool")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + PoolUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + CpuCores = $InputObject.cpus.cores + PlatformVersion = $InputObject.platform_version + HAEnabled = $InputObject.HA_enabled + } + Set-XoObject $InputObject -TypeName XoPowershell.Pool -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoPoolPatchObject.ps1 b/src/Private/ConvertTo-XoPoolPatchObject.ps1 new file mode 100644 index 0000000..ce27845 --- /dev/null +++ b/src/Private/ConvertTo-XoPoolPatchObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +function ConvertTo-XoPoolPatchObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo PoolPatch object + + .DESCRIPTION + Convert api object to powershell xo PoolPatch object + + .PARAMETER InputObject + Pool patch input object from the API. + + .EXAMPLE + ConvertTo-XoPoolPatchObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.PoolPatch")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + Date = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.changelog.date).ToLocalTime() + Description = $InputObject.changelog.description + } + Set-XoObject $InputObject -TypeName XoPowershell.PoolPatch -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoProxyObject.ps1 b/src/Private/ConvertTo-XoProxyObject.ps1 new file mode 100644 index 0000000..f749482 --- /dev/null +++ b/src/Private/ConvertTo-XoProxyObject.ps1 @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_PROXY_FIELDS = "id,name,vmUuid,url,version" + +function ConvertTo-XoProxyObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Proxy object + + .DESCRIPTION + Convert an API response to an XO Proxy object. + + .PARAMETER InputObject + Proxy input object from the API. + + .EXAMPLE + ConvertTo-XoProxyObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Proxy")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + ProxyId = $InputObject.id + Name = $InputObject.name + } + Set-XoObject $InputObject -TypeName XoPowershell.Proxy -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoRestoreLogObject.ps1 b/src/Private/ConvertTo-XoRestoreLogObject.ps1 new file mode 100644 index 0000000..0cd4211 --- /dev/null +++ b/src/Private/ConvertTo-XoRestoreLogObject.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_RESTORE_LOG_FIELDS = "id,message,start,status,jobId" + +function ConvertTo-XoRestoreLogObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo RestoreLog object + + .DESCRIPTION + Convert an API response to an XO RestoreLog object. + + .PARAMETER InputObject + RestoreLog input object from the API. + + .EXAMPLE + ConvertTo-XoRestoreLogObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.RestoreLog")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + RestoreLogId = $InputObject.id + } + Set-XoObject $InputObject -TypeName XoPowershell.RestoreLog -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoScheduleObject.ps1 b/src/Private/ConvertTo-XoScheduleObject.ps1 new file mode 100644 index 0000000..13066e7 --- /dev/null +++ b/src/Private/ConvertTo-XoScheduleObject.ps1 @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_SCHEDULE_FIELDS = "cron,enabled,name,timezone,id,jobId" + +function ConvertTo-XoScheduleObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Schedule object + + .DESCRIPTION + Convert api object to powershell xo Schedule object + + .PARAMETER InputObject + Schedule input object from the API. + + .EXAMPLE + ConvertTo-XoScheduleObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.Schedule")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + ScheduleId = $InputObject.id + } + Set-XoObject $InputObject -TypeName XoPowershell.Schedule -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoServerObject.ps1 b/src/Private/ConvertTo-XoServerObject.ps1 new file mode 100644 index 0000000..42a72d4 --- /dev/null +++ b/src/Private/ConvertTo-XoServerObject.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_SERVER_FIELDS = "id,host,label,address,version,status,enabled,error,username,readOnly,allowUnauthorized" + +function ConvertTo-XoServerObject +{ + <# + .SYNOPSIS + Convert a server object from the API to a PowerShell object. + .DESCRIPTION + Convert a server object from the API to a PowerShell object with proper properties. + .PARAMETER InputObject + The server object from the API. + .EXAMPLE + ConvertTo-XoServerObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Server")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + $InputObject + ) + + process + { + $props = @{ + ServerUuid = $InputObject.id # API returns 'id' field, not 'uuid' for servers + Name = $InputObject.label + NameHost = $InputObject.host + Address = $InputObject.address + Status = $InputObject.status + Version = $InputObject.version + Enabled = $InputObject.enabled + ReadOnly = $InputObject.readOnly + Username = $InputObject.username + Error = $InputObject.error + AllowUnauthorized = $InputObject.allowUnauthorized + } + + Set-XoObject $InputObject -TypeName XoPowershell.Server -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoSmObject.ps1 b/src/Private/ConvertTo-XoSmObject.ps1 new file mode 100644 index 0000000..097c67f --- /dev/null +++ b/src/Private/ConvertTo-XoSmObject.ps1 @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_SM_FIELDS = "uuid,name_label,name_description,SM_type,vendor,version" + +function ConvertTo-XoSmObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Sm object + + .DESCRIPTION + Convert an API response to an XO Sm object. + + .PARAMETER InputObject + Sm input object from the API. + + .EXAMPLE + ConvertTo-XoSmObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Sm")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + SmUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + Type = $InputObject.SM_type + } + Set-XoObject $InputObject -TypeName XoPowershell.Sm -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoSrObject.ps1 b/src/Private/ConvertTo-XoSrObject.ps1 new file mode 100644 index 0000000..dcbf355 --- /dev/null +++ b/src/Private/ConvertTo-XoSrObject.ps1 @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_SR_FIELDS = "name_label,uuid,SR_type,content_type,allocationStrategy,size,physical_usage,usage,shared" + +function ConvertTo-XoSrObject +{ + <# + .SYNOPSIS + Convert a storage repository object from the API to a PowerShell object. + .DESCRIPTION + Convert a storage repository object from the API to a PowerShell object with proper properties and types. + .PARAMETER InputObject + The storage repository object from the API. + .EXAMPLE + ConvertTo-XoSrObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Sr")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + $InputObject + ) + + process + { + $props = @{ + SrUuid = $InputObject.uuid + Name = $InputObject.name_label + Type = $InputObject.SR_type + ContentType = $InputObject.content_type + SrSize = Format-XoSize $InputObject.size + UsageSize = Format-XoSize $InputObject.usage + PhysicalUsageSize = Format-XoSize $InputObject.physical_usage + } + Set-XoObject $InputObject -TypeName XoPowershell.Sr -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoStatObject.ps1 b/src/Private/ConvertTo-XoStatObject.ps1 new file mode 100644 index 0000000..ac8203d --- /dev/null +++ b/src/Private/ConvertTo-XoStatObject.ps1 @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 + +function ConvertTo-XoStatObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Stat object + + .DESCRIPTION + Convert an API response to an XO Stat object. + + .PARAMETER InputObject + Stat input object from the API. + + .EXAMPLE + ConvertTo-XoStatObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Stat")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + Set-XoObject $InputObject -TypeName XoPowershell.Stat + } +} diff --git a/src/Private/ConvertTo-XoTaskObject.ps1 b/src/Private/ConvertTo-XoTaskObject.ps1 new file mode 100644 index 0000000..bc04d73 --- /dev/null +++ b/src/Private/ConvertTo-XoTaskObject.ps1 @@ -0,0 +1,100 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_TASK_FIELDS = "id,properties,start,status,result,updatedAt,end,progress" + +function ConvertTo-XoTaskObject +{ + <# + .SYNOPSIS + Convert a task object from the API to a PowerShell object. + .DESCRIPTION + Convert a task object from the API to a PowerShell object with proper properties. + .PARAMETER InputObject + The task object from the API. + .EXAMPLE + ConvertTo-XoTaskObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + $InputObject + ) + + process + { + $name = if ($InputObject.properties.name) + { + $InputObject.properties.name + } + elseif ($InputObject.properties.method) + { + $InputObject.properties.method + } + else + { + "Unknown" + } + + $type = if ($InputObject.properties.type) + { + $InputObject.properties.type + } + else + { + "" + } + + $startTime = if ($InputObject.start -and $InputObject.start -gt 0) + { + [System.DateTimeOffset]::FromUnixTimeMilliseconds($InputObject.start).ToLocalTime() + } + else + { + $null + } + + $endTime = if ($InputObject.end -and $InputObject.end -gt 0) + { + [System.DateTimeOffset]::FromUnixTimeMilliseconds($InputObject.end).ToLocalTime() + } + else + { + $null + } + + $message = if ($InputObject.result.message) + { + $InputObject.result.message + } + elseif ($InputObject.result.code) + { + $InputObject.result.code + } + else + { + "" + } + + $props = @{ + PSTypeName = "XoPowershell.Task" + TaskId = $InputObject.id + Name = $name + Type = $type + Status = $InputObject.status + Progress = if ($null -ne $InputObject.progress) + { + $InputObject.progress + } + else + { + 0 + } + StartTime = $startTime + EndTime = $endTime + Message = $message + } + + [PSCustomObject]$props + } +} diff --git a/src/Private/ConvertTo-XoUserAuthenticationTokenObject.ps1 b/src/Private/ConvertTo-XoUserAuthenticationTokenObject.ps1 new file mode 100644 index 0000000..a5b9fa4 --- /dev/null +++ b/src/Private/ConvertTo-XoUserAuthenticationTokenObject.ps1 @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 + +function ConvertTo-XoUserAuthenticationTokenObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo UserAuthenticationToken object + + .DESCRIPTION + Convert an API response to an XO UserAuthenticationToken object. + + .PARAMETER InputObject + UserAuthenticationToken input object from the API. + + .EXAMPLE + ConvertTo-XoUserAuthenticationTokenObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.UserAuthenticationToken")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + TokenId = $InputObject.id + UserId = $InputObject.user_id + } + Set-XoObject $InputObject -TypeName XoPowershell.UserAuthenticationToken -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoUserObject.ps1 b/src/Private/ConvertTo-XoUserObject.ps1 new file mode 100644 index 0000000..688572f --- /dev/null +++ b/src/Private/ConvertTo-XoUserObject.ps1 @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_USER_FIELDS = "id,name,email,permission,groups" + +function ConvertTo-XoUserObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo User object + + .DESCRIPTION + Convert an API response to an XO User object. + + .PARAMETER InputObject + User input object from the API. + + .EXAMPLE + ConvertTo-XoUserObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.User")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + UserId = $InputObject.id + Name = $InputObject.name + } + Set-XoObject $InputObject -TypeName XoPowershell.User -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoVbdObject.ps1 b/src/Private/ConvertTo-XoVbdObject.ps1 new file mode 100644 index 0000000..8666e79 --- /dev/null +++ b/src/Private/ConvertTo-XoVbdObject.ps1 @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_VBD_FIELDS = "attached,bootable,device,is_cd_drive,position,read_only,uuid,`$pool" + +function ConvertTo-XoVbdObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Vbd object + + .DESCRIPTION + Convert api object to powershell xo Vbd object + + .PARAMETER InputObject + VBD input object returned from the API. + + .EXAMPLE + ConvertTo-XoVbdObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.Vbd")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + VbdUuid = $InputObject.uuid + IsCdDrive = $InputObject.is_cd_drive + ReadOnly = $InputObject.read_only + } + Set-XoObject $InputObject -TypeName XoPowershell.Vbd -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoVdiObject.ps1 b/src/Private/ConvertTo-XoVdiObject.ps1 new file mode 100644 index 0000000..471dbc9 --- /dev/null +++ b/src/Private/ConvertTo-XoVdiObject.ps1 @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_VDI_FIELDS = "name_label,uuid,content_type,size,usage,physical_usage,`$SR,sr_usage" + +function ConvertTo-XoVdiObject +{ + <# + .SYNOPSIS + Convert a VDI object from the API to a PowerShell object. + .DESCRIPTION + Convert a VDI object from the API to a PowerShell object with proper properties and types. + .PARAMETER InputObject + The VDI object from the API. + .EXAMPLE + ConvertTo-XoVdiObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vdi")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [PSObject] $InputObject + ) + + + process + { + $props = @{ + PSTypeName = "XoPowershell.Vdi" + VdiUuid = $InputObject.uuid + Name = $InputObject.name_label + ContentType = $InputObject.content_type + Size = $InputObject.size + Usage = $InputObject.usage + PhysicalUsage = $InputObject.physical_usage + SrUuid = $InputObject.sr_uuid + SrUsage = $InputObject.sr_usage + } + + [PSCustomObject]$props + } +} diff --git a/src/Private/ConvertTo-XoVdiSnapshotObject.ps1 b/src/Private/ConvertTo-XoVdiSnapshotObject.ps1 new file mode 100644 index 0000000..3a52343 --- /dev/null +++ b/src/Private/ConvertTo-XoVdiSnapshotObject.ps1 @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_VDI_SNAPSHOT_FIELDS = "name_label,size,uuid,snapshot_time,snapshot_of,sr_uuid,usage" + +function ConvertTo-XoVdiSnapshotObject +{ + <# + .SYNOPSIS + Convert a VDI snapshot object from the API to a PowerShell object. + .DESCRIPTION + Convert a VDI snapshot object from the API to a PowerShell object with proper properties. + .PARAMETER InputObject + The VDI snapshot object from the API. + .EXAMPLE + ConvertTo-XoSnapshotObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.VdiSnapshot")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [PSObject] $InputObject + ) + + process + { + $props = @{ + PSTypeName = "XoPowershell.VdiSnapshot" + VdiSnapshotUuid = $InputObject.uuid + Name = $InputObject.name_label + Size = $InputObject.size + SnapshotOf = $InputObject.snapshot_of + SnapshotTime = $InputObject.snapshot_time + SrUuid = $InputObject.sr_uuid + Usage = $InputObject.usage + } + + [PSCustomObject]$props + } +} diff --git a/src/Private/ConvertTo-XoVifObject.ps1 b/src/Private/ConvertTo-XoVifObject.ps1 new file mode 100644 index 0000000..d3180a6 --- /dev/null +++ b/src/Private/ConvertTo-XoVifObject.ps1 @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_VIF_FIELDS = "allowedIpv4Addresses,allowedIpv6Addresses,attached,device,lockingMode,MAC,MTU,txChecksumming,uuid,`$network,`$pool" + +function ConvertTo-XoVifObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo Vif object + + .DESCRIPTION + Convert api object to powershell xo Vif object + + .PARAMETER InputObject + VIF input object returned from the API. + + .EXAMPLE + ConvertTo-XoVifObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.Vif")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + VifUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + } + Set-XoObject $InputObject -TypeName XoPowershell.Vif -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoVmControllerObject.ps1 b/src/Private/ConvertTo-XoVmControllerObject.ps1 new file mode 100644 index 0000000..aac26f0 --- /dev/null +++ b/src/Private/ConvertTo-XoVmControllerObject.ps1 @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_VM_CONTROLLER_FIELDS = "uuid,name_label,name_description,power_state,$pool,host" + +function ConvertTo-XoVmControllerObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo VmController object + + .DESCRIPTION + Convert an API response to an XO VmController object. + + .PARAMETER InputObject + VmController input object from the API. + + .EXAMPLE + ConvertTo-XoVmControllerObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.VmController")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + VmControllerUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + PowerState = $InputObject.power_state + } + Set-XoObject $InputObject -TypeName XoPowershell.VmController -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoVmObject.ps1 b/src/Private/ConvertTo-XoVmObject.ps1 new file mode 100644 index 0000000..d1abe74 --- /dev/null +++ b/src/Private/ConvertTo-XoVmObject.ps1 @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_VM_FIELDS = "uuid,name_label,name_description,power_state,addresses,tags,memory,VIFs,snapshots,current_operations,auto_poweron,os_version,startTime,VCPUs_at_startup,CPUs,VCPUs_number,`$VBDs" +$script:XO_VM_TEMPLATE_FIELDS = $script:XO_VM_FIELDS + ",isDefaultTemplate" + +function ConvertTo-XoVmObject +{ + <# + .SYNOPSIS + Convert a VM object from the API to a PowerShell object. + .DESCRIPTION + Convert a VM object from the API to a PowerShell object with proper properties and types. + .PARAMETER InputObject + The VM object from the API. + .EXAMPLE + ConvertTo-XoVmObject -InputObject $object + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vm")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [PSObject] $InputObject + ) + + process + { + $props = @{ + VmUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + PowerState = $InputObject.power_state + OsVersion = $InputObject.os_version + Parent = $InputObject.parent + HostUuid = $InputObject.$container + } + + if ($InputObject.CPUs.number) + { + $props["CPUs"] = $InputObject.CPUs.number + } + elseif ($InputObject.CPUs.max) + { + $props["CPUs"] = $InputObject.CPUs.max + } + else + { + $props["CPUs"] = $null + } + + Set-XoObject $InputObject -TypeName XoPowershell.Vm -Properties $props + } +} diff --git a/src/Private/ConvertTo-XoVmSnapshotObject.ps1 b/src/Private/ConvertTo-XoVmSnapshotObject.ps1 new file mode 100644 index 0000000..fa0b122 --- /dev/null +++ b/src/Private/ConvertTo-XoVmSnapshotObject.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_VM_SNAPSHOT_FIELDS = "uuid,name_label,name_description,snapshot_time,snapshot_of,power_state,tags,CPUs,memory" + +function ConvertTo-XoVmSnapshotObject +{ + <# + .SYNOPSIS + Convert a VM snapshot object from the API to a PowerShell object. + .DESCRIPTION + Convert a VM snapshot object from the API to a PowerShell object with proper properties. + .PARAMETER InputObject + The VM snapshot object from the API. + .EXAMPLE + ConvertTo-XoVmSnapshotObject -InputObject $object + #> + [CmdletBinding()] + param ( + [parameter(Mandatory = $true)] + [PSObject] $InputObject + ) + + # Create object with direct properties from API + $snapshotObj = [PSCustomObject]@{ + PSTypeName = "XoPowershell.VmSnapshot" + VmSnapshotUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + PowerState = $InputObject.power_state + SnapshotOf = $InputObject.snapshot_of + SnapshotTime = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.snapshot_time).ToLocalTime() + Memory = $InputObject.memory + } + + if ($null -ne $InputObject.CPUs) + { + if ($InputObject.CPUs.PSObject.Properties.Name -contains 'number') + { + $snapshotObj | Add-Member -MemberType NoteProperty -Name CPUs -Value $InputObject.CPUs.number + } + elseif ($InputObject.CPUs.PSObject.Properties.Name -contains 'max') + { + $snapshotObj | Add-Member -MemberType NoteProperty -Name CPUs -Value $InputObject.CPUs.max + } + } + + return $snapshotObj +} diff --git a/src/Private/ConvertTo-XoVmTemplateObject.ps1 b/src/Private/ConvertTo-XoVmTemplateObject.ps1 new file mode 100644 index 0000000..685a4ed --- /dev/null +++ b/src/Private/ConvertTo-XoVmTemplateObject.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +# see ConvertTo-XoVmObject.ps1 for XO_VM_TEMPLATE_FIELDS (which depends on XO_VM_FIELDS) + +function ConvertTo-XoVmTemplateObject +{ + <# + .SYNOPSIS + Convert api object to powershell xo VmTemplate object + + .DESCRIPTION + Convert api object to powershell xo VmTemplate object + + .PARAMETER InputObject + VM template input object from the API. + + .EXAMPLE + ConvertTo-XoVmTemplateObject -InputObject $object + + #> + [Cmdletbinding()] + [OutputType("XoPowershell.VmTemplate")] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject + ) + + process + { + $props = @{ + VmTemplateUuid = $InputObject.uuid + Name = $InputObject.name_label + Description = $InputObject.name_description + OsVersion = $InputObject.os_version + Parent = $InputObject.parent + HostUuid = $InputObject.$container + } + + if ($InputObject.CPUs.number) + { + $props["CPUs"] = $InputObject.CPUs.number + } + elseif ($InputObject.CPUs.max) + { + $props["CPUs"] = $InputObject.CPUs.max + } + else + { + $props["CPUs"] = $null + } + + Set-XoObject $InputObject -TypeName XoPowershell.VmTemplate -Properties $props + } +} diff --git a/src/Private/Format-XoSize.ps1 b/src/Private/Format-XoSize.ps1 new file mode 100644 index 0000000..879800c --- /dev/null +++ b/src/Private/Format-XoSize.ps1 @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Format-XoSize +{ + <# + .SYNOPSIS + Converts size into a readable format + + .DESCRIPTION + Converts a byte size into a human-readable format. + + .PARAMETER Value + Target size in bytes to format. + + .EXAMPLE + 291843908213409 | Format-XoSize + #> + [CmdletBinding()] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [long]$Value + ) + process + { + # based off of https://stackoverflow.com/a/40887001/8642889 + + $suffix = " B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" + $index = 0 + while ($Value -gt 1kb -and $index -lt $suffix.Length) + { + $Value = $Value / 1kb + $index++ + } + + "{0:N1} {1}" -f $Value, $suffix[$index] + } +} diff --git a/src/Private/Invoke-XoPoolAction.ps1 b/src/Private/Invoke-XoPoolAction.ps1 new file mode 100644 index 0000000..3faa61f --- /dev/null +++ b/src/Private/Invoke-XoPoolAction.ps1 @@ -0,0 +1,149 @@ +# SPDX-License-Identifier: Apache-2.0 + +# For convenience. Internal use only. +function Invoke-XoPoolAction +{ + <# + .SYNOPSIS + Internal function used to manage Xen Orchestra pool actions + + .DESCRIPTION + Internal function used to manage Xen Orchestra pool actions + + .PARAMETER PoolUuid + Target Xen Orchestra Pool Id + + .PARAMETER Action + Target Xen Orchestra Pool action + + .PARAMETER Sync + Force the Xen Orchestra pool to sync + + .PARAMETER ActionParameters + A hashtable with the required parameters for each action + + .EXAMPLE + Invoke-XoPoolAction -PoolUuid $id -Action "rolling_reboot" + #> + + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$PoolUuid, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [ValidateSet( + "create_bonded_network", + "create_internal_network", + "create_network", + "create_vm", + "emergency_shutdown", + "management_reconfigure", + "rolling_reboot", + "rolling_update" + )] + [string]$Action, + + [Parameter()] + [switch]$Sync, + + [Parameter()] + [hashtable]$ActionParameters + ) + + process + { + switch ($Action) + { + "create_bonded_network" + { + + if (-not ($PSBoundParameters.ContainsKey("ActionParameters"))) + { + throw "ActionParameters are required. For all available parameters, check the docs '/rest/v0/docs/#/pools/CreateBondedNetwork'" + } + } + "create_internal_network" + { + + if (-not ($PSBoundParameters.ContainsKey("ActionParameters"))) + { + throw "ActionParameters are required. For all available parameters, check the docs '/rest/v0/docs/#/pools/CreateInternalNetwork'" + } + } + "create_network" + { + + if (-not ($PSBoundParameters.ContainsKey("ActionParameters"))) + { + throw "ActionParameters are required. For all available parameters, check the docs '/rest/v0/docs/#/pools/CreateNetwork'" + } + } + "create_vm" + { + + if (-not ($PSBoundParameters.ContainsKey("ActionParameters"))) + { + throw "ActionParameters are required. For all available parameters, check the docs '/rest/v0/docs/#/pools/CreateVm'" + } + } + "emergency_shutdown" + { + + $ActionParameters = @{} + } + "management_reconfigure" + { + + if (-not ($PSBoundParameters.ContainsKey("ActionParameters"))) + { + throw "ActionParameters are required. For all available parameters, check the docs '/rest/v0/docs/#/pools/ManagementReconfigure'" + } + } + "rolling_reboot" + { + + $ActionParameters = @{} + } + "rolling_update" + { + + $ActionParameters = @{} + } + } + + foreach ($id in $PoolUuid) + { + $bodyJson = ConvertTo-Json -InputObject $ActionParameters -Depth 99 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$id/actions/${Action}?sync=$($Sync.IsPresent.ToString().ToLower())" -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes | ForEach-Object { + # XO pool actions return one of: + # 1. a task href string (e.g. "/rest/v0/tasks/0m8k2zkzi") - async + # 2. a task id string (e.g. "0m8k2zkzi") + # 3. a PSObject with an "id" field (JSON body response) + # Normalise all three to an XoPowershell.Task by resolving through Get-XoTask. + if ($_ -is [string]) + { + if ($_ -match '\/rest\/v0\/tasks\/([0-9a-z]+)') + { + ConvertFrom-XoTaskHref $_ + } + else + { + Get-XoTask -TaskId $_ + } + } + elseif ($_ -and $_.PSObject.Properties.Name -contains 'id') + { + Get-XoTask -TaskId $_.id + } + else + { + $_ + } + } + } + } +} diff --git a/src/Private/Invoke-XoRestMethod.ps1 b/src/Private/Invoke-XoRestMethod.ps1 new file mode 100644 index 0000000..6ab99e4 --- /dev/null +++ b/src/Private/Invoke-XoRestMethod.ps1 @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoRestMethod +{ + <# + .SYNOPSIS + Helper for when Invoke-RestMethod returns unparseable JSON. + .DESCRIPTION + Helper for when Invoke-RestMethod returns unparseable JSON (e.g. due to duplicate keys). $script:XoRestParameters is already included. + + .PARAMETER Uri + Target Xen Orchestra REST URL. + + .PARAMETER Body + Body content for the REST request. + + .EXAMPLE + Invoke-XoRestMethod -Uri $Url -Body $body + #> + param( + [Parameter(Mandatory)] + [string]$Uri, + + [Parameter()] + [object]$Body + ) + + $result = Invoke-RestMethod @script:XoRestParameters -Uri $uri -Body $body + if ($result -is [string]) + { + Write-Verbose "server returned unparseable JSON, retrying with -AsHashtable" + $json = $result | ConvertFrom-Json -AsHashtable + return [pscustomobject]$json + } + else + { + return $result + } +} diff --git a/src/Private/Set-XoObject.ps1 b/src/Private/Set-XoObject.ps1 new file mode 100644 index 0000000..234e138 --- /dev/null +++ b/src/Private/Set-XoObject.ps1 @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoObject +{ + <# + .SYNOPSIS + Set Xo Object with custom type + + .DESCRIPTION + Sets an object's PSTypeName and adds custom properties. + + .PARAMETER InputObject + Target object to decorate with properties. + + .PARAMETER TypeName + Custom PSTypeName for the object. + + .PARAMETER Properties + Properties to add to the target object. + + .EXAMPLE + Set-XoObject $InputObject -TypeName XoPowershell.MyCustomType -Properties $props + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'low')] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject, + [Parameter()][string]$TypeName, + [Parameter()][hashtable]$Properties + ) + process + { + if ($PSCmdlet.ShouldProcess($TypeName, "Setting object ")) + { + + if ($TypeName) + { + $InputObject.PSObject.TypeNames.Insert(0, $TypeName) > $null + } + if ($Properties) + { + foreach ($key in $Properties.Keys) + { + $InputObject.PSObject.Properties.Add([psnoteproperty]::new($key, $Properties[$key])) > $null + } + } + [PSCustomObject]$InputObject + } + } +} diff --git a/src/Public/Add-XoGroupUser.ps1 b/src/Public/Add-XoGroupUser.ps1 new file mode 100644 index 0000000..ea788d3 --- /dev/null +++ b/src/Public/Add-XoGroupUser.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Add-XoGroupUser +{ + <# + .SYNOPSIS + Add an existing user to a Xen Orchestra group. + .DESCRIPTION + Associates a user with a group via PUT /groups/{id}/users/{userId}. The user must already exist (see New-XoUser). This is an idempotent operation - re-adding an already-member user is a no-op on the server. + .PARAMETER GroupId + The UUID of the group the user will be added to. + .PARAMETER UserId + The UUID of the user to add to the group. + .EXAMPLE + Add-XoGroupUser -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$GroupId, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$UserId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("group $GroupId", "add user $UserId")) + { + return + } + + $uri = "$script:XoHost/rest/v0/groups/$GroupId/users/$UserId" + Invoke-RestMethod -Uri $uri -Method Put @script:XoRestParameters + } +} diff --git a/src/Public/Add-XoVmStatDataSource.ps1 b/src/Public/Add-XoVmStatDataSource.ps1 new file mode 100644 index 0000000..f2a4230 --- /dev/null +++ b/src/Public/Add-XoVmStatDataSource.ps1 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Add-XoVmStatDataSource +{ + <# + .SYNOPSIS + Add a stats data source on a VM. + .DESCRIPTION + Calls PUT /vms/{id}/stats/data_source/{data_source} to add stat data source. + .PARAMETER VmUuid + The UUID of the target VM. + .PARAMETER DataSource + The name of the stats data source (e.g. 'cpu0', 'memory'). + .EXAMPLE + Add-XoVmStatDataSource -VmUuid "" -DataSource "cpu0" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$DataSource + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("VM $VmUuid", "add stat data source '$DataSource'")) + { + return + } + + $uri = "$script:XoHost/rest/v0/vms/$VmUuid/stats/data_source/$DataSource" + Invoke-RestMethod -Uri $uri -Method Put @script:XoRestParameters + } +} diff --git a/src/Public/Clear-XoTask.ps1 b/src/Public/Clear-XoTask.ps1 new file mode 100644 index 0000000..c2a8643 --- /dev/null +++ b/src/Public/Clear-XoTask.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Clear-XoTask +{ + <# + .SYNOPSIS + Delete all Xen Orchestra tasks (bulk cleanup). + .DESCRIPTION + Issues DELETE /tasks. Used to purge the task log. Typically invoked with -Filter to scope to completed/failed tasks only; check the XO REST documentation for the exact filter semantics supported on this endpoint. + .PARAMETER Filter + Optional filter expression forwarded to the server. + .EXAMPLE + Clear-XoTask -Filter 'status:success' + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter()] + [string]$Filter + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("all tasks", "bulk delete")) + { + return + } + + $body = @{} + if ($Filter) { $body["filter"] = $Filter } + + $uri = "$script:XoHost/rest/v0/tasks" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters -Body $body + } +} diff --git a/src/Public/Connect-XoPbd.ps1 b/src/Public/Connect-XoPbd.ps1 new file mode 100644 index 0000000..87490a3 --- /dev/null +++ b/src/Public/Connect-XoPbd.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Connect-XoPbd +{ + <# + .SYNOPSIS + Plug one or more Xen Orchestra PBDs. + .DESCRIPTION + Attaches the PBD to its host, making the underlying SR available. Returns a task that can be passed to Wait-XoTask. + .PARAMETER PbdUuid + The UUID(s) of the PBD to act on. Accepts pipeline input by property name. + .EXAMPLE + Connect-XoPbd -PbdUuid "" + .EXAMPLE + Connect-XoPbd -PbdUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$PbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $PbdUuid) + { + if ($PSCmdlet.ShouldProcess($id, "plug")) + { + $uri = "$script:XoHost/rest/v0/pbds/$id/actions/plug" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Connect-XoServer.ps1 b/src/Public/Connect-XoServer.ps1 new file mode 100644 index 0000000..4d55357 --- /dev/null +++ b/src/Public/Connect-XoServer.ps1 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Connect-XoServer +{ + <# + .SYNOPSIS + Connect one or more Xen Orchestra XO servers. + .DESCRIPTION + Establishes the XAPI connection for the registered XO server. Returns a task object. + .PARAMETER ServerUuid + The UUID(s) of the XO server to act on. Accepts pipeline input by property name. + .EXAMPLE + Connect-XoServer -ServerUuid "" + .EXAMPLE + Connect-XoServer -ServerUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]]$ServerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $ServerUuid) + { + if ($PSCmdlet.ShouldProcess($id, "connect")) + { + $uri = "$script:XoHost/rest/v0/servers/$id/actions/connect" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/session.ps1 b/src/Public/Connect-XoSession.ps1 similarity index 57% rename from src/session.ps1 rename to src/Public/Connect-XoSession.ps1 index 4fe7670..f763d34 100644 --- a/src/session.ps1 +++ b/src/Public/Connect-XoSession.ps1 @@ -1,34 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_DEFAULT_LIMIT = 25 -$script:XoSessionLimit = $script:XO_DEFAULT_LIMIT - -function Test-XoSession { - <# - .SYNOPSIS - Check the connection to Xen Orchestra. - .DESCRIPTION - Tests if the current session is connected to a Xen Orchestra instance. - .EXAMPLE - Test-XoSession - Returns $true if connected, $false otherwise. - #> - [CmdletBinding()] - param() - - # Test connection by attempting to get tasks with a minimal limit - try { - Get-XoTask -Limit 1 | Out-Null - Write-Verbose "Successful connection to Xen Orchestra - $script:XoHost" - return $true - } - catch { - Write-Error "Xen Orchestra connection error - $script:XoHost $_" - return $false - } -} - -function Connect-XoSession { +function Connect-XoSession +{ <# .SYNOPSIS Connect to a Xen Orchestra instance. @@ -40,6 +13,8 @@ function Connect-XoSession { Credentials for authentication (not currently implemented). .PARAMETER Token API token for authentication. + .PARAMETER Limit + Default page size limit for query cmdlets. .PARAMETER SaveCredentials Save credentials for future sessions. .PARAMETER SkipCertificateCheck @@ -52,6 +27,7 @@ function Connect-XoSession { Prompts for a token and connects to the specified Xen Orchestra instance. #> [CmdletBinding(DefaultParameterSetName = "Token")] + [OutputType([bool])] param ( [Parameter(Mandatory, Position = 0)] [string]$HostName, @@ -75,10 +51,12 @@ function Connect-XoSession { $script:XoHost = $HostName.TrimEnd("/") Write-Verbose "Connecting to Xen Orchestra at $script:XoHost" - if ($PSBoundParameters.ContainsKey('Limit')) { + if ($PSBoundParameters.ContainsKey('Limit')) + { $script:XoSessionLimit = $Limit } - else { + else + { Write-Warning "No limit specified. Using default limit of $script:XO_DEFAULT_LIMIT. Use -Limit 0 for unlimited results." # Reset session limit to default value on new connection $script:XoSessionLimit = $script:XO_DEFAULT_LIMIT @@ -86,15 +64,19 @@ function Connect-XoSession { $needsSave = $SaveCredentials - if ($PSCmdlet.ParameterSetName -eq "Credential") { + if ($PSCmdlet.ParameterSetName -eq "Credential") + { throw [System.NotImplementedException]::new("TODO: implement username/password login") } - elseif ($PSCmdlet.ParameterSetName -eq "Token" -and !$Token) { + elseif ($PSCmdlet.ParameterSetName -eq "Token" -and !$Token) + { # TODO: load saved token - if ($Token) { + if ($Token) + { $needsSave = $false } - else { + else + { $secureToken = Read-Host -AsSecureString -Prompt "Enter XO API token" $Token = [System.Net.NetworkCredential]::new("", $secureToken).Password } @@ -106,13 +88,17 @@ function Connect-XoSession { } } - if ($SkipCertificateCheck) { - if ($PSVersionTable.PSVersion.Major -ge 6) { + if ($SkipCertificateCheck) + { + if ($PSVersionTable.PSVersion.Major -ge 6) + { $script:XoRestParameters["SkipCertificateCheck"] = $true } - else { + else + { Write-Warning "Certificate check skipping is only supported in PowerShell 6+. Using insecure handling method." - if (-not ([System.Management.Automation.PSTypeName]'TrustAllCertsPolicy').Type) { + if (-not ([System.Management.Automation.PSTypeName]'TrustAllCertsPolicy').Type) + { Add-Type @" using System.Net; using System.Security.Cryptography.X509Certificates; @@ -131,18 +117,21 @@ function Connect-XoSession { } # Save credentials if requested - if ($needsSave) { + if ($needsSave) + { # TODO: Implement credential saving } $connectionSuccessful = Test-XoSession - if ($connectionSuccessful) { + if ($connectionSuccessful) + { Write-Verbose "XoHost value: $script:XoHost" Write-Verbose "XoRestParameters: $($script:XoRestParameters.Headers | ConvertTo-Json -Compress)" return $true } - else { + else + { Write-Error "Failed to connect to Xen Orchestra at $script:XoHost" $script:XoHost = $null $script:XoRestParameters = $null @@ -150,73 +139,3 @@ function Connect-XoSession { } } New-Alias -Name Connect-XenOrchestra -Value Connect-XoSession - -function Disconnect-XoSession { - <# - .SYNOPSIS - Disconnect from a Xen Orchestra instance. - .DESCRIPTION - Disconnects from the current Xen Orchestra session and optionally clears saved credentials. - .PARAMETER ClearCredentials - Clears any saved credentials for the current session. - .EXAMPLE - Disconnect-XoSession - Disconnects from the current session. - .EXAMPLE - Disconnect-XoSession -ClearCredentials - Disconnects from the current session and clears saved credentials. - #> - [CmdletBinding()] - param ( - [Parameter()][switch]$ClearCredentials - ) - if ($ClearCredentials -and $script:XoHost) { - # TODO: clear saved token - } - $script:XoHost = $null - $script:XoRestParameters = $null - $script:XoSessionLimit = $script:XO_DEFAULT_LIMIT -} -New-Alias -Name Disconnect-XenOrchestra -Value Disconnect-XoSession - -function Get-XoSession { - <# - .SYNOPSIS - Get the current XO session settings. - .DESCRIPTION - Get the current XO session settings. - #> - [CmdletBinding()] - param() - - [pscustomobject]@{ - Limit = $script:XoSessionLimit - } -} - -function Set-XoSession { - <# - .SYNOPSIS - Set the current XO session settings. - .DESCRIPTION - Set the current XO session settings. - .PARAMETER Limit - Sets the current XO query limit for all Get-Xo* cmdlets that support a -Limit parameter. - .EXAMPLE - Set-XoSession -Limit 50 - Sets the current session-wide limit to 50 items for all query cmdlets. - .EXAMPLE - Set-XoSession -Limit 0 - Sets cmdlets to return all items by default. - #> - [CmdletBinding()] - param( - [Parameter()] - [int]$Limit - ) - - if ($PSBoundParameters.ContainsKey("Limit")) { - Write-Verbose "Default limit for XO queries changed from $script:XoSessionLimit to $Limit" - $script:XoSessionLimit = $Limit - } -} diff --git a/src/Public/Connect-XoVbd.ps1 b/src/Public/Connect-XoVbd.ps1 new file mode 100644 index 0000000..34bd4d9 --- /dev/null +++ b/src/Public/Connect-XoVbd.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Connect-XoVbd +{ + <# + .SYNOPSIS + Plug one or more Xen Orchestra VBDs. + .DESCRIPTION + Plugs the VBD into its VM so the guest can see the backing VDI (hot-plug if the VM is running). Returns a task. + .PARAMETER VbdUuid + The UUID(s) of the VBD to act on. Accepts pipeline input by property name. + .EXAMPLE + Connect-XoVbd -VbdUuid "" + .EXAMPLE + Connect-XoVbd -VbdUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VbdUuid) + { + if ($PSCmdlet.ShouldProcess($id, "connect")) + { + $uri = "$script:XoHost/rest/v0/vbds/$id/actions/connect" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Copy-XoVm.ps1 b/src/Public/Copy-XoVm.ps1 new file mode 100644 index 0000000..c4ec543 --- /dev/null +++ b/src/Public/Copy-XoVm.ps1 @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Copy-XoVm +{ + <# + .SYNOPSIS + Clone a Xen Orchestra VM. + .DESCRIPTION + Clones the specified VM. Use -Parameters to pass optional clone options (e.g. ``@{ name = "copy"; full_copy = $true }``). Returns a task object. + .PARAMETER VmUuid + The UUID of the VM to act on. + .PARAMETER Parameters + Hashtable of action body parameters. See the linked XO REST documentation for the expected fields. + .EXAMPLE + Copy-XoVm -VmUuid "" -Parameters @{ } + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter()] + [hashtable]$Parameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if ($PSCmdlet.ShouldProcess($VmUuid, "clone")) + { + $uri = "$script:XoHost/rest/v0/vms/$VmUuid/actions/clone" + $body = if ($Parameters) { [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $Parameters -Depth 99)) } else { [byte[]]@() } + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $body | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } +} + diff --git a/src/Public/Disable-XoHost.ps1 b/src/Public/Disable-XoHost.ps1 new file mode 100644 index 0000000..21d00e9 --- /dev/null +++ b/src/Public/Disable-XoHost.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Disable-XoHost +{ + <# + .SYNOPSIS + Disable one or more Xen Orchestra hosts. + .DESCRIPTION + Marks the host as disabled so the pool scheduler stops placing new VMs on it. Existing VMs keep running until migrated or shut down. + .PARAMETER HostUuid + The UUID(s) of the host to act on. Accepts pipeline input by property name. + .EXAMPLE + Disable-XoHost -HostUuid "" + .EXAMPLE + Disable-XoHost -HostUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $HostUuid) + { + if ($PSCmdlet.ShouldProcess($id, "disable")) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/actions/disable" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Disconnect-XoPbd.ps1 b/src/Public/Disconnect-XoPbd.ps1 new file mode 100644 index 0000000..8bbacd9 --- /dev/null +++ b/src/Public/Disconnect-XoPbd.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Disconnect-XoPbd +{ + <# + .SYNOPSIS + Unplug one or more Xen Orchestra PBDs. + .DESCRIPTION + Detaches the PBD from its host, taking the SR offline on that host. All VMs/VDIs using the SR from this host must be detached or migrated first. + .PARAMETER PbdUuid + The UUID(s) of the PBD to act on. Accepts pipeline input by property name. + .EXAMPLE + Disconnect-XoPbd -PbdUuid "" + .EXAMPLE + Disconnect-XoPbd -PbdUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$PbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $PbdUuid) + { + if ($PSCmdlet.ShouldProcess($id, "unplug")) + { + $uri = "$script:XoHost/rest/v0/pbds/$id/actions/unplug" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Disconnect-XoServer.ps1 b/src/Public/Disconnect-XoServer.ps1 new file mode 100644 index 0000000..c8887df --- /dev/null +++ b/src/Public/Disconnect-XoServer.ps1 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Disconnect-XoServer +{ + <# + .SYNOPSIS + Disconnect one or more Xen Orchestra XO servers. + .DESCRIPTION + Drops the XAPI connection for the registered XO server. The server stays registered but its pool stops syncing until reconnected. + .PARAMETER ServerUuid + The UUID(s) of the XO server to act on. Accepts pipeline input by property name. + .EXAMPLE + Disconnect-XoServer -ServerUuid "" + .EXAMPLE + Disconnect-XoServer -ServerUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]]$ServerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $ServerUuid) + { + if ($PSCmdlet.ShouldProcess($id, "disconnect")) + { + $uri = "$script:XoHost/rest/v0/servers/$id/actions/disconnect" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Disconnect-XoSession.ps1 b/src/Public/Disconnect-XoSession.ps1 new file mode 100644 index 0000000..8798d43 --- /dev/null +++ b/src/Public/Disconnect-XoSession.ps1 @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Disconnect-XoSession +{ + <# + .SYNOPSIS + Disconnect from a Xen Orchestra instance. + .DESCRIPTION + Disconnects from the current Xen Orchestra session and optionally clears saved credentials. + .PARAMETER ClearCredentials + Clears any saved credentials for the current session. + .EXAMPLE + Disconnect-XoSession + Disconnects from the current session. + .EXAMPLE + Disconnect-XoSession -ClearCredentials + Disconnects from the current session and clears saved credentials. + #> + [CmdletBinding()] + param ( + [Parameter()][switch]$ClearCredentials + ) + if ($ClearCredentials -and $script:XoHost) + { + # TODO: clear saved token + } + $script:XoHost = $null + $script:XoRestParameters = $null + $script:XoSessionLimit = $script:XO_DEFAULT_LIMIT +} +New-Alias -Name Disconnect-XenOrchestra -Value Disconnect-XoSession diff --git a/src/Public/Disconnect-XoVbd.ps1 b/src/Public/Disconnect-XoVbd.ps1 new file mode 100644 index 0000000..6b61c0b --- /dev/null +++ b/src/Public/Disconnect-XoVbd.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Disconnect-XoVbd +{ + <# + .SYNOPSIS + Unplug one or more Xen Orchestra VBDs. + .DESCRIPTION + Unplugs the VBD from its VM. Any guest I/O to the disk is cut off. + .PARAMETER VbdUuid + The UUID(s) of the VBD to act on. Accepts pipeline input by property name. + .EXAMPLE + Disconnect-XoVbd -VbdUuid "" + .EXAMPLE + Disconnect-XoVbd -VbdUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VbdUuid) + { + if ($PSCmdlet.ShouldProcess($id, "disconnect")) + { + $uri = "$script:XoHost/rest/v0/vbds/$id/actions/disconnect" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Enable-XoHost.ps1 b/src/Public/Enable-XoHost.ps1 new file mode 100644 index 0000000..9eeecc4 --- /dev/null +++ b/src/Public/Enable-XoHost.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Enable-XoHost +{ + <# + .SYNOPSIS + Enable one or more Xen Orchestra hosts. + .DESCRIPTION + Marks the host as enabled so the pool scheduler will place new VMs on it. + .PARAMETER HostUuid + The UUID(s) of the host to act on. Accepts pipeline input by property name. + .EXAMPLE + Enable-XoHost -HostUuid "" + .EXAMPLE + Enable-XoHost -HostUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $HostUuid) + { + if ($PSCmdlet.ShouldProcess($id, "enable")) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/actions/enable" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Export-XoVdi.ps1 b/src/Public/Export-XoVdi.ps1 new file mode 100644 index 0000000..0590987 --- /dev/null +++ b/src/Public/Export-XoVdi.ps1 @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Export-XoVdi +{ + <# + .SYNOPSIS + Export a VDI. + .DESCRIPTION + Export a VDI from Xen Orchestra. Downloads the VDI to a local file. + .PARAMETER VdiUuid + The UUID of the VDI to export. + .PARAMETER Format + The format to export the VDI in. Valid values: raw, vhd. + .PARAMETER OutFile + The path to save the exported VDI to. + .PARAMETER PassThru + If specified, returns the exported file info as a FileInfo object. + .EXAMPLE + Export-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" -Format vhd -OutFile "C:\Exports\disk.vhd" + Exports the VDI in VHD format to the specified file. + .EXAMPLE + Get-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" | Export-XoVdi -Format vhd -OutFile "C:\Exports\disk.vhd" + Exports the VDI in VHD format to the specified file, piping from Get-XoVdi. + #> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias("VdiId")] + [string]$VdiUuid, + + [Parameter(Mandatory)] + [ValidateSet("raw", "vhd")] + [string]$Format, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$OutFile, + + [Parameter()] + [switch]$PassThru + ) + + process + { + if ($PSCmdlet.ShouldProcess($VdiUuid, "export to $OutFile in $Format format")) + { + try + { + # swagger-canonical path: /vdis/{id}.{format} + $uri = "$script:XoHost/rest/v0/vdis/$VdiUuid.$Format" + Invoke-RestMethod -Uri $uri @script:XoRestParameters -OutFile $OutFile + + if ($PassThru) + { + Get-Item $OutFile + } + } + catch + { + throw ("Failed to export VDI with UUID {0}: {1}" -f $VdiUuid, $_) + } + } + } +} diff --git a/src/Public/Export-XoVdiSnapshot.ps1 b/src/Public/Export-XoVdiSnapshot.ps1 new file mode 100644 index 0000000..acbe2ef --- /dev/null +++ b/src/Public/Export-XoVdiSnapshot.ps1 @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Export-XoVdiSnapshot +{ + <# + .SYNOPSIS + Export a VDI snapshot. + .DESCRIPTION + Export a VDI snapshot from Xen Orchestra. Downloads the snapshot to a local file. + .PARAMETER VdiSnapshotUuid + The UUID of the VDI snapshot to export. + .PARAMETER Format + The format to export the VDI snapshot in. Valid values: raw, vhd. + .PARAMETER OutFile + The path to save the exported VDI snapshot to. + .PARAMETER PassThru + If specified, returns the exported file info as a FileInfo object. + .EXAMPLE + Export-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" -Format vhd -OutFile "C:\Exports\snapshot.vhd" + Exports the VDI snapshot in VHD format to the specified file. + .EXAMPLE + Get-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" | Export-XoVdiSnapshot -Format vhd -OutFile "C:\Exports\snapshot.vhd" + Exports the VDI snapshot in VHD format to the specified file, piping from Get-XoVdiSnapshot. + #> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias("VdiSnapshotId")] + [string]$VdiSnapshotUuid, + + [Parameter(Mandatory)] + [ValidateSet("raw", "vhd")] + [string]$Format, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$OutFile, + + [Parameter()] + [switch]$PassThru + ) + + + process + { + $resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutFile) + + if ($PSCmdlet.ShouldProcess($VdiSnapshotUuid, "export to $resolvedPath in $Format format")) + { + try + { + # swagger-canonical path: /vdi-snapshots/{id}.{format} + $uri = "$script:XoHost/rest/v0/vdi-snapshots/$VdiSnapshotUuid.$Format" + Invoke-RestMethod -Uri $uri @script:XoRestParameters -OutFile $resolvedPath + + if ($PassThru) + { + Get-Item $resolvedPath + } + } + catch + { + throw ("Failed to export VDI snapshot with UUID {0}: {1}" -f $VdiSnapshotUuid, $_) + } + } + } +} diff --git a/src/Public/Export-XoVm.ps1 b/src/Public/Export-XoVm.ps1 new file mode 100644 index 0000000..159fff1 --- /dev/null +++ b/src/Public/Export-XoVm.ps1 @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Export-XoVm +{ + <# + .SYNOPSIS + Export a Xen Orchestra VM to a local file. + .DESCRIPTION + Downloads the specified VM in either xva (XenServer native) or ova format. The download is streamed to -OutFile; nothing is returned unless -PassThru is specified. For large VMs the export can take a while - consider running it as a background job. + .PARAMETER VmUuid + The UUID of the VM to export. + .PARAMETER Format + Export format: 'xva' (XenServer native, fastest) or 'ova' (portable OVF). + .PARAMETER OutFile + Local path to write the exported file to. Parent directory must exist. + .PARAMETER PassThru + Return the written file as a FileInfo object. + .EXAMPLE + Export-XoVm -VmUuid "" -Format xva -OutFile "./export.xva" + #> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter(Mandatory)] + [ValidateSet("xva", "ova")] + [string]$Format, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$OutFile, + + [Parameter()] + [switch]$PassThru + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutFile) + + if ($PSCmdlet.ShouldProcess($VmUuid, "export to $resolvedPath in $Format format")) + { + try + { + $uri = "$script:XoHost/rest/v0/vms/$VmUuid.$Format" + Invoke-RestMethod -Uri $uri @script:XoRestParameters -OutFile $resolvedPath + + if ($PassThru) + { + Get-Item $resolvedPath + } + } + catch + { + throw ("Failed to export Vm with UUID {0}: {1}" -f $VmUuid, $_) + } + } + } +} + diff --git a/src/Public/Export-XoVmSnapshot.ps1 b/src/Public/Export-XoVmSnapshot.ps1 new file mode 100644 index 0000000..a7e35e8 --- /dev/null +++ b/src/Public/Export-XoVmSnapshot.ps1 @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Export-XoVmSnapshot +{ + <# + .SYNOPSIS + Export a Xen Orchestra VM snapshot to a local file. + .DESCRIPTION + Downloads the specified VM snapshot in either xva (XenServer native) or ova format. The download is streamed to -OutFile; nothing is returned unless -PassThru is specified. For large VM snapshots the export can take a while - consider running it as a background job. + .PARAMETER VmSnapshotUuid + The UUID of the VM snapshot to export. + .PARAMETER Format + Export format: 'xva' (XenServer native, fastest) or 'ova' (portable OVF). + .PARAMETER OutFile + Local path to write the exported file to. Parent directory must exist. + .PARAMETER PassThru + Return the written file as a FileInfo object. + .EXAMPLE + Export-XoVmSnapshot -VmSnapshotUuid "" -Format xva -OutFile "./export.xva" + #> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmSnapshotUuid, + + [Parameter(Mandatory)] + [ValidateSet("xva", "ova")] + [string]$Format, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$OutFile, + + [Parameter()] + [switch]$PassThru + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutFile) + + if ($PSCmdlet.ShouldProcess($VmSnapshotUuid, "export to $resolvedPath in $Format format")) + { + try + { + $uri = "$script:XoHost/rest/v0/vm-snapshots/$VmSnapshotUuid.$Format" + Invoke-RestMethod -Uri $uri @script:XoRestParameters -OutFile $resolvedPath + + if ($PassThru) + { + Get-Item $resolvedPath + } + } + catch + { + throw ("Failed to export VmSnapshot with UUID {0}: {1}" -f $VmSnapshotUuid, $_) + } + } + } +} + diff --git a/src/Public/Export-XoVmTemplate.ps1 b/src/Public/Export-XoVmTemplate.ps1 new file mode 100644 index 0000000..b4a1406 --- /dev/null +++ b/src/Public/Export-XoVmTemplate.ps1 @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Export-XoVmTemplate +{ + <# + .SYNOPSIS + Export a Xen Orchestra VM template to a local file. + .DESCRIPTION + Downloads the specified VM template in either xva (XenServer native) or ova format. The download is streamed to -OutFile; nothing is returned unless -PassThru is specified. For large VM templates the export can take a while - consider running it as a background job. + .PARAMETER VmTemplateUuid + The UUID of the VM template to export. + .PARAMETER Format + Export format: 'xva' (XenServer native, fastest) or 'ova' (portable OVF). + .PARAMETER OutFile + Local path to write the exported file to. Parent directory must exist. + .PARAMETER PassThru + Return the written file as a FileInfo object. + .EXAMPLE + Export-XoVmTemplate -VmTemplateUuid "" -Format xva -OutFile "./export.xva" + #> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmTemplateUuid, + + [Parameter(Mandatory)] + [ValidateSet("xva", "ova")] + [string]$Format, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$OutFile, + + [Parameter()] + [switch]$PassThru + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutFile) + + if ($PSCmdlet.ShouldProcess($VmTemplateUuid, "export to $resolvedPath in $Format format")) + { + try + { + $uri = "$script:XoHost/rest/v0/vm-templates/$VmTemplateUuid.$Format" + Invoke-RestMethod -Uri $uri @script:XoRestParameters -OutFile $resolvedPath + + if ($PassThru) + { + Get-Item $resolvedPath + } + } + catch + { + throw ("Failed to export VmTemplate with UUID {0}: {1}" -f $VmTemplateUuid, $_) + } + } + } +} + diff --git a/src/alarm.ps1 b/src/Public/Get-XoAlarm.ps1 similarity index 69% rename from src/alarm.ps1 rename to src/Public/Get-XoAlarm.ps1 index 273b6b3..bb33148 100644 --- a/src/alarm.ps1 +++ b/src/Public/Get-XoAlarm.ps1 @@ -1,28 +1,24 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_ALARM_FIELDS = "body,name,time,type,uuid,`$pool" - -function ConvertTo-XoAlarmObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - AlarmTime = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.time).ToLocalTime() - BodyName = $InputObject.body.name - BodyValue = $InputObject.body.value - } - Set-XoObject $InputObject -TypeName XoPowershell.Alarm -Properties $props - } -} - -function Get-XoAlarm { +function Get-XoAlarm +{ <# .SYNOPSIS List or query alarms. .DESCRIPTION Get Xen Orchestra alarms by UUID or list all existing alarms. + .PARAMETER AlarmUuid + The UUID(s) of the alarm(s) to retrieve. + .PARAMETER BodyName + Filter alarms matching the specified body name. + .PARAMETER Filter + Custom filter expression for the alarm query. + .PARAMETER PoolUuid + UUID of the pool whose alarms to retrieve. + .PARAMETER Limit + Maximum number of alarms to return. + .EXAMPLE + Get-XoAlarm -AlarmUuid "12345678-abcd-1234-abcd-1234567890ab" #> [CmdletBinding(DefaultParameterSetName = "Filter")] param ( @@ -48,40 +44,50 @@ function Get-XoAlarm { [int]$Limit = $script:XoSessionLimit ) - begin { + begin + { $params = @{ fields = $script:XO_ALARM_FIELDS } } - process { - if ($PSCmdlet.ParameterSetName -eq "AlarmUuid") { - foreach ($id in $AlarmUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "AlarmUuid") + { + foreach ($id in $AlarmUuid) + { ConvertTo-XoAlarmObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/alarms/$id" @script:XoRestParameters -Body $params) } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { $AllFilters = $Filter - if ($BodyName) { + if ($BodyName) + { $AllFilters = "$AllFilters body:name:`"$BodyName`"" } - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } # the parentheses forces the resulting array to unpack, don't remove them! (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/alarms" @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject } - elseif ($PSCmdlet.ParameterSetName -eq "PoolUuid") { + elseif ($PSCmdlet.ParameterSetName -eq "PoolUuid") + { (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/alarms" @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject } } diff --git a/src/Public/Get-XoBackupArchive.ps1 b/src/Public/Get-XoBackupArchive.ps1 new file mode 100644 index 0000000..c7eaf06 --- /dev/null +++ b/src/Public/Get-XoBackupArchive.ps1 @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupArchive +{ + <# + .SYNOPSIS + List or query Xen Orchestra backup archives. + .DESCRIPTION + Retrieves Xen Orchestra backup archives - restorable snapshots stored in a backup repository. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupArchiveId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER BackupArchiveId + One or more IDs of the backup archives to retrieve. When omitted, the cmdlet enumerates backup archives using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of backup archives to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoBackupArchive -Filter 'type:xo-vm-backup' + .EXAMPLE + Get-XoBackupArchive -BackupArchiveId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupArchive")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupArchiveId")] + [string[]]$BackupArchiveId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_ARCHIVE_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupArchiveId") + { + foreach ($id in $BackupArchiveId) + { + $uri = "$script:XoHost/rest/v0/backup-archives/$id" + ConvertTo-XoBackupArchiveObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/backup-archives" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupArchiveObject + } + } +} + diff --git a/src/Public/Get-XoBackupJob.ps1 b/src/Public/Get-XoBackupJob.ps1 new file mode 100644 index 0000000..7f54738 --- /dev/null +++ b/src/Public/Get-XoBackupJob.ps1 @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupJob +{ + <# + .SYNOPSIS + List or query backup jobs. + .DESCRIPTION + Get Xen Orchestra backup jobs by ID or list all existing backup jobs. + .PARAMETER BackupJobId + The ID(s) of the backup job(s) to retrieve. + .PARAMETER Filter + Custom filter expression for the backup job query. + .PARAMETER Limit + Maximum number of backup jobs to return. + .EXAMPLE + Get-XoBackupJob -BackupJobId "d33f3dc1-92b4-469c-ad58-4c2a106a4721" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupJob")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupJobId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$BackupJobId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{ + fields = $script:XO_BACKUP_JOB_FIELDS + } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupJobId") + { + foreach ($id in $BackupJobId) + { + $uri = "$script:XoHost/rest/v0/backup-jobs/$id" + ConvertTo-XoBackupJobObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) + { + $params["filter"] = $Filter + } + + if ($Limit) + { + $params["limit"] = $Limit + } + + $uri = "$script:XoHost/rest/v0/backup-jobs" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupJobObject + } + } +} diff --git a/src/Public/Get-XoBackupJobLog.ps1 b/src/Public/Get-XoBackupJobLog.ps1 new file mode 100644 index 0000000..0bc4015 --- /dev/null +++ b/src/Public/Get-XoBackupJobLog.ps1 @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupJobLog +{ + <# + .SYNOPSIS + List or query Xen Orchestra backup job logs. + .DESCRIPTION + Retrieves run logs for Xen Orchestra backup jobs via the /backup/logs endpoint (alias of Get-XoBackupLog using the alternative path). When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupLogId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER BackupLogId + One or more IDs of the backup job logs to retrieve. When omitted, the cmdlet enumerates backup job logs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of backup job logs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoBackupJobLog -Limit 50 + .EXAMPLE + Get-XoBackupJobLog -BackupLogId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupLog")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupLogId")] + [string[]]$BackupLogId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_LOG_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupLogId") + { + foreach ($id in $BackupLogId) + { + $uri = "$script:XoHost/rest/v0/backup/logs/$id" + ConvertTo-XoBackupLogObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/backup/logs" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupLogObject + } + } +} + diff --git a/src/Public/Get-XoBackupJobMetadata.ps1 b/src/Public/Get-XoBackupJobMetadata.ps1 new file mode 100644 index 0000000..334724d --- /dev/null +++ b/src/Public/Get-XoBackupJobMetadata.ps1 @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupJobMetadata +{ + <# + .SYNOPSIS + List or query Xen Orchestra metadata backup jobs. + .DESCRIPTION + Retrieves metadata backup jobs - jobs that back up XO/XCP-ng metadata rather than VM disks. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupJobId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER BackupJobId + One or more IDs of the metadata backup jobs to retrieve. When omitted, the cmdlet enumerates metadata backup jobs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of metadata backup jobs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoBackupJobMetadata + .EXAMPLE + Get-XoBackupJobMetadata -BackupJobId "" + #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '')] + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupJob")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupJobId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$BackupJobId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_JOB_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupJobId") + { + foreach ($id in $BackupJobId) + { + $uri = "$script:XoHost/rest/v0/backup/jobs/metadata/$id" + ConvertTo-XoBackupJobObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) + { + $params["filter"] = $Filter + } + if ($Limit) + { + $params["limit"] = $Limit + } + + $uri = "$script:XoHost/rest/v0/backup/jobs/metadata" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupJobObject + } + } +} + diff --git a/src/Public/Get-XoBackupJobMirror.ps1 b/src/Public/Get-XoBackupJobMirror.ps1 new file mode 100644 index 0000000..7b03440 --- /dev/null +++ b/src/Public/Get-XoBackupJobMirror.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupJobMirror +{ + <# + .SYNOPSIS + List or query Xen Orchestra mirror backup jobs. + .DESCRIPTION + Retrieves mirror backup jobs - jobs that replicate backups between remotes. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupJobId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER BackupJobId + One or more IDs of the mirror backup jobs to retrieve. When omitted, the cmdlet enumerates mirror backup jobs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of mirror backup jobs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoBackupJobMirror + .EXAMPLE + Get-XoBackupJobMirror -BackupJobId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupJob")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupJobId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$BackupJobId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_JOB_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupJobId") + { + foreach ($id in $BackupJobId) + { + $uri = "$script:XoHost/rest/v0/backup/jobs/mirror/$id" + ConvertTo-XoBackupJobObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/backup/jobs/mirror" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupJobObject + } + } +} + diff --git a/src/Public/Get-XoBackupJobVm.ps1 b/src/Public/Get-XoBackupJobVm.ps1 new file mode 100644 index 0000000..4540aa5 --- /dev/null +++ b/src/Public/Get-XoBackupJobVm.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupJobVm +{ + <# + .SYNOPSIS + List or query Xen Orchestra VM backup jobs. + .DESCRIPTION + Retrieves VM backup jobs - the jobs that snapshot and archive VMs to a backup repository. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupJobId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER BackupJobId + One or more IDs of the VM backup jobs to retrieve. When omitted, the cmdlet enumerates VM backup jobs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of VM backup jobs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoBackupJobVm + .EXAMPLE + Get-XoBackupJobVm -BackupJobId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupJob")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupJobId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$BackupJobId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_JOB_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupJobId") + { + foreach ($id in $BackupJobId) + { + $uri = "$script:XoHost/rest/v0/backup/jobs/vm/$id" + ConvertTo-XoBackupJobObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/backup/jobs/vm" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupJobObject + } + } +} + diff --git a/src/Public/Get-XoBackupLog.ps1 b/src/Public/Get-XoBackupLog.ps1 new file mode 100644 index 0000000..38b974c --- /dev/null +++ b/src/Public/Get-XoBackupLog.ps1 @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupLog +{ + <# + .SYNOPSIS + List or query Xen Orchestra backup logs. + .DESCRIPTION + Retrieves run logs for Xen Orchestra backup jobs. Each log captures the status, start time, and nested tasks of one backup run. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupLogId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER BackupLogId + One or more IDs of the backup logs to retrieve. When omitted, the cmdlet enumerates backup logs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of backup logs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoBackupLog -Filter 'status:failure' + .EXAMPLE + Get-XoBackupLog -BackupLogId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupLog")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupLogId")] + [string[]]$BackupLogId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_LOG_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupLogId") + { + foreach ($id in $BackupLogId) + { + $uri = "$script:XoHost/rest/v0/backup-logs/$id" + ConvertTo-XoBackupLogObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/backup-logs" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupLogObject + } + } +} + diff --git a/src/Public/Get-XoBackupRepository.ps1 b/src/Public/Get-XoBackupRepository.ps1 new file mode 100644 index 0000000..b583606 --- /dev/null +++ b/src/Public/Get-XoBackupRepository.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoBackupRepository +{ + <# + .SYNOPSIS + List or query Xen Orchestra backup repositories. + .DESCRIPTION + Retrieves backup repositories (remotes) configured in Xen Orchestra - the destinations where backup archives are stored. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -BackupRepositoryId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER BackupRepositoryId + One or more IDs of the backup repositories to retrieve. When omitted, the cmdlet enumerates backup repositories using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of backup repositories to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoBackupRepository | Where-Object enabled + .EXAMPLE + Get-XoBackupRepository -BackupRepositoryId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.BackupRepository")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "BackupRepositoryId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$BackupRepositoryId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_REPOSITORY_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "BackupRepositoryId") + { + foreach ($id in $BackupRepositoryId) + { + $uri = "$script:XoHost/rest/v0/backup-repositories/$id" + ConvertTo-XoBackupRepositoryObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/backup-repositories" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupRepositoryObject + } + } +} + diff --git a/src/Public/Get-XoDashboard.ps1 b/src/Public/Get-XoDashboard.ps1 new file mode 100644 index 0000000..5e6a87b --- /dev/null +++ b/src/Public/Get-XoDashboard.ps1 @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoDashboard +{ + <# + .SYNOPSIS + Get the Xen Orchestra global dashboard summary. + .DESCRIPTION + Retrieves the global dashboard object exposed at /dashboard: aggregate counters (nHosts, nPools), resource overview (cpus, memory, storage), pool connectivity status, and repository totals. Useful for a one-shot health snapshot of the XO deployment. + .EXAMPLE + Get-XoDashboard + .EXAMPLE + (Get-XoDashboard).resourcesOverview + #> + [CmdletBinding()] + [OutputType("XoPowershell.Dashboard")] + param () + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $uri = "$script:XoHost/rest/v0/dashboard" + ConvertTo-XoDashboardObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters) + } +} + diff --git a/src/Public/Get-XoEvent.ps1 b/src/Public/Get-XoEvent.ps1 new file mode 100644 index 0000000..7af3caa --- /dev/null +++ b/src/Public/Get-XoEvent.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoEvent +{ + <# + .SYNOPSIS + List Xen Orchestra events. + .DESCRIPTION + Retrieves entries from the Xen Orchestra event log. Events represent system-level occurrences (object changes, connection events, user actions). Useful for audit/troubleshooting. Supports XO filter expressions and paging. + .PARAMETER Filter + XO filter expression applied server-side (e.g. `type:host`). + .PARAMETER Limit + Maximum number of events to return. Defaults to the session limit. + .EXAMPLE + Get-XoEvent -Limit 100 + .EXAMPLE + Get-XoEvent -Filter 'type:connection-lost' + #> + [CmdletBinding()] + [OutputType("XoPowershell.Event")] + param ( + [Parameter()] + [string]$Filter, + + [Parameter()] + [int]$Limit = $script:XoSessionLimit + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_EVENT_FIELDS + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/events" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoEventObject + } +} + diff --git a/src/Public/Get-XoGroup.ps1 b/src/Public/Get-XoGroup.ps1 new file mode 100644 index 0000000..13a0114 --- /dev/null +++ b/src/Public/Get-XoGroup.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoGroup +{ + <# + .SYNOPSIS + List or query Xen Orchestra groups. + .DESCRIPTION + Retrieves user groups configured in Xen Orchestra. Groups are used to grant permissions to collections of users. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -GroupId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER GroupId + One or more IDs of the groups to retrieve. When omitted, the cmdlet enumerates groups using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of groups to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoGroup + .EXAMPLE + Get-XoGroup -GroupId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.Group")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "GroupId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$GroupId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_GROUP_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "GroupId") + { + foreach ($id in $GroupId) + { + $uri = "$script:XoHost/rest/v0/groups/$id" + ConvertTo-XoGroupObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/groups" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoGroupObject + } + } +} + diff --git a/src/Public/Get-XoGroupTask.ps1 b/src/Public/Get-XoGroupTask.ps1 new file mode 100644 index 0000000..671b8c0 --- /dev/null +++ b/src/Public/Get-XoGroupTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoGroupTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific group. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra group. Accepts one or more group UUIDs; each is queried independently and the combined results are returned. + .PARAMETER GroupId + The UUID(s) of the group whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoGroupTask -GroupId "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoGroup | Get-XoGroupTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$GroupId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $GroupId) + { + $uri = "$script:XoHost/rest/v0/groups/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoGroupUser.ps1 b/src/Public/Get-XoGroupUser.ps1 new file mode 100644 index 0000000..1022ced --- /dev/null +++ b/src/Public/Get-XoGroupUser.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoGroupUser +{ + <# + .SYNOPSIS + Get user scoped to a specific group. + .DESCRIPTION + Retrieves user attached to the specified Xen Orchestra group. Accepts one or more group UUIDs; each is queried independently and the combined results are returned. + .PARAMETER GroupId + The UUID(s) of the group whose user should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoGroupUser -GroupId "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoGroup | Get-XoGroupUser + #> + [CmdletBinding()] + [OutputType("XoPowershell.User")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$GroupId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_USER_FIELDS + } + + process + { + foreach ($id in $GroupId) + { + $uri = "$script:XoHost/rest/v0/groups/$id/users" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoUserObject + } + } +} + diff --git a/src/Public/Get-XoGuiRoute.ps1 b/src/Public/Get-XoGuiRoute.ps1 new file mode 100644 index 0000000..e817913 --- /dev/null +++ b/src/Public/Get-XoGuiRoute.ps1 @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoGuiRoute +{ + <# + .SYNOPSIS + Get the Xen Orchestra GUI route table. + .DESCRIPTION + Retrieves the /gui-routes resource which maps GUI generation names (e.g. xo5, xo6) to their URL prefixes. This is mainly useful for tooling that needs to construct GUI deep links. + .EXAMPLE + Get-XoGuiRoute + #> + [CmdletBinding()] + [OutputType("XoPowershell.GuiRoute")] + param () + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $uri = "$script:XoHost/rest/v0/gui-routes" + ConvertTo-XoGuiRouteObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters) + } +} + diff --git a/src/Public/Get-XoHost.ps1 b/src/Public/Get-XoHost.ps1 new file mode 100644 index 0000000..b98622e --- /dev/null +++ b/src/Public/Get-XoHost.ps1 @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHost +{ + <# + .SYNOPSIS + Get physical hosts from Xen Orchestra. + .DESCRIPTION + Retrieves physical XCP-ng/XenServer hosts from Xen Orchestra. + Can retrieve specific hosts by their UUID or filter hosts by various criteria. + .PARAMETER HostUuid + The UUID(s) of the host(s) to retrieve. + .PARAMETER Filter + Filter to apply to the host query. + .PARAMETER PoolUuid + UUID of the pool whose hosts to retrieve. + .PARAMETER Limit + Maximum number of results to return. Default is 25 if not specified. + .EXAMPLE + Get-XoHost + Returns up to 25 hosts. + .EXAMPLE + Get-XoHost -Limit 0 + Returns all hosts without limit. + .EXAMPLE + Get-XoHost -HostUuid "12345678-abcd-1234-abcd-1234567890ab" + Returns the host with the specified UUID. + .EXAMPLE + Get-XoHost -Filter "power_state:running" + Returns running hosts (up to default limit). + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + # Parameter sets: + # - "Filter": Gets hosts with optional filtering criteria (with optional limit) + # - "HostUuid": Gets specific hosts by UUID + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "HostUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [Alias("HostId")] + [string[]]$HostUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = "Filter")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$PoolUuid, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + # use Invoke-XoRestMethod with JSON hashtable fallback in this cmdlet since server may send JSON object with multiple "cpus" keys, which confuses PowerShell when outputting PSObjects + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") + } + + $params = @{ fields = $script:XO_HOST_FIELDS } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "HostUuid") + { + foreach ($id in $HostUuid) + { + ConvertTo-XoHostObject (Invoke-XoRestMethod -Uri "$script:XoHost/rest/v0/hosts/$id" -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + $AllFilters = $Filter + + if ($PoolUuid) + { + $AllFilters = "$AllFilters `$pool:$PoolUuid" + } + + if ($AllFilters) + { + Write-Verbose "Filter: $AllFilters" + $params["filter"] = $AllFilters + } + + if ($Limit) + { + $params["limit"] = $Limit + } + + try + { + $uri = "$script:XoHost/rest/v0/hosts" + $hostsResponse = Invoke-XoRestMethod -Uri $uri -Body $params + + if (!$hostsResponse -or $hostsResponse.Count -eq 0) + { + Write-Verbose "No hosts found" + return + } + + foreach ($hostItem in $hostsResponse) + { + ConvertTo-XoHostObject -InputObject $hostItem + } + } + catch + { + throw ("Failed to list hosts. Error: {0}" -f $_) + } + } + } +} diff --git a/src/Public/Get-XoHostAlarm.ps1 b/src/Public/Get-XoHostAlarm.ps1 new file mode 100644 index 0000000..3cbc0e8 --- /dev/null +++ b/src/Public/Get-XoHostAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific host. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra host. Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + .PARAMETER HostUuid + The UUID(s) of the host whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoHostAlarm -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" + .EXAMPLE + Get-XoHost | Get-XoHostAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $HostUuid) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoHostAudit.ps1 b/src/Public/Get-XoHostAudit.ps1 new file mode 100644 index 0000000..bf7f255 --- /dev/null +++ b/src/Public/Get-XoHostAudit.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostAudit +{ + <# + .SYNOPSIS + Download the audit log for a Xen Orchestra host. + .DESCRIPTION + Downloads the plain-text XAPI audit log from /hosts/{id}/audit.txt. When -OutFile is supplied the file is written to disk; otherwise the content is returned as a string. Useful for compliance reporting and forensic investigation. + .PARAMETER HostUuid + The UUID of the host whose audit log to download. + .PARAMETER OutFile + Path to save the downloaded content to. If omitted, content is returned as a string. + .EXAMPLE + Get-XoHostAudit -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" -OutFile "./host-audit.txt" + .EXAMPLE + Get-XoHost | ForEach-Object { Get-XoHostAudit -HostUuid $_.HostUuid -OutFile "./audit-$($_.Name).txt" } + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$HostUuid, + + [Parameter()] + [string]$OutFile + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $uri = "$script:XoHost/rest/v0/hosts/$HostUuid/audit.txt" + if ($OutFile) + { + Invoke-RestMethod -Uri $uri @script:XoRestParameters -OutFile $OutFile + Get-Item $OutFile + } + else + { + Invoke-RestMethod -Uri $uri @script:XoRestParameters + } + } +} + diff --git a/src/Public/Get-XoHostLogBundle.ps1 b/src/Public/Get-XoHostLogBundle.ps1 new file mode 100644 index 0000000..ac88e9d --- /dev/null +++ b/src/Public/Get-XoHostLogBundle.ps1 @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostLogBundle +{ + <# + .SYNOPSIS + Download the diagnostic log bundle for a Xen Orchestra host. + .DESCRIPTION + Downloads the compressed .tgz log bundle from /hosts/{id}/logs.tgz. The bundle contains xensource.log, messages, xapi database dumps and other data that support engineers typically ask for. When -OutFile is supplied the file is written to disk. + .PARAMETER HostUuid + The UUID of the host whose log bundle to download. + .PARAMETER OutFile + Path to save the downloaded .tgz to. If omitted, content is streamed back as bytes. + .EXAMPLE + Get-XoHostLogBundle -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" -OutFile "./host-logs.tgz" + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$HostUuid, + + [Parameter()] + [string]$OutFile + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $uri = "$script:XoHost/rest/v0/hosts/$HostUuid/logs.tgz" + if ($OutFile) + { + Invoke-RestMethod -Uri $uri @script:XoRestParameters -OutFile $OutFile + Get-Item $OutFile + } + else + { + Invoke-RestMethod -Uri $uri @script:XoRestParameters + } + } +} + diff --git a/src/Public/Get-XoHostMessage.ps1 b/src/Public/Get-XoHostMessage.ps1 new file mode 100644 index 0000000..5984444 --- /dev/null +++ b/src/Public/Get-XoHostMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific host. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra host. Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + .PARAMETER HostUuid + The UUID(s) of the host whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoHostMessage -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" + .EXAMPLE + Get-XoHost | Get-XoHostMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $HostUuid) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoHostPatch.ps1 b/src/Public/Get-XoHostPatch.ps1 new file mode 100644 index 0000000..cd69592 --- /dev/null +++ b/src/Public/Get-XoHostPatch.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostPatch +{ + <# + .SYNOPSIS + Get missing patches scoped to a specific host. + .DESCRIPTION + Retrieves missing patches attached to the specified Xen Orchestra host. Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + .PARAMETER HostUuid + The UUID(s) of the host whose missing patches should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoHostPatch -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" + .EXAMPLE + Get-XoHost | Get-XoHostPatch + #> + [CmdletBinding()] + [OutputType("XoPowershell.PoolPatch")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + foreach ($id in $HostUuid) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/missing_patches" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoPoolPatchObject + } + } +} + diff --git a/src/Public/Get-XoHostSmt.ps1 b/src/Public/Get-XoHostSmt.ps1 new file mode 100644 index 0000000..7c1b167 --- /dev/null +++ b/src/Public/Get-XoHostSmt.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostSmt +{ + <# + .SYNOPSIS + Get SMT status scoped to a specific host. + .DESCRIPTION + Retrieves SMT status attached to the specified Xen Orchestra host. Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + .PARAMETER HostUuid + The UUID(s) of the host whose SMT status should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoHostSmt -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" + .EXAMPLE + Get-XoHost | Get-XoHostSmt + #> + [CmdletBinding()] + [OutputType("System.Management.Automation.PSCustomObject")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + foreach ($id in $HostUuid) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/smt" + Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + } + } +} + diff --git a/src/Public/Get-XoHostStat.ps1 b/src/Public/Get-XoHostStat.ps1 new file mode 100644 index 0000000..c5b27cb --- /dev/null +++ b/src/Public/Get-XoHostStat.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostStat +{ + <# + .SYNOPSIS + Get performance statistics scoped to a specific host. + .DESCRIPTION + Retrieves performance statistics attached to the specified Xen Orchestra host. Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + .PARAMETER HostUuid + The UUID(s) of the host whose performance statistics should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoHostStat -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" + .EXAMPLE + Get-XoHost | Get-XoHostStat + #> + [CmdletBinding()] + [OutputType("XoPowershell.Stat")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + foreach ($id in $HostUuid) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/stats" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoStatObject + } + } +} + diff --git a/src/Public/Get-XoHostTask.ps1 b/src/Public/Get-XoHostTask.ps1 new file mode 100644 index 0000000..69c00b0 --- /dev/null +++ b/src/Public/Get-XoHostTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoHostTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific host. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra host. Accepts one or more host UUIDs; each is queried independently and the combined results are returned. + .PARAMETER HostUuid + The UUID(s) of the host whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoHostTask -HostUuid "812b59e1-2682-43ef-acd4-808d3551b907" + .EXAMPLE + Get-XoHost | Get-XoHostTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$HostUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $HostUuid) + { + $uri = "$script:XoHost/rest/v0/hosts/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/message.ps1 b/src/Public/Get-XoMessage.ps1 similarity index 83% rename from src/message.ps1 rename to src/Public/Get-XoMessage.ps1 index 86496c6..1edc160 100644 --- a/src/message.ps1 +++ b/src/Public/Get-XoMessage.ps1 @@ -1,27 +1,26 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_MESSAGE_FIELDS = "body,name,time,type,uuid" - -function ConvertTo-XoMessageObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - MessageUuid = $InputObject.uuid - MessageTime = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.time).ToLocalTime() - } - Set-XoObject $InputObject -TypeName XoPowershell.Message -Properties $props - } -} - -function Get-XoMessage { +function Get-XoMessage +{ <# .SYNOPSIS List or query messages. .DESCRIPTION Get Xen Orchestra messages by UUID or list all existing messages. + .PARAMETER MessageUuid + The UUID(s) of the message(s) to retrieve. + .PARAMETER Name + Filter messages matching the specified name. + .PARAMETER Filter + Custom filter expression for the message query. + .PARAMETER PoolUuid + UUID of the pool whose messages to retrieve. + .PARAMETER VmUuid + UUID of the VM whose messages to retrieve. + .PARAMETER Limit + Maximum number of messages to return. + .EXAMPLE + Get-XoMessage -MessageUuid "12345678-abcd-1234-abcd-1234567890ab" #> [CmdletBinding(DefaultParameterSetName = "Filter")] param ( @@ -52,45 +51,56 @@ function Get-XoMessage { [int]$Limit = $script:XoSessionLimit ) - begin { + begin + { $params = @{ fields = $script:XO_MESSAGE_FIELDS } } - process { - if ($PSCmdlet.ParameterSetName -eq "MessageUuid") { - foreach ($id in $MessageUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "MessageUuid") + { + foreach ($id in $MessageUuid) + { ConvertTo-XoMessageObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/messages/$id" @script:XoRestParameters -Body $params) } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { $AllFilters = $Filter - if ($Name) { + if ($Name) + { $AllFilters = "$AllFilters name:`"$Name`"" } - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } # having $Limit be in ParameterSetName = "MessageUuid" is quite nonsensical, but hopefully better than having # a ton of ParameterSetNames. - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } # the parentheses forces the resulting array to unpack, don't remove them! (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/messages" @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject } - elseif ($PSCmdlet.ParameterSetName -eq "PoolUuid") { + elseif ($PSCmdlet.ParameterSetName -eq "PoolUuid") + { (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/messages" @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject } - elseif ($PSCmdlet.ParameterSetName -eq "VmUuid") { + elseif ($PSCmdlet.ParameterSetName -eq "VmUuid") + { (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$VmUuid/messages" @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject } } diff --git a/src/network.ps1 b/src/Public/Get-XoNetwork.ps1 similarity index 50% rename from src/network.ps1 rename to src/Public/Get-XoNetwork.ps1 index 16d14ee..c7e1511 100644 --- a/src/network.ps1 +++ b/src/Public/Get-XoNetwork.ps1 @@ -1,30 +1,24 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_NETWORK_FIELDS = "automatic,defaultIsLocked,MTU,name_description,name_label,tags,PIFs,VIFs,nbd,uuid,`$pool" - -function ConvertTo-XoNetworkObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - NetworkUuid = $InputObject.uuid - Name = $InputObject.name_label - Description = $InputObject.name_description - PifUuid = $InputObject.PIFs - VifUuid = $InputObject.VIFs - } - Set-XoObject $InputObject -TypeName XoPowershell.Network -Properties $props - } -} - -function Get-XoNetwork { +function Get-XoNetwork +{ <# .SYNOPSIS Query networks by UUID or condition. .DESCRIPTION Get network details. You can specify networks by their UUIDs or properties. + .PARAMETER NetworkUuid + The UUID(s) of the network(s) to retrieve. + .PARAMETER Name + Filter networks matching the specified name. + .PARAMETER Filter + Custom filter expression for the network query. + .PARAMETER Tag + Filter networks matching any of the specified tags. + .PARAMETER Limit + Maximum number of networks to return. + .EXAMPLE + Get-XoNetwork -NetworkUuid "12345678-abcd-1234-abcd-1234567890ab" #> [CmdletBinding(DefaultParameterSetName = "Filter")] param ( @@ -51,38 +45,48 @@ function Get-XoNetwork { [int]$Limit = $script:XoSessionLimit ) - begin { + begin + { $params = @{ fields = $script:XO_NETWORK_FIELDS } } - process { - if ($PSCmdlet.ParameterSetName -eq "NetworkUuid") { - foreach ($id in $NetworkUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "NetworkUuid") + { + foreach ($id in $NetworkUuid) + { ConvertTo-XoNetworkObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/networks/$id" @script:XoRestParameters -Body $params) } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { $AllFilters = $Filter - if ($Name) { + if ($Name) + { $AllFilters = "$AllFilters name_label:`"$Name`"" } - if ($Tag) { + if ($Tag) + { $tags = ($tag | ForEach-Object { "`"$_`"" }) -join " " $AllFilters = "$AllFilters tags:($tags)" } - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } @@ -90,38 +94,3 @@ function Get-XoNetwork { } } } - -function Set-XoNetwork { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("NetworkId")] - [string]$NetworkUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description, - - [Parameter()] - [string[]]$Tags - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - if ($PSBoundParameters.ContainsKey("Tags")) { - $params["tags"] = $Tags - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/networks/$NetworkUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} diff --git a/src/Public/Get-XoNetworkAlarm.ps1 b/src/Public/Get-XoNetworkAlarm.ps1 new file mode 100644 index 0000000..9eb72c3 --- /dev/null +++ b/src/Public/Get-XoNetworkAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoNetworkAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific network. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra network. Accepts one or more network UUIDs; each is queried independently and the combined results are returned. + .PARAMETER NetworkUuid + The UUID(s) of the network whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoNetworkAlarm -NetworkUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoNetwork | Get-XoNetworkAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$NetworkUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $NetworkUuid) + { + $uri = "$script:XoHost/rest/v0/networks/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoNetworkMessage.ps1 b/src/Public/Get-XoNetworkMessage.ps1 new file mode 100644 index 0000000..c217870 --- /dev/null +++ b/src/Public/Get-XoNetworkMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoNetworkMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific network. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra network. Accepts one or more network UUIDs; each is queried independently and the combined results are returned. + .PARAMETER NetworkUuid + The UUID(s) of the network whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoNetworkMessage -NetworkUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoNetwork | Get-XoNetworkMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$NetworkUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $NetworkUuid) + { + $uri = "$script:XoHost/rest/v0/networks/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoNetworkTask.ps1 b/src/Public/Get-XoNetworkTask.ps1 new file mode 100644 index 0000000..40df01e --- /dev/null +++ b/src/Public/Get-XoNetworkTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoNetworkTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific network. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra network. Accepts one or more network UUIDs; each is queried independently and the combined results are returned. + .PARAMETER NetworkUuid + The UUID(s) of the network whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoNetworkTask -NetworkUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoNetwork | Get-XoNetworkTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$NetworkUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $NetworkUuid) + { + $uri = "$script:XoHost/rest/v0/networks/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoPbd.ps1 b/src/Public/Get-XoPbd.ps1 new file mode 100644 index 0000000..e99e76c --- /dev/null +++ b/src/Public/Get-XoPbd.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPbd +{ + <# + .SYNOPSIS + List or query Xen Orchestra PBDs. + .DESCRIPTION + Retrieves physical block devices (PBDs). A PBD is the XAPI object that connects a host to a storage repository. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -PbdUuid to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER PbdUuid + One or more IDs of the PBDs to retrieve. When omitted, the cmdlet enumerates PBDs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of PBDs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoPbd | Where-Object attached -eq $false + .EXAMPLE + Get-XoPbd -PbdUuid "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.Pbd")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "PbdUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PbdUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_PBD_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "PbdUuid") + { + foreach ($id in $PbdUuid) + { + $uri = "$script:XoHost/rest/v0/pbds/$id" + ConvertTo-XoPbdObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/pbds" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoPbdObject + } + } +} + diff --git a/src/Public/Get-XoPci.ps1 b/src/Public/Get-XoPci.ps1 new file mode 100644 index 0000000..7864ead --- /dev/null +++ b/src/Public/Get-XoPci.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPci +{ + <# + .SYNOPSIS + List or query Xen Orchestra PCI devices. + .DESCRIPTION + Retrieves PCI devices visible to pool hosts. Useful for discovering devices available for passthrough. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -PciUuid to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER PciUuid + One or more IDs of the PCI devices to retrieve. When omitted, the cmdlet enumerates PCI devices using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of PCI devices to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoPci -Limit 0 + .EXAMPLE + Get-XoPci -PciUuid "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.Pci")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "PciUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PciUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_PCI_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "PciUuid") + { + foreach ($id in $PciUuid) + { + $uri = "$script:XoHost/rest/v0/pcis/$id" + ConvertTo-XoPciObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/pcis" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoPciObject + } + } +} + diff --git a/src/Public/Get-XoPgpu.ps1 b/src/Public/Get-XoPgpu.ps1 new file mode 100644 index 0000000..0f0930d --- /dev/null +++ b/src/Public/Get-XoPgpu.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPgpu +{ + <# + .SYNOPSIS + List or query Xen Orchestra physical GPUs (PGPUs). + .DESCRIPTION + Retrieves physical GPUs attached to pool hosts, including their GPU group membership and dom0 access status. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -PgpuUuid to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER PgpuUuid + One or more IDs of the physical GPUs (PGPUs) to retrieve. When omitted, the cmdlet enumerates physical GPUs (PGPUs) using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of physical GPUs (PGPUs) to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoPgpu + .EXAMPLE + Get-XoPgpu -PgpuUuid "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.Pgpu")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "PgpuUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PgpuUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_PGPU_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "PgpuUuid") + { + foreach ($id in $PgpuUuid) + { + $uri = "$script:XoHost/rest/v0/pgpus/$id" + ConvertTo-XoPgpuObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/pgpus" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoPgpuObject + } + } +} + diff --git a/src/pif.ps1 b/src/Public/Get-XoPif.ps1 similarity index 50% rename from src/pif.ps1 rename to src/Public/Get-XoPif.ps1 index 6b9d543..d1ebee3 100644 --- a/src/pif.ps1 +++ b/src/Public/Get-XoPif.ps1 @@ -1,28 +1,24 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_PIF_FIELDS = "attached,isBondMaster,isBondSlave,device,deviceName,dns,disallowUnplug,gateway,ip,ipv6,mac,management,carrier,mode,ipv6Mode,mtu,netmask,physical,primaryAddressType,vlan,speed,uuid,`$network,`$pool" - -function ConvertTo-XoPifObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - PifUuid = $InputObject.uuid - Name = $InputObject.name_label - Description = $InputObject.name_description - } - Set-XoObject $InputObject -TypeName XoPowershell.Pif -Properties $props - } -} - -function Get-XoPif { +function Get-XoPif +{ <# .SYNOPSIS Query PIFs by UUID or condition. .DESCRIPTION Get PIF details. You can specify PIFs by their UUIDs or properties. + .PARAMETER PifUuid + The UUID(s) of the PIF(s) to retrieve. + .PARAMETER Name + Filter PIFs matching the specified name. + .PARAMETER Filter + Custom filter expression for the PIF query. + .PARAMETER Tag + Filter PIFs matching any of the specified tags. + .PARAMETER Limit + Maximum number of PIFs to return. + .EXAMPLE + Get-XoPif -PifUuid "12345678-abcd-1234-abcd-1234567890ab" #> [CmdletBinding(DefaultParameterSetName = "Filter")] param ( @@ -50,38 +46,48 @@ function Get-XoPif { [int]$Limit = $script:XoSessionLimit ) - begin { + begin + { $params = @{ fields = $script:XO_PIF_FIELDS } - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } } - process { - if ($PSCmdlet.ParameterSetName -eq "PifUuid") { - foreach ($id in $PifUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "PifUuid") + { + foreach ($id in $PifUuid) + { ConvertTo-XoPifObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pifs/$id" @script:XoRestParameters -Body $params) } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { $AllFilters = $Filter - if ($Name) { + if ($Name) + { $AllFilters = "$AllFilters name_label:`"$Name`"" } - if ($Tag) { + if ($Tag) + { $tags = ($tag | ForEach-Object { "`"$_`"" }) -join " " $AllFilters = "$AllFilters tags:($tags)" } - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } @@ -89,38 +95,3 @@ function Get-XoPif { } } } - -function Set-XoPif { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("PifId")] - [string]$PifUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description, - - [Parameter()] - [string[]]$Tags - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - if ($PSBoundParameters.ContainsKey("Tags")) { - $params["tags"] = $Tags - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pifs/$PifUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} diff --git a/src/Public/Get-XoPifAlarm.ps1 b/src/Public/Get-XoPifAlarm.ps1 new file mode 100644 index 0000000..068f599 --- /dev/null +++ b/src/Public/Get-XoPifAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPifAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific PIF. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra PIF. Accepts one or more PIF UUIDs; each is queried independently and the combined results are returned. + .PARAMETER PifUuid + The UUID(s) of the PIF whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoPifAlarm -PifUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoPif | Get-XoPifAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PifUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $PifUuid) + { + $uri = "$script:XoHost/rest/v0/pifs/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoPifMessage.ps1 b/src/Public/Get-XoPifMessage.ps1 new file mode 100644 index 0000000..10714ae --- /dev/null +++ b/src/Public/Get-XoPifMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPifMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific PIF. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra PIF. Accepts one or more PIF UUIDs; each is queried independently and the combined results are returned. + .PARAMETER PifUuid + The UUID(s) of the PIF whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoPifMessage -PifUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoPif | Get-XoPifMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PifUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $PifUuid) + { + $uri = "$script:XoHost/rest/v0/pifs/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoPifTask.ps1 b/src/Public/Get-XoPifTask.ps1 new file mode 100644 index 0000000..044b78d --- /dev/null +++ b/src/Public/Get-XoPifTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPifTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific PIF. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra PIF. Accepts one or more PIF UUIDs; each is queried independently and the combined results are returned. + .PARAMETER PifUuid + The UUID(s) of the PIF whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoPifTask -PifUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoPif | Get-XoPifTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PifUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $PifUuid) + { + $uri = "$script:XoHost/rest/v0/pifs/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoPool.ps1 b/src/Public/Get-XoPool.ps1 new file mode 100644 index 0000000..2d495a2 --- /dev/null +++ b/src/Public/Get-XoPool.ps1 @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPool +{ + <# + .SYNOPSIS + Query pools by UUID or condition. + .DESCRIPTION + Get pool details. You can specify pools by their UUIDs or properties. + .PARAMETER PoolUuid + The UUID(s) of the pool(s) to retrieve. + .PARAMETER Name + Filter pools matching the specified name. + .PARAMETER Filter + Custom filter expression for the pool query. + .PARAMETER Tag + Filter pools matching any of the specified tags. + .PARAMETER Limit + Maximum number of pools to return. + .EXAMPLE + Get-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + param ( + # UUIDs of pools to query. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "PoolUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PoolUuid, + + # Find pools that match the specified name substring. + [Parameter(ParameterSetName = "Filter")] + [string]$Name, + + # Filter to apply to the pool query. + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + # Find pools that match any of the specified tags. + [Parameter(ParameterSetName = "Filter")] + [ValidateNotNullOrEmpty()] + [string[]]$Tag, + + # Maximum number of results to return. + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + $params = @{ + fields = $script:XO_POOL_FIELDS + } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "PoolUuid") + { + foreach ($id in $PoolUuid) + { + ConvertTo-XoPoolObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$id" @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + $AllFilters = $Filter + + if ($Name) + { + $AllFilters = "$AllFilters name_label:`"$Name`"" + } + + if ($Tag) + { + $tags = ($tag | ForEach-Object { "`"$_`"" }) -join " " + $AllFilters = "$AllFilters tags:($tags)" + } + + if ($AllFilters) + { + $params["filter"] = $AllFilters + } + + if ($Limit) + { + $params["limit"] = $Limit + } + + (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools" @script:XoRestParameters -Body $params) | ConvertTo-XoPoolObject + } + } +} diff --git a/src/Public/Get-XoPoolDashboard.ps1 b/src/Public/Get-XoPoolDashboard.ps1 new file mode 100644 index 0000000..de521e5 --- /dev/null +++ b/src/Public/Get-XoPoolDashboard.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPoolDashboard +{ + <# + .SYNOPSIS + Get dashboard summary scoped to a specific pool. + .DESCRIPTION + Retrieves dashboard summary attached to the specified Xen Orchestra pool. Accepts one or more pool UUIDs; each is queried independently and the combined results are returned. + .PARAMETER PoolUuid + The UUID(s) of the pool whose dashboard summary should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoPoolDashboard -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" + .EXAMPLE + Get-XoPool | Get-XoPoolDashboard + #> + [CmdletBinding()] + [OutputType("XoPowershell.Dashboard")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PoolUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + foreach ($id in $PoolUuid) + { + $uri = "$script:XoHost/rest/v0/pools/$id/dashboard" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoDashboardObject + } + } +} + diff --git a/src/Public/Get-XoPoolMessage.ps1 b/src/Public/Get-XoPoolMessage.ps1 new file mode 100644 index 0000000..2d88610 --- /dev/null +++ b/src/Public/Get-XoPoolMessage.ps1 @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPoolMessage +{ + <# + .SYNOPSIS + Get Pool message + + .DESCRIPTION + Retrieves messages associated with a Xen Orchestra pool. + + .PARAMETER PoolUuid + Target Xen Orchestra pool UUID. + + .EXAMPLE + Get-XoPoolMessage -PoolUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$PoolUuid + ) + process + { + + (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/messages" @script:XoRestParameters -Body $params) | ConvertFrom-XoUuidHref | ForEach-Object { + Get-XoMessage $_ + } + } +} diff --git a/src/Public/Get-XoPoolPatch.ps1 b/src/Public/Get-XoPoolPatch.ps1 new file mode 100644 index 0000000..53aa93d --- /dev/null +++ b/src/Public/Get-XoPoolPatch.ps1 @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPoolPatch +{ + <# + .SYNOPSIS + Query pending patches for a Xen Orchestra pool. + .DESCRIPTION + Query pending patches for a Xen Orchestra pool. + .PARAMETER PoolUuid + Target Xen Orchestra pool UUID. + .EXAMPLE + Get-XoPoolPatch -PoolUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' + #> + [CmdletBinding()] + param ( + # UUID of pools to query. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$PoolUuid + ) + process + { + + (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/missing_patches" @script:XoRestParameters -Body $params) | ConvertTo-XoPoolPatchObject + } +} diff --git a/src/Public/Get-XoPoolStat.ps1 b/src/Public/Get-XoPoolStat.ps1 new file mode 100644 index 0000000..89a5064 --- /dev/null +++ b/src/Public/Get-XoPoolStat.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPoolStat +{ + <# + .SYNOPSIS + Get performance statistics scoped to a specific pool. + .DESCRIPTION + Retrieves performance statistics attached to the specified Xen Orchestra pool. Accepts one or more pool UUIDs; each is queried independently and the combined results are returned. + .PARAMETER PoolUuid + The UUID(s) of the pool whose performance statistics should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoPoolStat -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" + .EXAMPLE + Get-XoPool | Get-XoPoolStat + #> + [CmdletBinding()] + [OutputType("XoPowershell.Stat")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PoolUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + foreach ($id in $PoolUuid) + { + $uri = "$script:XoHost/rest/v0/pools/$id/stats" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoStatObject + } + } +} + diff --git a/src/Public/Get-XoPoolTask.ps1 b/src/Public/Get-XoPoolTask.ps1 new file mode 100644 index 0000000..0fb33a3 --- /dev/null +++ b/src/Public/Get-XoPoolTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPoolTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific pool. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra pool. Accepts one or more pool UUIDs; each is queried independently and the combined results are returned. + .PARAMETER PoolUuid + The UUID(s) of the pool whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoPoolTask -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" + .EXAMPLE + Get-XoPool | Get-XoPoolTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PoolUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $PoolUuid) + { + $uri = "$script:XoHost/rest/v0/pools/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoPoolVm.ps1 b/src/Public/Get-XoPoolVm.ps1 new file mode 100644 index 0000000..b4ac2ba --- /dev/null +++ b/src/Public/Get-XoPoolVm.ps1 @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoPoolVm +{ + <# + .SYNOPSIS + Get VMs scoped to a specific pool. + .DESCRIPTION + Returns the VMs that belong to the specified pool(s). The XO REST API does not expose a dedicated GET /pools/{id}/vms endpoint (only POST for imports), so this cmdlet delegates to Get-XoVm with a $pool filter. Accepts one or more pool UUIDs and pipeline input by property name. + .PARAMETER PoolUuid + The UUID(s) of the pool whose VMs should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoPoolVm -PoolUuid "b7569d99-30f8-178a-7d94-801de3e29b5b" + .EXAMPLE + Get-XoPool | Get-XoPoolVm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$PoolUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $PoolUuid) + { + Get-XoVm -PoolUuid $id + } + } +} diff --git a/src/Public/Get-XoProxy.ps1 b/src/Public/Get-XoProxy.ps1 new file mode 100644 index 0000000..2b03188 --- /dev/null +++ b/src/Public/Get-XoProxy.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoProxy +{ + <# + .SYNOPSIS + List or query Xen Orchestra XO proxies. + .DESCRIPTION + Retrieves Xen Orchestra proxies - lightweight VMs that relay backup/migration traffic between XO and a pool. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -ProxyId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER ProxyId + One or more IDs of the XO proxies to retrieve. When omitted, the cmdlet enumerates XO proxies using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of XO proxies to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoProxy + .EXAMPLE + Get-XoProxy -ProxyId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.Proxy")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "ProxyId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$ProxyId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_PROXY_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "ProxyId") + { + foreach ($id in $ProxyId) + { + $uri = "$script:XoHost/rest/v0/proxies/$id" + ConvertTo-XoProxyObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/proxies" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoProxyObject + } + } +} + diff --git a/src/Public/Get-XoRestoreJobLog.ps1 b/src/Public/Get-XoRestoreJobLog.ps1 new file mode 100644 index 0000000..608b91e --- /dev/null +++ b/src/Public/Get-XoRestoreJobLog.ps1 @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoRestoreJobLog +{ + <# + .SYNOPSIS + List or query Xen Orchestra restore logs. + .DESCRIPTION + Retrieves restore logs via the /restore/logs endpoint (alias of Get-XoRestoreLog using the alternative path). When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -RestoreLogId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER RestoreLogId + One or more IDs of the restore logs to retrieve. When omitted, the cmdlet enumerates restore logs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of restore logs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoRestoreJobLog -Limit 50 + .EXAMPLE + Get-XoRestoreJobLog -RestoreLogId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.RestoreLog")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "RestoreLogId")] + [string[]]$RestoreLogId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_RESTORE_LOG_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "RestoreLogId") + { + foreach ($id in $RestoreLogId) + { + $uri = "$script:XoHost/rest/v0/restore/logs/$id" + ConvertTo-XoRestoreLogObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/restore/logs" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoRestoreLogObject + } + } +} + diff --git a/src/Public/Get-XoRestoreLog.ps1 b/src/Public/Get-XoRestoreLog.ps1 new file mode 100644 index 0000000..0a2c8f8 --- /dev/null +++ b/src/Public/Get-XoRestoreLog.ps1 @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoRestoreLog +{ + <# + .SYNOPSIS + List or query Xen Orchestra restore logs. + .DESCRIPTION + Retrieves restore logs - the per-run records produced when a backup archive is restored to a VM or SR. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -RestoreLogId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER RestoreLogId + One or more IDs of the restore logs to retrieve. When omitted, the cmdlet enumerates restore logs using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of restore logs to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoRestoreLog -Filter 'status:failure' + .EXAMPLE + Get-XoRestoreLog -RestoreLogId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.RestoreLog")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "RestoreLogId")] + [string[]]$RestoreLogId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_RESTORE_LOG_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "RestoreLogId") + { + foreach ($id in $RestoreLogId) + { + $uri = "$script:XoHost/rest/v0/restore-logs/$id" + ConvertTo-XoRestoreLogObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/restore-logs" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoRestoreLogObject + } + } +} + diff --git a/src/Public/Get-XoSchedule.ps1 b/src/Public/Get-XoSchedule.ps1 new file mode 100644 index 0000000..2e2f953 --- /dev/null +++ b/src/Public/Get-XoSchedule.ps1 @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSchedule +{ + <# + .SYNOPSIS + List or query schedules. + .DESCRIPTION + Get Xen Orchestra schedules by UUID or list all existing schedules. + .PARAMETER ScheduleUuid + The UUID(s) of the schedule(s) to retrieve. + .PARAMETER Filter + Custom filter expression for the schedule query. + .PARAMETER Limit + Maximum number of schedules to return. + .EXAMPLE + Get-XoSchedule -ScheduleUuid "12345678-abcd-1234-abcd-1234567890ab" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + param ( + # UUIDs of schedules to query. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "ScheduleUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$ScheduleUuid, + + # Filter to apply to the schedule query. + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + # Maximum number of results to return. + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + $params = @{ + fields = $script:XO_SCHEDULE_FIELDS + } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "ScheduleUuid") + { + foreach ($id in $ScheduleUuid) + { + ConvertTo-XoScheduleObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/schedules/$id" @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + $AllFilters = $Filter + + if ($AllFilters) + { + $params["filter"] = $AllFilters + } + + if ($Limit) + { + $params["limit"] = $Limit + } + + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/schedules" @script:XoRestParameters -Body $params) | ConvertTo-XoScheduleObject + } + } +} diff --git a/src/server.ps1 b/src/Public/Get-XoServer.ps1 similarity index 50% rename from src/server.ps1 rename to src/Public/Get-XoServer.ps1 index cab14f3..22b78d6 100644 --- a/src/server.ps1 +++ b/src/Public/Get-XoServer.ps1 @@ -1,72 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_SERVER_FIELDS = "id,host,label,address,version,status,enabled,error,username,readOnly,allowUnauthorized" - -function ConvertTo-XoServerObject { - <# - .SYNOPSIS - Convert a server object from the API to a PowerShell object. - .DESCRIPTION - Convert a server object from the API to a PowerShell object with proper properties. - .PARAMETER InputObject - The server object from the API. - #> - [CmdletBinding()] - [OutputType("XoPowershell.Server")] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)] - $InputObject - ) - - process { - $props = @{ - ServerUuid = $InputObject.id # API returns 'id' field, not 'uuid' for servers - Name = $InputObject.label - NameHost = $InputObject.host - Address = $InputObject.address - Status = $InputObject.status - Version = $InputObject.version - Enabled = $InputObject.enabled - ReadOnly = $InputObject.readOnly - Username = $InputObject.username - Error = $InputObject.error - AllowUnauthorized = $InputObject.allowUnauthorized - } - - Set-XoObject $InputObject -TypeName XoPowershell.Server -Properties $props - } -} - -function Get-XoSingleServerById { - param ( - [string]$ServerUuid, - [hashtable]$Params - ) - - try { - Write-Verbose "Getting server with ID $ServerUuid" - $uri = "$script:XoHost/rest/v0/servers/$ServerUuid" - - if ($null -eq $Params) { - $Params = @{} - } - if (-not $Params.ContainsKey('fields')) { - $Params['fields'] = $script:XO_SERVER_FIELDS - } - - $serverData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params - - if ($serverData) { - return ConvertTo-XoServerObject -InputObject $serverData - } - } - catch { - throw ("Failed to retrieve server with ID {0}: {1}" -f $ServerUuid, $_) - } - return $null -} - -function Get-XoServer { +function Get-XoServer +{ <# .SYNOPSIS Get servers from Xen Orchestra. @@ -108,51 +43,64 @@ function Get-XoServer { [int]$Limit = $script:XoSessionLimit ) - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") } $params = @{ fields = $script:XO_SERVER_FIELDS } } - process { - if ($PSCmdlet.ParameterSetName -eq "ServerUuid") { - foreach ($id in $ServerUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "ServerUuid") + { + foreach ($id in $ServerUuid) + { Get-XoSingleServerById -ServerUuid $id -Params $params } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { $AllFilters = $Filter - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } - try { + try + { Write-Verbose "Getting servers with parameters: $($params | ConvertTo-Json -Compress)" $uri = "$script:XoHost/rest/v0/servers" $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - if (!$response -or $response.Count -eq 0) { + if (!$response -or $response.Count -eq 0) + { Write-Verbose "No servers found matching criteria" return } Write-Verbose "Found $($response.Count) servers" - foreach ($serverItem in $response) { + foreach ($serverItem in $response) + { ConvertTo-XoServerObject -InputObject $serverItem } } - catch { + catch + { throw ("Failed to list servers. Error: {0}" -f $_) } } diff --git a/src/Public/Get-XoServerTask.ps1 b/src/Public/Get-XoServerTask.ps1 new file mode 100644 index 0000000..bceae82 --- /dev/null +++ b/src/Public/Get-XoServerTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoServerTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific XO server. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra XO server. Accepts one or more XO server UUIDs; each is queried independently and the combined results are returned. + .PARAMETER ServerUuid + The UUID(s) of the XO server whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoServerTask -ServerUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoServer | Get-XoServerTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$ServerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $ServerUuid) + { + $uri = "$script:XoHost/rest/v0/servers/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoSession.ps1 b/src/Public/Get-XoSession.ps1 new file mode 100644 index 0000000..ac2d1bc --- /dev/null +++ b/src/Public/Get-XoSession.ps1 @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSession +{ + <# + .SYNOPSIS + Get the current XO session settings. + .DESCRIPTION + Get the current Xen Orchestra session settings. + .EXAMPLE + Get-XoSession + #> + [CmdletBinding()] + param() + + [pscustomobject]@{ + Limit = $script:XoSessionLimit + } +} diff --git a/src/Public/Get-XoSingleHostById.ps1 b/src/Public/Get-XoSingleHostById.ps1 new file mode 100644 index 0000000..4aed0a1 --- /dev/null +++ b/src/Public/Get-XoSingleHostById.ps1 @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSingleHostById +{ + <# + .SYNOPSIS + Get a single host by ID + + .DESCRIPTION + Get a single host from Xen Orchestra by its UUID. + + .PARAMETER HostUuid + Target host UUID to retrieve. + + .PARAMETER Params + Hashtable with request parameters. + + .EXAMPLE + Get-XoSingleHostById -HostUuid '812b59e1-2682-43ef-acd4-808d3551b907' + #> + [CmdletBinding()] + [OutputType("XoPowershell.Host")] + param ( + [string]$HostUuid, + [hashtable]$Params + ) + process + { + + try + { + $uri = "$script:XoHost/rest/v0/hosts/$HostUuid" + $params = @{ fields = $script:XO_HOST_FIELDS } + $hostData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if ($hostData) + { + return ConvertTo-XoHostObject -InputObject $hostData + } + } + catch + { + throw ("Failed to retrieve host with UUID {0}: {1}" -f $HostUuid, $_) + } + } +} diff --git a/src/Public/Get-XoSingleServerById.ps1 b/src/Public/Get-XoSingleServerById.ps1 new file mode 100644 index 0000000..29f2ece --- /dev/null +++ b/src/Public/Get-XoSingleServerById.ps1 @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSingleServerById +{ + <# + .SYNOPSIS + Get single server by ID + + .DESCRIPTION + Get a single server from Xen Orchestra by its ID. + + .PARAMETER ServerUuid + Target server UUID to retrieve. + + .PARAMETER Params + Target server query parameters. + + .EXAMPLE + Get-XoSingleServerById -ServerUuid '812b59e1-2682-43ef-acd4-808d3551b907' + #> + [CmdletBinding()] + [OutputType("XoPowershell.Server")] + param ( + [string]$ServerUuid, + [hashtable]$Params + ) + process + { + + try + { + Write-Verbose "Getting server with ID $ServerUuid" + $uri = "$script:XoHost/rest/v0/servers/$ServerUuid" + + if ($null -eq $Params) + { + $Params = @{} + } + if (-not $Params.ContainsKey('fields')) + { + $Params['fields'] = $script:XO_SERVER_FIELDS + } + + $serverData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params + + if ($serverData) + { + return ConvertTo-XoServerObject -InputObject $serverData + } + } + catch + { + throw ("Failed to retrieve server with ID {0}: {1}" -f $ServerUuid, $_) + } + return $null + } +} diff --git a/src/Public/Get-XoSingleSrById.ps1 b/src/Public/Get-XoSingleSrById.ps1 new file mode 100644 index 0000000..db32258 --- /dev/null +++ b/src/Public/Get-XoSingleSrById.ps1 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSingleSrById +{ + <# + .SYNOPSIS + Get single SR by ID + + .DESCRIPTION + Get a single storage repository by its UUID. + + .PARAMETER SrUuid + Target storage repository UUID. + + .PARAMETER Params + Target SR request parameters hash. + + .EXAMPLE + Get-XoSingleSrById -SrUuid '812b59e1-2682-43ef-acd4-808d3551b907' + #> + [CmdletBinding()] + [OutputType("XoPowershell.Sr")] + param ( + [string]$SrUuid, + [hashtable]$Params + ) + process + { + + try + { + Write-Verbose "Getting SR with UUID $SrUuid" + $uri = "$script:XoHost/rest/v0/srs/$SrUuid" + $srData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params + + if ($srData) + { + return ConvertTo-XoSrObject -InputObject $srData + } + } + catch + { + throw ("Failed to retrieve SR with UUID {0}: {1}" -f $SrUuid, $_) + } + return $null + } +} diff --git a/src/Public/Get-XoSingleTaskById.ps1 b/src/Public/Get-XoSingleTaskById.ps1 new file mode 100644 index 0000000..804544e --- /dev/null +++ b/src/Public/Get-XoSingleTaskById.ps1 @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSingleTaskById +{ + <# + .SYNOPSIS + Get a single task by ID + .DESCRIPTION + Retrieves a single task from the API by its ID + .PARAMETER TaskId + The ID of the task to retrieve + .PARAMETER Params + Additional parameters to pass to the API + .EXAMPLE + Get-XoSingleTaskById -TaskId "0m8k2zkzi" + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [string]$TaskId, + [hashtable]$Params + ) + process + { + + try + { + Write-Verbose "Getting task with ID $TaskId" + $uri = "$script:XoHost/rest/v0/tasks/$TaskId" + $taskData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params + + if ($taskData) + { + return ConvertTo-XoTaskObject -InputObject $taskData + } + } + catch + { + throw ("Failed to retrieve task with ID {0}: {1}" -f $TaskId, $_) + } + return $null + } +} diff --git a/src/Public/Get-XoSingleVdiById.ps1 b/src/Public/Get-XoSingleVdiById.ps1 new file mode 100644 index 0000000..7d90bb9 --- /dev/null +++ b/src/Public/Get-XoSingleVdiById.ps1 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSingleVdiById +{ + <# + .SYNOPSIS + Get VDI by ID + + .DESCRIPTION + Get a single VDI from Xen Orchestra by UUID. + + .PARAMETER VdiUuid + Target VDI UUID to retrieve. + + .PARAMETER Params + Target VDI request parameters hash. + + .EXAMPLE + Get-XoSingleVdiById -VdiUuid '812b59e1-2682-43ef-acd4-808d3551b907' + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vdi")] + param ( + [string]$VdiUuid, + [hashtable]$Params + ) + process + { + + try + { + Write-Verbose "Getting VDI with UUID $VdiUuid" + $uri = "$script:XoHost/rest/v0/vdis/$VdiUuid" + $vdiData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params + + if ($vdiData) + { + return ConvertTo-XoVdiObject -InputObject $vdiData + } + } + catch + { + throw ("Failed to retrieve VDI with UUID {0}: {1}" -f $VdiUuid, $_) + } + return $null + } +} diff --git a/src/Public/Get-XoSingleVdiSnapshotById.ps1 b/src/Public/Get-XoSingleVdiSnapshotById.ps1 new file mode 100644 index 0000000..cb8ecda --- /dev/null +++ b/src/Public/Get-XoSingleVdiSnapshotById.ps1 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSingleVdiSnapshotById +{ + <# + .SYNOPSIS + Get a VDI Snapshot by ID + + .DESCRIPTION + Get a single VDI Snapshot from Xen Orchestra by UUID. + + .PARAMETER VdiSnapshotUuid + Target VDI Snapshot UUID to retrieve. + + .PARAMETER Params + Target VDI Snapshot request parameters hash. + + .EXAMPLE + Get-XoSingleVdiSnapshotById -VdiSnapshotUuid '812b59e1-2682-43ef-acd4-808d3551b907' + #> + [CmdletBinding()] + [OutputType("XoPowershell.VdiSnapshot")] + param ( + [string]$VdiSnapshotUuid, + [hashtable]$Params + ) + process + { + + try + { + Write-Verbose "Getting VDI snapshot with UUID $VdiSnapshotUuid" + $uri = "$script:XoHost/rest/v0/vdi-snapshots/$VdiSnapshotUuid" + $snapshotData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params + + if ($snapshotData) + { + return ConvertTo-XoVdiSnapshotObject -InputObject $snapshotData + } + } + catch + { + throw ("Failed to retrieve VDI snapshot with UUID {0}: {1}" -f $VdiSnapshotUuid, $_) + } + return $null + } +} diff --git a/src/Public/Get-XoSingleVmById.ps1 b/src/Public/Get-XoSingleVmById.ps1 new file mode 100644 index 0000000..781138a --- /dev/null +++ b/src/Public/Get-XoSingleVmById.ps1 @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSingleVmById +{ + <# + .SYNOPSIS + Get a VM by ID + + .DESCRIPTION + Get a single VM from Xen Orchestra by UUID. + + .PARAMETER VmUuid + Target VM UUID to retrieve. + + .EXAMPLE + Get-XoSingleVmById -VmUuid '812b59e1-2682-43ef-acd4-808d3551b907' + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vm")] + param ( + [string]$VmUuid + ) + process + { + + try + { + $uri = "$script:XoHost/rest/v0/vms/$VmUuid" + $params = @{ fields = $script:XO_VM_FIELDS } + $vmData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if ($vmData) + { + return ConvertTo-XoVmObject -InputObject $vmData + } + } + catch + { + throw ("Failed to retrieve VM with UUID {0}: {1}" -f $VmUuid, $_) + } + return $null + } +} diff --git a/src/Public/Get-XoSm.ps1 b/src/Public/Get-XoSm.ps1 new file mode 100644 index 0000000..b18016e --- /dev/null +++ b/src/Public/Get-XoSm.ps1 @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSm +{ + <# + .SYNOPSIS + List or query Xen Orchestra storage managers (SMs). + .DESCRIPTION + Retrieves XAPI storage manager plugins installed on pool hosts. Each SM corresponds to a supported SR type (ext, lvm, nfs, ...). When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -SmUuid to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER SmUuid + One or more IDs of the storage managers (SMs) to retrieve. When omitted, the cmdlet enumerates storage managers (SMs) using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of storage managers (SMs) to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoSm | Sort-Object -Property SM_type + .EXAMPLE + Get-XoSm -SmUuid "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.Sm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "SmUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$SmUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_SM_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "SmUuid") + { + foreach ($id in $SmUuid) + { + $uri = "$script:XoHost/rest/v0/sms/$id" + ConvertTo-XoSmObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) + { + $params["filter"] = $Filter + } + if ($Limit) + { + $params["limit"] = $Limit + } + + $uri = "$script:XoHost/rest/v0/sms" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoSmObject + } + } +} + diff --git a/src/Public/Get-XoSr.ps1 b/src/Public/Get-XoSr.ps1 new file mode 100644 index 0000000..b256238 --- /dev/null +++ b/src/Public/Get-XoSr.ps1 @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSr +{ + <# + .SYNOPSIS + Get storage repositories from Xen Orchestra. + .DESCRIPTION + Retrieves storage repositories from Xen Orchestra. Can retrieve specific SRs by their UUID + or all SRs. + .PARAMETER SrUuid + The UUID(s) of the SR(s) to retrieve. + .PARAMETER Limit + Maximum number of results to return. Default is 25 if not specified. + Use -Limit 0 to return all results without limitation. + .EXAMPLE + Get-XoSr + Returns up to 25 SRs. + .EXAMPLE + Get-XoSr -Limit 0 + Returns all SRs without limit. + .EXAMPLE + Get-XoSr -SrUuid "a1b2c3d4" + Returns the SR with the specified UUID. + .EXAMPLE + Get-XoSr -Limit 5 + Returns the first 5 SRs. + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.Sr")] + # Parameter sets: + # - "Filter": Gets SRs with optional filtering criteria (with optional limit) + # - "SrUuid": Gets specific SRs by UUID + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "SrUuid")] + [ValidatePattern("[0-9a-z-]+")] + [Alias("SrId")] + [string[]]$SrUuid, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") + } + + $params = @{ + fields = $script:XO_SR_FIELDS + } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "SrUuid") + { + foreach ($id in $SrUuid) + { + Get-XoSingleSrById -SrUuid $id -Params $params + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Limit) + { + $params['limit'] = $Limit + } + + try + { + Write-Verbose "Getting SRs with parameters: $($params | ConvertTo-Json -Compress)" + $uri = "$script:XoHost/rest/v0/srs" + $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if (!$response -or $response.Count -eq 0) + { + Write-Verbose "No SRs found" + return + } + + Write-Verbose "Found $($response.Count) SRs" + + foreach ($srItem in $response) + { + ConvertTo-XoSrObject -InputObject $srItem + } + } + catch + { + throw ("Failed to list SRs. Error: {0}" -f $_) + } + } + } +} diff --git a/src/Public/Get-XoSrAlarm.ps1 b/src/Public/Get-XoSrAlarm.ps1 new file mode 100644 index 0000000..750b404 --- /dev/null +++ b/src/Public/Get-XoSrAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSrAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific storage repository. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra storage repository. Accepts one or more storage repository UUIDs; each is queried independently and the combined results are returned. + .PARAMETER SrUuid + The UUID(s) of the storage repository whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoSrAlarm -SrUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoSr | Get-XoSrAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$SrUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $SrUuid) + { + $uri = "$script:XoHost/rest/v0/srs/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoSrMessage.ps1 b/src/Public/Get-XoSrMessage.ps1 new file mode 100644 index 0000000..0157d39 --- /dev/null +++ b/src/Public/Get-XoSrMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSrMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific storage repository. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra storage repository. Accepts one or more storage repository UUIDs; each is queried independently and the combined results are returned. + .PARAMETER SrUuid + The UUID(s) of the storage repository whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoSrMessage -SrUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoSr | Get-XoSrMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$SrUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $SrUuid) + { + $uri = "$script:XoHost/rest/v0/srs/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoSrTask.ps1 b/src/Public/Get-XoSrTask.ps1 new file mode 100644 index 0000000..c37ae80 --- /dev/null +++ b/src/Public/Get-XoSrTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSrTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific storage repository. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra storage repository. Accepts one or more storage repository UUIDs; each is queried independently and the combined results are returned. + .PARAMETER SrUuid + The UUID(s) of the storage repository whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoSrTask -SrUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoSr | Get-XoSrTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$SrUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $SrUuid) + { + $uri = "$script:XoHost/rest/v0/srs/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoSrVdi.ps1 b/src/Public/Get-XoSrVdi.ps1 new file mode 100644 index 0000000..f5405ea --- /dev/null +++ b/src/Public/Get-XoSrVdi.ps1 @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoSrVdi +{ + <# + .SYNOPSIS + Get virtual disks (VDIs) scoped to a specific storage repository. + .DESCRIPTION + Returns the VDIs that live on the specified storage repository. The XO REST API does not expose a dedicated GET /srs/{id}/vdis endpoint (only POST for VDI uploads), so this cmdlet delegates to Get-XoVdi with the $SR filter. Accepts one or more SR UUIDs and pipeline input by property name. + .PARAMETER SrUuid + The UUID(s) of the storage repository whose virtual disks (VDIs) should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoSrVdi -SrUuid "c787b75c-3e0d-70fa-d0c3-cbfd382d7e33" + .EXAMPLE + Get-XoSr | Get-XoSrVdi + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vdi")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$SrUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $SrUuid) + { + Get-XoVdi -SrUuid $id + } + } +} diff --git a/src/Public/Get-XoTask.ps1 b/src/Public/Get-XoTask.ps1 new file mode 100644 index 0000000..dd38eb5 --- /dev/null +++ b/src/Public/Get-XoTask.ps1 @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoTask +{ + <# + .SYNOPSIS + Get tasks from Xen Orchestra. + .DESCRIPTION + Retrieves tasks from Xen Orchestra. Can retrieve specific tasks by their ID + or filter tasks by status. + .PARAMETER TaskId + The ID(s) of the task(s) to retrieve. + .PARAMETER Status + Filter tasks by status. Valid values: pending, success, failure. + .PARAMETER Limit + Maximum number of results to return. Default is 25 if not specified. + .EXAMPLE + Get-XoTask + Returns up to 25 tasks of any status. + .EXAMPLE + Get-XoTask -Status failure + Returns failed tasks. + .EXAMPLE + Get-XoTask -TaskId "0m8k2zkzi" + Returns the task with the specified ID. + .EXAMPLE + Get-XoTask -Limit 5 + Returns the first 5 tasks. + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "TaskId")] + [ValidateNotNullOrEmpty()] + [string[]]$TaskId, + + [Parameter(ParameterSetName = "Filter")] + [ValidateSet("pending", "success", "failure")] + [string]$Status, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") + } + + $params = @{ + fields = $script:XO_TASK_FIELDS + } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "TaskId") + { + foreach ($id in $TaskId) + { + Get-XoSingleTaskById -TaskId $id -Params $params + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Status) + { + $params['filter'] = $Status + } + + if ($Limit) + { + $params['limit'] = $Limit + } + + try + { + Write-Verbose "Getting tasks with parameters: $($params | ConvertTo-Json -Compress)" + $uri = "$script:XoHost/rest/v0/tasks" + $tasksResponse = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if ($null -eq $tasksResponse -or $tasksResponse.Count -eq 0) + { + Write-Verbose "No tasks found matching criteria" + return + } + + Write-Verbose "Found $($tasksResponse.Count) tasks" + + foreach ($taskItem in $tasksResponse) + { + ConvertTo-XoTaskObject -InputObject $taskItem + } + } + catch + { + if ($PSBoundParameters.ContainsKey('Status')) + { + throw ("Failed to retrieve tasks with status {0}: {1}" -f $Status, $_) + } + else + { + throw ("Failed to retrieve tasks: {0}" -f $_) + } + } + } + } +} + +New-Alias -Name Get-XoTaskDetails -Value Get-XoTask diff --git a/src/Public/Get-XoUser.ps1 b/src/Public/Get-XoUser.ps1 new file mode 100644 index 0000000..5037308 --- /dev/null +++ b/src/Public/Get-XoUser.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoUser +{ + <# + .SYNOPSIS + List or query Xen Orchestra users. + .DESCRIPTION + Retrieves Xen Orchestra users, including their permission level, email and group membership. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -UserId to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER UserId + One or more IDs of the users to retrieve. When omitted, the cmdlet enumerates users using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of users to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoUser | Where-Object permission -eq 'admin' + .EXAMPLE + Get-XoUser -UserId "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.User")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "UserId")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$UserId, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_USER_FIELDS + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "UserId") + { + foreach ($id in $UserId) + { + $uri = "$script:XoHost/rest/v0/users/$id" + ConvertTo-XoUserObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/users" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoUserObject + } + } +} + diff --git a/src/Public/Get-XoUserAuthenticationToken.ps1 b/src/Public/Get-XoUserAuthenticationToken.ps1 new file mode 100644 index 0000000..0803c39 --- /dev/null +++ b/src/Public/Get-XoUserAuthenticationToken.ps1 @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoUserAuthenticationToken +{ + <# + .SYNOPSIS + List authentication tokens for a specific user. + .DESCRIPTION + Retrieves the API authentication tokens owned by a user via GET /users/{id}/authentication_tokens. Each token includes the client id, description, creation/expiration timestamps and most recent use. Useful for auditing long-lived tokens created via xo-cli. The REST API does not expose a "self" variant for listing (only for creation), so a UserId is required. + .PARAMETER UserId + The UUID of the user whose authentication tokens should be returned. + .EXAMPLE + Get-XoUserAuthenticationToken -UserId '722d17b9-699b-49d2-8193-be1ac573d3de' + .EXAMPLE + Get-XoUser | Get-XoUserAuthenticationToken + #> + [CmdletBinding()] + [OutputType("XoPowershell.UserAuthenticationToken")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$UserId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $UserId) + { + $uri = "$script:XoHost/rest/v0/users/$id/authentication_tokens" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters) | ConvertTo-XoUserAuthenticationTokenObject + } + } +} diff --git a/src/Public/Get-XoUserGroup.ps1 b/src/Public/Get-XoUserGroup.ps1 new file mode 100644 index 0000000..058ba0e --- /dev/null +++ b/src/Public/Get-XoUserGroup.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoUserGroup +{ + <# + .SYNOPSIS + Get group scoped to a specific user. + .DESCRIPTION + Retrieves group attached to the specified Xen Orchestra user. Accepts one or more user UUIDs; each is queried independently and the combined results are returned. + .PARAMETER UserId + The UUID(s) of the user whose group should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoUserGroup -UserId "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoUser | Get-XoUserGroup + #> + [CmdletBinding()] + [OutputType("XoPowershell.Group")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$UserId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_GROUP_FIELDS + } + + process + { + foreach ($id in $UserId) + { + $uri = "$script:XoHost/rest/v0/users/$id/groups" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoGroupObject + } + } +} + diff --git a/src/Public/Get-XoUserTask.ps1 b/src/Public/Get-XoUserTask.ps1 new file mode 100644 index 0000000..c724151 --- /dev/null +++ b/src/Public/Get-XoUserTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoUserTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific user. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra user. Accepts one or more user UUIDs; each is queried independently and the combined results are returned. + .PARAMETER UserId + The UUID(s) of the user whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoUserTask -UserId "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoUser | Get-XoUserTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$UserId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $UserId) + { + $uri = "$script:XoHost/rest/v0/users/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/vbd.ps1 b/src/Public/Get-XoVbd.ps1 similarity index 69% rename from src/vbd.ps1 rename to src/Public/Get-XoVbd.ps1 index 818c11a..23b7b8d 100644 --- a/src/vbd.ps1 +++ b/src/Public/Get-XoVbd.ps1 @@ -1,28 +1,24 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_VBD_FIELDS = "attached,bootable,device,is_cd_drive,position,read_only,uuid,`$pool" - -function ConvertTo-XoVbdObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - VbdUuid = $InputObject.uuid - IsCdDrive = $InputObject.is_cd_drive - ReadOnly = $InputObject.read_only - } - Set-XoObject $InputObject -TypeName XoPowershell.Vbd -Properties $props - } -} - -function Get-XoVbd { +function Get-XoVbd +{ <# .SYNOPSIS Query VBDs by UUID or condition. .DESCRIPTION Get VBD details. You can specify VBDs by their UUIDs or properties. + .PARAMETER VbdUuid + The UUID(s) of the VBD(s) to retrieve. + .PARAMETER Name + Filter VBDs matching the specified name. + .PARAMETER Filter + Custom filter expression for the VBD query. + .PARAMETER Tag + Filter VBDs matching any of the specified tags. + .PARAMETER Limit + Maximum number of VBDs to return. + .EXAMPLE + Get-XoVbd -VbdUuid "12345678-abcd-1234-abcd-1234567890ab" #> [CmdletBinding(DefaultParameterSetName = "Filter")] param ( @@ -50,38 +46,48 @@ function Get-XoVbd { [int]$Limit = $script:XoSessionLimit ) - begin { + begin + { $params = @{ fields = $script:XO_VBD_FIELDS } } - process { - if ($PSCmdlet.ParameterSetName -eq "VbdUuid") { - foreach ($id in $VbdUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "VbdUuid") + { + foreach ($id in $VbdUuid) + { ConvertTo-XoVbdObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vbds/$id" @script:XoRestParameters -Body $params) } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { $AllFilters = $Filter - if ($Name) { + if ($Name) + { $AllFilters = "$AllFilters name_label:`"$Name`"" } - if ($Tag) { + if ($Tag) + { $tags = ($tag | ForEach-Object { "`"$_`"" }) -join " " $AllFilters = "$AllFilters tags:($tags)" } - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } diff --git a/src/Public/Get-XoVbdAlarm.ps1 b/src/Public/Get-XoVbdAlarm.ps1 new file mode 100644 index 0000000..215f28a --- /dev/null +++ b/src/Public/Get-XoVbdAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVbdAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VBD. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VBD. Accepts one or more VBD UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VbdUuid + The UUID(s) of the VBD whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVbdAlarm -VbdUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVbd | Get-XoVbdAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VbdUuid) + { + $uri = "$script:XoHost/rest/v0/vbds/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVbdMessage.ps1 b/src/Public/Get-XoVbdMessage.ps1 new file mode 100644 index 0000000..0cc8a56 --- /dev/null +++ b/src/Public/Get-XoVbdMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVbdMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific VBD. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra VBD. Accepts one or more VBD UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VbdUuid + The UUID(s) of the VBD whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVbdMessage -VbdUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVbd | Get-XoVbdMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $VbdUuid) + { + $uri = "$script:XoHost/rest/v0/vbds/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoVbdTask.ps1 b/src/Public/Get-XoVbdTask.ps1 new file mode 100644 index 0000000..d24645e --- /dev/null +++ b/src/Public/Get-XoVbdTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVbdTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VBD. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VBD. Accepts one or more VBD UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VbdUuid + The UUID(s) of the VBD whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVbdTask -VbdUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVbd | Get-XoVbdTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VbdUuid) + { + $uri = "$script:XoHost/rest/v0/vbds/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoVdi.ps1 b/src/Public/Get-XoVdi.ps1 new file mode 100644 index 0000000..6d19095 --- /dev/null +++ b/src/Public/Get-XoVdi.ps1 @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdi +{ + <# + .SYNOPSIS + Get VDIs from Xen Orchestra. + .DESCRIPTION + Retrieves VDIs from Xen Orchestra. Can retrieve specific VDIs by their UUID + or filter VDIs by various criteria. + .PARAMETER VdiUuid + The UUID(s) of the VDI(s) to retrieve. + .PARAMETER SrUuid + Filter VDIs by storage repository UUID. + .PARAMETER Filter + Custom filter to apply to the VDI query. + .PARAMETER Limit + Maximum number of results to return. Default is 25 if not specified. + .EXAMPLE + Get-XoVdi + Returns up to 25 VDIs. + .EXAMPLE + Get-XoVdi -Limit 0 + Returns all VDIs without limit. + .EXAMPLE + Get-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" + Returns the VDI with the specified UUID. + .EXAMPLE + Get-XoVdi -SrUuid "12345678-abcd-1234-abcd-1234567890ab" + Returns VDIs on the specified storage repository (up to default limit). + .EXAMPLE + Get-XoVdi -Filter "name_label:backup*" + Returns VDIs with names starting with "backup" (up to default limit). + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VdiUuid")] + [Alias("VdiId")] + [string[]]$VdiUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$SrUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") + } + + $params = @{ fields = $script:XO_VDI_FIELDS } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "VdiUuid") + { + foreach ($id in $VdiUuid) + { + Get-XoSingleVdiById -VdiUuid $id -Params $params + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + $filterParts = @() + + if ($SrUuid) + { + $filterParts += "`$SR:$SrUuid" + } + + if ($Filter) + { + $filterParts += $Filter + } + + if ($filterParts.Count -gt 0) + { + $params['filter'] = $filterParts -join " " + } + + if ($Limit) + { + $params['limit'] = $Limit + } + + try + { + Write-Verbose "Getting VDIs with parameters: $($params | ConvertTo-Json -Compress)" + $uri = "$script:XoHost/rest/v0/vdis" + $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if (!$response -or $response.Count -eq 0) + { + Write-Verbose "No VDIs found matching criteria" + return + } + + Write-Verbose "Found $($response.Count) VDIs" + + foreach ($vdiItem in $response) + { + ConvertTo-XoVdiObject -InputObject $vdiItem + } + } + catch + { + throw ("Failed to list VDIs. Error: {0}" -f $_) + } + } + } +} diff --git a/src/Public/Get-XoVdiAlarm.ps1 b/src/Public/Get-XoVdiAlarm.ps1 new file mode 100644 index 0000000..ed750a1 --- /dev/null +++ b/src/Public/Get-XoVdiAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdiAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VDI. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VDI. Accepts one or more VDI UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VdiUuid + The UUID(s) of the VDI whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVdiAlarm -VdiUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVdi | Get-XoVdiAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VdiUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VdiUuid) + { + $uri = "$script:XoHost/rest/v0/vdis/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVdiMessage.ps1 b/src/Public/Get-XoVdiMessage.ps1 new file mode 100644 index 0000000..6910448 --- /dev/null +++ b/src/Public/Get-XoVdiMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdiMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific VDI. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra VDI. Accepts one or more VDI UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VdiUuid + The UUID(s) of the VDI whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVdiMessage -VdiUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVdi | Get-XoVdiMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VdiUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $VdiUuid) + { + $uri = "$script:XoHost/rest/v0/vdis/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoVdiSnapshot.ps1 b/src/Public/Get-XoVdiSnapshot.ps1 new file mode 100644 index 0000000..972742c --- /dev/null +++ b/src/Public/Get-XoVdiSnapshot.ps1 @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdiSnapshot +{ + <# + .SYNOPSIS + Get VDI snapshots from Xen Orchestra. + .DESCRIPTION + Retrieves VDI snapshots from Xen Orchestra. Can retrieve specific snapshots by their UUID + or filter snapshots by various criteria. + .PARAMETER VdiSnapshotUuid + The UUID(s) of the VDI snapshot(s) to retrieve. + .PARAMETER Filter + Filter to apply to the snapshot query. + .PARAMETER Limit + Maximum number of results to return. Default is 25 if not specified. + .EXAMPLE + Get-XoVdiSnapshot + Returns up to 25 VDI snapshots. + .EXAMPLE + Get-XoVdiSnapshot -Limit 0 + Returns all VDI snapshots without limit. + .EXAMPLE + Get-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" + Returns the VDI snapshot with the specified UUID. + .EXAMPLE + Get-XoVdiSnapshot -Filter "name_label:backup*" + Returns VDI snapshots with names starting with "backup" (up to default limit). + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VdiSnapshotUuid")] + [Alias("VdiSnapshotId")] + [string[]]$VdiSnapshotUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") + } + + $params = @{ fields = $script:XO_VDI_SNAPSHOT_FIELDS } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "VdiSnapshotUuid") + { + foreach ($id in $VdiSnapshotUuid) + { + Get-XoSingleVdiSnapshotById -VdiSnapshotUuid $id -Params $params + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) + { + $params['filter'] = $Filter + } + + if ($Limit) + { + $params['limit'] = $Limit + } + + try + { + Write-Verbose "Getting VDI snapshots with parameters: $($params | ConvertTo-Json -Compress)" + $uri = "$script:XoHost/rest/v0/vdi-snapshots" + $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if (!$response -or $response.Count -eq 0) + { + Write-Verbose "No VDI snapshots found matching criteria" + return + } + + Write-Verbose "Found $($response.Count) VDI snapshots" + + foreach ($snapshotItem in $response) + { + ConvertTo-XoVdiSnapshotObject -InputObject $snapshotItem + } + } + catch + { + throw ("Failed to list VDI snapshots. Error: {0}" -f $_) + } + } + } +} diff --git a/src/Public/Get-XoVdiSnapshotAlarm.ps1 b/src/Public/Get-XoVdiSnapshotAlarm.ps1 new file mode 100644 index 0000000..1cc5fc2 --- /dev/null +++ b/src/Public/Get-XoVdiSnapshotAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdiSnapshotAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VDI snapshot. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VDI snapshot. Accepts one or more VDI snapshot UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VdiSnapshotUuid + The UUID(s) of the VDI snapshot whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVdiSnapshotAlarm -VdiSnapshotUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVdiSnapshot | Get-XoVdiSnapshotAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VdiSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VdiSnapshotUuid) + { + $uri = "$script:XoHost/rest/v0/vdi-snapshots/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVdiSnapshotMessage.ps1 b/src/Public/Get-XoVdiSnapshotMessage.ps1 new file mode 100644 index 0000000..4a7b9cb --- /dev/null +++ b/src/Public/Get-XoVdiSnapshotMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdiSnapshotMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific VDI snapshot. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra VDI snapshot. Accepts one or more VDI snapshot UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VdiSnapshotUuid + The UUID(s) of the VDI snapshot whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVdiSnapshotMessage -VdiSnapshotUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVdiSnapshot | Get-XoVdiSnapshotMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VdiSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $VdiSnapshotUuid) + { + $uri = "$script:XoHost/rest/v0/vdi-snapshots/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoVdiSnapshotTask.ps1 b/src/Public/Get-XoVdiSnapshotTask.ps1 new file mode 100644 index 0000000..4f56857 --- /dev/null +++ b/src/Public/Get-XoVdiSnapshotTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdiSnapshotTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VDI snapshot. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VDI snapshot. Accepts one or more VDI snapshot UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VdiSnapshotUuid + The UUID(s) of the VDI snapshot whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVdiSnapshotTask -VdiSnapshotUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVdiSnapshot | Get-XoVdiSnapshotTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VdiSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VdiSnapshotUuid) + { + $uri = "$script:XoHost/rest/v0/vdi-snapshots/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoVdiTask.ps1 b/src/Public/Get-XoVdiTask.ps1 new file mode 100644 index 0000000..61121b5 --- /dev/null +++ b/src/Public/Get-XoVdiTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVdiTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VDI. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VDI. Accepts one or more VDI UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VdiUuid + The UUID(s) of the VDI whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVdiTask -VdiUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVdi | Get-XoVdiTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VdiUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VdiUuid) + { + $uri = "$script:XoHost/rest/v0/vdis/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/vif.ps1 b/src/Public/Get-XoVif.ps1 similarity index 51% rename from src/vif.ps1 rename to src/Public/Get-XoVif.ps1 index 7912344..b8b051f 100644 --- a/src/vif.ps1 +++ b/src/Public/Get-XoVif.ps1 @@ -1,28 +1,24 @@ # SPDX-License-Identifier: Apache-2.0 -$script:XO_VIF_FIELDS = "allowedIpv4Addresses,allowedIpv6Addresses,attached,device,lockingMode,MAC,MTU,txChecksumming,uuid,`$network,`$pool" - -function ConvertTo-XoVifObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - VifUuid = $InputObject.uuid - Name = $InputObject.name_label - Description = $InputObject.name_description - } - Set-XoObject $InputObject -TypeName XoPowershell.Vif -Properties $props - } -} - -function Get-XoVif { +function Get-XoVif +{ <# .SYNOPSIS Query VIFs by UUID or condition. .DESCRIPTION Get VIF details. You can specify VIFs by their UUIDs or properties. + .PARAMETER VifUuid + The UUID(s) of the VIF(s) to retrieve. + .PARAMETER Name + Filter VIFs matching the specified name. + .PARAMETER Filter + Custom filter expression for the VIF query. + .PARAMETER Tag + Filter VIFs matching any of the specified tags. + .PARAMETER Limit + Maximum number of VIFs to return. + .EXAMPLE + Get-XoVif -VifUuid "12345678-abcd-1234-abcd-1234567890ab" #> [CmdletBinding(DefaultParameterSetName = "Filter")] param ( @@ -50,38 +46,48 @@ function Get-XoVif { [int]$Limit = $script:XoSessionLimit ) - begin { + begin + { $params = @{ fields = $script:XO_VIF_FIELDS } } - process { - if ($PSCmdlet.ParameterSetName -eq "VifUuid") { - foreach ($id in $VifUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "VifUuid") + { + foreach ($id in $VifUuid) + { ConvertTo-XoVifObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vifs/$id" @script:XoRestParameters -Body $params) } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { $AllFilters = $Filter - if ($Name) { + if ($Name) + { $AllFilters = "$AllFilters name_label:`"$Name`"" } - if ($Tag) { + if ($Tag) + { $tags = ($tag | ForEach-Object { "`"$_`"" }) -join " " $AllFilters = "$AllFilters tags:($tags)" } - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } @@ -89,38 +95,3 @@ function Get-XoVif { } } } - -function Set-XoVif { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("VifId")] - [string]$VifUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description, - - [Parameter()] - [string[]]$Tags - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - if ($PSBoundParameters.ContainsKey("Tags")) { - $params["tags"] = $Tags - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vifs/$VifUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} diff --git a/src/Public/Get-XoVifAlarm.ps1 b/src/Public/Get-XoVifAlarm.ps1 new file mode 100644 index 0000000..11ec6d3 --- /dev/null +++ b/src/Public/Get-XoVifAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVifAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VIF. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VIF. Accepts one or more VIF UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VifUuid + The UUID(s) of the VIF whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVifAlarm -VifUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVif | Get-XoVifAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VifUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VifUuid) + { + $uri = "$script:XoHost/rest/v0/vifs/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVifMessage.ps1 b/src/Public/Get-XoVifMessage.ps1 new file mode 100644 index 0000000..c8f7d31 --- /dev/null +++ b/src/Public/Get-XoVifMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVifMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific VIF. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra VIF. Accepts one or more VIF UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VifUuid + The UUID(s) of the VIF whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVifMessage -VifUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVif | Get-XoVifMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VifUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $VifUuid) + { + $uri = "$script:XoHost/rest/v0/vifs/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoVifTask.ps1 b/src/Public/Get-XoVifTask.ps1 new file mode 100644 index 0000000..1331bef --- /dev/null +++ b/src/Public/Get-XoVifTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVifTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VIF. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VIF. Accepts one or more VIF UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VifUuid + The UUID(s) of the VIF whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVifTask -VifUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVif | Get-XoVifTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VifUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VifUuid) + { + $uri = "$script:XoHost/rest/v0/vifs/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoVm.ps1 b/src/Public/Get-XoVm.ps1 new file mode 100644 index 0000000..f0466d4 --- /dev/null +++ b/src/Public/Get-XoVm.ps1 @@ -0,0 +1,157 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVm +{ + <# + .SYNOPSIS + Get VMs from Xen Orchestra. + .DESCRIPTION + Retrieves VMs from Xen Orchestra. Can retrieve specific VMs by their UUID + or filter VMs by power state, tags, or custom filters. + .PARAMETER VmUuid + The UUID(s) of the VM(s) to retrieve. + .PARAMETER PowerState + Filter VMs by power state. Valid values: Running, Halted, Suspended. + .PARAMETER Tag + Filter VMs by one or more tags. + .PARAMETER Filter + Custom filter to apply to the VM query. + .PARAMETER PoolUuid + UUID of the pool whose VMs to retrieve. + .PARAMETER HostUuid + UUID of the host whose VMs to retrieve. + .PARAMETER Limit + Maximum number of results to return. Default is 25 if not specified. + .EXAMPLE + Get-XoVm + Returns up to 25 VMs. + .EXAMPLE + Get-XoVm -Limit 0 + Returns all VMs without limit. + .EXAMPLE + Get-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" + Returns the VM with the specified UUID. + .EXAMPLE + Get-XoVm -PowerState Running + Returns running VMs (up to default limit). + .EXAMPLE + Get-XoVm -Tag "Production" + Returns VMs tagged with "Production" (up to default limit). + .EXAMPLE + Get-XoVm -Filter "name_label:test*" + Returns VMs with names starting with "test" (up to default limit). + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VmUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [Alias("VmId")] + [string[]]$VmUuid, + + [Parameter(ParameterSetName = "Filter")] + [ValidateSet("Running", "Halted", "Suspended")] + [string[]]$PowerState, + + [Parameter(ParameterSetName = "Filter")] + [string[]]$Tag, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = "Filter")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$PoolUuid, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = "Filter")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$HostUuid, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") + } + + $params = @{ fields = $script:XO_VM_FIELDS } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "VmUuid") + { + foreach ($id in $VmUuid) + { + Get-XoSingleVmById -VmUuid $id + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + $AllFilters = $Filter + + if ($PowerState) + { + $AllFilters = "$AllFilters power_state:($($PowerState -join '|'))" + } + + if ($Tag) + { + $AllFilters = "$AllFilters tags:($($Tag -join '&'))" + } + + if ($PoolUuid) + { + $AllFilters = "$AllFilters `$pool:$PoolUuid" + } + + if ($HostUuid) + { + $AllFilters = "$AllFilters `$container:$HostUuid" + } + + if ($AllFilters) + { + Write-Verbose "Filter: $AllFilters" + $params["filter"] = $AllFilters + } + + if ($Limit) + { + $params['limit'] = $Limit + } + + try + { + $uri = "$script:XoHost/rest/v0/vms" + Write-Verbose "Getting VMs from $uri with parameters: $($params | ConvertTo-Json -Compress)" + + $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if (!$response -or $response.Count -eq 0) + { + Write-Verbose "No VMs found matching criteria" + return + } + + Write-Verbose "Found $($response.Count) VMs" + + foreach ($vmItem in $response) + { + ConvertTo-XoVmObject -InputObject $vmItem + } + } + catch + { + throw ("Failed to list VMs. Error: {0}" -f $_) + } + } + } +} diff --git a/src/Public/Get-XoVmAlarm.ps1 b/src/Public/Get-XoVmAlarm.ps1 new file mode 100644 index 0000000..86f92a2 --- /dev/null +++ b/src/Public/Get-XoVmAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VM. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VM. Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmUuid + The UUID(s) of the VM whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmAlarm -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" + .EXAMPLE + Get-XoVm | Get-XoVmAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VmUuid) + { + $uri = "$script:XoHost/rest/v0/vms/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVmBackupJob.ps1 b/src/Public/Get-XoVmBackupJob.ps1 new file mode 100644 index 0000000..f60ea34 --- /dev/null +++ b/src/Public/Get-XoVmBackupJob.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmBackupJob +{ + <# + .SYNOPSIS + Get backup jobs scoped to a specific VM. + .DESCRIPTION + Retrieves backup jobs attached to the specified Xen Orchestra VM. Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmUuid + The UUID(s) of the VM whose backup jobs should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmBackupJob -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" + .EXAMPLE + Get-XoVm | Get-XoVmBackupJob + #> + [CmdletBinding()] + [OutputType("XoPowershell.BackupJob")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_BACKUP_JOB_FIELDS + } + + process + { + foreach ($id in $VmUuid) + { + $uri = "$script:XoHost/rest/v0/vms/$id/backup-jobs" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoBackupJobObject + } + } +} + diff --git a/src/Public/Get-XoVmController.ps1 b/src/Public/Get-XoVmController.ps1 new file mode 100644 index 0000000..26c639e --- /dev/null +++ b/src/Public/Get-XoVmController.ps1 @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmController +{ + <# + .SYNOPSIS + List or query Xen Orchestra VM controllers. + .DESCRIPTION + Retrieves VM controllers (dom0 control-domain VMs) from Xen Orchestra. These are the privileged VMs that run on each host to manage guest VMs. When called without parameters the cmdlet returns up to the session-wide limit (see Set-XoSession); supply -VmControllerUuid to fetch specific entries or -Filter / -Limit to scope a list query. + .PARAMETER VmControllerUuid + One or more IDs of the VM controllers to retrieve. When omitted, the cmdlet enumerates VM controllers using Filter and Limit. + .PARAMETER Filter + XO filter expression applied server-side (same syntax as the REST `filter` query parameter, e.g. `status:success`). + .PARAMETER Limit + Maximum number of VM controllers to return when listing. Defaults to the session limit set by Connect-XoSession or Set-XoSession. + .EXAMPLE + Get-XoVmController + .EXAMPLE + Get-XoVmController -VmControllerUuid "" + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.VmController")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VmControllerUuid")] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmControllerUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "VmControllerUuid") + { + foreach ($id in $VmControllerUuid) + { + $uri = "$script:XoHost/rest/v0/vm-controllers/$id" + ConvertTo-XoVmControllerObject (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) { $params["filter"] = $Filter } + if ($Limit) { $params["limit"] = $Limit } + + $uri = "$script:XoHost/rest/v0/vm-controllers" + # the parentheses forces the resulting array to unpack, don't remove them! + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoVmControllerObject + } + } +} + diff --git a/src/Public/Get-XoVmControllerAlarm.ps1 b/src/Public/Get-XoVmControllerAlarm.ps1 new file mode 100644 index 0000000..9e2bec0 --- /dev/null +++ b/src/Public/Get-XoVmControllerAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmControllerAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VM controller. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VM controller. Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmControllerUuid + The UUID(s) of the VM controller whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmControllerAlarm -VmControllerUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmController | Get-XoVmControllerAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmControllerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VmControllerUuid) + { + $uri = "$script:XoHost/rest/v0/vm-controllers/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVmControllerMessage.ps1 b/src/Public/Get-XoVmControllerMessage.ps1 new file mode 100644 index 0000000..d89f7e8 --- /dev/null +++ b/src/Public/Get-XoVmControllerMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmControllerMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific VM controller. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra VM controller. Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmControllerUuid + The UUID(s) of the VM controller whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmControllerMessage -VmControllerUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmController | Get-XoVmControllerMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmControllerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $VmControllerUuid) + { + $uri = "$script:XoHost/rest/v0/vm-controllers/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoVmControllerTask.ps1 b/src/Public/Get-XoVmControllerTask.ps1 new file mode 100644 index 0000000..4357c29 --- /dev/null +++ b/src/Public/Get-XoVmControllerTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmControllerTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VM controller. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VM controller. Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmControllerUuid + The UUID(s) of the VM controller whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmControllerTask -VmControllerUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmController | Get-XoVmControllerTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmControllerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VmControllerUuid) + { + $uri = "$script:XoHost/rest/v0/vm-controllers/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoVmControllerVdi.ps1 b/src/Public/Get-XoVmControllerVdi.ps1 new file mode 100644 index 0000000..c2308e7 --- /dev/null +++ b/src/Public/Get-XoVmControllerVdi.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmControllerVdi +{ + <# + .SYNOPSIS + Get virtual disks (VDIs) scoped to a specific VM controller. + .DESCRIPTION + Retrieves virtual disks (VDIs) attached to the specified Xen Orchestra VM controller. Accepts one or more VM controller UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmControllerUuid + The UUID(s) of the VM controller whose virtual disks (VDIs) should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmControllerVdi -VmControllerUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmController | Get-XoVmControllerVdi + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vdi")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmControllerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_VDI_FIELDS + } + + process + { + foreach ($id in $VmControllerUuid) + { + $uri = "$script:XoHost/rest/v0/vm-controllers/$id/vdis" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoVdiObject + } + } +} + diff --git a/src/Public/Get-XoVmDashboard.ps1 b/src/Public/Get-XoVmDashboard.ps1 new file mode 100644 index 0000000..0884d4e --- /dev/null +++ b/src/Public/Get-XoVmDashboard.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmDashboard +{ + <# + .SYNOPSIS + Get dashboard summary scoped to a specific VM. + .DESCRIPTION + Retrieves dashboard summary attached to the specified Xen Orchestra VM. Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmUuid + The UUID(s) of the VM whose dashboard summary should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmDashboard -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" + .EXAMPLE + Get-XoVm | Get-XoVmDashboard + #> + [CmdletBinding()] + [OutputType("XoPowershell.Dashboard")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + foreach ($id in $VmUuid) + { + $uri = "$script:XoHost/rest/v0/vms/$id/dashboard" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoDashboardObject + } + } +} + diff --git a/src/Public/Get-XoVmSnapshot.ps1 b/src/Public/Get-XoVmSnapshot.ps1 new file mode 100644 index 0000000..3e8cb7c --- /dev/null +++ b/src/Public/Get-XoVmSnapshot.ps1 @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmSnapshot +{ + <# + .SYNOPSIS + Get VM snapshots. + .DESCRIPTION + Retrieves VM snapshots from Xen Orchestra. Can retrieve specific snapshots by their UUID + or filter snapshots by various criteria. + .PARAMETER VmSnapshotUuid + The UUID(s) of the VM snapshot(s) to retrieve. + .PARAMETER Filter + Filter to apply to the snapshot query. + .PARAMETER Limit + Maximum number of results to return. Default is 25 if not specified. + .EXAMPLE + Get-XoVmSnapshot + Returns up to 25 VM snapshots. + .EXAMPLE + Get-XoVmSnapshot -Limit 0 + Returns all VM snapshots without limit. + .EXAMPLE + Get-XoVmSnapshot -VmSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" + Returns the VM snapshot with the specified UUID. + .EXAMPLE + Get-XoVmSnapshot -Filter "name_label:backup" + Returns VM snapshots with "backup" in their name (up to default limit). + #> + [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.VmSnapshot")] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VmSnapshotUuid")] + [ValidateNotNullOrEmpty()] + [Alias("Snapshot")] + [string[]]$VmSnapshotUuid, + + [Parameter(ParameterSetName = "Filter")] + [string]$Filter, + + [Parameter(ParameterSetName = "Filter")] + [int]$Limit = $script:XoSessionLimit + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") + } + + $params = @{ fields = $script:XO_VM_SNAPSHOT_FIELDS } + } + + process + { + if ($PSCmdlet.ParameterSetName -eq "VmSnapshotUuid") + { + foreach ($id in $VmSnapshotUuid) + { + try + { + Write-Verbose "Getting VM snapshot with UUID $id" + $snapshotData = Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vm-snapshots/$id" @script:XoRestParameters + ConvertTo-XoVmSnapshotObject $snapshotData + } + catch + { + throw ("Failed to retrieve VM snapshot with UUID {0}: {1}" -f $id, $_) + } + } + } + } + + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { + if ($Filter) + { + $params["filter"] = $Filter + } + + if ($Limit) + { + $params["limit"] = $Limit + } + + try + { + $uri = "$script:XoHost/rest/v0/vm-snapshots" + Write-Verbose "Getting VM snapshots from $uri with parameters: $($params | ConvertTo-Json -Compress)" + + $snapshotsResponse = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if (!$snapshotsResponse -or $snapshotsResponse.Count -eq 0) + { + Write-Verbose "No VM snapshots found matching criteria" + return + } + + Write-Verbose "Found $($snapshotsResponse.Count) VM snapshots" + + foreach ($snapshotItem in $snapshotsResponse) + { + ConvertTo-XoVmSnapshotObject $snapshotItem + } + } + catch + { + throw ("Failed to list VM snapshots. Error: {0}" -f $_) + } + } + } +} diff --git a/src/Public/Get-XoVmSnapshotAlarm.ps1 b/src/Public/Get-XoVmSnapshotAlarm.ps1 new file mode 100644 index 0000000..0fcbfdc --- /dev/null +++ b/src/Public/Get-XoVmSnapshotAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmSnapshotAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VM snapshot. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VM snapshot. Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmSnapshotUuid + The UUID(s) of the VM snapshot whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmSnapshotAlarm -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmSnapshot | Get-XoVmSnapshotAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VmSnapshotUuid) + { + $uri = "$script:XoHost/rest/v0/vm-snapshots/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVmSnapshotMessage.ps1 b/src/Public/Get-XoVmSnapshotMessage.ps1 new file mode 100644 index 0000000..a8f76c7 --- /dev/null +++ b/src/Public/Get-XoVmSnapshotMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmSnapshotMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific VM snapshot. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra VM snapshot. Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmSnapshotUuid + The UUID(s) of the VM snapshot whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmSnapshotMessage -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmSnapshot | Get-XoVmSnapshotMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $VmSnapshotUuid) + { + $uri = "$script:XoHost/rest/v0/vm-snapshots/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoVmSnapshotTask.ps1 b/src/Public/Get-XoVmSnapshotTask.ps1 new file mode 100644 index 0000000..c18211a --- /dev/null +++ b/src/Public/Get-XoVmSnapshotTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmSnapshotTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VM snapshot. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VM snapshot. Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmSnapshotUuid + The UUID(s) of the VM snapshot whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmSnapshotTask -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmSnapshot | Get-XoVmSnapshotTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VmSnapshotUuid) + { + $uri = "$script:XoHost/rest/v0/vm-snapshots/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoVmSnapshotVdi.ps1 b/src/Public/Get-XoVmSnapshotVdi.ps1 new file mode 100644 index 0000000..7f16a28 --- /dev/null +++ b/src/Public/Get-XoVmSnapshotVdi.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmSnapshotVdi +{ + <# + .SYNOPSIS + Get virtual disks (VDIs) scoped to a specific VM snapshot. + .DESCRIPTION + Retrieves virtual disks (VDIs) attached to the specified Xen Orchestra VM snapshot. Accepts one or more VM snapshot UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmSnapshotUuid + The UUID(s) of the VM snapshot whose virtual disks (VDIs) should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmSnapshotVdi -VmSnapshotUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmSnapshot | Get-XoVmSnapshotVdi + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vdi")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_VDI_FIELDS + } + + process + { + foreach ($id in $VmSnapshotUuid) + { + $uri = "$script:XoHost/rest/v0/vm-snapshots/$id/vdis" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoVdiObject + } + } +} + diff --git a/src/Public/Get-XoVmStat.ps1 b/src/Public/Get-XoVmStat.ps1 new file mode 100644 index 0000000..4399497 --- /dev/null +++ b/src/Public/Get-XoVmStat.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmStat +{ + <# + .SYNOPSIS + Get performance statistics scoped to a specific VM. + .DESCRIPTION + Retrieves performance statistics attached to the specified Xen Orchestra VM. Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmUuid + The UUID(s) of the VM whose performance statistics should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmStat -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" + .EXAMPLE + Get-XoVm | Get-XoVmStat + #> + [CmdletBinding()] + [OutputType("XoPowershell.Stat")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + + } + + process + { + foreach ($id in $VmUuid) + { + $uri = "$script:XoHost/rest/v0/vms/$id/stats" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoStatObject + } + } +} + diff --git a/src/Public/Get-XoVmTask.ps1 b/src/Public/Get-XoVmTask.ps1 new file mode 100644 index 0000000..05f50bb --- /dev/null +++ b/src/Public/Get-XoVmTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VM. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VM. Accepts one or more VM UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmUuid + The UUID(s) of the VM whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmTask -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" + .EXAMPLE + Get-XoVm | Get-XoVmTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VmUuid) + { + $uri = "$script:XoHost/rest/v0/vms/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/vm-template.ps1 b/src/Public/Get-XoVmTemplate.ps1 similarity index 60% rename from src/vm-template.ps1 rename to src/Public/Get-XoVmTemplate.ps1 index aa02822..aa24b90 100644 --- a/src/vm-template.ps1 +++ b/src/Public/Get-XoVmTemplate.ps1 @@ -1,44 +1,27 @@ # SPDX-License-Identifier: Apache-2.0 -# see vm.ps1 for XO_VM_TEMPLATE_FIELDS (which depends on XO_VM_FIELDS) - -function ConvertTo-XoVmTemplateObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - VmTemplateUuid = $InputObject.uuid - Name = $InputObject.name_label - Description = $InputObject.name_description - OsVersion = $InputObject.os_version - Parent = $InputObject.parent - HostUuid = $InputObject.$container - } - - if ($InputObject.CPUs.number) { - $props["CPUs"] = $InputObject.CPUs.number - } - elseif ($InputObject.CPUs.max) { - $props["CPUs"] = $InputObject.CPUs.max - } - else { - $props["CPUs"] = $null - } - - Set-XoObject $InputObject -TypeName XoPowershell.VmTemplate -Properties $props - } -} - -function Get-XoVmTemplate { +function Get-XoVmTemplate +{ <# .SYNOPSIS List or query VM templates. .DESCRIPTION Get Xen Orchestra VM templates by UUID or list all existing VM templates. + .PARAMETER VmTemplateUuid + The UUID(s) of the VM template(s) to retrieve. + .PARAMETER Default + Only return default VM templates when set. + .PARAMETER PoolUuid + UUID of the pool whose templates to retrieve. + .PARAMETER Filter + Custom filter expression for the template query. + .PARAMETER Limit + Maximum number of VM templates to return. + .EXAMPLE + Get-XoVmTemplate -VmTemplateUuid "12345678-abcd-1234-abcd-1234567890ab" #> [CmdletBinding(DefaultParameterSetName = "Filter")] + [OutputType("XoPowershell.VmTemplate")] param ( # UUIDs of VM templates to query. [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VmTemplateUuid")] @@ -61,41 +44,52 @@ function Get-XoVmTemplate { [int]$Limit = $script:XoSessionLimit ) - begin { + begin + { $params = @{ fields = $script:XO_VM_TEMPLATE_FIELDS } } - process { - if ($PSCmdlet.ParameterSetName -eq "VmTemplateUuid") { - foreach ($id in $VmTemplateUuid) { + process + { + if ($PSCmdlet.ParameterSetName -eq "VmTemplateUuid") + { + foreach ($id in $VmTemplateUuid) + { ConvertTo-XoVmTemplateObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vm-templates/$id" @script:XoRestParameters -Body $params) } } } - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { + end + { + if ($PSCmdlet.ParameterSetName -eq "Filter") + { Write-Verbose $script:XO_VM_TEMPLATE_FIELDS $AllFilters = $Filter - if ($Default) { + if ($Default) + { $AllFilters = "$AllFilters isDefaultTemplate?" } - elseif ($PSBoundParameters.ContainsKey("Default")) { + elseif ($PSBoundParameters.ContainsKey("Default")) + { $AllFilters = "$AllFilters !isDefaultTemplate?" } - if ($PoolUuid) { + if ($PoolUuid) + { $AllFilters = "$AllFilters `$pool:$PoolUuid" } - if ($AllFilters) { + if ($AllFilters) + { $params["filter"] = $AllFilters } - if ($Limit) { + if ($Limit) + { $params["limit"] = $Limit } diff --git a/src/Public/Get-XoVmTemplateAlarm.ps1 b/src/Public/Get-XoVmTemplateAlarm.ps1 new file mode 100644 index 0000000..14a3388 --- /dev/null +++ b/src/Public/Get-XoVmTemplateAlarm.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmTemplateAlarm +{ + <# + .SYNOPSIS + Get alarms scoped to a specific VM template. + .DESCRIPTION + Retrieves alarms attached to the specified Xen Orchestra VM template. Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmTemplateUuid + The UUID(s) of the VM template whose alarms should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmTemplateAlarm -VmTemplateUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmTemplate | Get-XoVmTemplateAlarm + #> + [CmdletBinding()] + [OutputType("XoPowershell.Alarm")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmTemplateUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_ALARM_FIELDS + } + + process + { + foreach ($id in $VmTemplateUuid) + { + $uri = "$script:XoHost/rest/v0/vm-templates/$id/alarms" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoAlarmObject + } + } +} + diff --git a/src/Public/Get-XoVmTemplateMessage.ps1 b/src/Public/Get-XoVmTemplateMessage.ps1 new file mode 100644 index 0000000..8a2fc7a --- /dev/null +++ b/src/Public/Get-XoVmTemplateMessage.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmTemplateMessage +{ + <# + .SYNOPSIS + Get messages scoped to a specific VM template. + .DESCRIPTION + Retrieves messages attached to the specified Xen Orchestra VM template. Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmTemplateUuid + The UUID(s) of the VM template whose messages should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmTemplateMessage -VmTemplateUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmTemplate | Get-XoVmTemplateMessage + #> + [CmdletBinding()] + [OutputType("XoPowershell.Message")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmTemplateUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_MESSAGE_FIELDS + } + + process + { + foreach ($id in $VmTemplateUuid) + { + $uri = "$script:XoHost/rest/v0/vm-templates/$id/messages" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoMessageObject + } + } +} + diff --git a/src/Public/Get-XoVmTemplateTask.ps1 b/src/Public/Get-XoVmTemplateTask.ps1 new file mode 100644 index 0000000..03e9ced --- /dev/null +++ b/src/Public/Get-XoVmTemplateTask.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmTemplateTask +{ + <# + .SYNOPSIS + Get tasks scoped to a specific VM template. + .DESCRIPTION + Retrieves tasks attached to the specified Xen Orchestra VM template. Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmTemplateUuid + The UUID(s) of the VM template whose tasks should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmTemplateTask -VmTemplateUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmTemplate | Get-XoVmTemplateTask + #> + [CmdletBinding()] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmTemplateUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_TASK_FIELDS + } + + process + { + foreach ($id in $VmTemplateUuid) + { + $uri = "$script:XoHost/rest/v0/vm-templates/$id/tasks" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoTaskObject + } + } +} + diff --git a/src/Public/Get-XoVmTemplateVdi.ps1 b/src/Public/Get-XoVmTemplateVdi.ps1 new file mode 100644 index 0000000..7ccf7e8 --- /dev/null +++ b/src/Public/Get-XoVmTemplateVdi.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmTemplateVdi +{ + <# + .SYNOPSIS + Get virtual disks (VDIs) scoped to a specific VM template. + .DESCRIPTION + Retrieves virtual disks (VDIs) attached to the specified Xen Orchestra VM template. Accepts one or more VM template UUIDs; each is queried independently and the combined results are returned. + .PARAMETER VmTemplateUuid + The UUID(s) of the VM template whose virtual disks (VDIs) should be returned. Accepts pipeline input by property name. + .EXAMPLE + Get-XoVmTemplateVdi -VmTemplateUuid "00000000-0000-0000-0000-000000000000" + .EXAMPLE + Get-XoVmTemplate | Get-XoVmTemplateVdi + #> + [CmdletBinding()] + [OutputType("XoPowershell.Vdi")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string[]]$VmTemplateUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $params = @{} + $params["fields"] = $script:XO_VDI_FIELDS + } + + process + { + foreach ($id in $VmTemplateUuid) + { + $uri = "$script:XoHost/rest/v0/vm-templates/$id/vdis" + (Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params) | ConvertTo-XoVdiObject + } + } +} + diff --git a/src/Public/Get-XoVmVdi.ps1 b/src/Public/Get-XoVmVdi.ps1 new file mode 100644 index 0000000..1e8c4fa --- /dev/null +++ b/src/Public/Get-XoVmVdi.ps1 @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Get-XoVmVdi +{ + <# + .SYNOPSIS + Get virtual disks attached to a VM. + .DESCRIPTION + Retrieves all virtual disk images (VDIs) attached to a specified VM. + .PARAMETER VmUuid + The UUID of the VM to get VDIs for. + .EXAMPLE + Get-XoVmVdi -VmUuid "12345678-abcd-1234-abcd-1234567890ab" + Returns all virtual disks attached to the specified VM. + .EXAMPLE + Get-XoVm -PowerState Running | Get-XoVmVdi + Returns all virtual disks attached to running VMs. + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid + ) + + begin + { + $params = @{ + fields = $script:XO_VDI_FIELDS + } + } + + process + { + foreach ($id in $VmUuid) + { + (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/vdis" @script:XoRestParameters -Body $params) | ConvertTo-XoVdiObject + } + } +} diff --git a/src/Public/Import-XoSrVdi.ps1 b/src/Public/Import-XoSrVdi.ps1 new file mode 100644 index 0000000..ccbef18 --- /dev/null +++ b/src/Public/Import-XoSrVdi.ps1 @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Import-XoSrVdi +{ + <# + .SYNOPSIS + Import a VDI file into a Xen Orchestra storage repository. + .DESCRIPTION + Calls POST /srs/{id}/vdis with the file contents as an application/octet-stream body. XO creates a VDI on the target SR and streams the uploaded content into it. Returns a task object that can be passed to Wait-XoTask. + .PARAMETER SrUuid + The UUID of the SR to import the VDI into. + .PARAMETER InFile + Path to the VDI file on disk (raw or vhd). + .EXAMPLE + Import-XoSrVdi -SrUuid "" -InFile "./disk.vhd" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$SrUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$InFile + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + $resolved = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($InFile) + if (-not (Test-Path -LiteralPath $resolved)) + { + throw "File not found: $resolved" + } + + if (-not $PSCmdlet.ShouldProcess($SrUuid, "import VDI from $resolved")) + { + return + } + + $uri = "$script:XoHost/rest/v0/srs/$SrUuid/vdis" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/octet-stream" -InFile $resolved | ForEach-Object { + if ($_ -is [string] -and $_ -match '\/rest\/v0\/tasks\/([0-9a-z]+)') + { + ConvertFrom-XoTaskHref $_ + } + elseif ($_ -and $_.PSObject.Properties.Name -contains 'id') + { + Get-XoTask -TaskId $_.id + } + else + { + $_ + } + } + } +} diff --git a/src/Public/Import-XoVdi.ps1 b/src/Public/Import-XoVdi.ps1 new file mode 100644 index 0000000..7f47ede --- /dev/null +++ b/src/Public/Import-XoVdi.ps1 @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Import-XoVdi +{ + <# + .SYNOPSIS + Import content into an existing VDI. + .DESCRIPTION + Calls PUT /vdis/{id}.{format} to upload raw VDI content (raw or vhd) to a pre-existing VDI. Use New-XoVdi first to create an empty VDI of the correct size. + .PARAMETER VdiUuid + The UUID of the target VDI. + .PARAMETER Format + Upload format: 'raw' or 'vhd'. + .PARAMETER InFile + Path to the file to upload. + .EXAMPLE + Import-XoVdi -VdiUuid "" -Format vhd -InFile "./disk.vhd" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VdiUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateSet("raw", "vhd")] + [string]$Format, + + [Parameter(Mandatory, Position = 2)] + [ValidateNotNullOrEmpty()] + [string]$InFile + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + $resolved = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($InFile) + if (-not (Test-Path -LiteralPath $resolved)) + { + throw "File not found: $resolved" + } + + if (-not $PSCmdlet.ShouldProcess($VdiUuid, "import VDI content from $resolved ($Format)")) + { + return + } + + $uri = "$script:XoHost/rest/v0/vdis/$VdiUuid.$Format" + Invoke-RestMethod -Uri $uri -Method Put @script:XoRestParameters -ContentType "application/octet-stream" -InFile $resolved + } +} diff --git a/src/Public/Import-XoVm.ps1 b/src/Public/Import-XoVm.ps1 new file mode 100644 index 0000000..c5629c6 --- /dev/null +++ b/src/Public/Import-XoVm.ps1 @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Import-XoVm +{ + <# + .SYNOPSIS + Import a VM file (.xva/.ova) into a pool. + .DESCRIPTION + Calls POST /pools/{id}/vms with the file contents as an application/octet-stream body. Large files are streamed from disk via Invoke-RestMethod's -InFile parameter. Returns a task object that can be passed to Wait-XoTask. + .PARAMETER PoolUuid + The UUID of the pool to import the VM into. + .PARAMETER InFile + Path to the .xva or .ova file on disk. + .EXAMPLE + Import-XoVm -PoolUuid "" -InFile "./mytemplate.xva" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$PoolUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$InFile + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + $resolved = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($InFile) + if (-not (Test-Path -LiteralPath $resolved)) + { + throw "File not found: $resolved" + } + + if (-not $PSCmdlet.ShouldProcess($PoolUuid, "import VM from $resolved")) + { + return + } + + $uri = "$script:XoHost/rest/v0/pools/$PoolUuid/vms" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/octet-stream" -InFile $resolved | ForEach-Object { + if ($_ -is [string] -and $_ -match '\/rest\/v0\/tasks\/([0-9a-z]+)') + { + ConvertFrom-XoTaskHref $_ + } + elseif ($_ -and $_.PSObject.Properties.Name -contains 'id') + { + Get-XoTask -TaskId $_.id + } + else + { + $_ + } + } + } +} diff --git a/src/Public/Invoke-XoHostManagementReconfigure.ps1 b/src/Public/Invoke-XoHostManagementReconfigure.ps1 new file mode 100644 index 0000000..3cc51a0 --- /dev/null +++ b/src/Public/Invoke-XoHostManagementReconfigure.ps1 @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoHostManagementReconfigure +{ + <# + .SYNOPSIS + Reconfigure the management network on a host. + .DESCRIPTION + Points the host management interface at a different network/PIF. Pass the target as -Parameters (e.g. ``@{ pif = }``). Returns a task. + .PARAMETER HostUuid + The UUID of the host to act on. + .PARAMETER Parameters + Hashtable of action body parameters. See the linked XO REST documentation for the expected fields. + .EXAMPLE + Invoke-XoHostManagementReconfigure -HostUuid "" -Parameters @{ } + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$HostUuid, + + [Parameter()] + [hashtable]$Parameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if ($PSCmdlet.ShouldProcess($HostUuid, "reconfigure management")) + { + $uri = "$script:XoHost/rest/v0/hosts/$HostUuid/actions/management_reconfigure" + $body = if ($Parameters) { [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $Parameters -Depth 99)) } else { [byte[]]@() } + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $body | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } +} + diff --git a/src/Public/Invoke-XoPoolManagementReconfigure.ps1 b/src/Public/Invoke-XoPoolManagementReconfigure.ps1 new file mode 100644 index 0000000..6ccd84b --- /dev/null +++ b/src/Public/Invoke-XoPoolManagementReconfigure.ps1 @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoPoolManagementReconfigure +{ + <# + .SYNOPSIS + Reconfigure the management network of a Xen Orchestra pool. + .DESCRIPTION + Points the pool's management interface at a different network. Thin wrapper + around the internal Invoke-XoPoolAction -Action management_reconfigure helper. + Returns a task object that can be passed to Wait-XoTask to monitor completion. + .PARAMETER PoolUuid + The UUID of the pool whose management network is being reconfigured. + .PARAMETER NetworkUuid + The UUID of the network to use as the new management network. + .PARAMETER AdditionalParameters + Optional hashtable of extra body parameters to merge into the + management_reconfigure action payload. Values here override NetworkUuid. + .EXAMPLE + Invoke-XoPoolManagementReconfigure -PoolUuid $pool.PoolUuid -NetworkUuid $net.NetworkUuid + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$PoolUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$NetworkUuid, + + [Parameter()] + [hashtable]$AdditionalParameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($PoolUuid, "reconfigure management network to $NetworkUuid")) + { + return + } + + $params = @{ + network = $NetworkUuid + } + + if ($AdditionalParameters) + { + foreach ($key in $AdditionalParameters.Keys) + { + $params[$key] = $AdditionalParameters[$key] + } + } + + Invoke-XoPoolAction -PoolUuid $PoolUuid -Action "management_reconfigure" -ActionParameters $params + } +} diff --git a/src/Public/Invoke-XoSrForget.ps1 b/src/Public/Invoke-XoSrForget.ps1 new file mode 100644 index 0000000..e0e49c2 --- /dev/null +++ b/src/Public/Invoke-XoSrForget.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoSrForget +{ + <# + .SYNOPSIS + Forget one or more Xen Orchestra SRs. + .DESCRIPTION + Detaches the SR from the pool without destroying the underlying storage (the data and VDIs remain on the remote; they can be re-introduced later). + .PARAMETER SrUuid + The UUID(s) of the SR to act on. Accepts pipeline input by property name. + .EXAMPLE + Invoke-XoSrForget -SrUuid "" + .EXAMPLE + Invoke-XoSrForget -SrUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$SrUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $SrUuid) + { + if ($PSCmdlet.ShouldProcess($id, "forget")) + { + $uri = "$script:XoHost/rest/v0/srs/$id/actions/forget" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Invoke-XoSrReclaimSpace.ps1 b/src/Public/Invoke-XoSrReclaimSpace.ps1 new file mode 100644 index 0000000..a83716d --- /dev/null +++ b/src/Public/Invoke-XoSrReclaimSpace.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoSrReclaimSpace +{ + <# + .SYNOPSIS + Reclaim space on one or more Xen Orchestra SRs. + .DESCRIPTION + Triggers space reclamation (TRIM/UNMAP) on the SR. Useful on thin-provisioned storage to return freed blocks. + .PARAMETER SrUuid + The UUID(s) of the SR to act on. Accepts pipeline input by property name. + .EXAMPLE + Invoke-XoSrReclaimSpace -SrUuid "" + .EXAMPLE + Invoke-XoSrReclaimSpace -SrUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$SrUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $SrUuid) + { + if ($PSCmdlet.ShouldProcess($id, "reclaim space")) + { + $uri = "$script:XoHost/rest/v0/srs/$id/actions/reclaim_space" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Invoke-XoSrScan.ps1 b/src/Public/Invoke-XoSrScan.ps1 new file mode 100644 index 0000000..e435857 --- /dev/null +++ b/src/Public/Invoke-XoSrScan.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoSrScan +{ + <# + .SYNOPSIS + Rescan one or more Xen Orchestra SRs. + .DESCRIPTION + Forces XAPI to rescan the SR. Reconciles newly appeared or disappeared VDIs with the database. + .PARAMETER SrUuid + The UUID(s) of the SR to act on. Accepts pipeline input by property name. + .EXAMPLE + Invoke-XoSrScan -SrUuid "" + .EXAMPLE + Invoke-XoSrScan -SrUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$SrUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $SrUuid) + { + if ($PSCmdlet.ShouldProcess($id, "scan")) + { + $uri = "$script:XoHost/rest/v0/srs/$id/actions/scan" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Invoke-XoVmPause.ps1 b/src/Public/Invoke-XoVmPause.ps1 new file mode 100644 index 0000000..413065c --- /dev/null +++ b/src/Public/Invoke-XoVmPause.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoVmPause +{ + <# + .SYNOPSIS + Pause one or more Xen Orchestra VMs. + .DESCRIPTION + Freezes CPU execution of the VM without saving RAM state. Use Invoke-XoVmUnpause to resume. Not to be confused with Suspend-XoVm, which writes memory to disk. + .PARAMETER VmUuid + The UUID(s) of the VM to act on. Accepts pipeline input by property name. + .EXAMPLE + Invoke-XoVmPause -VmUuid "" + .EXAMPLE + Invoke-XoVmPause -VmUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, "pause")) + { + $uri = "$script:XoHost/rest/v0/vms/$id/actions/pause" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Invoke-XoVmUnpause.ps1 b/src/Public/Invoke-XoVmUnpause.ps1 new file mode 100644 index 0000000..7ee61b8 --- /dev/null +++ b/src/Public/Invoke-XoVmUnpause.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Invoke-XoVmUnpause +{ + <# + .SYNOPSIS + Unpause one or more Xen Orchestra VMs. + .DESCRIPTION + Resumes CPU execution of a paused VM (previously paused with Invoke-XoVmPause). + .PARAMETER VmUuid + The UUID(s) of the VM to act on. Accepts pipeline input by property name. + .EXAMPLE + Invoke-XoVmUnpause -VmUuid "" + .EXAMPLE + Invoke-XoVmUnpause -VmUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, "unpause")) + { + $uri = "$script:XoHost/rest/v0/vms/$id/actions/unpause" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Move-XoVdi.ps1 b/src/Public/Move-XoVdi.ps1 new file mode 100644 index 0000000..e5504f4 --- /dev/null +++ b/src/Public/Move-XoVdi.ps1 @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Move-XoVdi +{ + <# + .SYNOPSIS + Migrate a Xen Orchestra VDI to another storage repository. + .DESCRIPTION + Triggers a live VDI migration to a different SR. The destination SR UUID must be provided via -Parameters (e.g. ``@{ sr_id = }``); see the XO REST docs at /rest/v0/docs/#/vdis/MigrateVdi for the full schema. Returns a task object. + .PARAMETER VdiUuid + The UUID of the VDI to act on. + .PARAMETER Parameters + Hashtable of action body parameters. See the linked XO REST documentation for the expected fields. + .EXAMPLE + Move-XoVdi -VdiUuid "" -Parameters @{ } + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VdiUuid, + + [Parameter()] + [hashtable]$Parameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if ($PSCmdlet.ShouldProcess($VdiUuid, "migrate")) + { + $uri = "$script:XoHost/rest/v0/vdis/$VdiUuid/actions/migrate" + $body = if ($Parameters) { [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $Parameters -Depth 99)) } else { [byte[]]@() } + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $body | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } +} + diff --git a/src/Public/Move-XoVm.ps1 b/src/Public/Move-XoVm.ps1 new file mode 100644 index 0000000..8758a7e --- /dev/null +++ b/src/Public/Move-XoVm.ps1 @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Move-XoVm +{ + <# + .SYNOPSIS + Live-migrate a Xen Orchestra VM to another host. + .DESCRIPTION + Triggers a live VM migration. The destination host UUID (and optionally migration network / storage) must be provided via -Parameters. See /rest/v0/docs/#/vms/MigrateVm for the expected body. Returns a task object. + .PARAMETER VmUuid + The UUID of the VM to act on. + .PARAMETER Parameters + Hashtable of action body parameters. See the linked XO REST documentation for the expected fields. + .EXAMPLE + Move-XoVm -VmUuid "" -Parameters @{ } + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter()] + [hashtable]$Parameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if ($PSCmdlet.ShouldProcess($VmUuid, "migrate")) + { + $uri = "$script:XoHost/rest/v0/vms/$VmUuid/actions/migrate" + $body = if ($Parameters) { [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $Parameters -Depth 99)) } else { [byte[]]@() } + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $body | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } +} + diff --git a/src/Public/New-XoBondedNetwork.ps1 b/src/Public/New-XoBondedNetwork.ps1 new file mode 100644 index 0000000..d825b04 --- /dev/null +++ b/src/Public/New-XoBondedNetwork.ps1 @@ -0,0 +1,94 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoBondedNetwork +{ + <# + .SYNOPSIS + Create a new bonded network on a Xen Orchestra pool. + .DESCRIPTION + Creates a bonded network from a set of PIFs on the specified pool. Thin wrapper + around the internal Invoke-XoPoolAction -Action create_bonded_network helper. + Returns a task object that can be passed to Wait-XoTask to monitor completion. + .PARAMETER PoolUuid + The UUID of the pool to create the bonded network on. + .PARAMETER Name + The name of the new bonded network. + .PARAMETER PifUuid + The UUIDs of the PIFs to bond together. + .PARAMETER BondMode + The bonding mode. Typical values: balance-slb, active-backup, lacp. + .PARAMETER Description + Optional description of the new bonded network. + .PARAMETER AdditionalParameters + Optional hashtable of extra body parameters to merge into the + create_bonded_network action payload. Values here override the dedicated + parameters above. + .EXAMPLE + New-XoBondedNetwork -PoolUuid $pool.PoolUuid -Name "bond0" -PifUuid $p1,$p2 -BondMode lacp + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$PoolUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Name, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [Alias("PifIds")] + [string[]]$PifUuid, + + [Parameter(Mandatory)] + [ValidateSet("balance-slb", "active-backup", "lacp")] + [string]$BondMode, + + [Parameter()] + [string]$Description, + + [Parameter()] + [hashtable]$AdditionalParameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($Name, "create bonded network on pool $PoolUuid")) + { + return + } + + $params = @{ + name = $Name + pifIds = @($PifUuid) + bondMode = $BondMode + } + + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["description"] = $Description + } + + if ($AdditionalParameters) + { + foreach ($key in $AdditionalParameters.Keys) + { + $params[$key] = $AdditionalParameters[$key] + } + } + + Invoke-XoPoolAction -PoolUuid $PoolUuid -Action "create_bonded_network" -ActionParameters $params + } +} diff --git a/src/Public/New-XoEventSubscription.ps1 b/src/Public/New-XoEventSubscription.ps1 new file mode 100644 index 0000000..5c7d72f --- /dev/null +++ b/src/Public/New-XoEventSubscription.ps1 @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoEventSubscription +{ + <# + .SYNOPSIS + Create a new subscription on a Xen Orchestra event. + .DESCRIPTION + Calls POST /events/{id}/subscriptions to register a subscription that pushes filtered collection updates to the caller. + .PARAMETER EventId + The ID of the event to subscribe to. + .PARAMETER Collection + XO collection to watch (e.g. 'VM'). + .PARAMETER Fields + Fields to include in notification payloads. + .EXAMPLE + New-XoEventSubscription -EventId "events" -Collection "VM" -Fields id,name_label + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$EventId, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Collection, + + [Parameter()] + [string[]]$Fields + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($EventId, "add subscription")) + { + return + } + + $body = @{ collection = $Collection } + if ($PSBoundParameters.ContainsKey("Fields")) { $body["fields"] = @($Fields) } + + $bodyJson = ConvertTo-Json -InputObject $body -Depth 5 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/events/$EventId/subscriptions" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + } +} diff --git a/src/Public/New-XoGroup.ps1 b/src/Public/New-XoGroup.ps1 new file mode 100644 index 0000000..02648cc --- /dev/null +++ b/src/Public/New-XoGroup.ps1 @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoGroup +{ + <# + .SYNOPSIS + Create a new Xen Orchestra group. + .DESCRIPTION + Creates a new group via POST /groups. Groups are used to grant permissions to collections of users. + .PARAMETER Name + The name of the new group. + .EXAMPLE + New-XoGroup -Name "ops" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Group")] + param ( + [Parameter(Mandatory, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$Name + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($Name, "create group")) + { + return + } + + $params = @{ name = $Name } + $bodyJson = ConvertTo-Json -InputObject $params -Depth 3 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/groups" + $response = Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + + if ($response -is [string] -and $response -match '\/rest\/v0\/groups\/([0-9a-f-]+)') + { + Get-XoGroup -GroupId $matches[1] + } + elseif ($response -and $response.PSObject.Properties.Name -contains 'id') + { + Get-XoGroup -GroupId $response.id + } + else + { + $response + } + } +} diff --git a/src/Public/New-XoInternalNetwork.ps1 b/src/Public/New-XoInternalNetwork.ps1 new file mode 100644 index 0000000..5bdca68 --- /dev/null +++ b/src/Public/New-XoInternalNetwork.ps1 @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoInternalNetwork +{ + <# + .SYNOPSIS + Create a new internal network on a Xen Orchestra pool. + .DESCRIPTION + Creates an internal (host-local, no external uplink) network on the specified + pool. Thin wrapper around the internal Invoke-XoPoolAction -Action + create_internal_network helper. Returns a task object that can be passed to + Wait-XoTask to monitor completion. + .PARAMETER PoolUuid + The UUID of the pool to create the internal network on. + .PARAMETER Name + The name of the new internal network. + .PARAMETER Description + Optional description of the new internal network. + .PARAMETER AdditionalParameters + Optional hashtable of extra body parameters to merge into the + create_internal_network action payload. Values here override the dedicated + parameters above. + .EXAMPLE + New-XoInternalNetwork -PoolUuid $pool.PoolUuid -Name "private-lab" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$PoolUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [hashtable]$AdditionalParameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($Name, "create internal network on pool $PoolUuid")) + { + return + } + + $params = @{ + name = $Name + } + + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["description"] = $Description + } + + if ($AdditionalParameters) + { + foreach ($key in $AdditionalParameters.Keys) + { + $params[$key] = $AdditionalParameters[$key] + } + } + + Invoke-XoPoolAction -PoolUuid $PoolUuid -Action "create_internal_network" -ActionParameters $params + } +} diff --git a/src/Public/New-XoNetwork.ps1 b/src/Public/New-XoNetwork.ps1 new file mode 100644 index 0000000..35c94b7 --- /dev/null +++ b/src/Public/New-XoNetwork.ps1 @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoNetwork +{ + <# + .SYNOPSIS + Create a new network on a Xen Orchestra pool. + .DESCRIPTION + Creates a regular network on the specified pool. Thin wrapper around the + internal Invoke-XoPoolAction -Action create_network helper. Returns a task + object that can be passed to Wait-XoTask to monitor completion. + .PARAMETER PoolUuid + The UUID of the pool to create the network on. + .PARAMETER Name + The name of the new network. + .PARAMETER Description + Optional description of the new network. + .PARAMETER PifUuid + Optional UUID of the PIF to attach the network to. + .PARAMETER Vlan + Optional VLAN id for the new network. Use 0 for untagged. + .PARAMETER AdditionalParameters + Optional hashtable of extra body parameters to merge into the create_network + action payload. Values here override the dedicated parameters above. + .EXAMPLE + New-XoNetwork -PoolUuid $pool.PoolUuid -Name "frontend" -PifUuid $pif.PifUuid -Vlan 100 + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$PoolUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [string]$PifUuid, + + [Parameter()] + [ValidateRange(0, 4094)] + [int]$Vlan, + + [Parameter()] + [hashtable]$AdditionalParameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($Name, "create network on pool $PoolUuid")) + { + return + } + + $params = @{ + name = $Name + } + + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["description"] = $Description + } + if ($PSBoundParameters.ContainsKey("PifUuid")) + { + $params["pif"] = $PifUuid + } + if ($PSBoundParameters.ContainsKey("Vlan")) + { + $params["vlan"] = $Vlan + } + + if ($AdditionalParameters) + { + foreach ($key in $AdditionalParameters.Keys) + { + $params[$key] = $AdditionalParameters[$key] + } + } + + Invoke-XoPoolAction -PoolUuid $PoolUuid -Action "create_network" -ActionParameters $params + } +} diff --git a/src/Public/New-XoServer.ps1 b/src/Public/New-XoServer.ps1 new file mode 100644 index 0000000..9190652 --- /dev/null +++ b/src/Public/New-XoServer.ps1 @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoServer +{ + <# + .SYNOPSIS + Register a new XCP-ng/XenServer pool master with Xen Orchestra. + .DESCRIPTION + Calls POST /servers to add a pool master. The credentials are supplied as a PSCredential so the password is not exposed in plain text. Label and connection flags are optional; host/username/password are mandatory. + .PARAMETER HostName + The IP address or hostname of the pool master to register. + .PARAMETER Credential + PSCredential with the XCP-ng root (or equivalent) username and password. + .PARAMETER Label + Optional friendly label shown in the XO UI. + .PARAMETER AllowUnauthorized + Accept self-signed certificates when connecting to the pool master. + .EXAMPLE + New-XoServer -Host "192.168.1.10" -Credential (Get-Credential root) -Label "lab pool" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Server")] + param ( + [Parameter(Mandatory, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$HostName, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNull()] + [pscredential]$Credential, + + [Parameter()] + [string]$Label, + + [Parameter()] + [switch]$AllowUnauthorized + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($Host, "register XO server")) + { + return + } + + $body = @{ + host = $Host + username = $Credential.UserName + password = $Credential.GetNetworkCredential().Password + allowUnauthorized = [bool]$AllowUnauthorized + } + if ($PSBoundParameters.ContainsKey("Label")) + { + $body["label"] = $Label + } + + $bodyJson = ConvertTo-Json -InputObject $body -Depth 5 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/servers" + $response = Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + + if ($response -is [string] -and $response -match '\/rest\/v0\/servers\/([0-9a-f-]+)') + { + Get-XoServer -ServerUuid $matches[1] + } + elseif ($response -and $response.PSObject.Properties.Name -contains 'id') + { + Get-XoServer -ServerUuid $response.id + } + else + { + $response + } + } +} diff --git a/src/Public/New-XoUser.ps1 b/src/Public/New-XoUser.ps1 new file mode 100644 index 0000000..bab9f1b --- /dev/null +++ b/src/Public/New-XoUser.ps1 @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoUser +{ + <# + .SYNOPSIS + Create a new Xen Orchestra user. + .DESCRIPTION + Creates a new user via POST /users. The name and password are supplied together as a PSCredential so the password never has to sit in a plain-text variable. Permission defaults to 'none' (read-only). + .PARAMETER Credential + PSCredential whose UserName becomes the XO user name and whose Password is sent to XO as the initial password. + .PARAMETER Permission + Permission level for the new user: 'none', 'viewer' (read-only), or 'admin'. Defaults to 'none'. + .EXAMPLE + New-XoUser -Credential (Get-Credential) -Permission viewer + .EXAMPLE + $cred = [pscredential]::new("alice@example.com", (ConvertTo-SecureString "s3cret" -AsPlainText -Force)) + New-XoUser -Credential $cred + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.User")] + param ( + [Parameter(Mandatory, Position = 0)] + [ValidateNotNull()] + [pscredential]$Credential, + + [Parameter()] + [ValidateSet("none", "viewer", "admin")] + [string]$Permission = "none" + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + $userName = $Credential.UserName + if (-not $PSCmdlet.ShouldProcess($userName, "create user")) + { + return + } + + $params = @{ + name = $userName + password = $Credential.GetNetworkCredential().Password + permission = $Permission + } + $bodyJson = ConvertTo-Json -InputObject $params -Depth 5 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/users" + $response = Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + + if ($response -is [string] -and $response -match '\/rest\/v0\/users\/([0-9a-f-]+)') + { + Get-XoUser -UserId $matches[1] + } + elseif ($response -and $response.PSObject.Properties.Name -contains 'id') + { + Get-XoUser -UserId $response.id + } + else + { + $response + } + } +} diff --git a/src/Public/New-XoUserAuthenticationToken.ps1 b/src/Public/New-XoUserAuthenticationToken.ps1 new file mode 100644 index 0000000..c88d23b --- /dev/null +++ b/src/Public/New-XoUserAuthenticationToken.ps1 @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoUserAuthenticationToken +{ + <# + .SYNOPSIS + Create a new API authentication token for a user. + .DESCRIPTION + Calls POST /users/{id}/authentication_tokens to mint a new XO API token. The token value is returned once; store it securely. + .PARAMETER UserId + The UUID of the user the token is minted for. + .PARAMETER Description + Human-readable description of what the token is for. + .PARAMETER ClientId + Optional stable client identifier to associate with the token. + .PARAMETER ExpiresIn + Optional expiration expressed as an XO duration string (e.g. '1 hour', '30 days'). + .EXAMPLE + New-XoUserAuthenticationToken -UserId "" -Description "ci pipeline" -ExpiresIn "30 days" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$UserId, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string]$ClientId, + + [Parameter()] + [string]$ExpiresIn + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($UserId, "create authentication token")) + { + return + } + + $body = @{} + if ($PSBoundParameters.ContainsKey("Description")) { $body["description"] = $Description } + if ($PSBoundParameters.ContainsKey("ClientId")) { $body["client"] = @{ id = $ClientId } } + if ($PSBoundParameters.ContainsKey("ExpiresIn")) { $body["expiresIn"] = $ExpiresIn } + + $bodyJson = ConvertTo-Json -InputObject $body -Depth 5 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/users/$UserId/authentication_tokens" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + } +} diff --git a/src/Public/New-XoVbd.ps1 b/src/Public/New-XoVbd.ps1 new file mode 100644 index 0000000..876fd14 --- /dev/null +++ b/src/Public/New-XoVbd.ps1 @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoVbd +{ + <# + .SYNOPSIS + Create a new Xen Orchestra VBD linking a VDI to a VM. + .DESCRIPTION + Calls POST /vbds to attach a VDI to a VM. The resulting VBD controls whether the VM boots from the VDI and whether it is read-only or read/write. + .PARAMETER VmUuid + The UUID of the VM to attach the VDI to. + .PARAMETER VdiUuid + The UUID of the VDI to attach. + .PARAMETER Bootable + Mark the VBD as bootable. + .PARAMETER Mode + Access mode: 'RW' (read/write, default) or 'RO' (read-only). + .EXAMPLE + New-XoVbd -VmUuid "" -VdiUuid "" -Bootable + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Vbd")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VdiUuid, + + [Parameter()] + [switch]$Bootable, + + [Parameter()] + [ValidateSet("RW", "RO")] + [string]$Mode = "RW" + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("VM $VmUuid", "attach VDI $VdiUuid")) + { + return + } + + $body = @{ + VM = $VmUuid + VDI = $VdiUuid + bootable = [bool]$Bootable + mode = $Mode + } + $bodyJson = ConvertTo-Json -InputObject $body -Depth 5 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/vbds" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + } +} diff --git a/src/Public/New-XoVdi.ps1 b/src/Public/New-XoVdi.ps1 new file mode 100644 index 0000000..5e54776 --- /dev/null +++ b/src/Public/New-XoVdi.ps1 @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoVdi +{ + <# + .SYNOPSIS + Create a new Xen Orchestra VDI on a storage repository. + .DESCRIPTION + Calls POST /vdis to create an empty VDI of the specified size on the given SR. Returns the created VDI (resolved via Get-XoVdi) or the raw server response. + .PARAMETER SrUuid + The UUID of the SR to create the VDI on. + .PARAMETER Name + Name label for the new VDI. + .PARAMETER SizeBytes + Virtual size of the VDI, in bytes. + .PARAMETER Description + Optional name_description for the new VDI. + .EXAMPLE + New-XoVdi -SrUuid "" -Name "scratch" -SizeBytes 10737418240 + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Vdi")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$SrUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Name, + + [Parameter(Mandatory, Position = 2)] + [ValidateRange(1, [long]::MaxValue)] + [long]$SizeBytes, + + [Parameter()] + [string]$Description + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($Name, "create VDI on SR $SrUuid")) + { + return + } + + $body = @{ + srId = $SrUuid + name_label = $Name + virtual_size = $SizeBytes + } + if ($PSBoundParameters.ContainsKey("Description")) { $body["name_description"] = $Description } + + $bodyJson = ConvertTo-Json -InputObject $body -Depth 5 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/vdis" + $response = Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + + $newId = $null + if ($response -is [string] -and $response -match '\/rest\/v0\/vdis\/([0-9a-f-]+)') + { + $newId = $matches[1] + } + elseif ($response -and $response.PSObject.Properties.Name -contains 'id') + { + $newId = $response.id + } + + if ($newId) + { + # XO may take a moment to publish the new VDI via GET, so fall back to a + # lightweight object if the follow-up lookup fails. + try + { + Get-XoVdi -VdiUuid $newId -ErrorAction Stop + } + catch + { + Write-Verbose "Get-XoVdi failed after create ($_); returning a stub." + [PSCustomObject]@{ + PSTypeName = 'XoPowershell.Vdi' + VdiUuid = $newId + Name = $Name + SrUuid = $SrUuid + Size = $SizeBytes + } + } + } + else + { + $response + } + } +} diff --git a/src/Public/New-XoVif.ps1 b/src/Public/New-XoVif.ps1 new file mode 100644 index 0000000..e4829f3 --- /dev/null +++ b/src/Public/New-XoVif.ps1 @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoVif +{ + <# + .SYNOPSIS + Create a new Xen Orchestra VIF attaching a VM to a network. + .DESCRIPTION + Calls POST /vifs to add a new virtual network interface to the specified VM on the specified network. + .PARAMETER VmUuid + The UUID of the VM to attach the VIF to. + .PARAMETER NetworkUuid + The UUID of the network to connect the VIF to. + .PARAMETER Mac + Optional MAC address. If omitted, XO generates one. + .EXAMPLE + New-XoVif -VmUuid "" -NetworkUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Vif")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$NetworkUuid, + + [Parameter()] + [string]$Mac + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("VM $VmUuid", "attach VIF on network $NetworkUuid")) + { + return + } + + $body = @{ + vmId = $VmUuid + networkId = $NetworkUuid + } + if ($PSBoundParameters.ContainsKey("Mac")) { $body["mac"] = $Mac } + + $bodyJson = ConvertTo-Json -InputObject $body -Depth 5 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/vifs" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + } +} diff --git a/src/Public/New-XoVm.ps1 b/src/Public/New-XoVm.ps1 new file mode 100644 index 0000000..153de5a --- /dev/null +++ b/src/Public/New-XoVm.ps1 @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoVm +{ + <# + .SYNOPSIS + Create a new VM on a Xen Orchestra pool. + .DESCRIPTION + Creates a new VM on the specified pool from a VM template. Thin wrapper around the + internal Invoke-XoPoolAction -Action create_vm helper. Returns a task object that + can be passed to Wait-XoTask to monitor completion. + .PARAMETER PoolUuid + The UUID of the pool to create the VM on. + .PARAMETER Name + The name_label to assign to the new VM. + .PARAMETER TemplateUuid + The UUID of the VM template to clone from. See Get-XoVmTemplate. + .PARAMETER Description + Optional name_description for the new VM. + .PARAMETER HostUuid + Optional UUID of the host the VM should prefer (affinity). See Get-XoHost. + .PARAMETER CPUs + Optional number of virtual CPUs to assign to the new VM. + .PARAMETER MemoryBytes + Optional amount of memory, in bytes, to assign to the new VM. + .PARAMETER AdditionalParameters + Optional hashtable of extra body parameters to merge into the create_vm action + payload. Values in this hashtable override any of the dedicated parameters above. + .EXAMPLE + New-XoVm -PoolUuid $pool.PoolUuid -Name "web-01" -TemplateUuid $tpl.VmTemplateUuid + .EXAMPLE + New-XoVm -PoolUuid $pool.PoolUuid -Name "web-01" -TemplateUuid $tpl.VmTemplateUuid -HostUuid $host.HostUuid -CPUs 2 -MemoryBytes 2147483648 + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$PoolUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Name, + + [Parameter(Mandatory)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [Alias("TemplateId")] + [string]$TemplateUuid, + + [Parameter()] + [string]$Description, + + [Parameter()] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [Alias("AffinityHost")] + [string]$HostUuid, + + [Parameter()] + [ValidateRange(1, 4096)] + [int]$CPUs, + + [Parameter()] + [ValidateRange(1, [long]::MaxValue)] + [long]$MemoryBytes, + + [Parameter()] + [hashtable]$AdditionalParameters + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($Name, "create VM on pool $PoolUuid")) + { + return + } + + $params = @{ + name_label = $Name + template = $TemplateUuid + } + + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("HostUuid")) + { + $params["affinity"] = $HostUuid + } + if ($PSBoundParameters.ContainsKey("CPUs")) + { + # swagger expects lowercase "cpus" in the create_vm body + $params["cpus"] = $CPUs + } + if ($PSBoundParameters.ContainsKey("MemoryBytes")) + { + $params["memory"] = $MemoryBytes + } + + if ($AdditionalParameters) + { + foreach ($key in $AdditionalParameters.Keys) + { + $params[$key] = $AdditionalParameters[$key] + } + } + + Invoke-XoPoolAction -PoolUuid $PoolUuid -Action "create_vm" -ActionParameters $params + } +} diff --git a/src/Public/New-XoVmSnapshot.ps1 b/src/Public/New-XoVmSnapshot.ps1 new file mode 100644 index 0000000..f0cbe4e --- /dev/null +++ b/src/Public/New-XoVmSnapshot.ps1 @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: Apache-2.0 + +function New-XoVmSnapshot +{ + <# + .SYNOPSIS + Create a snapshot of one or more VMs. + .DESCRIPTION + Creates a snapshot of the specified VMs. Optionally, you can specify a custom name + for the snapshot. + .PARAMETER VmUuid + The UUID(s) of the VM(s) to snapshot. + .PARAMETER SnapshotName + The name to give to the snapshot. If not specified, a default name will be used. + .PARAMETER NameLabel + Alias for SnapshotName. The name to give to the snapshot. + .EXAMPLE + New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" + Creates a snapshot of the VM with the specified UUID. + .EXAMPLE + New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" -SnapshotName "Before Update" + Creates a snapshot named "Before Update" of the VM with the specified UUID. + .EXAMPLE + New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" -NameLabel "Before Update" + Creates a snapshot named "Before Update" of the VM with the specified UUID. + .EXAMPLE + Get-XoVm -PowerState Running | New-XoVmSnapshot -SnapshotName "Backup $(Get-Date -Format 'yyyy-MM-dd')" + Creates a dated snapshot of all running VMs. + #> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid, + + [Parameter()] + [Alias("NameLabel")] + [string]$SnapshotName + ) + + begin + { + $params = Remove-XoEmptyValues @{ + name_label = $SnapshotName + } + } + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, "snapshot")) + { + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/snapshot" -Method Post @script:XoRestParameters -Body $params | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} diff --git a/src/Public/Remove-XoEmptyValue.ps1 b/src/Public/Remove-XoEmptyValue.ps1 new file mode 100644 index 0000000..16d8c99 --- /dev/null +++ b/src/Public/Remove-XoEmptyValue.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoEmptyValue +{ + <# + .SYNOPSIS + Removes XO empty values + + .DESCRIPTION + Removes null or empty entries from a hashtable. + + .PARAMETER InputObject + Target hashtable to filter entries. + + .EXAMPLE + Remove-XoEmptyValue -InputObject $MyObject + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + [OutputType([hashtable])] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [ValidateNotNull()] + [System.Collections.IDictionary]$InputObject + ) + process + { + if ($PSCmdlet.ShouldProcess('Remove Empty values from target')) + { + + $ret = @{} + + foreach ($kv in $InputObject.GetEnumerator()) + { + if ($null -ne $kv.Value -and ![string]::IsNullOrEmpty($kv.Value -as [string])) + { + $ret.Add($kv.Key, $kv.Value) + } + } + return $ret + } + } +} diff --git a/src/Public/Remove-XoEventSubscription.ps1 b/src/Public/Remove-XoEventSubscription.ps1 new file mode 100644 index 0000000..87df660 --- /dev/null +++ b/src/Public/Remove-XoEventSubscription.ps1 @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoEventSubscription +{ + <# + .SYNOPSIS + Remove a subscription from a Xen Orchestra event. + .DESCRIPTION + Calls DELETE /events/{id}/subscriptions/{subscriptionId} to detach a subscription previously registered with New-XoEventSubscription. + .PARAMETER EventId + The ID of the event that the subscription belongs to. + .PARAMETER SubscriptionId + The ID of the subscription to remove. + .EXAMPLE + Remove-XoEventSubscription -EventId "events" -SubscriptionId "sub-123" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$EventId, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$SubscriptionId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("event $EventId", "remove subscription $SubscriptionId")) + { + return + } + + $uri = "$script:XoHost/rest/v0/events/$EventId/subscriptions/$SubscriptionId" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } +} diff --git a/src/Public/Remove-XoGroup.ps1 b/src/Public/Remove-XoGroup.ps1 new file mode 100644 index 0000000..4a76a04 --- /dev/null +++ b/src/Public/Remove-XoGroup.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoGroup +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra groups. + .DESCRIPTION + Issues DELETE /groups/{id}. Members are not deleted - only the group itself is removed. + .PARAMETER GroupId + The UUID(s) of the group(s) to delete. + .EXAMPLE + Remove-XoGroup -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$GroupId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $GroupId) + { + if ($PSCmdlet.ShouldProcess($id, "delete group")) + { + $uri = "$script:XoHost/rest/v0/groups/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoGroupUser.ps1 b/src/Public/Remove-XoGroupUser.ps1 new file mode 100644 index 0000000..f30ccd0 --- /dev/null +++ b/src/Public/Remove-XoGroupUser.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoGroupUser +{ + <# + .SYNOPSIS + Remove a user from a Xen Orchestra group. + .DESCRIPTION + Disassociates a user from a group via DELETE /groups/{id}/users/{userId}. The user itself is not deleted - only the membership is removed. + .PARAMETER GroupId + The UUID of the group to remove the user from. + .PARAMETER UserId + The UUID of the user to remove from the group. + .EXAMPLE + Remove-XoGroupUser -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$GroupId, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$UserId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("group $GroupId", "remove user $UserId")) + { + return + } + + $uri = "$script:XoHost/rest/v0/groups/$GroupId/users/$UserId" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } +} diff --git a/src/Public/Remove-XoNetwork.ps1 b/src/Public/Remove-XoNetwork.ps1 new file mode 100644 index 0000000..fda123f --- /dev/null +++ b/src/Public/Remove-XoNetwork.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoNetwork +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra networks. + .DESCRIPTION + Issues DELETE /networks/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER NetworkUuid + The ID(s) of the network(s) to delete. + .EXAMPLE + Remove-XoNetwork -NetworkUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$NetworkUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $NetworkUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete network")) + { + $uri = "$script:XoHost/rest/v0/networks/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoServer.ps1 b/src/Public/Remove-XoServer.ps1 new file mode 100644 index 0000000..27d402c --- /dev/null +++ b/src/Public/Remove-XoServer.ps1 @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoServer +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra XO servers. + .DESCRIPTION + Issues DELETE /servers/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER ServerUuid + The ID(s) of the XO server(s) to delete. + .EXAMPLE + Remove-XoServer -ServerUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]]$ServerUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $ServerUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete XO server")) + { + $uri = "$script:XoHost/rest/v0/servers/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoTask.ps1 b/src/Public/Remove-XoTask.ps1 new file mode 100644 index 0000000..95116af --- /dev/null +++ b/src/Public/Remove-XoTask.ps1 @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoTask +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra tasks. + .DESCRIPTION + Issues DELETE /tasks/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER TaskId + The ID(s) of the task(s) to delete. + .EXAMPLE + Remove-XoTask -TaskId "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]]$TaskId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $TaskId) + { + if ($PSCmdlet.ShouldProcess($id, "delete task")) + { + $uri = "$script:XoHost/rest/v0/tasks/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoUser.ps1 b/src/Public/Remove-XoUser.ps1 new file mode 100644 index 0000000..889d382 --- /dev/null +++ b/src/Public/Remove-XoUser.ps1 @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoUser +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra users. + .DESCRIPTION + Issues DELETE /users/{id}. Accepts multiple UUIDs and pipeline input by property name. + .PARAMETER UserId + The UUID(s) of the user(s) to delete. + .EXAMPLE + Remove-XoUser -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" + .EXAMPLE + Get-XoUser | Where-Object permission -eq 'none' | Remove-XoUser + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$UserId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $UserId) + { + if ($PSCmdlet.ShouldProcess($id, "delete user")) + { + $uri = "$script:XoHost/rest/v0/users/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoVbd.ps1 b/src/Public/Remove-XoVbd.ps1 new file mode 100644 index 0000000..9cda96c --- /dev/null +++ b/src/Public/Remove-XoVbd.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVbd +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra VBDs. + .DESCRIPTION + Issues DELETE /vbds/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER VbdUuid + The ID(s) of the VBD(s) to delete. + .EXAMPLE + Remove-XoVbd -VbdUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VbdUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VbdUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete VBD")) + { + $uri = "$script:XoHost/rest/v0/vbds/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoVdi.ps1 b/src/Public/Remove-XoVdi.ps1 new file mode 100644 index 0000000..9ade2b7 --- /dev/null +++ b/src/Public/Remove-XoVdi.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVdi +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra VDIs. + .DESCRIPTION + Issues DELETE /vdis/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER VdiUuid + The ID(s) of the VDI(s) to delete. + .EXAMPLE + Remove-XoVdi -VdiUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VdiUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VdiUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete VDI")) + { + $uri = "$script:XoHost/rest/v0/vdis/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoVdiSnapshot.ps1 b/src/Public/Remove-XoVdiSnapshot.ps1 new file mode 100644 index 0000000..e6237e5 --- /dev/null +++ b/src/Public/Remove-XoVdiSnapshot.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVdiSnapshot +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra VDI snapshots. + .DESCRIPTION + Issues DELETE /vdi-snapshots/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER VdiSnapshotUuid + The ID(s) of the VDI snapshot(s) to delete. + .EXAMPLE + Remove-XoVdiSnapshot -VdiSnapshotUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VdiSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VdiSnapshotUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete VDI snapshot")) + { + $uri = "$script:XoHost/rest/v0/vdi-snapshots/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoVif.ps1 b/src/Public/Remove-XoVif.ps1 new file mode 100644 index 0000000..0a1fc60 --- /dev/null +++ b/src/Public/Remove-XoVif.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVif +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra VIFs. + .DESCRIPTION + Issues DELETE /vifs/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER VifUuid + The ID(s) of the VIF(s) to delete. + .EXAMPLE + Remove-XoVif -VifUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VifUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VifUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete VIF")) + { + $uri = "$script:XoHost/rest/v0/vifs/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoVm.ps1 b/src/Public/Remove-XoVm.ps1 new file mode 100644 index 0000000..3786418 --- /dev/null +++ b/src/Public/Remove-XoVm.ps1 @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVm +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra VMs. + .DESCRIPTION + Issues DELETE /vms/{id}. The VM must be shut down before it can be deleted. Associated VDIs are destroyed along with the VM unless detached first. Accepts multiple UUIDs and pipeline input by property name. + .PARAMETER VmUuid + The UUID(s) of the VM(s) to delete. + .EXAMPLE + Remove-XoVm -VmUuid "613f541c-4bed-fc77-7ca8-2db6b68f079c" + .EXAMPLE + Get-XoVm -PowerState Halted | Where-Object Name -like 'tmp-*' | Remove-XoVm + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete VM")) + { + $uri = "$script:XoHost/rest/v0/vms/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoVmSnapshot.ps1 b/src/Public/Remove-XoVmSnapshot.ps1 new file mode 100644 index 0000000..a9c8bbd --- /dev/null +++ b/src/Public/Remove-XoVmSnapshot.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVmSnapshot +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra VM snapshots. + .DESCRIPTION + Issues DELETE /vm-snapshots/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER VmSnapshotUuid + The ID(s) of the VM snapshot(s) to delete. + .EXAMPLE + Remove-XoVmSnapshot -VmSnapshotUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VmSnapshotUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VmSnapshotUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete VM snapshot")) + { + $uri = "$script:XoHost/rest/v0/vm-snapshots/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Remove-XoVmStatDataSource.ps1 b/src/Public/Remove-XoVmStatDataSource.ps1 new file mode 100644 index 0000000..61a2c87 --- /dev/null +++ b/src/Public/Remove-XoVmStatDataSource.ps1 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVmStatDataSource +{ + <# + .SYNOPSIS + Remove a stats data source on a VM. + .DESCRIPTION + Calls DELETE /vms/{id}/stats/data_source/{data_source} to remove stat data source. + .PARAMETER VmUuid + The UUID of the target VM. + .PARAMETER DataSource + The name of the stats data source (e.g. 'cpu0', 'memory'). + .EXAMPLE + Remove-XoVmStatDataSource -VmUuid "" -DataSource "cpu0" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$DataSource + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess("VM $VmUuid", "remove stat data source '$DataSource'")) + { + return + } + + $uri = "$script:XoHost/rest/v0/vms/$VmUuid/stats/data_source/$DataSource" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } +} diff --git a/src/Public/Remove-XoVmTemplate.ps1 b/src/Public/Remove-XoVmTemplate.ps1 new file mode 100644 index 0000000..6e0a50a --- /dev/null +++ b/src/Public/Remove-XoVmTemplate.ps1 @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Remove-XoVmTemplate +{ + <# + .SYNOPSIS + Delete one or more Xen Orchestra VM templates. + .DESCRIPTION + Issues DELETE /vm-templates/{id}. Accepts multiple IDs and pipeline input by property name. + .PARAMETER VmTemplateUuid + The ID(s) of the VM template(s) to delete. + .EXAMPLE + Remove-XoVmTemplate -VmTemplateUuid "" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VmTemplateUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VmTemplateUuid) + { + if ($PSCmdlet.ShouldProcess($id, "delete VM template")) + { + $uri = "$script:XoHost/rest/v0/vm-templates/$id" + Invoke-RestMethod -Uri $uri -Method Delete @script:XoRestParameters + } + } + } +} diff --git a/src/Public/Restart-XoPool.ps1 b/src/Public/Restart-XoPool.ps1 new file mode 100644 index 0000000..25b7c16 --- /dev/null +++ b/src/Public/Restart-XoPool.ps1 @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Restart-XoPool +{ + <# + .SYNOPSIS + Restart a running pool. + .DESCRIPTION + Restart the specified pools using a rolling pool reboot. + .PARAMETER PoolUuid + The UUID(s) of the pools(s) to restart. + .EXAMPLE + Restart-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$PoolUuid + ) + + process + { + foreach ($id in $PoolUuid) + { + if ($PSCmdlet.ShouldProcess($id, "Rolling pool reboot")) + { + Invoke-XoPoolAction -PoolUuid $id -Action "rolling_reboot" + } + } + } +} diff --git a/src/Public/Restart-XoVm.ps1 b/src/Public/Restart-XoVm.ps1 new file mode 100644 index 0000000..139c681 --- /dev/null +++ b/src/Public/Restart-XoVm.ps1 @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Restart-XoVm +{ + <# + .SYNOPSIS + Restart one or more VMs. + .DESCRIPTION + Restarts the specified VMs. By default, performs a clean reboot. + Use -Force to perform a hard reboot. + .PARAMETER VmUuid + The UUID(s) of the VM(s) to restart. + .PARAMETER Force + If specified, performs a hard reboot instead of a clean reboot. + .EXAMPLE + Restart-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" + Performs a clean reboot of the VM with the specified UUID. + .EXAMPLE + Get-XoVm -PowerState Running | Restart-XoVm -Force + Performs a hard reboot of all running VMs. + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid, + [Parameter()][switch]$Force + ) + + begin + { + $action = if ($Force) + { + "hard_reboot" + } + else + { + "clean_reboot" + } + } + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, $action)) + { + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/$action" -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} diff --git a/src/Public/Resume-XoVm.ps1 b/src/Public/Resume-XoVm.ps1 new file mode 100644 index 0000000..b8ad35a --- /dev/null +++ b/src/Public/Resume-XoVm.ps1 @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Resume-XoVm +{ + <# + .SYNOPSIS + Resume one or more Xen Orchestra VMs. + .DESCRIPTION + Resumes a suspended VM, restoring its memory from disk and returning it to the Running state. + .PARAMETER VmUuid + The UUID(s) of the VM to act on. Accepts pipeline input by property name. + .EXAMPLE + Resume-XoVm -VmUuid "" + .EXAMPLE + Resume-XoVm -VmUuid "" | Wait-XoTask -PassThru + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + [OutputType("XoPowershell.Task")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, "resume")) + { + $uri = "$script:XoHost/rest/v0/vms/$id/actions/resume" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} + diff --git a/src/Public/Set-XoGroup.ps1 b/src/Public/Set-XoGroup.ps1 new file mode 100644 index 0000000..91598f1 --- /dev/null +++ b/src/Public/Set-XoGroup.ps1 @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoGroup +{ + <# + .SYNOPSIS + Update a Xen Orchestra group. + .DESCRIPTION + Renames an existing group via PATCH /groups/{id}. + .PARAMETER GroupId + The UUID of the group to update. + .PARAMETER Name + The new name for the group. + .EXAMPLE + Set-XoGroup -GroupId "7d98fee4-3357-41a7-ac3f-9124212badb7" -Name "ops-team" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$GroupId, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Name + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + if (-not $PSCmdlet.ShouldProcess($GroupId, "rename group to '$Name'")) + { + return + } + + $params = @{ name = $Name } + $bodyJson = ConvertTo-Json -InputObject $params -Depth 3 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/groups/$GroupId" + Invoke-RestMethod -Uri $uri -Method Patch @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + } +} diff --git a/src/Public/Set-XoHost.ps1 b/src/Public/Set-XoHost.ps1 new file mode 100644 index 0000000..5990546 --- /dev/null +++ b/src/Public/Set-XoHost.ps1 @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoHost +{ + <# + .SYNOPSIS + Set Host + + .DESCRIPTION + Update properties of a host in Xen Orchestra. + + .PARAMETER HostUuid + UUID of the host to update. + + .PARAMETER Name + New name label for the host. + + .PARAMETER Description + New description for the host. + + .PARAMETER Tags + Tags to assign to the target host. + + .EXAMPLE + Set-XoHost -HostUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'MyHost' -Description 'First Host' -Tags @('Critical','Backups') + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("HostId")] + [string]$HostUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string[]]$Tags + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /hosts/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoHost targets PATCH /hosts/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("Tags")) + { + $params["tags"] = $Tags + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($HostUuid, 'Set Host')) + { + + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/hosts/$HostUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } +} + diff --git a/src/Public/Set-XoHostTag.ps1 b/src/Public/Set-XoHostTag.ps1 new file mode 100644 index 0000000..3907893 --- /dev/null +++ b/src/Public/Set-XoHostTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoHostTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra host. + .DESCRIPTION + Manages individual tags on the specified host using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER HostUuid + The UUID of the host to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoHostTag -HostUuid "" -Tag "production" + .EXAMPLE + Set-XoHostTag -HostUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$HostUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($HostUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/hosts/$HostUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoNetwork.ps1 b/src/Public/Set-XoNetwork.ps1 new file mode 100644 index 0000000..89ebdb7 --- /dev/null +++ b/src/Public/Set-XoNetwork.ps1 @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoNetwork +{ + <# + .SYNOPSIS + Set XO Network + + .DESCRIPTION + Update properties of a network in Xen Orchestra. + + .PARAMETER NetworkUuid + UUID of the network to update. + + .PARAMETER Name + New name label for the network. + + .PARAMETER Description + Target network description + + .PARAMETER Tags + Tags to assign to the target network. + + .EXAMPLE + $params = @{ + NetworkUuid = '011ccf6a-c5ad-48ec-a255-d056584686f0' + Name = 'MyNetwork' + Description = "My awesome network" + Tags = @('Important', 'MainNetwork') + } + Set-XoNetwork @params + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("NetworkId")] + [string]$NetworkUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string[]]$Tags + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /networks/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoNetwork targets PATCH /networks/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("Tags")) + { + $params["tags"] = $Tags + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($NetworkUuid, "Set network target ")) + { + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/networks/$NetworkUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } +} + diff --git a/src/Public/Set-XoNetworkTag.ps1 b/src/Public/Set-XoNetworkTag.ps1 new file mode 100644 index 0000000..6d80674 --- /dev/null +++ b/src/Public/Set-XoNetworkTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoNetworkTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra network. + .DESCRIPTION + Manages individual tags on the specified network using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER NetworkUuid + The UUID of the network to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoNetworkTag -NetworkUuid "" -Tag "production" + .EXAMPLE + Set-XoNetworkTag -NetworkUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$NetworkUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($NetworkUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/networks/$NetworkUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoPif.ps1 b/src/Public/Set-XoPif.ps1 new file mode 100644 index 0000000..3cdd619 --- /dev/null +++ b/src/Public/Set-XoPif.ps1 @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoPif +{ + <# + .SYNOPSIS + Set Pif + + .DESCRIPTION + Update properties of a PIF in Xen Orchestra. + + .PARAMETER PifUuid + UUID of the PIF to update. + + .PARAMETER Name + New name label for the PIF. + + .PARAMETER Description + New description for the PIF. + + .PARAMETER Tags + Tags to assign to the target PIF. + + .EXAMPLE + Set-XoPif -PifUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'New Name' + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("PifId")] + [string]$PifUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string[]]$Tags + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /pifs/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoPif targets PATCH /pifs/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("Tags")) + { + $params["tags"] = $Tags + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($PifUuid, "Set Pif on target ")) + { + + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pifs/$PifUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } +} + diff --git a/src/Public/Set-XoPool.ps1 b/src/Public/Set-XoPool.ps1 new file mode 100644 index 0000000..7af84b8 --- /dev/null +++ b/src/Public/Set-XoPool.ps1 @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoPool +{ + <# + .SYNOPSIS + Set XO pool + + .DESCRIPTION + Update properties of a pool in Xen Orchestra. + + .PARAMETER PoolUuid + UUID of the pool to update. + + .PARAMETER Name + New name label for the pool. + + .PARAMETER Description + New description for the pool. + + .PARAMETER Tags + Tags to assign to the target pool. + + .EXAMPLE + Set-XoPool -PoolUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'New Pool Name' + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("PoolId")] + [string]$PoolUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string[]]$Tags + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /pools/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoPool targets PATCH /pools/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("Tags")) + { + $params["tags"] = $Tags + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($PoolUuid, "Set pool on target")) + { + + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } +} + diff --git a/src/Public/Set-XoPoolTag.ps1 b/src/Public/Set-XoPoolTag.ps1 new file mode 100644 index 0000000..e25e49d --- /dev/null +++ b/src/Public/Set-XoPoolTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoPoolTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra pool. + .DESCRIPTION + Manages individual tags on the specified pool using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER PoolUuid + The UUID of the pool to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoPoolTag -PoolUuid "" -Tag "production" + .EXAMPLE + Set-XoPoolTag -PoolUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$PoolUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($PoolUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/pools/$PoolUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoSession.ps1 b/src/Public/Set-XoSession.ps1 new file mode 100644 index 0000000..c32727d --- /dev/null +++ b/src/Public/Set-XoSession.ps1 @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoSession +{ + <# + .SYNOPSIS + Set the current XO session settings. + .DESCRIPTION + Set the current Xen Orchestra session settings. + .PARAMETER Limit + Sets the current XO query limit for all Get-Xo* cmdlets that support a -Limit parameter. + .EXAMPLE + Set-XoSession -Limit 50 + Sets the current session-wide limit to 50 items for all query cmdlets. + .EXAMPLE + Set-XoSession -Limit 0 + Sets cmdlets to return all items by default. + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'low')] + param( + [Parameter()] + [int]$Limit + ) + process + { + + if ($PSBoundParameters.ContainsKey("Limit")) + { + if ($PSCmdlet.ShouldProcess($Limit, "Set updated limit")) + { + + Write-Verbose "Default limit for XO queries changed from $script:XoSessionLimit to $Limit" + $script:XoSessionLimit = $Limit + } + } + } +} diff --git a/src/Public/Set-XoSr.ps1 b/src/Public/Set-XoSr.ps1 new file mode 100644 index 0000000..b777174 --- /dev/null +++ b/src/Public/Set-XoSr.ps1 @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoSr +{ + <# + .SYNOPSIS + Set XO sr + + .DESCRIPTION + Update properties of a storage repository in XO. + + .PARAMETER SrUuid + UUID of the storage repository to update. + + .PARAMETER Name + New name label for the SR. + + .PARAMETER Description + New description for the SR. + + .PARAMETER Tags + Tags to assign to the target SR. + + .EXAMPLE + Set-XoSr -SrUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name "MySR" + + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("SrId")] + [string]$SrUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string[]]$Tags + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /srs/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoSr targets PATCH /srs/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("Tags")) + { + $params["tags"] = $Tags + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($SrUuid, "Set SR on target")) + { + + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/srs/$SrUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } +} + diff --git a/src/Public/Set-XoSrTag.ps1 b/src/Public/Set-XoSrTag.ps1 new file mode 100644 index 0000000..9e17a45 --- /dev/null +++ b/src/Public/Set-XoSrTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoSrTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra storage repository. + .DESCRIPTION + Manages individual tags on the specified storage repository using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER SrUuid + The UUID of the storage repository to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoSrTag -SrUuid "" -Tag "production" + .EXAMPLE + Set-XoSrTag -SrUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$SrUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($SrUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/srs/$SrUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoUser.ps1 b/src/Public/Set-XoUser.ps1 new file mode 100644 index 0000000..143828c --- /dev/null +++ b/src/Public/Set-XoUser.ps1 @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoUser +{ + <# + .SYNOPSIS + Update a Xen Orchestra user. + .DESCRIPTION + Edits an existing user via PATCH /users/{id}. Any combination of Credential, Permission, or Preferences may be supplied; omitted fields are left unchanged. When Credential is supplied, both the user name and password are sent (XO treats them as a pair on update). + .PARAMETER UserId + The UUID of the user to update. + .PARAMETER Credential + PSCredential holding the new user name and password to assign. The UserName is sent as 'name' and the password is sent in the request body. + .PARAMETER Permission + New permission level: 'none', 'viewer', or 'admin'. + .PARAMETER Preferences + Hashtable of preference key/values to store on the user. + .EXAMPLE + Set-XoUser -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" -Permission admin + .EXAMPLE + Set-XoUser -UserId "722d17b9-699b-49d2-8193-be1ac573d3de" -Credential (Get-Credential) + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$UserId, + + [Parameter()] + [ValidateNotNull()] + [pscredential]$Credential, + + [Parameter()] + [ValidateSet("none", "viewer", "admin")] + [string]$Permission, + + [Parameter()] + [hashtable]$Preferences + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + $params = @{} + if ($PSBoundParameters.ContainsKey("Credential")) + { + $params["name"] = $Credential.UserName + $params["password"] = $Credential.GetNetworkCredential().Password + } + if ($PSBoundParameters.ContainsKey("Permission")) { $params["permission"] = $Permission } + if ($PSBoundParameters.ContainsKey("Preferences")) { $params["preferences"] = $Preferences } + + if ($params.Count -eq 0) { return } + + if (-not $PSCmdlet.ShouldProcess($UserId, "update user")) + { + return + } + + $bodyJson = ConvertTo-Json -InputObject $params -Depth 10 -Compress + $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($bodyJson) + + $uri = "$script:XoHost/rest/v0/users/$UserId" + Invoke-RestMethod -Uri $uri -Method Patch @script:XoRestParameters -ContentType "application/json" -Body $bodyBytes + } +} diff --git a/src/Public/Set-XoVdi.ps1 b/src/Public/Set-XoVdi.ps1 new file mode 100644 index 0000000..9faab87 --- /dev/null +++ b/src/Public/Set-XoVdi.ps1 @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVdi +{ + <# + .SYNOPSIS + Set XO VDI + + .DESCRIPTION + Update properties of a VDI in Xen Orchestra. + + .PARAMETER VdiUuid + UUID of the VDI to update. + + .PARAMETER Name + New name label for the VDI. + + .PARAMETER Description + New description for the target VDI. + + .EXAMPLE + Set-XoVdi -VdiUuid '011ccf6a-c5ad-48ec-a255-d056584686f0' -Name 'MyVdi' + + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("VdiId")] + [string]$VdiUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /vdis/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoVdi targets PATCH /vdis/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($VdiUuid, "Set VDI on target")) + { + + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vdis/$VdiUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } +} + diff --git a/src/Public/Set-XoVdiSnapshotTag.ps1 b/src/Public/Set-XoVdiSnapshotTag.ps1 new file mode 100644 index 0000000..1f03058 --- /dev/null +++ b/src/Public/Set-XoVdiSnapshotTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVdiSnapshotTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra VDI snapshot. + .DESCRIPTION + Manages individual tags on the specified VDI snapshot using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER VdiSnapshotUuid + The UUID of the VDI snapshot to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoVdiSnapshotTag -VdiSnapshotUuid "" -Tag "production" + .EXAMPLE + Set-XoVdiSnapshotTag -VdiSnapshotUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VdiSnapshotUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($VdiSnapshotUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/vdi-snapshots/$VdiSnapshotUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoVdiTag.ps1 b/src/Public/Set-XoVdiTag.ps1 new file mode 100644 index 0000000..df83d11 --- /dev/null +++ b/src/Public/Set-XoVdiTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVdiTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra VDI. + .DESCRIPTION + Manages individual tags on the specified VDI using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER VdiUuid + The UUID of the VDI to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoVdiTag -VdiUuid "" -Tag "production" + .EXAMPLE + Set-XoVdiTag -VdiUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VdiUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($VdiUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/vdis/$VdiUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoVif.ps1 b/src/Public/Set-XoVif.ps1 new file mode 100644 index 0000000..857d4fb --- /dev/null +++ b/src/Public/Set-XoVif.ps1 @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVif +{ + <# + .SYNOPSIS + Set Vif + + .DESCRIPTION + Update properties of a VIF in Xen Orchestra. + + .PARAMETER VifUuid + UUID of the VIF to update. + + .PARAMETER Name + New name label for the VIF. + + .PARAMETER Description + New description for the VIF. + + .PARAMETER Tags + Tags to assign to the target VIF. + + .EXAMPLE + Set-XoVif -VifUuid '812b59e1-2682-43ef-acd4-808d3551b907' -Name 'MyVif' + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("VifId")] + [string]$VifUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string[]]$Tags + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /vifs/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoVif targets PATCH /vifs/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("Tags")) + { + $params["tags"] = $Tags + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($VifUuid, "Set Vif on Target")) + { + + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vifs/$VifUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } +} + diff --git a/src/Public/Set-XoVm.ps1 b/src/Public/Set-XoVm.ps1 new file mode 100644 index 0000000..7064798 --- /dev/null +++ b/src/Public/Set-XoVm.ps1 @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVm +{ + <# + .SYNOPSIS + Set Vm + + .DESCRIPTION + Update properties of a VM in Xen Orchestra. + + .PARAMETER VmUuid + UUID of the target VM to update. + + .PARAMETER Name + New name label for the VM. + + .PARAMETER Description + New description for the VM. + + .PARAMETER Tags + Tags to assign to the target VM. + + .EXAMPLE + Set-XoVm -VmUuid '812b59e1-2682-43ef-acd4-808d3551b907' -Name 'MyVm' + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [Alias("VmId")] + [string]$VmUuid, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Description, + + [Parameter()] + [string[]]$Tags + ) + process { + # NOTE: the current Xen Orchestra REST API does not expose a PATCH endpoint at /vms/{id}. + # This cmdlet is kept for backwards compatibility but will fail against modern XO releases. + Write-Warning "Set-XoVm targets PATCH /vms/{id}, which the current XO REST API does not expose. The call will likely fail." + + + $params = @{} + + if ($PSBoundParameters.ContainsKey("Name")) + { + $params["name_label"] = $Name + } + if ($PSBoundParameters.ContainsKey("Description")) + { + $params["name_description"] = $Description + } + if ($PSBoundParameters.ContainsKey("Tags")) + { + $params["tags"] = $Tags + } + + if ($params.Count -gt 0) + { + if ($PSCmdlet.ShouldProcess($VmUuid, "Set VM target")) + { + $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$VmUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body + } + } + } + +} + diff --git a/src/Public/Set-XoVmControllerTag.ps1 b/src/Public/Set-XoVmControllerTag.ps1 new file mode 100644 index 0000000..29bc020 --- /dev/null +++ b/src/Public/Set-XoVmControllerTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVmControllerTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra VM controller. + .DESCRIPTION + Manages individual tags on the specified VM controller using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER VmControllerUuid + The UUID of the VM controller to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoVmControllerTag -VmControllerUuid "" -Tag "production" + .EXAMPLE + Set-XoVmControllerTag -VmControllerUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmControllerUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($VmControllerUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/vm-controllers/$VmControllerUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoVmSnapshotTag.ps1 b/src/Public/Set-XoVmSnapshotTag.ps1 new file mode 100644 index 0000000..fc6d6c9 --- /dev/null +++ b/src/Public/Set-XoVmSnapshotTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVmSnapshotTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra VM snapshot. + .DESCRIPTION + Manages individual tags on the specified VM snapshot using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER VmSnapshotUuid + The UUID of the VM snapshot to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoVmSnapshotTag -VmSnapshotUuid "" -Tag "production" + .EXAMPLE + Set-XoVmSnapshotTag -VmSnapshotUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmSnapshotUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($VmSnapshotUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/vm-snapshots/$VmSnapshotUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoVmTag.ps1 b/src/Public/Set-XoVmTag.ps1 new file mode 100644 index 0000000..581b6da --- /dev/null +++ b/src/Public/Set-XoVmTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVmTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra VM. + .DESCRIPTION + Manages individual tags on the specified VM using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER VmUuid + The UUID of the VM to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoVmTag -VmUuid "" -Tag "production" + .EXAMPLE + Set-XoVmTag -VmUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($VmUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/vms/$VmUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Set-XoVmTemplateTag.ps1 b/src/Public/Set-XoVmTemplateTag.ps1 new file mode 100644 index 0000000..1807646 --- /dev/null +++ b/src/Public/Set-XoVmTemplateTag.ps1 @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Set-XoVmTemplateTag +{ + <# + .SYNOPSIS + Attach or detach a single tag on a Xen Orchestra VM template. + .DESCRIPTION + Manages individual tags on the specified VM template using the /tags/{tag} endpoint. By default the tag is added (HTTP PUT); pass -Remove to detach it (HTTP DELETE). Unlike Set-Xo* cmdlets, this does not replace the full tag list - only the single tag is modified. + .PARAMETER VmTemplateUuid + The UUID of the VM template to tag. + .PARAMETER Tag + The tag value to add or remove. + .PARAMETER Remove + Detach the tag instead of attaching it. + .EXAMPLE + Set-XoVmTemplateTag -VmTemplateUuid "" -Tag "production" + .EXAMPLE + Set-XoVmTemplateTag -VmTemplateUuid "" -Tag "production" -Remove + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] + [ValidateNotNullOrEmpty()] + [string]$VmTemplateUuid, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Tag, + + [Parameter()] + [switch]$Remove + ) + + process + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + $method = if ($Remove) { "Delete" } else { "Put" } + $verb = if ($Remove) { "remove tag '$Tag'" } else { "add tag '$Tag'" } + + if ($PSCmdlet.ShouldProcess($VmTemplateUuid, $verb)) + { + $uri = "$script:XoHost/rest/v0/vm-templates/$VmTemplateUuid/tags/$Tag" + Invoke-RestMethod -Uri $uri -Method $method @script:XoRestParameters + } + } +} + diff --git a/src/Public/Start-XoSchedule.ps1 b/src/Public/Start-XoSchedule.ps1 new file mode 100644 index 0000000..b94c783 --- /dev/null +++ b/src/Public/Start-XoSchedule.ps1 @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Start-XoSchedule +{ + <# + .SYNOPSIS + Start one or more schedules. + .DESCRIPTION + Starts the specified schedules. Returns a task object that can be used to monitor + the startup operation. + .PARAMETER ScheduleId + The ID(s) of the schedule(s) to start. + .EXAMPLE + Start-XoSchedule -ScheduleId "12345678-abcd-1234-abcd-1234567890ab" + Starts the schedule with the specified ID. + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$ScheduleId + ) + + process + { + foreach ($id in $ScheduleId) + { + if ($PSCmdlet.ShouldProcess($id, "start")) + { + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/schedules/$id/actions/run" -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} diff --git a/src/Public/Start-XoVm.ps1 b/src/Public/Start-XoVm.ps1 new file mode 100644 index 0000000..fbc24ba --- /dev/null +++ b/src/Public/Start-XoVm.ps1 @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Start-XoVm +{ + <# + .SYNOPSIS + Start one or more VMs. + .DESCRIPTION + Starts the specified VMs. Returns a task object that can be used to monitor + the startup operation. + .PARAMETER VmUuid + The UUID(s) of the VM(s) to start. + .EXAMPLE + Start-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" + Starts the VM with the specified UUID. + .EXAMPLE + Get-XoVm -PowerState Halted | Start-XoVm + Starts all halted VMs. + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid + ) + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, "start")) + { + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/start" -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} diff --git a/src/Public/Stop-XoPool.ps1 b/src/Public/Stop-XoPool.ps1 new file mode 100644 index 0000000..5566440 --- /dev/null +++ b/src/Public/Stop-XoPool.ps1 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Stop-XoPool +{ + <# + .SYNOPSIS + Stop a running pool. + .DESCRIPTION + Stop the specified pools. Currently only supports emergency shutdown. + .PARAMETER PoolUuid + The UUID(s) of the pools(s) to stop. + .PARAMETER Force + Perform an emergency shutdown. + .EXAMPLE + Stop-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" -Force + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$PoolUuid, + + [Parameter(Mandatory)] + [switch]$Force + ) + + process + { + # Note: "Stop" is quite different from "emergency shutdown", thus the "-Force" parameter being mandatory for now. + # Added splatting to make it more flexible in the future. + $params = @{} + foreach ($id in $PoolUuid) + { + $params["PoolUuid"] = $id + if ($PSBoundParameters.ContainsKey('Force')) + { + $params["Action"] = "emergency_shutdown" + } + if ($PSCmdlet.ShouldProcess($id, "Emergency shutdown")) + { + Invoke-XoPoolAction @params + } + } + } +} diff --git a/src/Public/Stop-XoTask.ps1 b/src/Public/Stop-XoTask.ps1 new file mode 100644 index 0000000..9a98481 --- /dev/null +++ b/src/Public/Stop-XoTask.ps1 @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Stop-XoTask +{ + <# + .SYNOPSIS + Abort one or more running Xen Orchestra tasks. + .DESCRIPTION + POSTs to /tasks/{id}/actions/abort to request cancellation of the specified task. Some XAPI tasks cannot be aborted; those will return an error. Aborting a task can leave partial state behind (e.g. a half-migrated VM) - use with care. + .PARAMETER TaskId + The ID(s) of the task(s) to abort. Accepts pipeline input by property name. + .EXAMPLE + Stop-XoTask -TaskId "0m8k2zkzi" + .EXAMPLE + Get-XoTask -Status pending | Stop-XoTask + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]]$TaskId + ) + + begin + { + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + } + + process + { + foreach ($id in $TaskId) + { + if ($PSCmdlet.ShouldProcess($id, "abort")) + { + $uri = "$script:XoHost/rest/v0/tasks/$id/actions/abort" + Invoke-RestMethod -Uri $uri -Method Post @script:XoRestParameters + } + } + } +} + diff --git a/src/Public/Stop-XoVm.ps1 b/src/Public/Stop-XoVm.ps1 new file mode 100644 index 0000000..b7bfa0f --- /dev/null +++ b/src/Public/Stop-XoVm.ps1 @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Stop-XoVm +{ + <# + .SYNOPSIS + Stop one or more VMs. + .DESCRIPTION + Stops the specified VMs. By default, performs a clean shutdown. + Use -Force to perform a hard shutdown. + .PARAMETER VmUuid + The UUID(s) of the VM(s) to stop. + .PARAMETER Force + If specified, performs a hard shutdown instead of a clean shutdown. + .EXAMPLE + Stop-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" + Performs a clean shutdown of the VM with the specified UUID. + .EXAMPLE + Get-XoVm -PowerState Running | Stop-XoVm -Force + Performs a hard shutdown of all running VMs. + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid, + [Parameter()][switch]$Force + ) + + begin + { + $action = if ($Force) + { + "hard_shutdown" + } + else + { + "clean_shutdown" + } + } + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, $action)) + { + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/$action" -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} diff --git a/src/Public/Suspend-XoVm.ps1 b/src/Public/Suspend-XoVm.ps1 new file mode 100644 index 0000000..790fe2e --- /dev/null +++ b/src/Public/Suspend-XoVm.ps1 @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Suspend-XoVm +{ + <# + .SYNOPSIS + Suspend one or more VMs. + .DESCRIPTION + Suspends the specified Xen Orchestra VMs. + .PARAMETER VmUuid + The UUID(s) of the VM(s) to suspend. + .EXAMPLE + Suspend-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" + Suspends the VM with the specified UUID. + .EXAMPLE + Get-XoVm -PowerState Running | Suspend-XoVm + Suspends all running VMs. + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$VmUuid + ) + + process + { + foreach ($id in $VmUuid) + { + if ($PSCmdlet.ShouldProcess($id, "suspend")) + { + Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/suspend" -Method Post @script:XoRestParameters | ForEach-Object { + ConvertFrom-XoTaskHref $_ + } + } + } + } +} diff --git a/src/Public/Test-XoPing.ps1 b/src/Public/Test-XoPing.ps1 new file mode 100644 index 0000000..c6e6a51 --- /dev/null +++ b/src/Public/Test-XoPing.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Test-XoPing +{ + <# + .SYNOPSIS + Test the reachability of the Xen Orchestra REST API. + .DESCRIPTION + Sends a GET to the /ping endpoint using the current session credentials. Returns $true on success (2xx) or $false on any failure (network error, auth error, non-2xx). Does not throw. Useful for quick health probes in monitoring scripts. + .EXAMPLE + if (-not (Test-XoPing)) { throw "XO API unreachable" } + #> + [CmdletBinding()] + [OutputType([bool])] + param () + + if (-not $script:XoHost -or -not $script:XoRestParameters) + { + throw "Not connected to Xen Orchestra. Call Connect-XoSession first." + } + + try + { + $null = Invoke-RestMethod -Uri "$script:XoHost/rest/v0/ping" @script:XoRestParameters + return $true + } + catch + { + Write-Verbose "Ping failed: $_" + return $false + } +} + diff --git a/src/Public/Test-XoSession.ps1 b/src/Public/Test-XoSession.ps1 new file mode 100644 index 0000000..411e16d --- /dev/null +++ b/src/Public/Test-XoSession.ps1 @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +$script:XO_DEFAULT_LIMIT = 25 +$script:XoSessionLimit = $script:XO_DEFAULT_LIMIT + +function Test-XoSession +{ + <# + .SYNOPSIS + Check the connection to Xen Orchestra. + .DESCRIPTION + Tests if the current session is connected to a Xen Orchestra instance. + .EXAMPLE + Test-XoSession + Returns $true if connected, $false otherwise. + #> + [CmdletBinding()] + [OutputType([bool])] + param() + + # Test connection by attempting to get tasks with a minimal limit + try + { + Get-XoTask -Limit 1 | Out-Null + Write-Verbose "Successful connection to Xen Orchestra - $script:XoHost" + return $true + } + catch + { + Write-Error "Xen Orchestra connection error - $script:XoHost $_" + return $false + } +} diff --git a/src/Public/Update-XoPool.ps1 b/src/Public/Update-XoPool.ps1 new file mode 100644 index 0000000..f14066d --- /dev/null +++ b/src/Public/Update-XoPool.ps1 @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Update-XoPool +{ + <# + .SYNOPSIS + Update a running pool. + .DESCRIPTION + Update the specified pools using a rolling pool update. + .PARAMETER PoolUuid + The UUID(s) of the pools(s) to update. + .EXAMPLE + Update-XoPool -PoolUuid "12345678-abcd-1234-abcd-1234567890ab" + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [string[]]$PoolUuid + ) + + process + { + foreach ($id in $PoolUuid) + { + if ($PSCmdlet.ShouldProcess($id, "Rolling pool update")) + { + Invoke-XoPoolAction -PoolUuid $id -Action "rolling_update" + } + } + } +} diff --git a/src/Public/Wait-XoTask.ps1 b/src/Public/Wait-XoTask.ps1 new file mode 100644 index 0000000..421bec4 --- /dev/null +++ b/src/Public/Wait-XoTask.ps1 @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: Apache-2.0 + +function Wait-XoTask +{ + <# + .SYNOPSIS + Wait for task completion. + .DESCRIPTION + Waits for the specified tasks to complete and optionally returns the result. + .PARAMETER TaskId + The ID(s) of the task(s) to wait for. + .PARAMETER PassThru + If specified, returns the task objects after completion. + .EXAMPLE + Wait-XoTask -TaskId "0m8k2zkzi" + Waits for the task to complete. + .EXAMPLE + Wait-XoTask -TaskId "0m8k2zkzi" -PassThru + Waits for the task to complete and returns the task object. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]]$TaskId, + + [Parameter()] + [switch]$PassThru + ) + + begin + { + $params = @{ + fields = $script:XO_TASK_FIELDS + wait = "result" + } + $ids = @() + } + + process + { + $ids += $TaskId + } + + end + { + foreach ($id in $ids) + { + try + { + $uri = "$script:XoHost/rest/v0/tasks/$id" + $result = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params + + if ($PassThru -and $result) + { + ConvertTo-XoTaskObject -InputObject $result + } + } + catch + { + throw ("Error waiting for task {0}: {1}" -f $id, $_) + } + } + } +} diff --git a/src/en-US/about_xo-powershell.help.txt b/src/en-US/about_xo-powershell.help.txt new file mode 100644 index 0000000..24be10a --- /dev/null +++ b/src/en-US/about_xo-powershell.help.txt @@ -0,0 +1,24 @@ +TOPIC + about_xo-powershell + +SHORT DESCRIPTION + Xen Orchestra PowerShell module + +LONG DESCRIPTION + Xen Orchestra PowerShell module + +EXAMPLES + PS C:\> {{ add examples here }} + +NOTE: + Thank you to all those who contributed to this module, by writing code, sharing opinions, and provided feedback. + +TROUBLESHOOTING NOTE: + Look out on the Github repository for issues and new releases. + +SEE ALSO + - {{ Please add Project URI such as github }}} + +KEYWORDS + {{ Add comma separated keywords here }} + diff --git a/formats/alarm.ps1xml b/src/formats/alarm.ps1xml similarity index 100% rename from formats/alarm.ps1xml rename to src/formats/alarm.ps1xml diff --git a/src/formats/backup-archive.ps1xml b/src/formats/backup-archive.ps1xml new file mode 100644 index 0000000..41f6111 --- /dev/null +++ b/src/formats/backup-archive.ps1xml @@ -0,0 +1,30 @@ + + + + + + XoPowershell.BackupArchive + + XoPowershell.BackupArchive + + + + + + + BackupArchiveId + + + type + + + backupRepository + + + + + + + + diff --git a/src/formats/backup-job.ps1xml b/src/formats/backup-job.ps1xml new file mode 100644 index 0000000..79c15eb --- /dev/null +++ b/src/formats/backup-job.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.BackupJob + + XoPowershell.BackupJob + + + + + + + BackupJobId + + + Name + + + Mode + + + Type + + + + + + + + diff --git a/src/formats/backup-log.ps1xml b/src/formats/backup-log.ps1xml new file mode 100644 index 0000000..742a3eb --- /dev/null +++ b/src/formats/backup-log.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.BackupLog + + XoPowershell.BackupLog + + + + + + + BackupLogId + + + jobName + + + status + + + message + + + + + + + + diff --git a/src/formats/backup-repository.ps1xml b/src/formats/backup-repository.ps1xml new file mode 100644 index 0000000..6fae43c --- /dev/null +++ b/src/formats/backup-repository.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.BackupRepository + + XoPowershell.BackupRepository + + + + + + + BackupRepositoryId + + + Name + + + enabled + + + url + + + + + + + + diff --git a/src/formats/dashboard.ps1xml b/src/formats/dashboard.ps1xml new file mode 100644 index 0000000..594a995 --- /dev/null +++ b/src/formats/dashboard.ps1xml @@ -0,0 +1,27 @@ + + + + + + XoPowershell.Dashboard + + XoPowershell.Dashboard + + + + + + + nPools + + + nHosts + + + + + + + + diff --git a/src/formats/event.ps1xml b/src/formats/event.ps1xml new file mode 100644 index 0000000..d00610c --- /dev/null +++ b/src/formats/event.ps1xml @@ -0,0 +1,30 @@ + + + + + + XoPowershell.Event + + XoPowershell.Event + + + + + + + EventId + + + name + + + type + + + + + + + + diff --git a/src/formats/group.ps1xml b/src/formats/group.ps1xml new file mode 100644 index 0000000..473a779 --- /dev/null +++ b/src/formats/group.ps1xml @@ -0,0 +1,30 @@ + + + + + + XoPowershell.Group + + XoPowershell.Group + + + + + + + GroupId + + + Name + + + users + + + + + + + + diff --git a/formats/host.ps1xml b/src/formats/host.ps1xml similarity index 98% rename from formats/host.ps1xml rename to src/formats/host.ps1xml index 3e3f90e..1e7bf46 100644 --- a/formats/host.ps1xml +++ b/src/formats/host.ps1xml @@ -39,7 +39,7 @@ - + 36 diff --git a/formats/message.ps1xml b/src/formats/message.ps1xml similarity index 100% rename from formats/message.ps1xml rename to src/formats/message.ps1xml diff --git a/formats/network.ps1xml b/src/formats/network.ps1xml similarity index 100% rename from formats/network.ps1xml rename to src/formats/network.ps1xml diff --git a/src/formats/pbd.ps1xml b/src/formats/pbd.ps1xml new file mode 100644 index 0000000..27c82c1 --- /dev/null +++ b/src/formats/pbd.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.Pbd + + XoPowershell.Pbd + + + + + + + PbdUuid + + + attached + + + host + + + SR + + + + + + + + diff --git a/src/formats/pci.ps1xml b/src/formats/pci.ps1xml new file mode 100644 index 0000000..a32af93 --- /dev/null +++ b/src/formats/pci.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.Pci + + XoPowershell.Pci + + + + + + + PciUuid + + + class_name + + + device_name + + + pci_id + + + + + + + + diff --git a/src/formats/pgpu.ps1xml b/src/formats/pgpu.ps1xml new file mode 100644 index 0000000..233a322 --- /dev/null +++ b/src/formats/pgpu.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.Pgpu + + XoPowershell.Pgpu + + + + + + + PgpuUuid + + + dom0Access + + + gpuGroup + + + host + + + + + + + + diff --git a/formats/pif.ps1xml b/src/formats/pif.ps1xml similarity index 100% rename from formats/pif.ps1xml rename to src/formats/pif.ps1xml diff --git a/formats/pool-patch.ps1xml b/src/formats/pool-patch.ps1xml similarity index 100% rename from formats/pool-patch.ps1xml rename to src/formats/pool-patch.ps1xml diff --git a/formats/pool.ps1xml b/src/formats/pool.ps1xml similarity index 100% rename from formats/pool.ps1xml rename to src/formats/pool.ps1xml diff --git a/src/formats/proxy.ps1xml b/src/formats/proxy.ps1xml new file mode 100644 index 0000000..fa56bf6 --- /dev/null +++ b/src/formats/proxy.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.Proxy + + XoPowershell.Proxy + + + + + + + ProxyId + + + Name + + + vmUuid + + + version + + + + + + + + diff --git a/src/formats/restore-log.ps1xml b/src/formats/restore-log.ps1xml new file mode 100644 index 0000000..632aeb4 --- /dev/null +++ b/src/formats/restore-log.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.RestoreLog + + XoPowershell.RestoreLog + + + + + + + RestoreLogId + + + message + + + status + + + start + + + + + + + + diff --git a/formats/schedule.ps1xml b/src/formats/schedule.ps1xml similarity index 100% rename from formats/schedule.ps1xml rename to src/formats/schedule.ps1xml diff --git a/formats/server.ps1xml b/src/formats/server.ps1xml similarity index 98% rename from formats/server.ps1xml rename to src/formats/server.ps1xml index 5c035cd..24e0f03 100644 --- a/formats/server.ps1xml +++ b/src/formats/server.ps1xml @@ -36,7 +36,7 @@ - + 36 diff --git a/src/formats/sm.ps1xml b/src/formats/sm.ps1xml new file mode 100644 index 0000000..f9ee2ec --- /dev/null +++ b/src/formats/sm.ps1xml @@ -0,0 +1,36 @@ + + + + + + XoPowershell.Sm + + XoPowershell.Sm + + + + + + + SmUuid + + + Name + + + Type + + + vendor + + + version + + + + + + + + diff --git a/formats/sr.ps1xml b/src/formats/sr.ps1xml similarity index 98% rename from formats/sr.ps1xml rename to src/formats/sr.ps1xml index 09cbe73..9a92519 100644 --- a/formats/sr.ps1xml +++ b/src/formats/sr.ps1xml @@ -37,7 +37,7 @@ - + 36 diff --git a/formats/task.ps1xml b/src/formats/task.ps1xml similarity index 98% rename from formats/task.ps1xml rename to src/formats/task.ps1xml index 7e1d642..23b395f 100644 --- a/formats/task.ps1xml +++ b/src/formats/task.ps1xml @@ -35,7 +35,7 @@ - + 12 diff --git a/src/formats/user-authentication-token.ps1xml b/src/formats/user-authentication-token.ps1xml new file mode 100644 index 0000000..8631436 --- /dev/null +++ b/src/formats/user-authentication-token.ps1xml @@ -0,0 +1,36 @@ + + + + + + XoPowershell.UserAuthenticationToken + + XoPowershell.UserAuthenticationToken + + + + + + + TokenId + + + UserId + + + description + + + created_at + + + expiration + + + + + + + + diff --git a/src/formats/user.ps1xml b/src/formats/user.ps1xml new file mode 100644 index 0000000..1a6ca82 --- /dev/null +++ b/src/formats/user.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.User + + XoPowershell.User + + + + + + + UserId + + + Name + + + email + + + permission + + + + + + + + diff --git a/formats/vbd.ps1xml b/src/formats/vbd.ps1xml similarity index 100% rename from formats/vbd.ps1xml rename to src/formats/vbd.ps1xml diff --git a/formats/vdi-snapshot.ps1xml b/src/formats/vdi-snapshot.ps1xml similarity index 98% rename from formats/vdi-snapshot.ps1xml rename to src/formats/vdi-snapshot.ps1xml index 48de0d5..9acb2da 100644 --- a/formats/vdi-snapshot.ps1xml +++ b/src/formats/vdi-snapshot.ps1xml @@ -34,7 +34,7 @@ - + 36 diff --git a/formats/vdi.ps1xml b/src/formats/vdi.ps1xml similarity index 98% rename from formats/vdi.ps1xml rename to src/formats/vdi.ps1xml index fe85330..9e859aa 100644 --- a/formats/vdi.ps1xml +++ b/src/formats/vdi.ps1xml @@ -37,7 +37,7 @@ - + 36 diff --git a/formats/vif.ps1xml b/src/formats/vif.ps1xml similarity index 100% rename from formats/vif.ps1xml rename to src/formats/vif.ps1xml diff --git a/src/formats/vm-controller.ps1xml b/src/formats/vm-controller.ps1xml new file mode 100644 index 0000000..113a547 --- /dev/null +++ b/src/formats/vm-controller.ps1xml @@ -0,0 +1,33 @@ + + + + + + XoPowershell.VmController + + XoPowershell.VmController + + + + + + + VmControllerUuid + + + Name + + + PowerState + + + host + + + + + + + + diff --git a/formats/vm-snapshot.ps1xml b/src/formats/vm-snapshot.ps1xml similarity index 98% rename from formats/vm-snapshot.ps1xml rename to src/formats/vm-snapshot.ps1xml index db72334..704e90e 100644 --- a/formats/vm-snapshot.ps1xml +++ b/src/formats/vm-snapshot.ps1xml @@ -43,7 +43,7 @@ - + 36 diff --git a/formats/vm-template.ps1xml b/src/formats/vm-template.ps1xml similarity index 98% rename from formats/vm-template.ps1xml rename to src/formats/vm-template.ps1xml index 2be0383..300a07c 100644 --- a/formats/vm-template.ps1xml +++ b/src/formats/vm-template.ps1xml @@ -43,7 +43,7 @@ - + 36 diff --git a/formats/vm.ps1xml b/src/formats/vm.ps1xml similarity index 98% rename from formats/vm.ps1xml rename to src/formats/vm.ps1xml index 17d89c3..9c83566 100644 --- a/formats/vm.ps1xml +++ b/src/formats/vm.ps1xml @@ -43,7 +43,7 @@ - + 36 diff --git a/src/host.ps1 b/src/host.ps1 deleted file mode 100644 index a15bc59..0000000 --- a/src/host.ps1 +++ /dev/null @@ -1,191 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_HOST_FIELDS = "uuid,name_label,name_description,power_state,memory,address,hostname,version,productBrand,build,startTime,tags,bios_strings,license_params,license_server,license_expiry,residentVms,PIFs,PCIs,PGPUs,poolId,CPUs" - -function ConvertTo-XoHostObject { - <# - .SYNOPSIS - Convert a host object from the API to a PowerShell object. - .DESCRIPTION - Convert a host object from the API to a PowerShell object with proper properties and types. - This function creates a flat object using the raw values from the API response. - .PARAMETER InputObject - The host object from the API. - #> - [CmdletBinding()] - [OutputType("XoPowershell.Host")] - param ( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - HostUuid = $InputObject.uuid - Name = $InputObject.name_label - PowerState = $InputObject.power_state - Description = $InputObject.name_description - BiosStrings = $InputObject.bios_strings - LicenseParams = $InputObject.license_params - LicenseServer = $InputObject.license_server - LicenseExpiry = $InputObject.license_expiry - } - Set-XoObject $InputObject -TypeName XoPowershell.Host -Properties $props - } -} - -function Get-XoSingleHostById { - param ( - [string]$HostUuid, - [hashtable]$Params - ) - - try { - $uri = "$script:XoHost/rest/v0/hosts/$HostUuid" - $params = @{ fields = $script:XO_HOST_FIELDS } - $hostData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if ($hostData) { - return ConvertTo-XoHostObject -InputObject $hostData - } - } - catch { - throw ("Failed to retrieve host with UUID {0}: {1}" -f $HostUuid, $_) - } -} - -function Get-XoHost { - <# - .SYNOPSIS - Get physical hosts from Xen Orchestra. - .DESCRIPTION - Retrieves physical XCP-ng/XenServer hosts from Xen Orchestra. - Can retrieve specific hosts by their UUID or filter hosts by various criteria. - .PARAMETER HostUuid - The UUID(s) of the host(s) to retrieve. - .PARAMETER Filter - Filter to apply to the host query. - .PARAMETER Limit - Maximum number of results to return. Default is 25 if not specified. - .EXAMPLE - Get-XoHost - Returns up to 25 hosts. - .EXAMPLE - Get-XoHost -Limit 0 - Returns all hosts without limit. - .EXAMPLE - Get-XoHost -HostUuid "12345678-abcd-1234-abcd-1234567890ab" - Returns the host with the specified UUID. - .EXAMPLE - Get-XoHost -Filter "power_state:running" - Returns running hosts (up to default limit). - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - # Parameter sets: - # - "Filter": Gets hosts with optional filtering criteria (with optional limit) - # - "HostUuid": Gets specific hosts by UUID - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "HostUuid")] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [Alias("HostId")] - [string[]]$HostUuid, - - [Parameter(ParameterSetName = "Filter")] - [string]$Filter, - - [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = "Filter")] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [string]$PoolUuid, - - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - # use Invoke-XoRestMethod with JSON hashtable fallback in this cmdlet since server may send JSON object with multiple "cpus" keys, which confuses PowerShell when outputting PSObjects - - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { - throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") - } - - $params = @{ fields = $script:XO_HOST_FIELDS } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "HostUuid") { - foreach ($id in $HostUuid) { - ConvertTo-XoHostObject (Invoke-XoRestMethod -Uri "$script:XoHost/rest/v0/hosts/$id" -Body $params) - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - $AllFilters = $Filter - - if ($PoolUuid) { - $AllFilters = "$AllFilters `$pool:$PoolUuid" - } - - if ($AllFilters) { - Write-Verbose "Filter: $AllFilters" - $params["filter"] = $AllFilters - } - - if ($Limit) { - $params["limit"] = $Limit - } - - try { - $uri = "$script:XoHost/rest/v0/hosts" - $hostsResponse = Invoke-XoRestMethod -Uri $uri -Body $params - - if (!$hostsResponse -or $hostsResponse.Count -eq 0) { - Write-Verbose "No hosts found" - return - } - - foreach ($hostItem in $hostsResponse) { - ConvertTo-XoHostObject -InputObject $hostItem - } - } - catch { - throw ("Failed to list hosts. Error: {0}" -f $_) - } - } - } -} - -function Set-XoHost { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("HostId")] - [string]$HostUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description, - - [Parameter()] - [string[]]$Tags - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - if ($PSBoundParameters.ContainsKey("Tags")) { - $params["tags"] = $Tags - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/hosts/$HostUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} diff --git a/src/pool-patch.ps1 b/src/pool-patch.ps1 deleted file mode 100644 index a9dae3f..0000000 --- a/src/pool-patch.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -function ConvertTo-XoPoolPatchObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - Date = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.changelog.date).ToLocalTime() - Description = $InputObject.changelog.description - } - Set-XoObject $InputObject -TypeName XoPowershell.PoolPatch -Properties $props - } -} - -function Get-XoPoolPatch { - <# - .SYNOPSIS - Query pending patches for a Xen Orchestra pool. - .DESCRIPTION - Query pending patches for a Xen Orchestra pool. - #> - [CmdletBinding()] - param ( - # UUID of pools to query. - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [string]$PoolUuid - ) - - (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/missing_patches" @script:XoRestParameters -Body $params) | ConvertTo-XoPoolPatchObject -} diff --git a/src/pool.ps1 b/src/pool.ps1 deleted file mode 100644 index 85b5d04..0000000 --- a/src/pool.ps1 +++ /dev/null @@ -1,245 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_POOL_FIELDS = "auto_poweron,default_SR,HA_enabled,haSrs,master,tags,name_description,name_label,migrationCompression,cpus,zstdSupported,vtpmSupported,platform_version,type,uuid" - -function ConvertTo-XoPoolObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - PoolUuid = $InputObject.uuid - Name = $InputObject.name_label - Description = $InputObject.name_description - CpuCores = $InputObject.cpus.cores - PlatformVersion = $InputObject.platform_version - HAEnabled = $InputObject.HA_enabled - } - Set-XoObject $InputObject -TypeName XoPowershell.Pool -Properties $props - } -} - -function Get-XoPool { - <# - .SYNOPSIS - Query pools by UUID or condition. - .DESCRIPTION - Get pool details. You can specify pools by their UUIDs or properties. - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - param ( - # UUIDs of pools to query. - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "PoolUuid")] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [string[]]$PoolUuid, - - # Find pools that match the specified name substring. - [Parameter(ParameterSetName = "Filter")] - [string]$Name, - - # Filter to apply to the pool query. - [Parameter(ParameterSetName = "Filter")] - [string]$Filter, - - # Find pools that match any of the specified tags. - [Parameter(ParameterSetName = "Filter")] - [ValidateNotNullOrEmpty()] - [string[]]$Tag, - - # Maximum number of results to return. - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - $params = @{ - fields = $script:XO_POOL_FIELDS - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "PoolUuid") { - foreach ($id in $PoolUuid) { - ConvertTo-XoPoolObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$id" @script:XoRestParameters -Body $params) - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - $AllFilters = $Filter - - if ($Name) { - $AllFilters = "$AllFilters name_label:`"$Name`"" - } - - if ($Tag) { - $tags = ($tag | ForEach-Object { "`"$_`"" }) -join " " - $AllFilters = "$AllFilters tags:($tags)" - } - - if ($AllFilters) { - $params["filter"] = $AllFilters - } - - if ($Limit) { - $params["limit"] = $Limit - } - - (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools" @script:XoRestParameters -Body $params) | ConvertTo-XoPoolObject - } - } -} - -function Set-XoPool { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("PoolId")] - [string]$PoolUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description, - - [Parameter()] - [string[]]$Tags - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - if ($PSBoundParameters.ContainsKey("Tags")) { - $params["tags"] = $Tags - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} - -function Get-XoPoolMessage { - [CmdletBinding()] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [string]$PoolUuid - ) - - (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/messages" @script:XoRestParameters -Body $params) | ConvertFrom-XoUuidHref | ForEach-Object { - Get-XoMessage $_ - } -} - -# For convenience. Internal use only. -function Invoke-XoPoolAction { - [CmdletBinding()] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$PoolUuid, - - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string]$Action - ) - - process { - foreach ($id in $PoolUuid) { - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/actions/$Action" -Method Post @script:XoRestParameters | ForEach-Object { - ConvertFrom-XoTaskHref $_ - } - } - } -} - -function Restart-XoPool { - <# - .SYNOPSIS - Restart a running pool. - .DESCRIPTION - Restart the specified pools using a rolling pool reboot. - .PARAMETER PoolUuid - The UUID(s) of the pools(s) to restart. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$PoolUuid - ) - - process { - foreach ($id in $PoolUuid) { - if ($PSCmdlet.ShouldProcess($id, "Rolling pool reboot")) { - Invoke-XoPoolAction -PoolUuid $id -Action "rolling_reboot" - } - } - } -} - -function Stop-XoPool { - <# - .SYNOPSIS - Stop a running pool. - .DESCRIPTION - Stop the specified pools. Currently only supports emergency shutdown. - .PARAMETER PoolUuid - The UUID(s) of the pools(s) to stop. - .PARAMETER Force - Perform an emergency shutdown. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$PoolUuid, - - [Parameter(Mandatory)] - [switch]$Force - ) - - process { - # Note: "Stop" is quite different from "emergency shutdown", thus the "-Force" parameter being mandatory for now. - - foreach ($id in $PoolUuid) { - if ($PSCmdlet.ShouldProcess($id, "Emergency shutdown")) { - Invoke-XoPoolAction -PoolUuid $id -Action "emergency_shutdown" - } - } - } -} - -function Update-XoPool { - <# - .SYNOPSIS - Update a running pool. - .DESCRIPTION - Update the specified pools using a rolling pool update. - .PARAMETER PoolUuid - The UUID(s) of the pools(s) to update. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$PoolUuid - ) - - process { - foreach ($id in $PoolUuid) { - if ($PSCmdlet.ShouldProcess($id, "Rolling pool update")) { - Invoke-XoPoolAction -PoolUuid $id -Action "rolling_update" - } - } - } -} diff --git a/src/schedule.ps1 b/src/schedule.ps1 deleted file mode 100644 index 2ed8df1..0000000 --- a/src/schedule.ps1 +++ /dev/null @@ -1,105 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_SCHEDULE_FIELDS = "cron,enabled,name,timezone,id,jobId" - -function ConvertTo-XoScheduleObject { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject - ) - - process { - $props = @{ - ScheduleId = $InputObject.id - } - Set-XoObject $InputObject -TypeName XoPowershell.Schedule -Properties $props - } -} - -function Get-XoSchedule { - <# - .SYNOPSIS - List or query schedules. - .DESCRIPTION - Get Xen Orchestra schedules by UUID or list all existing schedules. - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - param ( - # UUIDs of schedules to query. - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "ScheduleUuid")] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [string[]]$ScheduleUuid, - - # Filter to apply to the schedule query. - [Parameter(ParameterSetName = "Filter")] - [string]$Filter, - - # Maximum number of results to return. - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - $params = @{ - fields = $script:XO_SCHEDULE_FIELDS - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "ScheduleUuid") { - foreach ($id in $ScheduleUuid) { - ConvertTo-XoScheduleObject (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/schedules/$id" @script:XoRestParameters -Body $params) - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - $AllFilters = $Filter - - if ($AllFilters) { - $params["filter"] = $AllFilters - } - - if ($Limit) { - $params["limit"] = $Limit - } - - # the parentheses forces the resulting array to unpack, don't remove them! - (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/schedules" @script:XoRestParameters -Body $params) | ConvertTo-XoScheduleObject - } - elseif ($PSCmdlet.ParameterSetName -eq "PoolUuid") { - (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/pools/$PoolUuid/schedules" @script:XoRestParameters -Body $params) | ConvertTo-XoScheduleObject - } - } -} - -function Start-XoSchedule { - <# - .SYNOPSIS - Start one or more schedules. - .DESCRIPTION - Starts the specified schedules. Returns a task object that can be used to monitor - the startup operation. - .PARAMETER ScheduleId - The ID(s) of the schedule(s) to start. - .EXAMPLE - Start-XoSchedule -ScheduleId "12345678-abcd-1234-abcd-1234567890ab" - Starts the schedule with the specified ID. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$ScheduleId - ) - - process { - foreach ($id in $ScheduleId) { - if ($PSCmdlet.ShouldProcess($id, "start")) { - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/schedules/$id/run" -Method Post @script:XoRestParameters | ForEach-Object { - ConvertFrom-XoTaskHref $_ - } - } - } - } -} diff --git a/src/sr.ps1 b/src/sr.ps1 deleted file mode 100644 index bff67c8..0000000 --- a/src/sr.ps1 +++ /dev/null @@ -1,175 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_SR_FIELDS = "name_label,uuid,SR_type,content_type,allocationStrategy,size,physical_usage,usage,shared" - -function ConvertTo-XoSrObject { - <# - .SYNOPSIS - Convert a storage repository object from the API to a PowerShell object. - .DESCRIPTION - Convert a storage repository object from the API to a PowerShell object with proper properties and types. - .PARAMETER InputObject - The storage repository object from the API. - #> - [CmdletBinding()] - [OutputType("XoPowershell.Sr")] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)] - $InputObject - ) - - process { - $props = @{ - SrUuid = $InputObject.uuid - Name = $InputObject.name_label - Type = $InputObject.SR_type - ContentType = $InputObject.content_type - SrSize = Format-XoSize $InputObject.size - UsageSize = Format-XoSize $InputObject.usage - PhysicalUsageSize = Format-XoSize $InputObject.physical_usage - } - Set-XoObject $InputObject -TypeName XoPowershell.Sr -Properties $props - } -} - -function Get-XoSingleSrById { - param ( - [string]$SrUuid, - [hashtable]$Params - ) - - try { - Write-Verbose "Getting SR with UUID $SrUuid" - $uri = "$script:XoHost/rest/v0/srs/$SrUuid" - $srData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params - - if ($srData) { - return ConvertTo-XoSrObject -InputObject $srData - } - } - catch { - throw ("Failed to retrieve SR with UUID {0}: {1}" -f $SrUuid, $_) - } - return $null -} - -function Get-XoSr { - <# - .SYNOPSIS - Get storage repositories from Xen Orchestra. - .DESCRIPTION - Retrieves storage repositories from Xen Orchestra. Can retrieve specific SRs by their UUID - or all SRs. - .PARAMETER SrUuid - The UUID(s) of the SR(s) to retrieve. - .PARAMETER Limit - Maximum number of results to return. Default is 25 if not specified. - Use -Limit 0 to return all results without limitation. - .EXAMPLE - Get-XoSr - Returns up to 25 SRs. - .EXAMPLE - Get-XoSr -Limit 0 - Returns all SRs without limit. - .EXAMPLE - Get-XoSr -SrUuid "a1b2c3d4" - Returns the SR with the specified UUID. - .EXAMPLE - Get-XoSr -Limit 5 - Returns the first 5 SRs. - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - # Parameter sets: - # - "Filter": Gets SRs with optional filtering criteria (with optional limit) - # - "SrUuid": Gets specific SRs by UUID - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "SrUuid")] - [ValidatePattern("[0-9a-z-]+")] - [Alias("SrId")] - [string[]]$SrUuid, - - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { - throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") - } - - $params = @{ - fields = $script:XO_SR_FIELDS - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "SrUuid") { - foreach ($id in $SrUuid) { - Get-XoSingleSrById -SrUuid $id -Params $params - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - if ($Limit) { - $params['limit'] = $Limit - } - - try { - Write-Verbose "Getting SRs with parameters: $($params | ConvertTo-Json -Compress)" - $uri = "$script:XoHost/rest/v0/srs" - $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if (!$response -or $response.Count -eq 0) { - Write-Verbose "No SRs found" - return - } - - Write-Verbose "Found $($response.Count) SRs" - - foreach ($srItem in $response) { - ConvertTo-XoSrObject -InputObject $srItem - } - } - catch { - throw ("Failed to list SRs. Error: {0}" -f $_) - } - } - } -} - -function Set-XoSr { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("SrId")] - [string]$SrUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description, - - [Parameter()] - [string[]]$Tags - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - if ($PSBoundParameters.ContainsKey("Tags")) { - $params["tags"] = $Tags - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/srs/$SrUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} diff --git a/src/task.ps1 b/src/task.ps1 deleted file mode 100644 index 1a2514e..0000000 --- a/src/task.ps1 +++ /dev/null @@ -1,283 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_TASK_FIELDS = "id,properties,start,status,result,updatedAt,end,progress" - -function ConvertTo-XoTaskObject { - <# - .SYNOPSIS - Convert a task object from the API to a PowerShell object. - .DESCRIPTION - Convert a task object from the API to a PowerShell object with proper properties. - .PARAMETER InputObject - The task object from the API. - #> - [CmdletBinding()] - [OutputType("XoPowershell.Task")] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)] - $InputObject - ) - - process { - $name = if ($InputObject.properties.name) { - $InputObject.properties.name - } - elseif ($InputObject.properties.method) { - $InputObject.properties.method - } - else { - "Unknown" - } - - $type = if ($InputObject.properties.type) { $InputObject.properties.type } else { "" } - - $startTime = if ($InputObject.start -and $InputObject.start -gt 0) { - [System.DateTimeOffset]::FromUnixTimeMilliseconds($InputObject.start).ToLocalTime() - } - else { - $null - } - - $endTime = if ($InputObject.end -and $InputObject.end -gt 0) { - [System.DateTimeOffset]::FromUnixTimeMilliseconds($InputObject.end).ToLocalTime() - } - else { - $null - } - - $message = if ($InputObject.result.message) { - $InputObject.result.message - } - elseif ($InputObject.result.code) { - $InputObject.result.code - } - else { - "" - } - - $props = @{ - PSTypeName = "XoPowershell.Task" - TaskId = $InputObject.id - Name = $name - Type = $type - Status = $InputObject.status - Progress = if ($null -ne $InputObject.progress) { $InputObject.progress } else { 0 } - StartTime = $startTime - EndTime = $endTime - Message = $message - } - - [PSCustomObject]$props - } -} - -function ConvertFrom-XoTaskHref { - <# - .SYNOPSIS - Convert a task URL to a task object - .DESCRIPTION - Extracts the task ID from a URL and retrieves the task from the API - .PARAMETER Uri - The task URL to convert - #> - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)] - [string]$Uri - ) - - process { - if ($Uri -notmatch "\/rest\/v0\/tasks\/([0-9a-z]+)") { - throw ("Bad task href format: {0}" -f $Uri) - } - - $taskId = $matches[1] - Get-XoTask -TaskId $taskId - } -} - -function Get-XoSingleTaskById { - <# - .SYNOPSIS - Get a single task by ID - .DESCRIPTION - Retrieves a single task from the API by its ID - .PARAMETER TaskId - The ID of the task to retrieve - .PARAMETER Params - Additional parameters to pass to the API - #> - [CmdletBinding()] - param ( - [string]$TaskId, - [hashtable]$Params - ) - - try { - Write-Verbose "Getting task with ID $TaskId" - $uri = "$script:XoHost/rest/v0/tasks/$TaskId" - $taskData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params - - if ($taskData) { - return ConvertTo-XoTaskObject -InputObject $taskData - } - } - catch { - throw ("Failed to retrieve task with ID {0}: {1}" -f $TaskId, $_) - } - return $null -} - -function Get-XoTask { - <# - .SYNOPSIS - Get tasks from Xen Orchestra. - .DESCRIPTION - Retrieves tasks from Xen Orchestra. Can retrieve specific tasks by their ID - or filter tasks by status. - .PARAMETER TaskId - The ID(s) of the task(s) to retrieve. - .PARAMETER Status - Filter tasks by status. Valid values: pending, success, failure. - .PARAMETER Limit - Maximum number of results to return. Default is 25 if not specified. - .EXAMPLE - Get-XoTask - Returns up to 25 tasks of any status. - .EXAMPLE - Get-XoTask -Status failure - Returns failed tasks. - .EXAMPLE - Get-XoTask -TaskId "0m8k2zkzi" - Returns the task with the specified ID. - .EXAMPLE - Get-XoTask -Limit 5 - Returns the first 5 tasks. - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "TaskId")] - [ValidateNotNullOrEmpty()] - [string[]]$TaskId, - - [Parameter(ParameterSetName = "Filter")] - [ValidateSet("pending", "success", "failure")] - [string]$Status, - - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { - throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") - } - - $params = @{ - fields = $script:XO_TASK_FIELDS - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "TaskId") { - foreach ($id in $TaskId) { - Get-XoSingleTaskById -TaskId $id -Params $params - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - if ($Status) { - $params['filter'] = $Status - } - - if ($Limit) { - $params['limit'] = $Limit - } - - try { - Write-Verbose "Getting tasks with parameters: $($params | ConvertTo-Json -Compress)" - $uri = "$script:XoHost/rest/v0/tasks" - $tasksResponse = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if ($null -eq $tasksResponse -or $tasksResponse.Count -eq 0) { - Write-Verbose "No tasks found matching criteria" - return - } - - Write-Verbose "Found $($tasksResponse.Count) tasks" - - foreach ($taskItem in $tasksResponse) { - ConvertTo-XoTaskObject -InputObject $taskItem - } - } - catch { - if ($PSBoundParameters.ContainsKey('Status')) { - throw ("Failed to retrieve tasks with status {0}: {1}" -f $Status, $_) - } - else { - throw ("Failed to retrieve tasks: {0}" -f $_) - } - } - } - } -} - -New-Alias -Name Get-XoTaskDetails -Value Get-XoTask - -function Wait-XoTask { - <# - .SYNOPSIS - Wait for task completion. - .DESCRIPTION - Waits for the specified tasks to complete and optionally returns the result. - .PARAMETER TaskId - The ID(s) of the task(s) to wait for. - .PARAMETER PassThru - If specified, returns the task objects after completion. - .EXAMPLE - Wait-XoTask -TaskId "0m8k2zkzi" - Waits for the task to complete. - .EXAMPLE - Wait-XoTask -TaskId "0m8k2zkzi" -PassThru - Waits for the task to complete and returns the task object. - #> - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [ValidateNotNullOrEmpty()] - [string[]]$TaskId, - - [Parameter()] - [switch]$PassThru - ) - - begin { - $params = @{ - fields = $script:XO_TASK_FIELDS - wait = "result" - } - $ids = @() - } - - process { - $ids += $TaskId - } - - end { - foreach ($id in $ids) { - try { - $uri = "$script:XoHost/rest/v0/tasks/$id" - $result = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if ($PassThru -and $result) { - ConvertTo-XoTaskObject -InputObject $result - } - } - catch { - throw ("Error waiting for task {0}: {1}" -f $id, $_) - } - } - } -} diff --git a/src/utils.ps1 b/src/utils.ps1 deleted file mode 100644 index 5777288..0000000 --- a/src/utils.ps1 +++ /dev/null @@ -1,102 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -function Remove-XoEmptyValues { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)][ValidateNotNull()][System.Collections.IDictionary]$InputObject - ) - $ret = @{} - foreach ($kv in $InputObject.GetEnumerator()) { - if ($null -ne $kv.Value -and ![string]::IsNullOrEmpty($kv.Value -as [string])) { - $ret.Add($kv.Key, $kv.Value) - } - } - return $ret -} - -function Set-XoObject { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)]$InputObject, - [Parameter()][string]$TypeName, - [Parameter()][hashtable]$Properties - ) - - if ($TypeName) { - $InputObject.PSObject.TypeNames.Insert(0, $TypeName) > $null - } - if ($Properties) { - foreach ($key in $Properties.Keys) { - $InputObject.PSObject.Properties.Add([psnoteproperty]::new($key, $Properties[$key])) > $null - } - } - [PSCustomObject]$InputObject -} - -function ConvertFrom-XoSecureString { - [CmdletBinding()] - param ( - [Parameter(Mandatory, Position = 0, ValueFromPipeline)][securestring]$SecureString - ) - - process { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString) - try { - return [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - } - finally { - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) - } - } -} - -function Format-XoSize { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)][long]$Value - ) - - # based off of https://stackoverflow.com/a/40887001/8642889 - - $suffix = " B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" - $index = 0 - while ($Value -gt 1kb -and $index -lt $suffix.Length) { - $Value = $Value / 1kb - $index++ - } - - "{0:N1} {1}" -f $Value, $suffix[$index] -} - -function ConvertFrom-XoUuidHref { - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)][string]$Uri - ) - - process { - if ($Uri -notmatch "\/rest\/v0\/[0-9a-z-_]+\/[0-9a-z-]+") { - throw "Bad href format" - } - [uri]::new([uri]$script:XoHost, $Uri).Segments[-1] - } -} - -function Invoke-XoRestMethod { - <# - .SYNOPSIS - Helper for when Invoke-RestMethod returns unparseable JSON. - .DESCRIPTION - Helper for when Invoke-RestMethod returns unparseable JSON (e.g. due to duplicate keys). $script:XoRestParameters is already included. - #> - param( - [Parameter(Mandatory)][string]$Uri, - [Parameter()][object]$Body - ) - - $result = Invoke-RestMethod @script:XoRestParameters -Uri $uri -Body $body - if ($result -is [string]) { - Write-Verbose "server returned unparseable JSON, retrying with -AsHashtable" - return [pscustomobject](ConvertFrom-Json -AsHashtable $result) - } else { - return $result - } -} diff --git a/src/vdi-snapshot.ps1 b/src/vdi-snapshot.ps1 deleted file mode 100644 index 45e63d1..0000000 --- a/src/vdi-snapshot.ps1 +++ /dev/null @@ -1,206 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_VDI_SNAPSHOT_FIELDS = "name_label,size,uuid,snapshot_time,snapshot_of,sr_uuid,usage" - -function ConvertTo-XoVdiSnapshotObject { - <# - .SYNOPSIS - Convert a VDI snapshot object from the API to a PowerShell object. - .DESCRIPTION - Convert a VDI snapshot object from the API to a PowerShell object with proper properties. - .PARAMETER InputObject - The VDI snapshot object from the API. - #> - [CmdletBinding()] - [OutputType("XoPowershell.VdiSnapshot")] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)] - [PSObject] $InputObject - ) - - process { - $props = @{ - PSTypeName = "XoPowershell.VdiSnapshot" - VdiSnapshotUuid = $InputObject.uuid - Name = $InputObject.name_label - Size = $InputObject.size - SnapshotOf = $InputObject.snapshot_of - SnapshotTime = $InputObject.snapshot_time - SrUuid = $InputObject.sr_uuid - Usage = $InputObject.usage - } - - [PSCustomObject]$props - } -} - -function Get-XoSingleVdiSnapshotById { - param ( - [string]$VdiSnapshotUuid, - [hashtable]$Params - ) - - try { - Write-Verbose "Getting VDI snapshot with UUID $VdiSnapshotUuid" - $uri = "$script:XoHost/rest/v0/vdi-snapshots/$VdiSnapshotUuid" - $snapshotData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params - - if ($snapshotData) { - return ConvertTo-XoVdiSnapshotObject -InputObject $snapshotData - } - } - catch { - throw ("Failed to retrieve VDI snapshot with UUID {0}: {1}" -f $VdiSnapshotUuid, $_) - } - return $null -} - -function Get-XoVdiSnapshot { - <# - .SYNOPSIS - Get VDI snapshots from Xen Orchestra. - .DESCRIPTION - Retrieves VDI snapshots from Xen Orchestra. Can retrieve specific snapshots by their UUID - or filter snapshots by various criteria. - .PARAMETER VdiSnapshotUuid - The UUID(s) of the VDI snapshot(s) to retrieve. - .PARAMETER Filter - Filter to apply to the snapshot query. - .PARAMETER Limit - Maximum number of results to return. Default is 25 if not specified. - .EXAMPLE - Get-XoVdiSnapshot - Returns up to 25 VDI snapshots. - .EXAMPLE - Get-XoVdiSnapshot -Limit 0 - Returns all VDI snapshots without limit. - .EXAMPLE - Get-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" - Returns the VDI snapshot with the specified UUID. - .EXAMPLE - Get-XoVdiSnapshot -Filter "name_label:backup*" - Returns VDI snapshots with names starting with "backup" (up to default limit). - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VdiSnapshotUuid")] - [Alias("VdiSnapshotId")] - [string[]]$VdiSnapshotUuid, - - [Parameter(ParameterSetName = "Filter")] - [string]$Filter, - - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { - throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") - } - - $params = @{ fields = $script:XO_VDI_SNAPSHOT_FIELDS } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "VdiSnapshotUuid") { - foreach ($id in $VdiSnapshotUuid) { - Get-XoSingleVdiSnapshotById -VdiSnapshotUuid $id -Params $params - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - if ($Filter) { - $params['filter'] = $Filter - } - - if ($Limit) { - $params['limit'] = $Limit - } - - try { - Write-Verbose "Getting VDI snapshots with parameters: $($params | ConvertTo-Json -Compress)" - $uri = "$script:XoHost/rest/v0/vdi-snapshots" - $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if (!$response -or $response.Count -eq 0) { - Write-Verbose "No VDI snapshots found matching criteria" - return - } - - Write-Verbose "Found $($response.Count) VDI snapshots" - - foreach ($snapshotItem in $response) { - ConvertTo-XoVdiSnapshotObject -InputObject $snapshotItem - } - } - catch { - throw ("Failed to list VDI snapshots. Error: {0}" -f $_) - } - } - } -} - -function Export-XoVdiSnapshot { - <# - .SYNOPSIS - Export a VDI snapshot. - .DESCRIPTION - Export a VDI snapshot from Xen Orchestra. Downloads the snapshot to a local file. - .PARAMETER VdiSnapshotUuid - The UUID of the VDI snapshot to export. - .PARAMETER Format - The format to export the VDI snapshot in. Valid values: raw, vhd. - .PARAMETER OutFile - The path to save the exported VDI snapshot to. - .PARAMETER PassThru - If specified, returns the exported file info as a FileInfo object. - .EXAMPLE - Export-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" -Format vhd -OutFile "C:\Exports\snapshot.vhd" - Exports the VDI snapshot in VHD format to the specified file. - .EXAMPLE - Get-XoVdiSnapshot -VdiSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" | Export-XoVdiSnapshot -Format vhd -OutFile "C:\Exports\snapshot.vhd" - Exports the VDI snapshot in VHD format to the specified file, piping from Get-XoVdiSnapshot. - #> - [CmdletBinding(SupportsShouldProcess)] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [Alias("VdiSnapshotId")] - [string]$VdiSnapshotUuid, - - [Parameter(Mandatory)] - [ValidateSet("raw", "vhd")] - [string]$Format, - - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string]$OutFile, - - [Parameter()] - [switch]$PassThru - ) - - - process { - $resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutFile) - - if ($PSCmdlet.ShouldProcess($VdiSnapshotUuid, "export to $resolvedPath in $Format format")) { - try { - $uri = "$script:XoHost/rest/v0/vdi-snapshots/$VdiSnapshotUuid/export" - $params = @{ format = $Format } - - Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params -OutFile $resolvedPath - - if ($PassThru) { - Get-Item $resolvedPath - } - } - catch { - throw ("Failed to export VDI snapshot with UUID {0}: {1}" -f $VdiSnapshotUuid, $_) - } - } - } -} diff --git a/src/vdi.ps1 b/src/vdi.ps1 deleted file mode 100644 index 09aeaf8..0000000 --- a/src/vdi.ps1 +++ /dev/null @@ -1,252 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_VDI_FIELDS = "name_label,uuid,content_type,size,usage,physical_usage,`$SR,sr_usage" - -function ConvertTo-XoVdiObject { - <# - .SYNOPSIS - Convert a VDI object from the API to a PowerShell object. - .DESCRIPTION - Convert a VDI object from the API to a PowerShell object with proper properties and types. - .PARAMETER InputObject - The VDI object from the API. - #> - [CmdletBinding()] - [OutputType("XoPowershell.Vdi")] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)] - [PSObject] $InputObject - ) - - - process { - $props = @{ - PSTypeName = "XoPowershell.Vdi" - VdiUuid = $InputObject.uuid - Name = $InputObject.name_label - ContentType = $InputObject.content_type - Size = $InputObject.size - Usage = $InputObject.usage - PhysicalUsage = $InputObject.physical_usage - SrUuid = $InputObject.sr_uuid - SrUsage = $InputObject.sr_usage - } - - [PSCustomObject]$props - } -} - -function Get-XoSingleVdiById { - param ( - [string]$VdiUuid, - [hashtable]$Params - ) - - try { - Write-Verbose "Getting VDI with UUID $VdiUuid" - $uri = "$script:XoHost/rest/v0/vdis/$VdiUuid" - $vdiData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $Params - - if ($vdiData) { - return ConvertTo-XoVdiObject -InputObject $vdiData - } - } - catch { - throw ("Failed to retrieve VDI with UUID {0}: {1}" -f $VdiUuid, $_) - } - return $null -} - -function Get-XoVdi { - <# - .SYNOPSIS - Get VDIs from Xen Orchestra. - .DESCRIPTION - Retrieves VDIs from Xen Orchestra. Can retrieve specific VDIs by their UUID - or filter VDIs by various criteria. - .PARAMETER VdiUuid - The UUID(s) of the VDI(s) to retrieve. - .PARAMETER SrUuid - Filter VDIs by storage repository UUID. - .PARAMETER Filter - Custom filter to apply to the VDI query. - .PARAMETER Limit - Maximum number of results to return. Default is 25 if not specified. - .EXAMPLE - Get-XoVdi - Returns up to 25 VDIs. - .EXAMPLE - Get-XoVdi -Limit 0 - Returns all VDIs without limit. - .EXAMPLE - Get-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" - Returns the VDI with the specified UUID. - .EXAMPLE - Get-XoVdi -SrUuid "12345678-abcd-1234-abcd-1234567890ab" - Returns VDIs on the specified storage repository (up to default limit). - .EXAMPLE - Get-XoVdi -Filter "name_label:backup*" - Returns VDIs with names starting with "backup" (up to default limit). - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VdiUuid")] - [Alias("VdiId")] - [string[]]$VdiUuid, - - [Parameter(ParameterSetName = "Filter")] - [string]$SrUuid, - - [Parameter(ParameterSetName = "Filter")] - [string]$Filter, - - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { - throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") - } - - $params = @{ fields = $script:XO_VDI_FIELDS } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "VdiUuid") { - foreach ($id in $VdiUuid) { - Get-XoSingleVdiById -VdiUuid $id -Params $params - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - $filterParts = @() - - if ($SrUuid) { - $filterParts += "`$SR:$SrUuid" - } - - if ($Filter) { - $filterParts += $Filter - } - - if ($filterParts.Count -gt 0) { - $params['filter'] = $filterParts -join " " - } - - if ($Limit) { - $params['limit'] = $Limit - } - - try { - Write-Verbose "Getting VDIs with parameters: $($params | ConvertTo-Json -Compress)" - $uri = "$script:XoHost/rest/v0/vdis" - $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if (!$response -or $response.Count -eq 0) { - Write-Verbose "No VDIs found matching criteria" - return - } - - Write-Verbose "Found $($response.Count) VDIs" - - foreach ($vdiItem in $response) { - ConvertTo-XoVdiObject -InputObject $vdiItem - } - } - catch { - throw ("Failed to list VDIs. Error: {0}" -f $_) - } - } - } -} - -function Set-XoVdi { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("VdiId")] - [string]$VdiUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vdis/$VdiUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} - -function Export-XoVdi { - <# - .SYNOPSIS - Export a VDI. - .DESCRIPTION - Export a VDI from Xen Orchestra. Downloads the VDI to a local file. - .PARAMETER VdiUuid - The UUID of the VDI to export. - .PARAMETER Format - The format to export the VDI in. Valid values: raw, vhd. - .PARAMETER OutFile - The path to save the exported VDI to. - .PARAMETER PassThru - If specified, returns the exported file info as a FileInfo object. - .EXAMPLE - Export-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" -Format vhd -OutFile "C:\Exports\disk.vhd" - Exports the VDI in VHD format to the specified file. - .EXAMPLE - Get-XoVdi -VdiUuid "12345678-abcd-1234-abcd-1234567890ab" | Export-XoVdi -Format vhd -OutFile "C:\Exports\disk.vhd" - Exports the VDI in VHD format to the specified file, piping from Get-XoVdi. - #> - [CmdletBinding(SupportsShouldProcess)] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [Alias("VdiId")] - [string]$VdiUuid, - - [Parameter(Mandatory)] - [ValidateSet("raw", "vhd")] - [string]$Format, - - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] - [string]$OutFile, - - [Parameter()] - [switch]$PassThru - ) - - process { - if ($PSCmdlet.ShouldProcess($VdiUuid, "export to $OutFile in $Format format")) { - try { - $uri = "$script:XoHost/rest/v0/vdis/$VdiUuid/export" - $params = @{ format = $Format } - - Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params -OutFile $OutFile - - if ($PassThru) { - Get-Item $OutFile - } - } - catch { - throw ("Failed to export VDI with UUID {0}: {1}" -f $VdiUuid, $_) - } - } - } -} diff --git a/src/vm-snapshot.ps1 b/src/vm-snapshot.ps1 deleted file mode 100644 index 6ad8402..0000000 --- a/src/vm-snapshot.ps1 +++ /dev/null @@ -1,193 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_VM_SNAPSHOT_FIELDS = "uuid,name_label,name_description,snapshot_time,snapshot_of,power_state,tags,CPUs,memory" - -function ConvertTo-XoVmSnapshotObject { - <# - .SYNOPSIS - Convert a VM snapshot object from the API to a PowerShell object. - .DESCRIPTION - Convert a VM snapshot object from the API to a PowerShell object with proper properties. - .PARAMETER InputObject - The VM snapshot object from the API. - #> - [CmdletBinding()] - param ( - [parameter(Mandatory = $true)] - [PSObject] $InputObject - ) - - # Create object with direct properties from API - $snapshotObj = [PSCustomObject]@{ - PSTypeName = "XoPowershell.VmSnapshot" - VmSnapshotUuid = $InputObject.uuid - Name = $InputObject.name_label - Description = $InputObject.name_description - PowerState = $InputObject.power_state - SnapshotOf = $InputObject.snapshot_of - SnapshotTime = [System.DateTimeOffset]::FromUnixTimeSeconds($InputObject.snapshot_time).ToLocalTime() - Memory = $InputObject.memory - } - - if ($null -ne $InputObject.CPUs) { - if ($InputObject.CPUs.PSObject.Properties.Name -contains 'number') { - $snapshotObj | Add-Member -MemberType NoteProperty -Name CPUs -Value $InputObject.CPUs.number - } - elseif ($InputObject.CPUs.PSObject.Properties.Name -contains 'max') { - $snapshotObj | Add-Member -MemberType NoteProperty -Name CPUs -Value $InputObject.CPUs.max - } - } - - return $snapshotObj -} - -function Get-XoVmSnapshot { - <# - .SYNOPSIS - Get VM snapshots. - .DESCRIPTION - Retrieves VM snapshots from Xen Orchestra. Can retrieve specific snapshots by their UUID - or filter snapshots by various criteria. - .PARAMETER VmSnapshotUuid - The UUID(s) of the VM snapshot(s) to retrieve. - .PARAMETER Filter - Filter to apply to the snapshot query. - .PARAMETER Limit - Maximum number of results to return. Default is 25 if not specified. - .EXAMPLE - Get-XoVmSnapshot - Returns up to 25 VM snapshots. - .EXAMPLE - Get-XoVmSnapshot -Limit 0 - Returns all VM snapshots without limit. - .EXAMPLE - Get-XoVmSnapshot -VmSnapshotUuid "12345678-abcd-1234-abcd-1234567890ab" - Returns the VM snapshot with the specified UUID. - .EXAMPLE - Get-XoVmSnapshot -Filter "name_label:backup" - Returns VM snapshots with "backup" in their name (up to default limit). - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VmSnapshotUuid")] - [ValidateNotNullOrEmpty()] - [Alias("Snapshot")] - [string[]]$VmSnapshotUuid, - - [Parameter(ParameterSetName = "Filter")] - [string]$Filter, - - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { - throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") - } - - $params = @{ fields = $script:XO_VM_SNAPSHOT_FIELDS } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "VmSnapshotUuid") { - foreach ($id in $VmSnapshotUuid) { - try { - Write-Verbose "Getting VM snapshot with UUID $id" - $snapshotData = Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vm-snapshots/$id" @script:XoRestParameters - ConvertTo-XoVmSnapshotObject $snapshotData - } - catch { - throw ("Failed to retrieve VM snapshot with UUID {0}: {1}" -f $id, $_) - } - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - if ($Filter) { - $params["filter"] = $Filter - } - - if ($Limit) { - $params["limit"] = $Limit - } - - try { - $uri = "$script:XoHost/rest/v0/vm-snapshots" - Write-Verbose "Getting VM snapshots from $uri with parameters: $($params | ConvertTo-Json -Compress)" - - $snapshotsResponse = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if (!$snapshotsResponse -or $snapshotsResponse.Count -eq 0) { - Write-Verbose "No VM snapshots found matching criteria" - return - } - - Write-Verbose "Found $($snapshotsResponse.Count) VM snapshots" - - foreach ($snapshotItem in $snapshotsResponse) { - ConvertTo-XoVmSnapshotObject $snapshotItem - } - } - catch { - throw ("Failed to list VM snapshots. Error: {0}" -f $_) - } - } - } -} - -function New-XoVmSnapshot { - <# - .SYNOPSIS - Create a snapshot of one or more VMs. - .DESCRIPTION - Creates a snapshot of the specified VMs. Optionally, you can specify a custom name - for the snapshot. - .PARAMETER VmUuid - The UUID(s) of the VM(s) to snapshot. - .PARAMETER SnapshotName - The name to give to the snapshot. If not specified, a default name will be used. - .PARAMETER NameLabel - Alias for SnapshotName. The name to give to the snapshot. - .EXAMPLE - New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" - Creates a snapshot of the VM with the specified UUID. - .EXAMPLE - New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" -SnapshotName "Before Update" - Creates a snapshot named "Before Update" of the VM with the specified UUID. - .EXAMPLE - New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" -NameLabel "Before Update" - Creates a snapshot named "Before Update" of the VM with the specified UUID. - .EXAMPLE - Get-XoVm -PowerState Running | New-XoVmSnapshot -SnapshotName "Backup $(Get-Date -Format 'yyyy-MM-dd')" - Creates a dated snapshot of all running VMs. - #> - [CmdletBinding(SupportsShouldProcess)] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$VmUuid, - - [Parameter()] - [Alias("NameLabel")] - [string]$SnapshotName - ) - - begin { - $params = Remove-XoEmptyValues @{ - name_label = $SnapshotName - } - } - - process { - foreach ($id in $VmUuid) { - if ($PSCmdlet.ShouldProcess($id, "snapshot")) { - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/snapshot" -Method Post @script:XoRestParameters -Body $params | ForEach-Object { - ConvertFrom-XoTaskHref $_ - } - } - } - } -} diff --git a/src/vm.ps1 b/src/vm.ps1 deleted file mode 100644 index e3959de..0000000 --- a/src/vm.ps1 +++ /dev/null @@ -1,418 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$script:XO_VM_FIELDS = "uuid,name_label,name_description,power_state,addresses,tags,memory,VIFs,snapshots,current_operations,auto_poweron,os_version,startTime,VCPUs_at_startup,CPUs,VCPUs_number,`$VBDs" -$script:XO_VM_TEMPLATE_FIELDS = $script:XO_VM_FIELDS + ",isDefaultTemplate" - -function ConvertTo-XoVmObject { - <# - .SYNOPSIS - Convert a VM object from the API to a PowerShell object. - .DESCRIPTION - Convert a VM object from the API to a PowerShell object with proper properties and types. - .PARAMETER InputObject - The VM object from the API. - #> - [CmdletBinding()] - [OutputType("XoPowershell.Vm")] - param( - [Parameter(Mandatory, ValueFromPipeline, Position = 0)] - [PSObject] $InputObject - ) - - process { - $props = @{ - VmUuid = $InputObject.uuid - Name = $InputObject.name_label - Description = $InputObject.name_description - PowerState = $InputObject.power_state - OsVersion = $InputObject.os_version - Parent = $InputObject.parent - HostUuid = $InputObject.$container - } - - if ($InputObject.CPUs.number) { - $props["CPUs"] = $InputObject.CPUs.number - } - elseif ($InputObject.CPUs.max) { - $props["CPUs"] = $InputObject.CPUs.max - } - else { - $props["CPUs"] = $null - } - - Set-XoObject $InputObject -TypeName XoPowershell.Vm -Properties $props - } -} - -function Get-XoSingleVmById { - param ( - [string]$VmUuid - ) - - try { - $uri = "$script:XoHost/rest/v0/vms/$VmUuid" - $params = @{ fields = $script:XO_VM_FIELDS } - $vmData = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if ($vmData) { - return ConvertTo-XoVmObject -InputObject $vmData - } - } - catch { - throw ("Failed to retrieve VM with UUID {0}: {1}" -f $VmUuid, $_) - } - return $null -} - -function Get-XoVm { - <# - .SYNOPSIS - Get VMs from Xen Orchestra. - .DESCRIPTION - Retrieves VMs from Xen Orchestra. Can retrieve specific VMs by their UUID - or filter VMs by power state, tags, or custom filters. - .PARAMETER VmUuid - The UUID(s) of the VM(s) to retrieve. - .PARAMETER PowerState - Filter VMs by power state. Valid values: Running, Halted, Suspended. - .PARAMETER Tag - Filter VMs by tag. - .PARAMETER Filter - Custom filter to apply to the VM query. - .PARAMETER Limit - Maximum number of results to return. Default is 25 if not specified. - .EXAMPLE - Get-XoVm - Returns up to 25 VMs. - .EXAMPLE - Get-XoVm -Limit 0 - Returns all VMs without limit. - .EXAMPLE - Get-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" - Returns the VM with the specified UUID. - .EXAMPLE - Get-XoVm -PowerState Running - Returns running VMs (up to default limit). - .EXAMPLE - Get-XoVm -Tag "Production" - Returns VMs tagged with "Production" (up to default limit). - .EXAMPLE - Get-XoVm -Filter "name_label:test*" - Returns VMs with names starting with "test" (up to default limit). - #> - [CmdletBinding(DefaultParameterSetName = "Filter")] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = "VmUuid")] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [Alias("VmId")] - [string[]]$VmUuid, - - [Parameter(ParameterSetName = "Filter")] - [ValidateSet("Running", "Halted", "Suspended")] - [string[]]$PowerState, - - [Parameter(ParameterSetName = "Filter")] - [string[]]$Tag, - - [Parameter(ParameterSetName = "Filter")] - [string]$Filter, - - [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = "Filter")] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [string]$PoolUuid, - - [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = "Filter")] - [ValidatePattern("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")] - [string]$HostUuid, - - [Parameter(ParameterSetName = "Filter")] - [int]$Limit = $script:XoSessionLimit - ) - - begin { - if (-not $script:XoHost -or -not $script:XoRestParameters) { - throw ("Not connected to Xen Orchestra. Call Connect-XoSession first.") - } - - $params = @{ fields = $script:XO_VM_FIELDS } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "VmUuid") { - foreach ($id in $VmUuid) { - Get-XoSingleVmById -VmUuid $id - } - } - } - - end { - if ($PSCmdlet.ParameterSetName -eq "Filter") { - $AllFilters = $Filter - - if ($PowerState) { - $AllFilters = "$AllFilters power_state:($($PowerState -join '|'))" - } - - if ($Tag) { - $AllFilters = "$AllFilters tags:($($Tag -join '&'))" - } - - if ($PoolUuid) { - $AllFilters = "$AllFilters `$pool:$PoolUuid" - } - - if ($HostUuid) { - $AllFilters = "$AllFilters `$container:$HostUuid" - } - - if ($AllFilters) { - Write-Verbose "Filter: $AllFilters" - $params["filter"] = $AllFilters - } - - if ($Limit) { - $params['limit'] = $Limit - } - - try { - $uri = "$script:XoHost/rest/v0/vms" - Write-Verbose "Getting VMs from $uri with parameters: $($params | ConvertTo-Json -Compress)" - - $response = Invoke-RestMethod -Uri $uri @script:XoRestParameters -Body $params - - if (!$response -or $response.Count -eq 0) { - Write-Verbose "No VMs found matching criteria" - return - } - - Write-Verbose "Found $($response.Count) VMs" - - foreach ($vmItem in $response) { - ConvertTo-XoVmObject -InputObject $vmItem - } - } - catch { - throw ("Failed to list VMs. Error: {0}" -f $_) - } - } - } -} - -function Set-XoVm { - [CmdletBinding()] - param( - [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] - [Alias("VmId")] - [string]$VmUuid, - - [Parameter()] - [string]$Name, - - [Parameter()] - [string]$Description, - - [Parameter()] - [string[]]$Tags - ) - - $params = @{} - - if ($PSBoundParameters.ContainsKey("Name")) { - $params["name_label"] = $Name - } - if ($PSBoundParameters.ContainsKey("Description")) { - $params["name_description"] = $Description - } - if ($PSBoundParameters.ContainsKey("Tags")) { - $params["tags"] = $Tags - } - - if ($params.Count -gt 0) { - $body = [System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json $params)) - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$VmUuid" @script:XoRestParameters -Method Patch -ContentType "application/json" -Body $body - } -} - -function Get-XoVmVdi { - <# - .SYNOPSIS - Get virtual disks attached to a VM. - .DESCRIPTION - Retrieves all virtual disk images (VDIs) attached to a specified VM. - .PARAMETER VmUuid - The UUID of the VM to get VDIs for. - .EXAMPLE - Get-XoVmVdi -VmUuid "12345678-abcd-1234-abcd-1234567890ab" - Returns all virtual disks attached to the specified VM. - .EXAMPLE - Get-XoVm -PowerState Running | Get-XoVmVdi - Returns all virtual disks attached to running VMs. - #> - [CmdletBinding()] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$VmUuid - ) - - begin { - $params = @{ - fields = $script:XO_VDI_FIELDS - } - } - - process { - foreach ($id in $VmUuid) { - (Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/vdis" @script:XoRestParameters -Body $params) | ConvertTo-XoVdiObject - } - } -} - -function Start-XoVm { - <# - .SYNOPSIS - Start one or more VMs. - .DESCRIPTION - Starts the specified VMs. Returns a task object that can be used to monitor - the startup operation. - .PARAMETER VmUuid - The UUID(s) of the VM(s) to start. - .EXAMPLE - Start-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" - Starts the VM with the specified UUID. - .EXAMPLE - Get-XoVm -PowerState Halted | Start-XoVm - Starts all halted VMs. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$VmUuid - ) - - process { - foreach ($id in $VmUuid) { - if ($PSCmdlet.ShouldProcess($id, "start")) { - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/start" -Method Post @script:XoRestParameters | ForEach-Object { - ConvertFrom-XoTaskHref $_ - } - } - } - } -} - -function Stop-XoVm { - <# - .SYNOPSIS - Stop one or more VMs. - .DESCRIPTION - Stops the specified VMs. By default, performs a clean shutdown. - Use -Force to perform a hard shutdown. - .PARAMETER VmUuid - The UUID(s) of the VM(s) to stop. - .PARAMETER Force - If specified, performs a hard shutdown instead of a clean shutdown. - .EXAMPLE - Stop-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" - Performs a clean shutdown of the VM with the specified UUID. - .EXAMPLE - Get-XoVm -PowerState Running | Stop-XoVm -Force - Performs a hard shutdown of all running VMs. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$VmUuid, - [Parameter()][switch]$Force - ) - - begin { - $action = if ($Force) { "hard_shutdown" } else { "clean_shutdown" } - } - - process { - foreach ($id in $VmUuid) { - if ($PSCmdlet.ShouldProcess($id, $action)) { - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/$action" -Method Post @script:XoRestParameters | ForEach-Object { - ConvertFrom-XoTaskHref $_ - } - } - } - } -} - -function Restart-XoVm { - <# - .SYNOPSIS - Restart one or more VMs. - .DESCRIPTION - Restarts the specified VMs. By default, performs a clean reboot. - Use -Force to perform a hard reboot. - .PARAMETER VmUuid - The UUID(s) of the VM(s) to restart. - .PARAMETER Force - If specified, performs a hard reboot instead of a clean reboot. - .EXAMPLE - Restart-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" - Performs a clean reboot of the VM with the specified UUID. - .EXAMPLE - Get-XoVm -PowerState Running | Restart-XoVm -Force - Performs a hard reboot of all running VMs. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$VmUuid, - [Parameter()][switch]$Force - ) - - begin { - $action = if ($Force) { "hard_reboot" } else { "clean_reboot" } - } - - process { - foreach ($id in $VmUuid) { - if ($PSCmdlet.ShouldProcess($id, $action)) { - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/$action" -Method Post @script:XoRestParameters | ForEach-Object { - ConvertFrom-XoTaskHref $_ - } - } - } - } -} - -function Suspend-XoVm { - <# - .SYNOPSIS - Suspend one or more VMs. - .DESCRIPTION - Suspends the specified VMs. - .PARAMETER VmUuid - The UUID(s) of the VM(s) to suspend. - .EXAMPLE - Suspend-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab" - Suspends the VM with the specified UUID. - .EXAMPLE - Get-XoVm -PowerState Running | Suspend-XoVm - Suspends all running VMs. - #> - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Medium")] - param ( - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [ValidateNotNullOrEmpty()] - [string[]]$VmUuid - ) - - process { - foreach ($id in $VmUuid) { - if ($PSCmdlet.ShouldProcess($id, "suspend")) { - Invoke-RestMethod -Uri "$script:XoHost/rest/v0/vms/$id/actions/suspend" -Method Post @script:XoRestParameters | ForEach-Object { - ConvertFrom-XoTaskHref $_ - } - } - } - } -} diff --git a/src/xo-powershell.psd1 b/src/xo-powershell.psd1 new file mode 100644 index 0000000..1fd434c --- /dev/null +++ b/src/xo-powershell.psd1 @@ -0,0 +1,148 @@ +# +# Module manifest for module 'xo-powershell' +# +# Generated by: Vates +# +# Generated on: 4/20/2026 +# + +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'xo-powershell.psm1' + + # Version number of this module. + ModuleVersion = '1.0.0' + + # Supported PSEditions + # CompatiblePSEditions = @() + + # ID used to uniquely identify this module + GUID = 'adaf591c-6abd-4084-89f9-d75a9096743d' + + # Author of this module + Author = 'Vates' + + # Company or vendor of this module + CompanyName = 'Vates' + + # Copyright statement for this module + Copyright = 'Copyright (c) Vates.' + + # Description of the functionality provided by this module + Description = 'Xen Orchestra PowerShell module' + + # Minimum version of the PowerShell engine required by this module + PowerShellVersion = '7.0' + + # Name of the PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # ClrVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + RequiredModules = @() + + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + FormatsToProcess = @( + "formats/sr.ps1xml" + "formats/task.ps1xml" + "formats/vdi.ps1xml" + "formats/vm.ps1xml" + "formats/vdi-snapshot.ps1xml" + "formats/vm-snapshot.ps1xml" + "formats/server.ps1xml" + "formats/host.ps1xml" + "formats/pool.ps1xml" + "formats/pool-patch.ps1xml" + "formats/message.ps1xml" + "formats/network.ps1xml" + "formats/pif.ps1xml" + "formats/vif.ps1xml" + "formats/vbd.ps1xml" + "formats/alarm.ps1xml" + "formats/schedule.ps1xml" + "formats/vm-template.ps1xml" + "formats/backup-job.ps1xml" + "formats/backup-archive.ps1xml" + "formats/backup-log.ps1xml" + "formats/backup-repository.ps1xml" + "formats/dashboard.ps1xml" + "formats/event.ps1xml" + "formats/group.ps1xml" + "formats/pbd.ps1xml" + "formats/pci.ps1xml" + "formats/pgpu.ps1xml" + "formats/proxy.ps1xml" + "formats/restore-log.ps1xml" + "formats/sm.ps1xml" + "formats/user.ps1xml" + "formats/user-authentication-token.ps1xml" + "formats/vm-controller.ps1xml" + ) + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @() + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = @() + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @( + "Connect-XenOrchestra" + "Disconnect-XenOrchestra" + # task + "Get-XoTaskDetails" + ) + + # DSC resources to export from this module + DscResourcesToExport = @() + + # List of all modules packaged with this module + # ModuleList = @() + + # List of all files packaged with this module + # FileList = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + PSData = @{ + LicenseUri = 'https://spdx.org/licenses/Apache-2.0.html' + ProjectUri = 'https://github.com/vatesfr/xo-powershell' + Prerelease = 'beta' + ReleaseNotes = '' + } + } + + # HelpInfo URI of this module + # HelpInfoURI = '' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' + +} diff --git a/src/xo-powershell.psm1 b/src/xo-powershell.psm1 new file mode 100644 index 0000000..92d7cfb --- /dev/null +++ b/src/xo-powershell.psm1 @@ -0,0 +1,5 @@ +<# + This file is intentionally left empty. It is must be left here for the module + manifest to refer to. It is recreated during the build process. +#> + diff --git a/tests/QA/module.tests.ps1 b/tests/QA/module.tests.ps1 new file mode 100644 index 0000000..8d47e83 --- /dev/null +++ b/tests/QA/module.tests.ps1 @@ -0,0 +1,215 @@ +BeforeDiscovery { + $projectPath = "$($PSScriptRoot)\..\.." | Convert-Path + + <# + If the QA tests are run outside of the build script (e.g with Invoke-Pester) + the parent scope has not set the variable $ProjectName. + #> + if (-not $ProjectName) + { + # Assuming project folder name is project name. + $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath + } + + $script:moduleName = $ProjectName + + Remove-Module -Name $script:moduleName -Force -ErrorAction SilentlyContinue + + $mut = Get-Module -Name $script:moduleName -ListAvailable | + Select-Object -First 1 | + Import-Module -Force -ErrorAction Stop -PassThru +} + +BeforeAll { + # Convert-Path required for PS7 or Join-Path fails + $projectPath = "$($PSScriptRoot)\..\.." | Convert-Path + + <# + If the QA tests are run outside of the build script (e.g with Invoke-Pester) + the parent scope has not set the variable $ProjectName. + #> + if (-not $ProjectName) + { + # Assuming project folder name is project name. + $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath + } + + $script:moduleName = $ProjectName + + $sourcePath = ( + Get-ChildItem -Path $projectPath\*\*.psd1 | + Where-Object -FilterScript { + ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) ` + -and $( + try + { + Test-ModuleManifest -Path $_.FullName -ErrorAction Stop + } + catch + { + $false + } + ) + } + ).Directory.FullName +} + +Describe 'Changelog Management' -Tag 'Changelog' { + + It 'Changelog format compliant with keepachangelog format' -Skip:(![bool](Get-Command git -EA SilentlyContinue)) { + { Get-ChangelogData -Path (Join-Path $ProjectPath 'CHANGELOG.md') -ErrorAction Stop } | Should -Not -Throw + } + + It 'Changelog should have an Unreleased header' -Skip:$skipTest { + (Get-ChangelogData -Path (Join-Path -Path $ProjectPath -ChildPath 'CHANGELOG.md') -ErrorAction Stop).Unreleased | Should -Not -BeNullOrEmpty + } +} + +Describe 'General module control' -Tags 'FunctionalQuality' { + It 'Should import without errors' { + { Import-Module -Name $script:moduleName -Force -ErrorAction Stop } | Should -Not -Throw + + Get-Module -Name $script:moduleName | Should -Not -BeNullOrEmpty + } + + It 'Should remove without error' { + { Remove-Module -Name $script:moduleName -ErrorAction Stop } | Should -Not -Throw + + Get-Module $script:moduleName | Should -BeNullOrEmpty + } +} + +BeforeDiscovery { + # Must use the imported module to build test cases. + $allModuleFunctions = & $mut { Get-Command -Module $args[0] -CommandType Function } $script:moduleName + + # Build test cases. + $testCases = @() + + foreach ($function in $allModuleFunctions) + { + $testCases += @{ + Name = $function.Name + } + } +} + +Describe 'Quality for module' -Tags 'TestQuality' { + BeforeDiscovery { + if (Get-Command -Name Invoke-ScriptAnalyzer -ErrorAction SilentlyContinue) + { + $scriptAnalyzerRules = Get-ScriptAnalyzerRule + } + else + { + if ($ErrorActionPreference -ne 'Stop') + { + Write-Warning -Message 'ScriptAnalyzer not found!' + } + else + { + throw 'ScriptAnalyzer not found!' + } + } + } + + # It 'Should have a unit test for ' -ForEach $testCases { + # Get-ChildItem -Path 'tests\' -Recurse -Include "$Name.Tests.ps1" | Should -Not -BeNullOrEmpty + # } + + It 'Should pass Script Analyzer for ' -ForEach $testCases -Skip:(-not $scriptAnalyzerRules) { + $functionFile = Get-ChildItem -Path $sourcePath -Recurse -Include "$Name.ps1" + + $pssaResult = (Invoke-ScriptAnalyzer -Path $functionFile.FullName) + $report = $pssaResult | Format-Table -AutoSize | Out-String -Width 110 + $pssaResult | Should -BeNullOrEmpty -Because ` + "some rule triggered.`r`n`r`n $report" + } +} + +Describe 'Help for module' -Tags 'helpQuality' { + It 'Should have .SYNOPSIS for ' -ForEach $testCases { + $functionFile = Get-ChildItem -Path $sourcePath -Recurse -Include "$Name.ps1" + + $scriptFileRawContent = Get-Content -Raw -Path $functionFile.FullName + + $abstractSyntaxTree = [System.Management.Automation.Language.Parser]::ParseInput($scriptFileRawContent, [ref] $null, [ref] $null) + + $astSearchDelegate = { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } + + $parsedFunction = $abstractSyntaxTree.FindAll( $astSearchDelegate, $true ) | + Where-Object -FilterScript { + $_.Name -eq $Name + } + + $functionHelp = $parsedFunction.GetHelpContent() + + $functionHelp.Synopsis | Should -Not -BeNullOrEmpty + } + + It 'Should have a .DESCRIPTION with length greater than 40 characters for ' -ForEach $testCases { + $functionFile = Get-ChildItem -Path $sourcePath -Recurse -Include "$Name.ps1" + + $scriptFileRawContent = Get-Content -Raw -Path $functionFile.FullName + + $abstractSyntaxTree = [System.Management.Automation.Language.Parser]::ParseInput($scriptFileRawContent, [ref] $null, [ref] $null) + + $astSearchDelegate = { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } + + $parsedFunction = $abstractSyntaxTree.FindAll($astSearchDelegate, $true) | + Where-Object -FilterScript { + $_.Name -eq $Name + } + + $functionHelp = $parsedFunction.GetHelpContent() + + $functionHelp.Description.Length | Should -BeGreaterThan 40 + } + + It 'Should have at least one (1) example for ' -ForEach $testCases { + $functionFile = Get-ChildItem -Path $sourcePath -Recurse -Include "$Name.ps1" + + $scriptFileRawContent = Get-Content -Raw -Path $functionFile.FullName + + $abstractSyntaxTree = [System.Management.Automation.Language.Parser]::ParseInput($scriptFileRawContent, [ref] $null, [ref] $null) + + $astSearchDelegate = { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } + + $parsedFunction = $abstractSyntaxTree.FindAll( $astSearchDelegate, $true ) | + Where-Object -FilterScript { + $_.Name -eq $Name + } + + $functionHelp = $parsedFunction.GetHelpContent() + + $functionHelp.Examples.Count | Should -BeGreaterThan 0 + $functionHelp.Examples[0] | Should -Match ([regex]::Escape($function.Name)) + $functionHelp.Examples[0].Length | Should -BeGreaterThan ($function.Name.Length + 10) + + } + + It 'Should have described all parameters for ' -ForEach $testCases { + $functionFile = Get-ChildItem -Path $sourcePath -Recurse -Include "$Name.ps1" + + $scriptFileRawContent = Get-Content -Raw -Path $functionFile.FullName + + $abstractSyntaxTree = [System.Management.Automation.Language.Parser]::ParseInput($scriptFileRawContent, [ref] $null, [ref] $null) + + $astSearchDelegate = { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } + + $parsedFunction = $abstractSyntaxTree.FindAll( $astSearchDelegate, $true ) | + Where-Object -FilterScript { + $_.Name -eq $Name + } + + $functionHelp = $parsedFunction.GetHelpContent() + + $parameters = $parsedFunction.Body.ParamBlock.Parameters.Name.VariablePath.ForEach({ $_.ToString() }) + + foreach ($parameter in $parameters) + { + $functionHelp.Parameters.($parameter.ToUpper()) | Should -Not -BeNullOrEmpty -Because ('the parameter {0} must have a description' -f $parameter) + $functionHelp.Parameters.($parameter.ToUpper()).Length | Should -BeGreaterThan 25 -Because ('the parameter {0} must have descriptive description' -f $parameter) + } + } +} diff --git a/tests/Unit/Private/ConvertFrom-XoSecureString.tests.ps1 b/tests/Unit/Private/ConvertFrom-XoSecureString.tests.ps1 new file mode 100644 index 0000000..51b5e1c --- /dev/null +++ b/tests/Unit/Private/ConvertFrom-XoSecureString.tests.ps1 @@ -0,0 +1,78 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertFrom-XoSecureString { + Context 'When called with a SecureString' { + It 'Should return the original plain-text value' { + InModuleScope -ModuleName $dscModuleName { + $plain = 'P@ssw0rd!' + $secure = ConvertTo-SecureString -String $plain -AsPlainText -Force + + $result = ConvertFrom-XoSecureString -SecureString $secure + + $result | Should -Be $plain + } + } + + It 'Should return a single string object' { + InModuleScope -ModuleName $dscModuleName { + $secure = ConvertTo-SecureString -String 'abc' -AsPlainText -Force + + $result = ConvertFrom-XoSecureString -SecureString $secure + + ($result | Measure-Object).Count | Should -Be 1 + $result | Should -BeOfType ([string]) + } + } + + It 'Should return an empty string when the SecureString is empty' { + InModuleScope -ModuleName $dscModuleName { + $secure = [securestring]::new() + + $result = ConvertFrom-XoSecureString -SecureString $secure + + $result | Should -Be '' + } + } + + It 'Should preserve unicode characters' { + InModuleScope -ModuleName $dscModuleName { + $plain = 'пароль-密码-🔐' + $secure = ConvertTo-SecureString -String $plain -AsPlainText -Force + + $result = ConvertFrom-XoSecureString -SecureString $secure + + $result | Should -Be $plain + } + } + } + + Context 'When the SecureString is provided through the pipeline' { + It 'Should return the original plain-text value' { + InModuleScope -ModuleName $dscModuleName { + $plain = 'piped-secret' + $secure = ConvertTo-SecureString -String $plain -AsPlainText -Force + + $result = $secure | ConvertFrom-XoSecureString + + $result | Should -Be $plain + } + } + } + + Context 'When a null SecureString is provided' { + It 'Should throw because the parameter is mandatory' { + InModuleScope -ModuleName $dscModuleName { + { ConvertFrom-XoSecureString -SecureString $null } | Should -Throw + } + } + } +} diff --git a/tests/Unit/Private/ConvertFrom-XoTaskHref.tests.ps1 b/tests/Unit/Private/ConvertFrom-XoTaskHref.tests.ps1 new file mode 100644 index 0000000..b8bf5b6 --- /dev/null +++ b/tests/Unit/Private/ConvertFrom-XoTaskHref.tests.ps1 @@ -0,0 +1,44 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertFrom-XoTaskHref { + Context 'When the URL matches the task href pattern' { + It 'Should extract the task ID and call Get-XoTask with it' { + InModuleScope -ModuleName $dscModuleName { + Mock -CommandName Get-XoTask -MockWith { return [pscustomobject]@{ TaskId = $TaskId } } + + $result = ConvertFrom-XoTaskHref -Uri 'https://xo.example.com/rest/v0/tasks/0m8k2zkzi' + + Should -Invoke -CommandName Get-XoTask -Times 1 -Exactly -ParameterFilter { $TaskId -eq '0m8k2zkzi' } + $result.TaskId | Should -Be '0m8k2zkzi' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + Mock -CommandName Get-XoTask -MockWith { return [pscustomobject]@{ TaskId = $TaskId } } + + $result = '/rest/v0/tasks/abc123' | ConvertFrom-XoTaskHref + + $result.TaskId | Should -Be 'abc123' + } + } + } + + Context 'When the URL does not match the task href pattern' { + It 'Should throw a descriptive error' { + InModuleScope -ModuleName $dscModuleName { + { ConvertFrom-XoTaskHref -Uri 'https://example.com/not-a-task' } | + Should -Throw -ExpectedMessage 'Bad task href format*' + } + } + } +} diff --git a/tests/Unit/Private/ConvertFrom-XoUuidHref.tests.ps1 b/tests/Unit/Private/ConvertFrom-XoUuidHref.tests.ps1 new file mode 100644 index 0000000..b42286b --- /dev/null +++ b/tests/Unit/Private/ConvertFrom-XoUuidHref.tests.ps1 @@ -0,0 +1,53 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertFrom-XoUuidHref { + BeforeAll { + InModuleScope -ModuleName $dscModuleName { + $script:XoHost = 'https://xo.example.com' + } + } + + Context 'When the href matches the expected REST pattern' { + It 'Should return the last URL segment' { + InModuleScope -ModuleName $dscModuleName { + $result = ConvertFrom-XoUuidHref -Uri '/rest/v0/pools/011ccf6a-c5ad-48ec-a255-d056584686f0' + + $result | Should -Be '011ccf6a-c5ad-48ec-a255-d056584686f0' + } + } + + It 'Should work with an absolute URL' { + InModuleScope -ModuleName $dscModuleName { + $result = ConvertFrom-XoUuidHref -Uri 'https://xo.example.com/rest/v0/vms/abc-123' + + $result | Should -Be 'abc-123' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = '/rest/v0/hosts/deadbeef' | ConvertFrom-XoUuidHref + + $result | Should -Be 'deadbeef' + } + } + } + + Context 'When the href is malformed' { + It 'Should throw the "Bad href format" error' { + InModuleScope -ModuleName $dscModuleName { + { ConvertFrom-XoUuidHref -Uri '/not/an/api/path' } | + Should -Throw -ExpectedMessage 'Bad href format' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoAlarmObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoAlarmObject.tests.ps1 new file mode 100644 index 0000000..af6a46b --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoAlarmObject.tests.ps1 @@ -0,0 +1,53 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoAlarmObject { + Context 'When called with a typical alarm API object' { + It 'Should produce a decorated XoPowershell.Alarm object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'a1b2c3d4' + type = 'ALARM' + time = 1700000000 + name = 'MyAlarm' + body = [pscustomobject]@{ + name = 'HIGH_CPU' + value = '95%' + } + } + + $result = ConvertTo-XoAlarmObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Alarm' + $result.BodyName | Should -Be 'HIGH_CPU' + $result.BodyValue | Should -Be '95%' + $result.AlarmTime | Should -BeOfType ([System.DateTimeOffset]) + $result.AlarmTime.ToUnixTimeSeconds() | Should -Be 1700000000 + $result.uuid | Should -Be 'a1b2c3d4' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'x' + time = 0 + body = [pscustomobject]@{ name = 'X'; value = 'Y' } + } + + $result = $apiObject | ConvertTo-XoAlarmObject + + $result.BodyName | Should -Be 'X' + $result.BodyValue | Should -Be 'Y' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoBackupArchiveObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoBackupArchiveObject.tests.ps1 new file mode 100644 index 0000000..477505e --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoBackupArchiveObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoBackupArchiveObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.BackupArchive object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '1af95910-01b4-4e87-9c2f-d895cafe0776'; backupRepository = 'repo-1'; disks = @(); type = 'xo-vm-backup' } + + $result = ConvertTo-XoBackupArchiveObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupArchive' + $result.BackupArchiveId | Should -Be '1af95910-01b4-4e87-9c2f-d895cafe0776' + $result.backupRepository | Should -Be 'repo-1' + $result.type | Should -Be 'xo-vm-backup' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '1af95910-01b4-4e87-9c2f-d895cafe0776'; backupRepository = 'repo-1'; disks = @(); type = 'xo-vm-backup' } + + $result = $apiObject | ConvertTo-XoBackupArchiveObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupArchive' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoBackupJobObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoBackupJobObject.tests.ps1 new file mode 100644 index 0000000..e0716af --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoBackupJobObject.tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoBackupJobObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.BackupJob object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'd33f3dc1-92b4-469c-ad58-4c2a106a4721'; name = 'nightly'; mode = 'full'; type = 'backup' } + + $result = ConvertTo-XoBackupJobObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupJob' + $result.BackupJobId | Should -Be 'd33f3dc1-92b4-469c-ad58-4c2a106a4721' + $result.name | Should -Be 'nightly' + $result.mode | Should -Be 'full' + $result.type | Should -Be 'backup' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'd33f3dc1-92b4-469c-ad58-4c2a106a4721'; name = 'nightly'; mode = 'full'; type = 'backup' } + + $result = $apiObject | ConvertTo-XoBackupJobObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupJob' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoBackupLogObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoBackupLogObject.tests.ps1 new file mode 100644 index 0000000..68e2747 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoBackupLogObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoBackupLogObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.BackupLog object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '1753776067468'; jobId = '59af07fc-e82c-43b5-8137-026832f30166'; jobName = 'test-modal'; status = 'success'; message = 'backup'; start = 1753776067468 } + + $result = ConvertTo-XoBackupLogObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupLog' + $result.BackupLogId | Should -Be '1753776067468' + $result.jobName | Should -Be 'test-modal' + $result.status | Should -Be 'success' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '1753776067468'; jobId = '59af07fc-e82c-43b5-8137-026832f30166'; jobName = 'test-modal'; status = 'success'; message = 'backup'; start = 1753776067468 } + + $result = $apiObject | ConvertTo-XoBackupLogObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupLog' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoBackupRepositoryObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoBackupRepositoryObject.tests.ps1 new file mode 100644 index 0000000..2fbc984 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoBackupRepositoryObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoBackupRepositoryObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.BackupRepository object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '677e50c5-8d8a-4c89-b1ac-e2f4593d0ebb'; name = 'S3_Remote'; enabled = $true; url = 's3://example' } + + $result = ConvertTo-XoBackupRepositoryObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupRepository' + $result.BackupRepositoryId | Should -Be '677e50c5-8d8a-4c89-b1ac-e2f4593d0ebb' + $result.Name | Should -Be 'S3_Remote' + $result.enabled | Should -BeTrue + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '677e50c5-8d8a-4c89-b1ac-e2f4593d0ebb'; name = 'S3_Remote'; enabled = $true; url = 's3://example' } + + $result = $apiObject | ConvertTo-XoBackupRepositoryObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.BackupRepository' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoDashboardObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoDashboardObject.tests.ps1 new file mode 100644 index 0000000..dd8acd1 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoDashboardObject.tests.ps1 @@ -0,0 +1,36 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoDashboardObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Dashboard object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ nPools = 2; nHosts = 5 } + + $result = ConvertTo-XoDashboardObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Dashboard' + $result.nPools | Should -Be 2 + $result.nHosts | Should -Be 5 + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ nPools = 2; nHosts = 5 } + + $result = $apiObject | ConvertTo-XoDashboardObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Dashboard' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoEventObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoEventObject.tests.ps1 new file mode 100644 index 0000000..d571c1f --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoEventObject.tests.ps1 @@ -0,0 +1,36 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoEventObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Event object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'evt-1'; name = 'connection-lost'; type = 'host' } + + $result = ConvertTo-XoEventObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Event' + $result.EventId | Should -Be 'evt-1' + $result.name | Should -Be 'connection-lost' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'evt-1'; name = 'connection-lost'; type = 'host' } + + $result = $apiObject | ConvertTo-XoEventObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Event' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoGroupObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoGroupObject.tests.ps1 new file mode 100644 index 0000000..57aea0d --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoGroupObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoGroupObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Group object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '7d98fee4-3357-41a7-ac3f-9124212badb7'; name = 'group 1'; users = @('user-1') } + + $result = ConvertTo-XoGroupObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Group' + $result.GroupId | Should -Be '7d98fee4-3357-41a7-ac3f-9124212badb7' + $result.Name | Should -Be 'group 1' + $result.users | Should -Be @('user-1') + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '7d98fee4-3357-41a7-ac3f-9124212badb7'; name = 'group 1'; users = @('user-1') } + + $result = $apiObject | ConvertTo-XoGroupObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Group' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoGuiRouteObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoGuiRouteObject.tests.ps1 new file mode 100644 index 0000000..8a380de --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoGuiRouteObject.tests.ps1 @@ -0,0 +1,36 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoGuiRouteObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.GuiRoute object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ xo5 = '/'; xo6 = '/v6' } + + $result = ConvertTo-XoGuiRouteObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.GuiRoute' + $result.xo5 | Should -Be '/' + $result.xo6 | Should -Be '/v6' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ xo5 = '/'; xo6 = '/v6' } + + $result = $apiObject | ConvertTo-XoGuiRouteObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.GuiRoute' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoHostObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoHostObject.tests.ps1 new file mode 100644 index 0000000..163b5b4 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoHostObject.tests.ps1 @@ -0,0 +1,56 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoHostObject { + Context 'When called with a typical host API object' { + It 'Should produce a decorated XoPowershell.Host object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = '812b59e1-2682-43ef-acd4-808d3551b907' + name_label = 'host-01' + name_description = 'Primary host' + power_state = 'Running' + bios_strings = [pscustomobject]@{ vendor = 'Acme' } + license_params = [pscustomobject]@{ sku = 'std' } + license_server = 'license.example.com' + license_expiry = 1700000000 + } + + $result = ConvertTo-XoHostObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Host' + $result.HostUuid | Should -Be '812b59e1-2682-43ef-acd4-808d3551b907' + $result.Name | Should -Be 'host-01' + $result.Description | Should -Be 'Primary host' + $result.PowerState | Should -Be 'Running' + $result.BiosStrings.vendor | Should -Be 'Acme' + $result.LicenseParams.sku | Should -Be 'std' + $result.LicenseServer | Should -Be 'license.example.com' + $result.LicenseExpiry | Should -Be 1700000000 + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'u' + name_label = 'h' + power_state = 'Halted' + } + + $result = $apiObject | ConvertTo-XoHostObject + + $result.HostUuid | Should -Be 'u' + $result.PowerState | Should -Be 'Halted' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoMessageObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoMessageObject.tests.ps1 new file mode 100644 index 0000000..484cb17 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoMessageObject.tests.ps1 @@ -0,0 +1,43 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoMessageObject { + Context 'When called with a typical message API object' { + It 'Should produce a decorated XoPowershell.Message object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'msg-1' + name = 'VM_STARTED' + type = 'informational' + time = 1700000000 + body = 'VM has started' + } + + $result = ConvertTo-XoMessageObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Message' + $result.MessageUuid | Should -Be 'msg-1' + $result.MessageTime | Should -BeOfType ([System.DateTimeOffset]) + $result.MessageTime.ToUnixTimeSeconds() | Should -Be 1700000000 + $result.name | Should -Be 'VM_STARTED' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; time = 0 } | ConvertTo-XoMessageObject + + $result.MessageUuid | Should -Be 'u' + $result.MessageTime.ToUnixTimeSeconds() | Should -Be 0 + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoNetworkObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoNetworkObject.tests.ps1 new file mode 100644 index 0000000..fc18976 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoNetworkObject.tests.ps1 @@ -0,0 +1,44 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoNetworkObject { + Context 'When called with a typical network API object' { + It 'Should produce a decorated XoPowershell.Network object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'net-1' + name_label = 'lan' + name_description = 'Primary LAN' + PIFs = @('pif-a', 'pif-b') + VIFs = @('vif-1') + } + + $result = ConvertTo-XoNetworkObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Network' + $result.NetworkUuid | Should -Be 'net-1' + $result.Name | Should -Be 'lan' + $result.Description | Should -Be 'Primary LAN' + $result.PifUuid | Should -Be @('pif-a', 'pif-b') + $result.VifUuid | Should -Be @('vif-1') + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; name_label = 'n' } | ConvertTo-XoNetworkObject + + $result.NetworkUuid | Should -Be 'u' + $result.Name | Should -Be 'n' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoPbdObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoPbdObject.tests.ps1 new file mode 100644 index 0000000..9975785 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoPbdObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoPbdObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Pbd object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '16b2a60f-7c4d-f45f-7c7a-963b06fc587d'; id = '16b2a60f-7c4d-f45f-7c7a-963b06fc587d'; attached = $true; host = 'host-1'; SR = 'sr-1' } + + $result = ConvertTo-XoPbdObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pbd' + $result.PbdUuid | Should -Be '16b2a60f-7c4d-f45f-7c7a-963b06fc587d' + $result.attached | Should -BeTrue + $result.host | Should -Be 'host-1' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '16b2a60f-7c4d-f45f-7c7a-963b06fc587d'; id = '16b2a60f-7c4d-f45f-7c7a-963b06fc587d'; attached = $true; host = 'host-1'; SR = 'sr-1' } + + $result = $apiObject | ConvertTo-XoPbdObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pbd' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoPciObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoPciObject.tests.ps1 new file mode 100644 index 0000000..4d2bdf7 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoPciObject.tests.ps1 @@ -0,0 +1,36 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoPciObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Pci object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '9377b642-cc71-8749-1e71-308898b652da'; class_name = 'NVMe'; device_name = 'XG5 SSD'; pci_id = '0000:0d:00.0' } + + $result = ConvertTo-XoPciObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pci' + $result.PciUuid | Should -Be '9377b642-cc71-8749-1e71-308898b652da' + $result.device_name | Should -Be 'XG5 SSD' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '9377b642-cc71-8749-1e71-308898b652da'; class_name = 'NVMe'; device_name = 'XG5 SSD'; pci_id = '0000:0d:00.0' } + + $result = $apiObject | ConvertTo-XoPciObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pci' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoPgpuObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoPgpuObject.tests.ps1 new file mode 100644 index 0000000..044ea84 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoPgpuObject.tests.ps1 @@ -0,0 +1,36 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoPgpuObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Pgpu object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '838335fa-ee21-15e1-760a-a37a3a4ef1db'; dom0Access = 'enabled'; gpuGroup = 'grp-1'; host = 'host-1' } + + $result = ConvertTo-XoPgpuObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pgpu' + $result.PgpuUuid | Should -Be '838335fa-ee21-15e1-760a-a37a3a4ef1db' + $result.dom0Access | Should -Be 'enabled' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '838335fa-ee21-15e1-760a-a37a3a4ef1db'; dom0Access = 'enabled'; gpuGroup = 'grp-1'; host = 'host-1' } + + $result = $apiObject | ConvertTo-XoPgpuObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pgpu' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoPifObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoPifObject.tests.ps1 new file mode 100644 index 0000000..ccf9926 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoPifObject.tests.ps1 @@ -0,0 +1,44 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoPifObject { + Context 'When called with a typical PIF API object' { + It 'Should produce a decorated XoPowershell.Pif object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'pif-1' + name_label = 'eth0' + name_description = 'Primary NIC' + device = 'eth0' + mac = 'aa:bb:cc:dd:ee:ff' + } + + $result = ConvertTo-XoPifObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pif' + $result.PifUuid | Should -Be 'pif-1' + $result.Name | Should -Be 'eth0' + $result.Description | Should -Be 'Primary NIC' + $result.device | Should -Be 'eth0' + $result.mac | Should -Be 'aa:bb:cc:dd:ee:ff' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; name_label = 'n' } | ConvertTo-XoPifObject + + $result.PifUuid | Should -Be 'u' + $result.Name | Should -Be 'n' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoPoolObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoPoolObject.tests.ps1 new file mode 100644 index 0000000..18983b1 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoPoolObject.tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoPoolObject { + Context 'When called with a typical pool API object' { + It 'Should produce a decorated XoPowershell.Pool object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'pool-1' + name_label = 'primary' + name_description = 'Primary pool' + platform_version = '8.2.1' + HA_enabled = $true + cpus = [pscustomobject]@{ cores = 16 } + } + + $result = ConvertTo-XoPoolObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Pool' + $result.PoolUuid | Should -Be 'pool-1' + $result.Name | Should -Be 'primary' + $result.Description | Should -Be 'Primary pool' + $result.PlatformVersion | Should -Be '8.2.1' + $result.HAEnabled | Should -BeTrue + $result.CpuCores | Should -Be 16 + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; name_label = 'n' } | ConvertTo-XoPoolObject + + $result.PoolUuid | Should -Be 'u' + $result.Name | Should -Be 'n' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoPoolPatchObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoPoolPatchObject.tests.ps1 new file mode 100644 index 0000000..4f2d98c --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoPoolPatchObject.tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoPoolPatchObject { + Context 'When called with a typical pool patch API object' { + It 'Should produce a decorated XoPowershell.PoolPatch object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'patch-1' + changelog = [pscustomobject]@{ + date = 1700000000 + description = 'Security fix for XSA-XYZ' + } + } + + $result = ConvertTo-XoPoolPatchObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.PoolPatch' + $result.Date | Should -BeOfType ([System.DateTimeOffset]) + $result.Date.ToUnixTimeSeconds() | Should -Be 1700000000 + $result.Description | Should -Be 'Security fix for XSA-XYZ' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'p' + changelog = [pscustomobject]@{ date = 0; description = 'd' } + } + + $result = $apiObject | ConvertTo-XoPoolPatchObject + + $result.Description | Should -Be 'd' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoProxyObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoProxyObject.tests.ps1 new file mode 100644 index 0000000..e28740f --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoProxyObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoProxyObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Proxy object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'e625ea0c-a876-405a-b838-109d762efe88'; name = 'Proxy1'; vmUuid = 'vm-1'; url = 'https://proxy.example.com'; version = '0.29.29' } + + $result = ConvertTo-XoProxyObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Proxy' + $result.ProxyId | Should -Be 'e625ea0c-a876-405a-b838-109d762efe88' + $result.Name | Should -Be 'Proxy1' + $result.version | Should -Be '0.29.29' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'e625ea0c-a876-405a-b838-109d762efe88'; name = 'Proxy1'; vmUuid = 'vm-1'; url = 'https://proxy.example.com'; version = '0.29.29' } + + $result = $apiObject | ConvertTo-XoProxyObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Proxy' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoRestoreLogObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoRestoreLogObject.tests.ps1 new file mode 100644 index 0000000..5ef6f10 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoRestoreLogObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoRestoreLogObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.RestoreLog object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '1758180544428'; message = 'restore'; status = 'success'; start = 1758180544428; jobId = '33156c65-45e1-431a-bdbb-8c97ae80bd47' } + + $result = ConvertTo-XoRestoreLogObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.RestoreLog' + $result.RestoreLogId | Should -Be '1758180544428' + $result.status | Should -Be 'success' + $result.message | Should -Be 'restore' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '1758180544428'; message = 'restore'; status = 'success'; start = 1758180544428; jobId = '33156c65-45e1-431a-bdbb-8c97ae80bd47' } + + $result = $apiObject | ConvertTo-XoRestoreLogObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.RestoreLog' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoScheduleObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoScheduleObject.tests.ps1 new file mode 100644 index 0000000..96edf42 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoScheduleObject.tests.ps1 @@ -0,0 +1,43 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoScheduleObject { + Context 'When called with a typical schedule API object' { + It 'Should produce a decorated XoPowershell.Schedule object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + id = 'sched-1' + name = 'Nightly backup' + cron = '0 0 * * *' + enabled = $true + timezone = 'UTC' + jobId = 'job-42' + } + + $result = ConvertTo-XoScheduleObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Schedule' + $result.ScheduleId | Should -Be 'sched-1' + $result.cron | Should -Be '0 0 * * *' + $result.enabled | Should -BeTrue + $result.jobId | Should -Be 'job-42' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ id = 'x' } | ConvertTo-XoScheduleObject + + $result.ScheduleId | Should -Be 'x' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoServerObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoServerObject.tests.ps1 new file mode 100644 index 0000000..d7450bc --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoServerObject.tests.ps1 @@ -0,0 +1,56 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoServerObject { + Context 'When called with a typical server API object' { + It 'Should produce a decorated XoPowershell.Server object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + id = 'srv-1' + label = 'primary-xo' + host = 'xo-host-01' + address = '10.0.0.1' + status = 'connected' + version = '5.100.0' + enabled = $true + readOnly = $false + username = 'admin' + error = '' + allowUnauthorized = $false + } + + $result = ConvertTo-XoServerObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Server' + $result.ServerUuid | Should -Be 'srv-1' + $result.Name | Should -Be 'primary-xo' + $result.NameHost | Should -Be 'xo-host-01' + $result.Address | Should -Be '10.0.0.1' + $result.Status | Should -Be 'connected' + $result.Version | Should -Be '5.100.0' + $result.Enabled | Should -BeTrue + $result.ReadOnly | Should -BeFalse + $result.Username | Should -Be 'admin' + $result.Error | Should -Be '' + $result.AllowUnauthorized | Should -BeFalse + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ id = 'x'; label = 'y' } | ConvertTo-XoServerObject + + $result.ServerUuid | Should -Be 'x' + $result.Name | Should -Be 'y' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoSmObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoSmObject.tests.ps1 new file mode 100644 index 0000000..01ce21d --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoSmObject.tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoSmObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.Sm object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '5bfb2f8a-70f3-8cff-1748-3cd4de2153da'; name_label = 'Local EXT4'; name_description = 'Local ext4 SR'; SM_type = 'ext'; vendor = 'Citrix'; version = '1.0' } + + $result = ConvertTo-XoSmObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Sm' + $result.SmUuid | Should -Be '5bfb2f8a-70f3-8cff-1748-3cd4de2153da' + $result.Name | Should -Be 'Local EXT4' + $result.Description | Should -Be 'Local ext4 SR' + $result.Type | Should -Be 'ext' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '5bfb2f8a-70f3-8cff-1748-3cd4de2153da'; name_label = 'Local EXT4'; name_description = 'Local ext4 SR'; SM_type = 'ext'; vendor = 'Citrix'; version = '1.0' } + + $result = $apiObject | ConvertTo-XoSmObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Sm' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoSrObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoSrObject.tests.ps1 new file mode 100644 index 0000000..2061d54 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoSrObject.tests.ps1 @@ -0,0 +1,58 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoSrObject { + Context 'When called with a typical SR API object' { + It 'Should produce a decorated XoPowershell.Sr object with formatted sizes' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'sr-1' + name_label = 'local-storage' + SR_type = 'lvm' + content_type = 'user' + size = 2147483648 # 2 GB + usage = 2097152 # 2 MB + physical_usage = 2048 # 2 KB + } + + $result = ConvertTo-XoSrObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Sr' + $result.SrUuid | Should -Be 'sr-1' + $result.Name | Should -Be 'local-storage' + $result.Type | Should -Be 'lvm' + $result.ContentType | Should -Be 'user' + $result.SrSize | Should -Be '2.0 GB' + $result.UsageSize | Should -Be '2.0 MB' + $result.PhysicalUsageSize | Should -Be '2.0 KB' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'u' + name_label = 'n' + SR_type = 'ext' + content_type = 'user' + size = 0 + usage = 0 + physical_usage = 0 + } + + $result = $apiObject | ConvertTo-XoSrObject + + $result.SrUuid | Should -Be 'u' + $result.SrSize | Should -Be '0.0 B' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoStatObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoStatObject.tests.ps1 new file mode 100644 index 0000000..6854125 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoStatObject.tests.ps1 @@ -0,0 +1,39 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoStatObject { + Context 'When called with a typical stats payload' { + It 'Should tag the object as XoPowershell.Stat without changing its shape' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + endTimestamp = 1740158005 + interval = 5 + stats = [pscustomobject]@{ cpus = @(0.1, 0.2, 0.3) } + } + + $result = ConvertTo-XoStatObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Stat' + $result.endTimestamp | Should -Be 1740158005 + $result.interval | Should -Be 5 + $result.stats.cpus | Should -Be @(0.1, 0.2, 0.3) + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ interval = 60 } | ConvertTo-XoStatObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Stat' + $result.interval | Should -Be 60 + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoTaskObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoTaskObject.tests.ps1 new file mode 100644 index 0000000..bb17ec2 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoTaskObject.tests.ps1 @@ -0,0 +1,86 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoTaskObject { + Context 'When the task has name, type, timestamps, progress, and a result message' { + It 'Should map all fields onto the XoPowershell.Task object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + id = 'task-1' + status = 'success' + progress = 100 + start = 1700000000000 + end = 1700000060000 + properties = [pscustomobject]@{ + name = 'Snapshot' + type = 'VM' + } + result = [pscustomobject]@{ message = 'Done' } + } + + $result = ConvertTo-XoTaskObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Task' + $result.TaskId | Should -Be 'task-1' + $result.Name | Should -Be 'Snapshot' + $result.Type | Should -Be 'VM' + $result.Status | Should -Be 'success' + $result.Progress | Should -Be 100 + $result.StartTime | Should -BeOfType ([System.DateTimeOffset]) + $result.StartTime.ToUnixTimeMilliseconds() | Should -Be 1700000000000 + $result.EndTime.ToUnixTimeMilliseconds() | Should -Be 1700000060000 + $result.Message | Should -Be 'Done' + } + } + } + + Context 'When the task has no name but has a method, and no message but has a code' { + It 'Should fall back to method for Name and code for Message' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + id = 'task-2' + status = 'failure' + properties = [pscustomobject]@{ method = 'vm.start' } + result = [pscustomobject]@{ code = 'HOST_OFFLINE' } + } + + $result = ConvertTo-XoTaskObject -InputObject $apiObject + + $result.Name | Should -Be 'vm.start' + $result.Message | Should -Be 'HOST_OFFLINE' + } + } + } + + Context 'When the task has no name, type, timestamps, progress, or result' { + It 'Should default to the documented fallback values' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + id = 'task-3' + status = 'pending' + properties = [pscustomobject]@{} + result = [pscustomobject]@{} + start = 0 + end = 0 + } + + $result = ConvertTo-XoTaskObject -InputObject $apiObject + + $result.Name | Should -Be 'Unknown' + $result.Type | Should -Be '' + $result.Progress | Should -Be 0 + $result.StartTime | Should -BeNullOrEmpty + $result.EndTime | Should -BeNullOrEmpty + $result.Message | Should -Be '' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoUserAuthenticationTokenObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoUserAuthenticationTokenObject.tests.ps1 new file mode 100644 index 0000000..e6eba3b --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoUserAuthenticationTokenObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoUserAuthenticationTokenObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.UserAuthenticationToken object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'LB_DqCNhcmAoyiioNnajySHIYHrWfsIhYSYn3n8FfJA'; user_id = '722d17b9-699b-49d2-8193-be1ac573d3de'; description = 'xo-cli'; created_at = 1754383334192; expiration = 1756975334192 } + + $result = ConvertTo-XoUserAuthenticationTokenObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.UserAuthenticationToken' + $result.TokenId | Should -Be 'LB_DqCNhcmAoyiioNnajySHIYHrWfsIhYSYn3n8FfJA' + $result.UserId | Should -Be '722d17b9-699b-49d2-8193-be1ac573d3de' + $result.description | Should -Be 'xo-cli' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = 'LB_DqCNhcmAoyiioNnajySHIYHrWfsIhYSYn3n8FfJA'; user_id = '722d17b9-699b-49d2-8193-be1ac573d3de'; description = 'xo-cli'; created_at = 1754383334192; expiration = 1756975334192 } + + $result = $apiObject | ConvertTo-XoUserAuthenticationTokenObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.UserAuthenticationToken' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoUserObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoUserObject.tests.ps1 new file mode 100644 index 0000000..d375c25 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoUserObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoUserObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.User object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '722d17b9-699b-49d2-8193-be1ac573d3de'; name = 'admin@admin.net'; email = 'admin@admin.net'; permission = 'admin'; groups = @() } + + $result = ConvertTo-XoUserObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.User' + $result.UserId | Should -Be '722d17b9-699b-49d2-8193-be1ac573d3de' + $result.Name | Should -Be 'admin@admin.net' + $result.permission | Should -Be 'admin' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ id = '722d17b9-699b-49d2-8193-be1ac573d3de'; name = 'admin@admin.net'; email = 'admin@admin.net'; permission = 'admin'; groups = @() } + + $result = $apiObject | ConvertTo-XoUserObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.User' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVbdObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVbdObject.tests.ps1 new file mode 100644 index 0000000..884bf55 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVbdObject.tests.ps1 @@ -0,0 +1,45 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVbdObject { + Context 'When called with a typical VBD API object' { + It 'Should produce a decorated XoPowershell.Vbd object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vbd-1' + is_cd_drive = $true + read_only = $false + attached = $true + device = 'xvda' + } + + $result = ConvertTo-XoVbdObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Vbd' + $result.VbdUuid | Should -Be 'vbd-1' + $result.IsCdDrive | Should -BeTrue + $result.ReadOnly | Should -BeFalse + $result.attached | Should -BeTrue + $result.device | Should -Be 'xvda' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; is_cd_drive = $false; read_only = $true } | ConvertTo-XoVbdObject + + $result.VbdUuid | Should -Be 'u' + $result.IsCdDrive | Should -BeFalse + $result.ReadOnly | Should -BeTrue + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVdiObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVdiObject.tests.ps1 new file mode 100644 index 0000000..02468ae --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVdiObject.tests.ps1 @@ -0,0 +1,50 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVdiObject { + Context 'When called with a typical VDI API object' { + It 'Should produce an XoPowershell.Vdi object with renamed fields' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vdi-1' + name_label = 'root-disk' + content_type = 'user' + size = 10737418240 + usage = 5368709120 + physical_usage = 4294967296 + sr_uuid = 'sr-1' + sr_usage = 8589934592 + } + + $result = ConvertTo-XoVdiObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Vdi' + $result.VdiUuid | Should -Be 'vdi-1' + $result.Name | Should -Be 'root-disk' + $result.ContentType | Should -Be 'user' + $result.Size | Should -Be 10737418240 + $result.Usage | Should -Be 5368709120 + $result.PhysicalUsage | Should -Be 4294967296 + $result.SrUuid | Should -Be 'sr-1' + $result.SrUsage | Should -Be 8589934592 + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; name_label = 'n' } | ConvertTo-XoVdiObject + + $result.VdiUuid | Should -Be 'u' + $result.Name | Should -Be 'n' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVdiSnapshotObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVdiSnapshotObject.tests.ps1 new file mode 100644 index 0000000..77f36fd --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVdiSnapshotObject.tests.ps1 @@ -0,0 +1,48 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVdiSnapshotObject { + Context 'When called with a typical VDI snapshot API object' { + It 'Should produce an XoPowershell.VdiSnapshot object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vdi-snap-1' + name_label = 'daily-backup' + size = 10737418240 + snapshot_of = 'vdi-1' + snapshot_time = 1700000000 + sr_uuid = 'sr-1' + usage = 5368709120 + } + + $result = ConvertTo-XoVdiSnapshotObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.VdiSnapshot' + $result.VdiSnapshotUuid | Should -Be 'vdi-snap-1' + $result.Name | Should -Be 'daily-backup' + $result.Size | Should -Be 10737418240 + $result.SnapshotOf | Should -Be 'vdi-1' + $result.SnapshotTime | Should -Be 1700000000 + $result.SrUuid | Should -Be 'sr-1' + $result.Usage | Should -Be 5368709120 + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; name_label = 'n' } | ConvertTo-XoVdiSnapshotObject + + $result.VdiSnapshotUuid | Should -Be 'u' + $result.Name | Should -Be 'n' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVifObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVifObject.tests.ps1 new file mode 100644 index 0000000..096995a --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVifObject.tests.ps1 @@ -0,0 +1,44 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVifObject { + Context 'When called with a typical VIF API object' { + It 'Should produce a decorated XoPowershell.Vif object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vif-1' + name_label = 'vif-eth0' + name_description = 'Primary VIF' + MAC = 'aa:bb:cc:11:22:33' + device = '0' + attached = $true + } + + $result = ConvertTo-XoVifObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Vif' + $result.VifUuid | Should -Be 'vif-1' + $result.Name | Should -Be 'vif-eth0' + $result.Description | Should -Be 'Primary VIF' + $result.MAC | Should -Be 'aa:bb:cc:11:22:33' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ uuid = 'u'; name_label = 'n' } | ConvertTo-XoVifObject + + $result.VifUuid | Should -Be 'u' + $result.Name | Should -Be 'n' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVmControllerObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVmControllerObject.tests.ps1 new file mode 100644 index 0000000..dcfe8bf --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVmControllerObject.tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVmControllerObject { + Context 'When called with a typical API object' { + It 'Should produce a decorated XoPowershell.VmController object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '9b4775bd-9493-490a-9afa-f786a44caa4f'; name_label = 'dom0'; name_description = 'control domain'; power_state = 'Running'; host = 'b61a5c92-700e-4966-a13b-00633f03eea8' } + + $result = ConvertTo-XoVmControllerObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.VmController' + $result.VmControllerUuid | Should -Be '9b4775bd-9493-490a-9afa-f786a44caa4f' + $result.Name | Should -Be 'dom0' + $result.PowerState | Should -Be 'Running' + } + } + + It 'Should accept pipeline input' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = '9b4775bd-9493-490a-9afa-f786a44caa4f'; name_label = 'dom0'; name_description = 'control domain'; power_state = 'Running'; host = 'b61a5c92-700e-4966-a13b-00633f03eea8' } + + $result = $apiObject | ConvertTo-XoVmControllerObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.VmController' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVmObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVmObject.tests.ps1 new file mode 100644 index 0000000..b36a046 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVmObject.tests.ps1 @@ -0,0 +1,70 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVmObject { + Context 'When the CPU block exposes a "number" value' { + It 'Should use CPUs.number for the CPUs property' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vm-1' + name_label = 'web-01' + name_description = 'Web server' + power_state = 'Running' + os_version = [pscustomobject]@{ distro = 'debian' } + parent = 'parent-uuid' + CPUs = [pscustomobject]@{ number = 4; max = 8 } + } + + $result = ConvertTo-XoVmObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Vm' + $result.VmUuid | Should -Be 'vm-1' + $result.Name | Should -Be 'web-01' + $result.Description | Should -Be 'Web server' + $result.PowerState | Should -Be 'Running' + $result.Parent | Should -Be 'parent-uuid' + $result.CPUs | Should -Be 4 + } + } + } + + Context 'When the CPU block only exposes a "max" value' { + It 'Should fall back to CPUs.max for the CPUs property' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vm-2' + name_label = 'web-02' + CPUs = [pscustomobject]@{ max = 2 } + } + + $result = ConvertTo-XoVmObject -InputObject $apiObject + + $result.CPUs | Should -Be 2 + } + } + } + + Context 'When the CPU block has neither number nor max' { + It 'Should set CPUs to $null' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vm-3' + name_label = 'web-03' + CPUs = [pscustomobject]@{} + } + + $result = ConvertTo-XoVmObject -InputObject $apiObject + + $result.CPUs | Should -BeNullOrEmpty + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVmSnapshotObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVmSnapshotObject.tests.ps1 new file mode 100644 index 0000000..9a88d09 --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVmSnapshotObject.tests.ps1 @@ -0,0 +1,76 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVmSnapshotObject { + Context 'When the snapshot has a CPUs.number value' { + It 'Should produce an XoPowershell.VmSnapshot object with CPUs from number' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vm-snap-1' + name_label = 'pre-update' + name_description = 'Before update' + power_state = 'Halted' + snapshot_of = 'vm-1' + snapshot_time = 1700000000 + memory = 2147483648 + CPUs = [pscustomobject]@{ number = 2 } + } + + $result = ConvertTo-XoVmSnapshotObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.VmSnapshot' + $result.VmSnapshotUuid | Should -Be 'vm-snap-1' + $result.Name | Should -Be 'pre-update' + $result.Description | Should -Be 'Before update' + $result.PowerState | Should -Be 'Halted' + $result.SnapshotOf | Should -Be 'vm-1' + $result.SnapshotTime | Should -BeOfType ([System.DateTimeOffset]) + $result.SnapshotTime.ToUnixTimeSeconds() | Should -Be 1700000000 + $result.Memory | Should -Be 2147483648 + $result.CPUs | Should -Be 2 + } + } + } + + Context 'When the snapshot has only CPUs.max' { + It 'Should fall back to CPUs.max' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vm-snap-2' + name_label = 's' + snapshot_time = 0 + CPUs = [pscustomobject]@{ max = 8 } + } + + $result = ConvertTo-XoVmSnapshotObject -InputObject $apiObject + + $result.CPUs | Should -Be 8 + } + } + } + + Context 'When CPUs is $null' { + It 'Should not add a CPUs property' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'vm-snap-3' + name_label = 's' + snapshot_time = 0 + CPUs = $null + } + + $result = ConvertTo-XoVmSnapshotObject -InputObject $apiObject + + $result.PSObject.Properties.Name | Should -Not -Contain 'CPUs' + } + } + } +} diff --git a/tests/Unit/Private/ConvertTo-XoVmTemplateObject.tests.ps1 b/tests/Unit/Private/ConvertTo-XoVmTemplateObject.tests.ps1 new file mode 100644 index 0000000..5b5d23e --- /dev/null +++ b/tests/Unit/Private/ConvertTo-XoVmTemplateObject.tests.ps1 @@ -0,0 +1,68 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe ConvertTo-XoVmTemplateObject { + Context 'When the template has CPUs.number' { + It 'Should produce an XoPowershell.VmTemplate object using CPUs.number' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'tpl-1' + name_label = 'Ubuntu-22.04-Template' + name_description = 'Default Ubuntu template' + os_version = [pscustomobject]@{ name = 'ubuntu' } + parent = 'parent-uuid' + CPUs = [pscustomobject]@{ number = 2; max = 4 } + } + + $result = ConvertTo-XoVmTemplateObject -InputObject $apiObject + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.VmTemplate' + $result.VmTemplateUuid | Should -Be 'tpl-1' + $result.Name | Should -Be 'Ubuntu-22.04-Template' + $result.Description | Should -Be 'Default Ubuntu template' + $result.Parent | Should -Be 'parent-uuid' + $result.CPUs | Should -Be 2 + } + } + } + + Context 'When the template has only CPUs.max' { + It 'Should fall back to CPUs.max' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'tpl-2' + name_label = 't' + CPUs = [pscustomobject]@{ max = 8 } + } + + $result = ConvertTo-XoVmTemplateObject -InputObject $apiObject + + $result.CPUs | Should -Be 8 + } + } + } + + Context 'When the template has neither CPUs.number nor CPUs.max' { + It 'Should set CPUs to $null' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ + uuid = 'tpl-3' + name_label = 't' + CPUs = [pscustomobject]@{} + } + + $result = ConvertTo-XoVmTemplateObject -InputObject $apiObject + + $result.CPUs | Should -BeNullOrEmpty + } + } + } +} diff --git a/tests/Unit/Private/Format-XoSize.tests.ps1 b/tests/Unit/Private/Format-XoSize.tests.ps1 new file mode 100644 index 0000000..606c240 --- /dev/null +++ b/tests/Unit/Private/Format-XoSize.tests.ps1 @@ -0,0 +1,50 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe Format-XoSize { + # Format-XoSize uses a while ($Value -gt 1kb) loop and the parameter is [long], + # so $Value keeps integer semantics between iterations. These expectations + # match the actual (integer-truncated) behaviour rather than the ideal one. + Context 'When called with byte values' { + It 'Should format as ' -ForEach @( + @{ Bytes = 0L; Expected = '0.0 B' } + @{ Bytes = 512L; Expected = '512.0 B' } + @{ Bytes = 2048L; Expected = '2.0 KB' } + @{ Bytes = 2097152L; Expected = '2.0 MB' } + @{ Bytes = 2147483648L; Expected = '2.0 GB' } + @{ Bytes = 2199023255552L; Expected = '2.0 TB' } + @{ Bytes = 2251799813685248L; Expected = '2.0 PB' } + ) { + InModuleScope -ModuleName $dscModuleName -Parameters @{ Bytes = $Bytes; Expected = $Expected } { + param($Bytes, $Expected) + + Format-XoSize -Value $Bytes | Should -Be $Expected + } + } + } + + Context 'When the value is provided through the pipeline' { + It 'Should format it the same way' { + InModuleScope -ModuleName $dscModuleName { + 2147483648L | Format-XoSize | Should -Be '2.0 GB' + } + } + } + + Context 'When the value equals exactly one unit boundary' { + # Because the loop uses -gt (not -ge), the value stays one unit below. + It 'Should not cross the boundary' { + InModuleScope -ModuleName $dscModuleName { + Format-XoSize -Value 1024 | Should -Be '1,024.0 B' + } + } + } +} diff --git a/tests/Unit/Private/Invoke-XoPoolAction.tests.ps1 b/tests/Unit/Private/Invoke-XoPoolAction.tests.ps1 new file mode 100644 index 0000000..7ee60e6 --- /dev/null +++ b/tests/Unit/Private/Invoke-XoPoolAction.tests.ps1 @@ -0,0 +1,125 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName + + InModuleScope -ModuleName $script:dscModuleName { + $script:XoHost = 'https://xo.example.com' + $script:XoRestParameters = @{} + } +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe Invoke-XoPoolAction { + Context 'Parameter validation' { + It 'Should reject actions that are not in the ValidateSet' { + InModuleScope -ModuleName $dscModuleName { + { Invoke-XoPoolAction -PoolUuid 'p1' -Action 'not_a_real_action' } | + Should -Throw + } + } + + It 'Should accept each documented action' -ForEach @( + @{ Action = 'create_bonded_network'; NeedsParams = $true } + @{ Action = 'create_internal_network'; NeedsParams = $true } + @{ Action = 'create_network'; NeedsParams = $true } + @{ Action = 'create_vm'; NeedsParams = $true } + @{ Action = 'management_reconfigure'; NeedsParams = $true } + @{ Action = 'emergency_shutdown'; NeedsParams = $false } + @{ Action = 'rolling_reboot'; NeedsParams = $false } + @{ Action = 'rolling_update'; NeedsParams = $false } + ) { + InModuleScope -ModuleName $dscModuleName -Parameters @{ Action = $Action; NeedsParams = $NeedsParams } { + param($Action, $NeedsParams) + + Mock -CommandName Invoke-RestMethod -MockWith { return '/rest/v0/tasks/task-1' } + Mock -CommandName ConvertFrom-XoTaskHref -MockWith { return [pscustomobject]@{ TaskId = 'task-1' } } + + if ($NeedsParams) + { + { Invoke-XoPoolAction -PoolUuid 'p1' -Action $Action -ActionParameters @{ anything = 1 } } | Should -Not -Throw + } + else + { + { Invoke-XoPoolAction -PoolUuid 'p1' -Action $Action } | Should -Not -Throw + } + } + } + } + + Context 'When an action requires ActionParameters and none are supplied' { + It 'Should throw a descriptive error' -ForEach @( + @{ Action = 'create_bonded_network' } + @{ Action = 'create_internal_network' } + @{ Action = 'create_network' } + @{ Action = 'create_vm' } + @{ Action = 'management_reconfigure' } + ) { + InModuleScope -ModuleName $dscModuleName -Parameters @{ Action = $Action } { + param($Action) + + { Invoke-XoPoolAction -PoolUuid 'p1' -Action $Action } | + Should -Throw -ExpectedMessage 'ActionParameters are required*' + } + } + } + + Context 'When a parameterless action is invoked' { + It 'Should POST to /pools/{id}/actions/ and convert the task href' { + InModuleScope -ModuleName $dscModuleName { + $script:capturedUri = $null + $script:capturedMethod = $null + Mock -CommandName Invoke-RestMethod -MockWith { + $script:capturedUri = $Uri + $script:capturedMethod = $Method + return '/rest/v0/tasks/task-42' + } + Mock -CommandName ConvertFrom-XoTaskHref -MockWith { + param($Uri) + return [pscustomobject]@{ TaskId = 'task-42'; HrefSeen = $Uri } + } + + $result = Invoke-XoPoolAction -PoolUuid '00000000-0000-0000-0000-000000000001' -Action 'rolling_reboot' + + $script:capturedMethod | Should -Be 'Post' + $script:capturedUri | Should -Match '/pools/.+/actions/rolling_reboot' + $result.TaskId | Should -Be 'task-42' + $result.HrefSeen | Should -Be '/rest/v0/tasks/task-42' + } + } + + It 'Should pass sync=true in the URL when -Sync is specified' { + InModuleScope -ModuleName $dscModuleName { + $script:capturedUri = $null + Mock -CommandName Invoke-RestMethod -MockWith { + $script:capturedUri = $Uri + return '/rest/v0/tasks/t' + } + Mock -CommandName ConvertFrom-XoTaskHref -MockWith { return $null } + + $null = Invoke-XoPoolAction -PoolUuid 'p1' -Action 'rolling_update' -Sync + + $script:capturedUri | Should -Match 'sync=true' + } + } + + It 'Should pass sync=false in the URL when -Sync is not specified' { + InModuleScope -ModuleName $dscModuleName { + $script:capturedUri = $null + Mock -CommandName Invoke-RestMethod -MockWith { + $script:capturedUri = $Uri + return '/rest/v0/tasks/t' + } + Mock -CommandName ConvertFrom-XoTaskHref -MockWith { return $null } + + $null = Invoke-XoPoolAction -PoolUuid 'p1' -Action 'rolling_reboot' + + $script:capturedUri | Should -Match 'sync=false' + } + } + } +} diff --git a/tests/Unit/Private/Invoke-XoRestMethod.tests.ps1 b/tests/Unit/Private/Invoke-XoRestMethod.tests.ps1 new file mode 100644 index 0000000..5f201ef --- /dev/null +++ b/tests/Unit/Private/Invoke-XoRestMethod.tests.ps1 @@ -0,0 +1,62 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName + + InModuleScope -ModuleName $script:dscModuleName { + $script:XoRestParameters = @{} + } +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe Invoke-XoRestMethod { + Context 'When the underlying Invoke-RestMethod returns a parsed object' { + It 'Should return the object unchanged' { + InModuleScope -ModuleName $dscModuleName { + Mock -CommandName Invoke-RestMethod -MockWith { + return [pscustomobject]@{ hello = 'world' } + } + + $result = Invoke-XoRestMethod -Uri 'https://xo.example.com/rest/v0/hosts' + + $result.hello | Should -Be 'world' + Should -Invoke -CommandName Invoke-RestMethod -Times 1 -Exactly + } + } + } + + Context 'When the underlying Invoke-RestMethod returns a JSON string (parser failure)' { + It 'Should re-parse via -AsHashtable and return a PSCustomObject' { + InModuleScope -ModuleName $dscModuleName { + Mock -CommandName Invoke-RestMethod -MockWith { + return '{"key":"value","count":3}' + } + + $result = Invoke-XoRestMethod -Uri 'https://xo.example.com/rest/v0/hosts' + + $result | Should -BeOfType ([pscustomobject]) + $result.key | Should -Be 'value' + $result.count | Should -Be 3 + } + } + } + + Context 'When the Body parameter is provided' { + It 'Should forward it to the underlying Invoke-RestMethod' { + InModuleScope -ModuleName $dscModuleName { + Mock -CommandName Invoke-RestMethod -MockWith { return [pscustomobject]@{ ok = $true } } + + $body = @{ filter = 'power_state:Running' } + $null = Invoke-XoRestMethod -Uri 'https://xo.example.com/rest/v0/vms' -Body $body + + Should -Invoke -CommandName Invoke-RestMethod -Times 1 -Exactly -ParameterFilter { + $Body -and $Body.filter -eq 'power_state:Running' + } + } + } + } +} diff --git a/tests/Unit/Private/Set-XoObject.tests.ps1 b/tests/Unit/Private/Set-XoObject.tests.ps1 new file mode 100644 index 0000000..973c376 --- /dev/null +++ b/tests/Unit/Private/Set-XoObject.tests.ps1 @@ -0,0 +1,97 @@ +BeforeAll { + $script:dscModuleName = 'xo-powershell' + + Import-Module -Name $script:dscModuleName +} + +AfterAll { + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe Set-XoObject { + Context 'When called with a TypeName' { + It 'Should insert the TypeName at the top of the PSTypeName list' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ a = 1 } + + $result = Set-XoObject -InputObject $apiObject -TypeName 'XoPowershell.Demo' + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Demo' + } + } + } + + Context 'When called with a Properties hashtable' { + It 'Should add each key/value as a note property on the object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ existing = 'value' } + $props = @{ + AddedOne = 'one' + AddedTwo = 42 + } + + $result = Set-XoObject -InputObject $apiObject -Properties $props + + $result.existing | Should -Be 'value' + $result.AddedOne | Should -Be 'one' + $result.AddedTwo | Should -Be 42 + $result.PSObject.Properties.Name | Should -Contain 'AddedOne' + $result.PSObject.Properties.Name | Should -Contain 'AddedTwo' + } + } + } + + Context 'When called with both TypeName and Properties' { + It 'Should apply both and preserve the original properties' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = 'u-1' } + + $result = Set-XoObject -InputObject $apiObject -TypeName 'XoPowershell.Demo' -Properties @{ Label = 'hello' } + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Demo' + $result.uuid | Should -Be 'u-1' + $result.Label | Should -Be 'hello' + } + } + } + + Context 'When called with neither TypeName nor Properties' { + It 'Should return the object unmodified' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = 'u-2' } + $originalTypes = @($apiObject.PSObject.TypeNames) + + $result = Set-XoObject -InputObject $apiObject + + $result.uuid | Should -Be 'u-2' + $result.PSObject.TypeNames | Should -Be $originalTypes + } + } + } + + Context 'When the input is provided through the pipeline' { + It 'Should decorate the piped object' { + InModuleScope -ModuleName $dscModuleName { + $result = [pscustomobject]@{ id = 'abc' } | + Set-XoObject -TypeName 'XoPowershell.Piped' -Properties @{ Name = 'piped' } + + $result.PSObject.TypeNames[0] | Should -Be 'XoPowershell.Piped' + $result.id | Should -Be 'abc' + $result.Name | Should -Be 'piped' + } + } + } + + Context 'When ShouldProcess is declined via -WhatIf' { + It 'Should not emit an object' { + InModuleScope -ModuleName $dscModuleName { + $apiObject = [pscustomobject]@{ uuid = 'u-3' } + + $result = Set-XoObject -InputObject $apiObject -TypeName 'XoPowershell.Demo' -WhatIf + + $result | Should -BeNullOrEmpty + } + } + } +} diff --git a/xo-powershell.psd1 b/xo-powershell.psd1 deleted file mode 100644 index 828a811..0000000 --- a/xo-powershell.psd1 +++ /dev/null @@ -1,126 +0,0 @@ -@{ - RootModule = 'xo-powershell.psm1' - ModuleVersion = '1.0.0' - GUID = 'adaf591c-6abd-4084-89f9-d75a9096743d' - Author = 'Vates' - CompanyName = 'Vates' - Copyright = 'Copyright (c) Vates.' - Description = 'Xen Orchestra PowerShell module' - PowerShellVersion = '7.0' - PrivateData = @{ - PSData = @{ - LicenseUri = 'https://spdx.org/licenses/Apache-2.0.html' - ProjectUri = 'https://github.com/vatesfr/xo-powershell' - Prerelease = 'beta' - } - } - FunctionsToExport = @( - # session - "Test-XoSession" - "Connect-XoSession" - "Disconnect-XoSession" - "Get-XoSession" - "Set-XoSession" - - # sr - "Get-XoSr" - "Set-XoSr" - - # task - "Get-XoTask" - "Wait-XoTask" - - # vdi - "Get-XoVdi" - "Set-XoVdi" - "Export-XoVdi" - - # vdi-snapshot - "Get-XoVdiSnapshot" - "Export-XoVdiSnapshot" - - # vm - "Get-XoVm" - "Set-XoVm" - "Get-XoVmVdi" - "Start-XoVm" - "Stop-XoVm" - "Restart-XoVm" - "Suspend-XoVm" - - # vm-snapshot - "Get-XoVmSnapshot" - "New-XoVmSnapshot" - - # server - "Get-XoServer" - - # host - "Get-XoHost" - "Set-XoHost" - - # pool - "Get-XoPool" - "Set-XoPool" - "Get-XoPoolMessage" - "Restart-XoPool" - "Stop-XoPool" - "Update-XoPool" - - # pool-patch - "Get-XoPoolPatch" - - # message - "Get-XoMessage" - - # network - "Get-XoNetwork" - "Set-XoNetwork" - - # pif - "Get-XoPif" - "Set-XoPif" - - # vif - "Get-XoVif" - "Set-XoVif" - - # vbd - "Get-XoVbd" - - # alarm - "Get-XoAlarm" - - # schedule - "Get-XoSchedule" - - # vm-template - "Get-XoVmTemplate" - ) - AliasesToExport = @( - "Connect-XenOrchestra" - "Disconnect-XenOrchestra" - # task - "Get-XoTaskDetails" - ) - FormatsToProcess = @( - "formats/sr.ps1xml" - "formats/task.ps1xml" - "formats/vdi.ps1xml" - "formats/vm.ps1xml" - "formats/vdi-snapshot.ps1xml" - "formats/vm-snapshot.ps1xml" - "formats/server.ps1xml" - "formats/host.ps1xml" - "formats/pool.ps1xml" - "formats/pool-patch.ps1xml" - "formats/message.ps1xml" - "formats/network.ps1xml" - "formats/pif.ps1xml" - "formats/vif.ps1xml" - "formats/vbd.ps1xml" - "formats/alarm.ps1xml" - "formats/schedule.ps1xml" - "formats/vm-template.ps1xml" - ) -} diff --git a/xo-powershell.psm1 b/xo-powershell.psm1 deleted file mode 100644 index 2af1f6e..0000000 --- a/xo-powershell.psm1 +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -$ErrorActionPreference = "Stop" - -# Module-level variables -$script:XoHost = $null -$script:XoRestParameters = $null -$script:XO_DEFAULT_LIMIT = 25 - -foreach ($import in (Get-ChildItem $PSScriptRoot/src/*.ps1)) { - try { - . $import.FullName - } - catch { - Write-Error -Message "Cannot import $($import.FullName): $_" - throw - } -}