Permalink
Browse files

PowervRO v1.0.0

  • Loading branch information...
0 parents commit f7a823616b762e9fd472d2129fc7b07ba8bcf817 @chelnak chelnak committed Aug 14, 2016
Showing with 12,497 additions and 0 deletions.
  1. +9 −0 .gitattributes
  2. +153 −0 Get-PowervRO.ps1
  3. +174 −0 PowervRO/Functions/Connect-vROServer.psm1
  4. +39 −0 PowervRO/Functions/Disconnect-vROServer.psm1
  5. +149 −0 PowervRO/Functions/Invoke-vRORestMethod.psm1
  6. +93 −0 PowervRO/Functions/New-vROParameterDefinition.psm1
  7. +131 −0 PowervRO/Functions/actions-service/Add-vROActionPermission.psm1
  8. +114 −0 PowervRO/Functions/actions-service/Export-vROAction.psm1
  9. +153 −0 PowervRO/Functions/actions-service/Get-vROAction.psm1
  10. +95 −0 PowervRO/Functions/actions-service/Get-vROActionPermission.psm1
  11. +121 −0 PowervRO/Functions/actions-service/Import-vROAction.psm1
  12. +137 −0 PowervRO/Functions/actions-service/Invoke-vROAction.psm1
  13. +86 −0 PowervRO/Functions/actions-service/Remove-vROAction.psm1
  14. +104 −0 PowervRO/Functions/actions-service/Remove-vROActionPermission.psm1
  15. +143 −0 PowervRO/Functions/category-service/Add-vROCategoryPermission.psm1
  16. +131 −0 PowervRO/Functions/category-service/Get-vROCategory.psm1
  17. +83 −0 PowervRO/Functions/category-service/Get-vROCategoryPermission.psm1
  18. +134 −0 PowervRO/Functions/category-service/New-vROCategory.psm1
  19. +74 −0 PowervRO/Functions/category-service/Remove-vROCategory.psm1
  20. +92 −0 PowervRO/Functions/category-service/Remove-vROCategoryPermission.psm1
  21. +131 −0 PowervRO/Functions/configuration-service/Add-vROConfigurationElementPermission.psm1
  22. +115 −0 PowervRO/Functions/configuration-service/Export-vROConfigurationElement.psm1
  23. +151 −0 PowervRO/Functions/configuration-service/Get-vROConfigurationElement.psm1
  24. +96 −0 PowervRO/Functions/configuration-service/Get-vROConfigurationElementPermission.psm1
  25. +102 −0 PowervRO/Functions/configuration-service/Import-vROConfigurationElement.psm1
  26. +84 −0 PowervRO/Functions/configuration-service/Remove-vROConfigurationElement.psm1
  27. +104 −0 PowervRO/Functions/configuration-service/Remove-vROConfigurationElementPermission.psm1
  28. +120 −0 PowervRO/Functions/packages-service/Add-vROPackagePermission.psm1
  29. +110 −0 PowervRO/Functions/packages-service/Export-vROPackage.psm1
  30. +86 −0 PowervRO/Functions/packages-service/Get-vROPackage.psm1
  31. +82 −0 PowervRO/Functions/packages-service/Get-vROPackagePermission.psm1
  32. +164 −0 PowervRO/Functions/packages-service/Import-vROPackage.psm1
  33. +92 −0 PowervRO/Functions/packages-service/Remove-vROPackage.psm1
  34. +92 −0 PowervRO/Functions/packages-service/Remove-vROPackagePermission.psm1
  35. +119 −0 PowervRO/Functions/plugin-service/Export-vROPlugin.psm1
  36. +66 −0 PowervRO/Functions/plugin-service/Get-vROPlugin.psm1
  37. +102 −0 PowervRO/Functions/plugin-service/Import-vROPlugin.psm1
  38. +84 −0 PowervRO/Functions/plugin-service/Set-vROPluginState.psm1
  39. +131 −0 PowervRO/Functions/resource-service/Add-vROResourceElementPermission.psm1
  40. +111 −0 PowervRO/Functions/resource-service/Export-vROResourceElement.psm1
  41. +104 −0 PowervRO/Functions/resource-service/Get-vROResourceElement.psm1
  42. +95 −0 PowervRO/Functions/resource-service/Get-vROResourceElementPermission.psm1
  43. +101 −0 PowervRO/Functions/resource-service/Import-vROResourceElement.psm1
  44. +85 −0 PowervRO/Functions/resource-service/Remove-vROResourceElement.psm1
  45. +104 −0 PowervRO/Functions/resource-service/Remove-vROResourceElementPermission.psm1
  46. +45 −0 PowervRO/Functions/service-descriptor-service/Get-vROAPIEndpoint.psm1
  47. +52 −0 PowervRO/Functions/service-descriptor-service/Get-vROVersion.psm1
  48. +56 −0 PowervRO/Functions/user-service/Get-vROUser.psm1
  49. +90 −0 PowervRO/Functions/workflow-run-service/Get-vROWorkflowExecution.psm1
  50. +75 −0 PowervRO/Functions/workflow-run-service/Get-vROWorkflowExecutionResult.psm1
  51. +69 −0 PowervRO/Functions/workflow-run-service/Get-vROWorkflowExecutionState.psm1
  52. +187 −0 PowervRO/Functions/workflow-run-service/Invoke-vROWorkflow.psm1
  53. +121 −0 PowervRO/Functions/workflow-service/Add-vROWorkflowPermission.psm1
  54. +79 −0 PowervRO/Functions/workflow-service/Export-vROWorkflow.psm1
  55. +74 −0 PowervRO/Functions/workflow-service/Export-vROWorkflowIcon.psm1
  56. +74 −0 PowervRO/Functions/workflow-service/Export-vROWorkflowSchema.psm1
  57. +144 −0 PowervRO/Functions/workflow-service/Get-vROWorkflow.psm1
  58. +83 −0 PowervRO/Functions/workflow-service/Get-vROWorkflowPermission.psm1
  59. +130 −0 PowervRO/Functions/workflow-service/Import-vROWorkflow.psm1
  60. +74 −0 PowervRO/Functions/workflow-service/Remove-vROWorkflow.psm1
  61. +92 −0 PowervRO/Functions/workflow-service/Remove-vROWorkflowPermission.psm1
  62. +205 −0 PowervRO/PowervRO.psd1
  63. +37 −0 README.md
  64. +1 −0 Tests/Files/Export/README.txt
  65. +9 −0 Tests/Files/Import/configuration-element-tests.vsoconf
  66. BIN Tests/Files/Import/o11nplugin-helloworld-1.0.1-SNAPSHOT.vmoapp
  67. +5 −0 Tests/Files/Import/resource-element.tests.json
  68. BIN Tests/Files/Import/returnname.action
  69. +9 −0 Tests/Test000-Module.Tests.ps1
  70. +27 −0 Tests/Test001-Connection.Tests.ps1
  71. +114 −0 Tests/Test002-Workflow-Service.Tests.ps1
  72. +134 −0 Tests/Test003-Workflow-Run-Service.Tests.ps1
  73. +144 −0 Tests/Test004-Category-Service.Tests.ps1
  74. +19 −0 Tests/Test005-User-Service.Tests.ps1
  75. +74 −0 Tests/Test006-Packages-Service.Tests.ps1
  76. +53 −0 Tests/Test007-Plugin-Service.Tests.ps1
  77. +91 −0 Tests/Test008-Resource-Service.Tests.ps1
  78. +27 −0 Tests/Test009-Service-Descriptor-Service.Tests.ps1
  79. +102 −0 Tests/Test010-Action-Service.Tests.ps1
  80. +91 −0 Tests/Test011-Configuration-Service.Tests.ps1
  81. +109 −0 Tests/Variables.json
  82. BIN Tests/net.powervro.tests.package
  83. +147 −0 bin/DocumentTemplates/md-function-template.ps1
  84. +16 −0 bin/DocumentTemplates/mkdocs-yml-template.ps1
  85. +64 −0 bin/Update-MKDocsYML.psm1
  86. +78 −0 bin/Update-ModuleDocumentation.psm1
  87. +82 −0 bin/Update-ModuleManifestFunctions.psm1
  88. +146 −0 bin/Update-ModuleManifestVersion.psm1
  89. +105 −0 bin/psake.build.ps1
  90. +54 −0 build.ps1
  91. +75 −0 docs/Add-vROActionPermission.md
  92. +89 −0 docs/Add-vROCategoryPermission.md
  93. +75 −0 docs/Add-vROConfigurationElementPermission.md
  94. +88 −0 docs/Add-vROPackagePermission.md
  95. +75 −0 docs/Add-vROResourceElementPermission.md
  96. +89 −0 docs/Add-vROWorkflowPermission.md
  97. +107 −0 docs/Connect-vROServer.md
  98. +48 −0 docs/Disconnect-vROServer.md
  99. +60 −0 docs/Export-vROAction.md
  100. +61 −0 docs/Export-vROConfigurationElement.md
  101. +79 −0 docs/Export-vROPackage.md
  102. +60 −0 docs/Export-vROPlugin.md
  103. +60 −0 docs/Export-vROResourceElement.md
  104. +59 −0 docs/Export-vROWorkflow.md
  105. +59 −0 docs/Export-vROWorkflowIcon.md
  106. +59 −0 docs/Export-vROWorkflowSchema.md
  107. +29 −0 docs/Get-vROAPIEndpoint.md
  108. +78 −0 docs/Get-vROAction.md
  109. +50 −0 docs/Get-vROActionPermission.md
  110. +89 −0 docs/Get-vROCategory.md
  111. +50 −0 docs/Get-vROCategoryPermission.md
  112. +62 −0 docs/Get-vROConfigurationElement.md
  113. +50 −0 docs/Get-vROConfigurationElementPermission.md
  114. +51 −0 docs/Get-vROPackage.md
  115. +50 −0 docs/Get-vROPackagePermission.md
  116. +29 −0 docs/Get-vROPlugin.md
  117. +50 −0 docs/Get-vROResourceElement.md
  118. +50 −0 docs/Get-vROResourceElementPermission.md
  119. +29 −0 docs/Get-vROUser.md
  120. +29 −0 docs/Get-vROVersion.md
  121. +108 −0 docs/Get-vROWorkflow.md
  122. +49 −0 docs/Get-vROWorkflowExecution.md
  123. +51 −0 docs/Get-vROWorkflowExecutionResult.md
  124. +52 −0 docs/Get-vROWorkflowExecutionState.md
  125. +50 −0 docs/Get-vROWorkflowPermission.md
  126. +85 −0 docs/Import-vROAction.md
  127. +67 −0 docs/Import-vROConfigurationElement.md
  128. +95 −0 docs/Import-vROPackage.md
  129. +76 −0 docs/Import-vROPlugin.md
  130. +66 −0 docs/Import-vROResourceElement.md
  131. +108 −0 docs/Import-vROWorkflow.md
  132. +87 −0 docs/Invoke-vROAction.md
  133. +118 −0 docs/Invoke-vRORestMethod.md
  134. +176 −0 docs/Invoke-vROWorkflow.md
  135. +122 −0 docs/New-vROCategory.md
  136. +80 −0 docs/New-vROParameterDefinition.md
  137. +77 −0 docs/Remove-vROAction.md
  138. +76 −0 docs/Remove-vROActionPermission.md
  139. +77 −0 docs/Remove-vROCategory.md
  140. +76 −0 docs/Remove-vROCategoryPermission.md
  141. +77 −0 docs/Remove-vROConfigurationElement.md
  142. +77 −0 docs/Remove-vROConfigurationElementPermission.md
  143. +86 −0 docs/Remove-vROPackage.md
  144. +75 −0 docs/Remove-vROPackagePermission.md
  145. +77 −0 docs/Remove-vROResourceElement.md
  146. +77 −0 docs/Remove-vROResourceElementPermission.md
  147. +77 −0 docs/Remove-vROWorkflow.md
  148. +76 −0 docs/Remove-vROWorkflowPermission.md
  149. +75 −0 docs/Set-vROPluginState.md
  150. +31 −0 docs/index.md
  151. BIN mkdocs.yml
@@ -0,0 +1,9 @@
+bin/
+docs/ export-ignore
+Tests/ export-ignore
+README.md export-ignore
+mkdocs.yml export-ignore
+Get-PowervRO.ps1 export-ignore
+.gitignore export-ignore
+.gitattributes export-ignore
+build.ps1 export-ignore
@@ -0,0 +1,153 @@
+function Get-PowervRO {
+<#
+ .SYNOPSIS
+ Install PowervRO
+
+ .DESCRIPTION
+ Install PowervRO
+
+ .PARAMETER Global
+ Install for all users
+
+ .PARAMETER ImportAfterInstall
+ Import the module after a succesfull installation
+
+ .PARAMETER InstallFromRepo
+ Install latest release from github repo
+
+ .INPUTS
+ None
+
+ .OUTPUTS
+ None
+
+ .EXAMPLE
+ Get-PowervRO
+
+ .EXAMPLE
+ Get-PowervRO -Global
+
+ .EXAMPLE
+ Get-PowervRO -Global -ImportAfterInstall
+
+#>
+[CmdletBinding(SupportsShouldProcess,ConfirmImpact="High",DefaultParameterSetName="Standard")]
+
+ Param (
+
+ [parameter(Mandatory=$false,ParameterSetName="Standard")]
+ [ValidateNotNullOrEmpty()]
+ [String]$URI,
+
+ [parameter(Mandatory=$false,ParameterSetName="Standard")]
+ [ValidateNotNullOrEmpty()]
+ [Switch]$Global,
+
+ [parameter(Mandatory=$false,ParameterSetName="Standard")]
+ [ValidateNotNullOrEmpty()]
+ [Switch]$ImportAfterInstall
+
+ )
+
+ begin {
+
+ $Header = @"
+ _____ _____ ____
+| __ \ | __ \ / __ \
+| |__) |____ _____ _ ____ _| |__) | | | |
+| ___/ _ \ \ /\ / / _ \ '__\ \ / / _ /| | | |
+| | | (_) \ V V / __/ | \ V /| | \ \| |__| |
+|_| \___/ \_/\_/ \___|_| \_/ |_| \_\\____/
+"@
+
+ Write-Output $Header
+ Write-Output "Jakku Labs $([char]0x00A9) 2016"
+
+ }
+
+ process {
+
+ try {
+
+ # --- Set the installtion directory
+ $InstallationDir = "C:\Users\$($env:USERNAME)\Documents\WindowsPowerShell\Modules\PowervRO\"
+
+ if ($PSBoundParameters.ContainsKey('Global')) {
+
+ $InstallationDir = "C:\Program Files\WindowsPowerShell\Modules\PowervRO\"
+
+ }
+
+ Write-Verbose -Message "Intallation directory is: $($InstallationDir)"
+
+ # --- Download and unpack the latest release
+
+ Write-Verbose -Message "Downloading latest release from $($URI)"
+
+ $Response = Invoke-RestMethod -Method Get -Uri $URI
+
+ $ZipUrl = $Response.zipball_url
+
+ $GUID = ([guid]::NewGuid()).ToString()
+
+ $OutputFile = "$($env:TEMP)\PowervRO-$($GUID).zip"
+
+ Invoke-RestMethod -Method Get -Uri $ZipUrl -OutFile $OutputFile
+
+ Add-Type -assembly “system.io.compression.filesystem”
+
+ $PowervROModulePath = $OutputFile.Substring(0, $OutputFile.LastIndexOf('.'))
+
+ Write-Verbose -Message "Unpacking module to $($PowervROModulePath)"
+
+ [io.compression.zipfile]::ExtractToDirectory($OutputFile, $PowervROModulePath)
+
+ if ($PSCmdlet.ShouldProcess($InstallationDir)){
+
+ # --- Remove module if it is present
+ if ((Test-Path -Path $InstallationDir)){
+
+ Write-Verbose -Message "Removing old module"
+
+ Remove-Item -Path $InstallationDir -Recurse -Force
+
+ }
+
+ # --- Install PowervRO
+ Write-Verbose -Message "Installing PowervRO to $($InstallationDir)"
+
+ Copy-Item -Path "$($PowervROModulePath)\*\PowervRO" -Destination $InstallationDir -Force -Recurse
+
+ if ($PSBoundParameters.ContainsKey('ImportAfterInstall')) {
+
+ Write-Verbose -Message "Attempting to remove old module from session"
+ Remove-Module -Name "PowervRO" -Force -ErrorAction SilentlyContinue
+
+ Write-Verbose -Message "Importing module"
+ Import-Module -Name "PowervRO" -Force
+
+ }
+
+ Write-Verbose -Message "Installation complete"
+
+ }
+ }
+ catch [Exception]{
+
+ throw
+ }
+ }
+ end {
+
+ Write-Verbose -Message "Removing temporary file $($OutputFile)"
+ Remove-item -Path $OutputFile -Recurse -Force -ErrorAction SilentlyContinue -Confirm:$false
+
+ Write-Verbose -Message "Removing temporary directory $($PowervROModulePath)"
+ Remove-Item -Path $PowervROModulePath -Recurse -Force -ErrorAction SilentlyContinue -Confirm:$false
+
+ }
+
+}
+
+# --- Install PowervRO for the current user
+Get-PowervRO -URI "https://api.github.com/repos/jakkulabs/PowervRO/releases/latest" -ImportAfterInstall -Verbose
@@ -0,0 +1,174 @@
+function Connect-vROServer {
+<#
+ .SYNOPSIS
+ Connect to a vRO Server
+
+ .DESCRIPTION
+ Connect to a vRO Server and generate a connection object with Servername, Token etc
+
+ .PARAMETER Server
+ vRO Server to connect to
+
+ .PARAMETER Port
+ Optionally specify the server port. Default is 8281
+
+ .PARAMETER Username
+ Username to connect with
+
+ .PARAMETER Password
+ Password to connect with
+
+ .PARAMETER Credential
+ Credential object to connect with
+
+ .PARAMETER IgnoreCertRequirements
+ Ignore requirements to use fully signed certificates
+
+ .INPUTS
+ System.String
+ Management.Automation.PSCredential
+ Switch
+
+ .OUTPUTS
+ System.Management.Automation.PSObject.
+
+ .EXAMPLE
+ Connect-vROServer -Server vro01.domain.local -Username TenantAdmin01 -Password P@ssword -IgnoreCertRequirements
+
+ .EXAMPLE
+ Connect-vROServer -Server vro01.domain.local -Credential (Get-Credential)
+
+ .EXAMPLE
+ Connect-vROServer -Server vro01.domain.local -Port 443 -Credential (Get-Credential)
+
+#>
+[CmdletBinding(DefaultParametersetName="Username")][OutputType('System.Management.Automation.PSObject')]
+
+ Param (
+
+ [Parameter(Mandatory=$true)]
+ [ValidateNotNullOrEmpty()]
+ [String]$Server,
+
+ [Parameter(Mandatory=$false)]
+ [ValidateNotNullOrEmpty()]
+ [Int]$Port = 8281,
+
+ [Parameter(Mandatory=$true,ParameterSetName="Username")]
+ [ValidateNotNullOrEmpty()]
+ [String]$Username,
+
+ [Parameter(Mandatory=$true,ParameterSetName="Username")]
+ [ValidateNotNullOrEmpty()]
+ [String]$Password,
+
+ [Parameter(Mandatory=$true,ParameterSetName="Credential")]
+ [ValidateNotNullOrEmpty()]
+ [Management.Automation.PSCredential]$Credential,
+
+ [Parameter(Mandatory=$false)]
+ [Switch]$IgnoreCertRequirements
+
+ )
+
+ # --- Test Connectivity to vRO Server on the given port
+ try {
+
+ # --- Test Connection to the vRO Server
+ Write-Verbose -Message "Testing connectivity to $($Server):$($Port)"
+
+ $TCPClient = New-Object Net.Sockets.TcpClient
+ $TCPClient.Connect($Server, $Port)
+
+ $TCPClient.Close()
+
+ }
+ catch [Exception] {
+
+ throw "Could not connect to server $($Server) on port $($Port)"
+
+ }
+
+ # --- Work with Untrusted Certificates
+ if ($PSBoundParameters.ContainsKey("IgnoreCertRequirements")){
+
+ if ( -not ("TrustAllCertsPolicy" -as [type])) {
+
+ Add-Type @"
+ using System.Net;
+ using System.Security.Cryptography.X509Certificates;
+ public class TrustAllCertsPolicy : ICertificatePolicy {
+ public bool CheckValidationResult(
+ ServicePoint srvPoint, X509Certificate certificate,
+ WebRequest request, int certificateProblem) {
+ return true;
+ }
+ }
+"@
+ }
+ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
+ $SignedCertificates = $false
+ }
+ else {
+
+ $SignedCertificates = $true
+ }
+
+ #--- Fix for vRO 7.0.1 Tls version
+ $SecurityProtocols = @(
+ [System.Net.SecurityProtocolType]::Ssl3,
+ [System.Net.SecurityProtocolType]::Tls,
+ [System.Net.SecurityProtocolType]::Tls12
+ )
+
+ [System.Net.ServicePointManager]::SecurityProtocol = $SecurityProtocols -join ","
+
+ if ($PSBoundParameters.ContainsKey("Credential")){
+
+ $Username = $Credential.UserName
+ $Password = $Credential.GetNetworkCredential().Password
+
+ }
+
+ try {
+
+ # --- Set Encoded Password
+ $Auth = $Username + ':' + $Password
+ $Encoded = [System.Text.Encoding]::UTF8.GetBytes($Auth)
+ $EncodedPassword = [System.Convert]::ToBase64String($Encoded)
+
+ # --- Create Output Object
+ $Global:vROConnection = [pscustomobject]@{
+
+ Server = "https://$($Server):$($Port)"
+ Username = $Username
+ EncodedPassword = $EncodedPassword
+ Version = $Null
+ APIVersion = $Null
+ EnabledSecurityProtocols = [System.Net.ServicePointManager]::SecurityProtocol
+ SignedCertificates = $SignedCertificates
+
+ }
+
+ # --- Update vROConnection with version information
+ $VersionInfo = Get-vROVersion
+ $Global:vROConnection.Version = $VersionInfo.Version
+ $Global:vROConnection.APIVersion = $VersionInfo.APIVersion
+
+ # --- Test the credentials provided
+ Write-Verbose -Message "Testing credentials"
+ $URI = "/vco/api/server/permissions"
+ Invoke-vRORestMethod -Method Get -URI $URI -ErrorAction Stop | Out-Null
+
+ Write-Output $Global:vROConnection
+
+
+ }
+ catch [Exception]{
+
+ Remove-Variable -Name vROConnection -Scope Global -Force -ErrorAction SilentlyContinue
+ throw $_.Exception.Message
+
+ }
+
+}
@@ -0,0 +1,39 @@
+function Disconnect-vROServer {
+<#
+ .SYNOPSIS
+ Disconnect from a vRO server
+
+ .DESCRIPTION
+ Disconnect from a vRO server by removing the global vRAConnection variable from PowerShell
+
+ .EXAMPLE
+ Disconnect-vROServer
+
+ .EXAMPLE
+ Disconnect-vROServer -Confirm:$false
+#>
+[CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")]
+
+ Param ()
+
+ # --- Test for existing connection to vRA
+ if (-not $Global:vROConnection){
+
+ throw "vRO Connection variable does not exist. Please run Connect-vROServer first to create it"
+ }
+
+ if ($PSCmdlet.ShouldProcess($Global:vROConnection.Server)){
+
+ try {
+
+ Write-Verbose -Message "Removing vROConnection Global Variable"
+ Remove-Variable -Name vROConnection -Scope Global -Force -ErrorAction SilentlyContinue
+
+ }
+ catch [Exception]{
+
+ throw
+
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit f7a8236

Please sign in to comment.