Giter VIP home page Giter VIP logo

powervra's People

Contributors

basvinken avatar blackcatdeployment avatar chelnak avatar destroy-everything avatar fonta avatar jimpallomeni avatar jmedd-ats avatar jonathanmedd avatar kclinden avatar martin9700 avatar mponton avatar mpuckett159 avatar otabut avatar sammcgeown avatar scarnes54 avatar shorbachuk avatar skunkie avatar stevio54 avatar the-mentor avatar thitho007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powervra's Issues

xRequires not evaluating versions

It appears that xRequires is no longer evaluating some APIVersions as expected.

When passing a single digit it appears to work however when you pass a value with a decimal the test fails.

I think this is because the parameter type is an Int and values such as 7.1 are doubles...

Example:

APIVersion = 7.0
RequiredVersion = 7.1

xRequires -Version 7.1 will PASS.

Solution:

  • Change the parameter type back to [String]
  • Cast $Global:vRAConnection.APIVersion as [version]
  • Cast $Version as [Version]

Further explanation can be found http://www.powershellmagazine.com/2014/01/03/pstip-validating-version-numbers-without-regex/.

Set-vRAUserPrincipal Id Alias

Set-vRAUserPrincipal -Id Should have an alias of PrincipalId so it can accept Get-vRAUserPrincipal from the pipeline

Get-vRAConsumerRequest - MaxJsonSize

When the response is over a certain size you the cmdlet will return nothing.

Examining the response object shows that it is returned as a large string.

Trying to run ConvertFrom-Json on that string produces the following error:

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

Options:

  1. Try to override the .net class and manually parse the json
  2. Implement ordering and paging on the cmd

ISSUE: Remove-vRAReservation - Id Parameter in URI should be $ReservationId not $Id

The by id block needs updating to the following:


            'ById' {

                foreach ($ReservationId in $Id) {

                    if ($PSCmdlet.ShouldProcess($ReservationId)){

                        $URI = "/reservation-service/api/reservations/$($ReservationId)"

                        Write-Verbose -Message "Preparing DELETE to $($URI)"

                        $Response = Invoke-vRARestMethod -Method DELETE -URI "$($URI)"

                        Write-Verbose -Message "SUCCESS"

                    }

Private functions?

How do you feel about having them in the project?

Starting to see how they could be useful.

Update API version check in functions to check for a valid $vRAConnection variable

The current test for API version in various functions is this at the beginning of the function:

    # --- Test for vRA API version
    if ($Global:vRAConnection.APIVersion -lt 7){

        throw "$($MyInvocation.MyCommand) is not supported with vRA API version $($Global:vRAConnection.APIVersion)"
    }   

However, if $Global:vRAConnection does not exist yet, then the user will receive an error that the API version is not supported, rather than the usual error to go run Connect-vRAServer

Export-vRAContentPackage - Change File Param to Path

@jonathanmedd What do you think about this? I was doing similar things in PowervRO.

Import functions have a File parameter (Import-Something -File file.zip)

Export functions have a Path parameter and the file name will equal the name of the object being exported plus it's file extension. (Export-Something -Path C:\Exports OR Get-Something | Export-Something)

Take a look at this for an example:
https://github.com/jakkulabs/PowervRO/blob/development/PowervRO/Functions/actions-service/Export-vROAction.psm1

New-vRAReservation fail with error 10101 Illegal GUID format null

New vRAReservation fail with error 10101 "Illegal GUID Fromat null".
Info and example:

Get-vRAVersion

BuildNumber : 3621464
BuildDate : 2016-03-04 06:35
ProductVersion : 7.0.1-SNAPSHOT
APIVersion : 7.0
ProductBuildNumber : 7.0.1-SNAPSHOT-3621464

$ComputeResource = Get-vRAReservationComputeResource -Type vSphere -Name "CLUSTER (abc)"

$NetworkDefinitionArray = @()
$Network1 = New-vRAReservationNetworkDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -NetworkPath "PG_CLCUSTER-IP"
$NetworkDefinitionArray += $Network1

$StorageDefinitionArray = @()
$Storage1 = New-vRAReservationStorageDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -Path "DS_LUN_CLUSTER" -ReservedSizeGB 3200 -Priority 0
$StorageDefinitionArray += $Storage1

--- Set the parameters and create the reservation

$Param = @{

Type = "vSphere"
Name = "XXXXXXX"
Tenant = "tenant"
BusinessGroup = "XXXXX"
Priority = 0
ComputeResourceId = $ComputeResource.Id
MemoryGB = 18
Storage = $StorageDefinitionArray
Network = $NetworkDefinitionArray
EnableAlerts = $false

}

New-vRAReservation @param -Verbose

New-vRAReservation @param -Verbose
VERBOSE: Preparing reservation payload
VERBOSE: Reservation name is RES_CL01_MIBER_AUPP
VERBOSE: ReservationTypeId for vSphere is Infrastructure.Reservation.Virtual.vSphere
VERBOSE: Tenant is nfvi-automation
VERBOSE: BusinessGroupId for XXXXX is c71c2d5f-f165-4672-9921-e0de467d6751
VERBOSE: ReservationPolicyId for is null
VERBOSE: Priority is 0
VERBOSE: Alerts enabled: false
VERBOSE: Email business group manager: false
VERBOSE: Adding extensionData for type vSphere
VERBOSE: Found compute resource XXXXXXXXX with id c83e77ca-9305-4418-b4cd-d887593c7581
VERBOSE: Setting machine quota to 0
VERBOSE: Setting reservation networks
VERBOSE: Setting reservation storage
VERBOSE: Setting reservation memory
VERBOSE: Performing the operation "New-vRAReservation" on target "XXXXXXXXXX".
VERBOSE: Preparing POST to /reservation-service/api/reservations
Invoke-RestMethod : {"errors":[{"code":10101,"message":"Invalid argument.","systemMessage":"Illegal GUID format null","moreInfoUrl":null}]}
At C:\Program Files\WindowsPowerShell\Modules\PowervRA\1.3.1\Functions\Public\Invoke-vRARestMethod.psm1:117 char:25

  • ... $Response = Invoke-RestMethod -Method $Method -Headers $Headers -Uri ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Add validate support for Import-vRAContentPackage

This should be optional but default to true:

/content-management-service/api/docs/content/resource_[Consumer]%20Package.html#path__api_packages_validate.html

From the docs:

"At this point, we don't support any form of rollback strategies. A failed import may potentially leave the system in an inconsistent state. Hence, its highly recommend to run a precheck/dry-run before the import to validate the package.

See HTTP POST /api/packages/validate for more details. This will help catch most of the errors upfront.

Although the API looks similar to create package API but differs in the 'Content-Type' header where it expects 'multipart/form-data'."

Add Pipeline support to Export-vRAContentPackage

Add Pipeline support to Export-vRAContentPackage. Not sure why it is not there, looks straightforward to implement.

Should be able to do:

Get-vRAContentPackage -Name ContentPackage01 | Export-vRAContentPackage -File C:\Packages\ContentPackage01.zip

Remove Get-vRARequest.psm1

Get-vRARequest.psm1 is a duplicate of Get-vRAConsumerRequest.psm1 and should be removed as there is no admin api equivalent

Add PSScriptAnalyzerSettings.psd1 file to prevent PS Gallery warnings

We currently do this to avoid generating an error for username / password with ScriptAnalyzer

$Exclusions = "PSAvoidUsingUserNameAndPassWordParams"

$Results = Invoke-ScriptAnalyzer -Path $ModuleDirectory -Severity Error -ExcludeRule $Exclusions -Recurse -Verbose:$VerbosePreference

However, we still get the error when the tests are run in the PS Gallery. Adding a Add PSScriptAnalyzerSettings.psd1 will stop this:

https://github.com/PowerShell/psscriptanalyzer#settings-support-in-scriptanalyzer

Get-vRABusinessGroup TenantId Parameter

After talking the other week I understand why this is important. But maybe it should take the value of the current tenant for a default value. I always think of business groups being managed from within the current tenant.
Also I rememer that tenantid is case sensitive, Would it be worth doing a get-vRATenant to ensure that the TenantId is correct.
I do something similar in New-vRAEntitlement:

Ensure the correct tenant name is used in Get-vRABusinessGroup
$TenantName = (Get-vRATenant $Global:vRAConnection.Tenant).Id

Function folders

@jonathanmedd Working on the build scripts and wondering if this would make more sense:

Functions\Private
Functions\Public

Rather than:
Functions
Functions\Private Functions

What do you think

SUGGESTION: Version Checking - xRequires

@jonathanmedd

I was having a play around with some PS stuff and thought it could be cool to implement the API Verison check with a declarative helper function.. e.g:

    function Get-Example {

        # This function does not support API versions lower than Version 7
        xRequires -Version 7 -Context $MyInvocation

    }

The code

function xRequires {
<#
    .SYNOPSIS
    Sets the required API Version for the current function

    .DESCRIPTION
    Sets the required API Version for the current function

    .PARAMETER Version
    The API Version that the function supports 

    .PARAMETER Context
    The functions execution context. This shold alwasy be $MyInvocation

    .INPUTS
    System.Int
    System.Management.Automation.PSObject.

    .OUTPUTS
    None

    .EXAMPLE

    function Get-Example {

        # This function does not support API versions lower than Version 7
        xRequires -Version 7 -Context $MyInvocation

    }

#>

[CmdletBinding()]

    Param (

        [Parameter(Mandatory=$true)]
        [Int]$Version,

        [Parameter(Mandatory=$true)]
        [PSCustomobject]$Context

    )

    if ($Global:vRAConnection.APIVersion) {

        if ($Global:vRAConnection.APIVersion -lt $Version) {

            throw "$($Context.MyCommand) is not supported with vRA API version $($Global:vRAConnection.APIVersion)"

        }

    }

}

Functions should only return ONE type

There are a few functions that will return a different PSCustomObject based on the type that comes back from the API.

I think when this happens we should separate out in to different functions. E.g.:

Get-vRAExternalNetworkProfile
Get-vRARoutedNetworkProfile

Request-vRACatalogItem also returns either an Id or a deployed resource depending on whether the wait switch has been passed... a reasonable solution would be for it to return the REQUEST object.

I'll update this issue with functions and solutions as i find them

Update the Module Manifest to better support the PowerShell Gallery

Add the following section:

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 = @{

    # Tags applied to this module. These help with module discovery in online galleries.
    # Tags = @()

    # A URL to the license for this module.
    LicenseUri = 'https://github.com/jakkulabs/PowervRA/blob/master/LICENSE'

    # A URL to the main website for this project.
    ProjectUri = 'https://github.com/jakkulabs/PowervRA'

    # A URL to an icon representing this module.
    # IconUri = ''

    # ReleaseNotes of this module
    # ReleaseNotes = ''

} # End of PSData hashtable

} # End of PrivateData hashtable

Request-vRAConsumerCatalogItem.psm1 calls an incorrect function

Request-vRAConsumerCatalogItem calls an incorrect function:

 $JSON = Get-vRAEntitledCatalogItemRequestTemplate -Id $Id

This should be:

 $JSON = Get-vRAConsumerCatalogItemRequestTemplate -Id $Id

Error code output is:

Get-vRAEntitledCatalogItemRequestTemplate : The term 'Get-vRAEntitledCatalogItemRequestTemplate' is not recognized as
the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At C:\Users\a615307\Documents\WindowsPowerShell\Modules\PowervRA\Functions\Request-vRAConsumerCatalogItem.psm1:106
char:25
+                 $JSON = Get-vRAEntitledCatalogItemRequestTemplate -Id $Id
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-vRAEntitled...RequestTemplate:String) [], ParentContainsErrorRecord
   Exception
    + FullyQualifiedErrorId : CommandNotFoundException

Implement New-vRAUserPrincipal

Implement New-vRAUserPrincipal so that local horizon users can be created for a tenant:

/identity/api/docs/resource_Principal.html#POST

Also see Get-vRAUserPrincipal for reference

New-VRAEntitlement doesn't add EntitledCatalogitems and EntitledResourceOperations (probable user error)

Hello,
after I've successfully created an Entitlement using the New-VRAEntitlement and JSON I found, via GUI and also via Get-VRAEntitlement, that the EntitledCatalogitems and EntitledResourceOperations, values are blank.
I tried some other test, but because I don't want to smudge the Entitlements table ( no delete in 7.0.1 ...) I stop my tentatives.
I think also that some error can be in my JSON; I tried to test only using "| ConvertFrom-Json" and it seems correct.
This is a sample (some id/label/name/value deleted):

$JSON = @"

{
    "description":  "",
    "entitledcatalogitems": {
                                     "approvalPolicyId":  null,
                                     "active":  false,
                                     "catalogItemRef":  {
                                       "id" : "fkjhksdhfk",
                                       "label" : "fdslkjlkfjfds"
                                     }
                            },
    "entitledresourceoperations":  [
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "csp.places.iaas.item.window.ConnectViaVmrc",
                                           "resourceOperationType":  "EXTENSION",
                                           "resourceOperationRef":  {
                                             "id":"110c13a5-8faf-4964-ab1e-db4e26d25841",
                                             "label":"Connect to Remote Console"
                                           },
                                           "targetResourceTypeRef": {
                                             "id":"Infrastructure.Machine",
                                             "label":"Machine"
                                           }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "csp.places.iaas.item.nowindow.ConnectViaNativeVmrc",
                                           "resourceOperationType":  "EXTENSION",
                                           "resourceOperationRef":  {
                                             "id":"de2ad362-bf59-4943-b776-671dca98139b",
                                             "label":"Connect using VMRC"
                                           },
                                             "targetResourceTypeRef": {
                                               "id":"Infrastructure.Machine",
                                               "label":"Machine"
                                             }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "fdsfdsfdsf!::!518ccf4a-6921-46b0-a2eb-99050806d30e",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"b01828b3-140a-4344-aca2-3562f40eef08",
                                             "label":"Mount ISO to CD-ROM drive"
                                           },
                                           "targetResourceTypeRef":  {
                                             "id":"Infrastructure.Virtual",
                                             "label":"Virtual Machine"
                                             }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "fdsfdsfsfds!::!50c11716-2e81-49cb-a9b5-6572544ba17e",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"a88dcb3b-0bd4-440d-9ea5-edd299eed17f",
                                             "label":"Mount tools installer"
                                           },
                                           "targetResourceTypeRef":  {
                                             "id":"Infrastructure.Virtual",
                                             "label":"Virtual Machine"
                                             }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "Infrastructure.Machine.Action.Reset",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"48bdc460-60a6-4f9f-a34a-41e5a6fa0c07",
                                             "label":"Power Cycle"
                                           },
                                           "targetResourceTypeRef": {
                                             "id":"Infrastructure.Machine",
                                             "label":"Machine"
                                           }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "Infrastructure.Machine.Action.PowerOff",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"3e273b78-08ee-479a-925c-095bafb0761c",
                                             "label":"Power Off"
                                           },
                                           "targetResourceTypeRef": {
                                             "id":"Infrastructure.Machine",
                                             "label":"Machine"
                                           }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "Infrastructure.Machine.Action.PowerOn",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"20ac9d76-30d2-4040-a435-32e9a117fb31",
                                             "label":"Power On"
                                           },
                                           "targetResourceTypeRef": {
                                             "id":"Infrastructure.Machine",
                                             "label":"Machine"
                                           }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "Infrastructure.Machine.Action.Reboot",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"6634de52-dce5-42e6-9bcd-f2fd5526d69f",
                                             "label":"Reboot"
                                           },
                                           "targetResourceTypeRef": {
                                             "id":"Infrastructure.Machine",
                                             "label":"Machine"
                                           }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "Infrastructure.Machine.Action.Shutdown",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"31555e50-43f5-45ed-a82a-b8c03c4f724e",
                                             "label":"Shutdown"
                                           },
                                           "targetResourceTypeRef": {
                                             "id":"Infrastructure.Machine",
                                             "label":"Machine"
                                           }
                                       },
                                       {
                                           "approvalPolicyId":  null,
                                           "active":  true,
                                           "externalId":  "fdsfdsfdsfsdfs!::!b1fd3802-6f63-4e3f-a30b-a4c031866e19",
                                           "resourceOperationType":  "ACTION",
                                           "resourceOperationRef":  {
                                             "id":"94aa9cdc-c783-4521-bb31-7c369b167cff",
                                             "label":"Unmount tools installer"
                                           },
                                           "targetResourceTypeRef":  {
                                             "id":"Infrastructure.Virtual",
                                             "label":"Virtual Machine"
                                             }
                                       }
                                   ],
    "entitledservices":  null,
    "expirydate":  null,
    "name":  "APITEST3",
    "organization":  {
                         "tenantRef":  "sdfdsfdfsfds",
                         "tenantLabel":  "dfsdfsfds",
                         "subtenantRef":  "dsfdsfdfs",
                         "subtenantLabel":  "SOME LABEL"
                     },
    "principals":  [
                       {
                           "tenantName":  "fdsafafdafds",
                           "ref":  "[email protected]",
                           "type":  "SSO_GROUP",
                           "value":  "SOME VALUE"
                       },
                       {
                           "tenantName":  "fsafdfasdfds",
                           "ref":  "[email protected]",
                           "type":  "SSO_GROUP",
                           "value":  "SOME OTHER VALUE"
                       }
                   ],
    "priorityorder":  1,
    "status":  "ACTIVE",
    "statusname":  "Active",
    "localscopeforactions":  true,
    "version":  1
}
"@

$JSON | New-vRAEntitlement -Verbose


 Get-vRAEntitlement -Name APITEST3


Description                :
EntitledCatalogItems       :
EntitledResourceOperations :
EntitledServices           :
ExpiryDate                 :
Id                         : 6fsdfasfddaeec2b05931
LastUpdatedBy              :  dasdasdas
LastUpdatedDate            : sadsadasd
Name                       : APITEST3
Organization               : @{CORRECT VALUE}
Principals                 : {@{CORRECT VALUE}, @{CORRECT VALUE}}
PriorityOrder              : CORRECT VALUE
Status                     : CORRECT VALUE
StatusName                 : CORRECT VALUE
LocalScopeForActions       : CORRECT VALUE
Version                    : 1

Prepare dev branch for reservation-service

Following the merge of the reservation-service branch, we need to complete the following tasks:

  • Update docs in dev branch
  • Update Module manifest to include the new functions

@jonathanmedd Am assigning this to you just for awareness just in case i go AWOL ;-)

Organise public functions in to api endpoint folders

Start to organise public functions in to api endpoint folders as we did for PowervRO

@jonathanmedd I've already started this with the catalog-svc branch that im working on.

You'll also notice that in the feature-networkprofiles branch there will be Functions\Public\iaas-proxy-provider which contains the functions for the feature.

Invoke-vRARestMethod location header

Would be interested to see if Invoke-RestMethod returns any headers from a POST... then see if we can pass them back up to Invoke-vRARestMethod.

The location header is some times passed back with the url of a created resource

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.