PowervRA icon indicating copy to clipboard operation
PowervRA copied to clipboard

Not fetching correct data from VRA

Open SandyKapil opened this issue 7 years ago • 12 comments

Hi There - Through PowerVRA I am trying to build a report which will be sent out as an email to the stakeholders to show them if the storage if reaching a threshold mark say 80 or 90% and the issue here is that I could successfully write all the code and get the info but it's not aligning with what our GUI showing us, and I have tested this piece of code in both our dev/test and Prod environment but there is a discrepancy out there always.

Do you know whether it works successfully or I am just wasting my time here?? Because it's been more than 10 days that i am trying to make it work.

Steps to reproduce

I am getting all of the storages from the reservations extension data entries. Here is the code: #connecting the VRA server first #Connect-vRAServer -Server vra-dev

#getting the vra collection $reservations = get-vrareservation

#looping through reservation one by one foreach ($reservation in $reservations) {

 $Storage = $reservation.ExtensionData.entries | Where-Object {$_.key -eq "reservationStorages"}

 $StorageItems = $Storage.value.items

    foreach ($item in $StorageItems) 
	{
                          
            $computeResourceStorage = $item.values.entries | Where-Object {$_.key -eq "computeResourceStorageTotalSizeGB"}
            $String = "Total Computer Resource Storage space" + $computeResourceStorage.value.value
			Write-Output $String				
            $computeResourceStorageFreeSize = $item.values.entries | Where-Object {$_.key -eq "computeResourceStorageFreeSizeGB"}
            $String = "Free Computer Resource Storage space" + $computeResourceStorageFreeSize.value.value
            Write-Output $String				        
            $computeResourceStorageReservedSize = $item.values.entries | Where-Object {$_.key -eq "computeResourceStorageReservedSizeGB "}
            $String = "Computer Resource Storage Reserved space" + $computeResourceStorageReservedSize.value.value
			Write-Output $String				
            $StorageReservedSizeGB = $item.values.entries | Where-Object {$_.key -eq "storageReservedSizeGB"}
            $String = "StorageReservedSize is" + $StorageReservedSizeGB.value.value
			Write-Output $String				
            $storageAllocatedSizeGB = $item.values.entries | Where-Object {$_.key -eq "storageAllocatedSizeGB"}
            $String = "storageAllocatedSize is" + $storageAllocatedSizeGB.value.value                       
			Write-Output $String									
    }
}

Disconnect-vRAServer

#Disconnecting the VRA server here

Expected behavior

image

Resv-01 Total Computer Resource Storage space is: 45053 Free Computer Resource Storage space is: 8784 Computer Resource Storage Reserved space is: 400 StorageReservedSize is: 400 storageAllocatedSize is: 0

Actual behavior

Resv-01 Total Computer Resource Storage space is: 36862 Free Computer Resource Storage space is: 8269 Computer Resource Storage Reserved space is: 0 StorageReservedSize is: 400 storageAllocatedSize is: 0

Environment data

$PSVersionTable

Name Value


PSVersion 5.1.14409.1012
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1012
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

$vRAConnection

Server : https://vra-dev Token : MTUxNjY1OTk4MjEzODo0ZTkxMGYxZWZiNjFkZTBmMjM5ZDp0ZW5hbnQ6dnNwaGVyZS5sb2NhbHVzZXJuYW1lOmthcGlscy5hZG1AdGF0dHNncm91cC5jb21leHBpcmF0aW9uOjE1MTY2ODg3ODIwMDA6ZGQ3NGU2YTg3NDlkY2UxM WZlNGU1YjM5M2Q0ODU2MTRlYWQ1ZWNmNmVmOGI4M2Y3YzdiMzU3ZDUyYmIzYjY0M2QwOWIwOTUzZTM3NGQ5Y2VmZDE0OGFiYTBiMGYyYTk2MWQ1NWZjMTI3ODgxNDg1ZGFiZWQ3YjlmZDg4MDU2ZGI= Tenant : vsphere.local Username : myuserid APIVersion : 7.3 SignedCertificates : True SslProtocol : Default

SandyKapil avatar Jan 22 '18 22:01 SandyKapil

I have posted this two days ago and till date no one have had a look at it. Are you guys generally that slow or this is the peculiar one?

SandyKapil avatar Jan 25 '18 03:01 SandyKapil

@SandyKapil Possibly you haven't noticed, but this is a community project, not something created by VMware. It's primarily developed by @chelnak and myself in our spare time.

That spare time is naturally limited and while we do aim to look at issues as soon as we are able to, sometimes that is not always possible. Given the attitude you are giving off in your previous comment, you are not exactly endearing yourself in us spending our own time looking into it.

However, @chelnak and I had actually briefly discussed what you have reported yesterday and we will be aiming to look at it over the next week or so.

jonathanmedd avatar Jan 25 '18 13:01 jonathanmedd

Nah sorry I didn't realize that it's just a community page and not by vmware, my apologies for that.

SandyKapil avatar Jan 25 '18 13:01 SandyKapil

OK, no worries. We'll update the issue in due course.....

jonathanmedd avatar Jan 25 '18 14:01 jonathanmedd

@SandyKapil I'm experiencing similar issues, although not exactly the same (Total space seems OK). However, the reservation in our lab is small in comparison so possibly some differences there.

Here's my reservation:

image

and the data:

1) Total Computer Resource Storage space is: 48
2) Free Computer Resource Storage space is: 33
3) Computer Resource Storage Reserved space is: 10
4) StorageReservedSize is: 20
5) storageAllocatedSize is: 0

So there definitely seems to be an issue with 2, 3 and 5.

I don't believe the issue is with PowervRA itself though, we are merely returning the values the API has returned to us. So I believe this would need to be picked up with VMware as a query around the API results from this request, either via a support call or the communities. We don't have access to VMware support for this project, so unless you are able to do that for us, we would have to settle for posting something on the communities site?

Side Note: you have an issue in your report code. It should be:

$computeResourceStorageReservedSize = $item.values.entries | Where-Object {$_.key -eq "computeResourceStorageReservedSizeGB"}

not:

$computeResourceStorageReservedSize = $item.values.entries | Where-Object {$_.key -eq "computeResourceStorageReservedSizeGB "}

Otherwise you get no results back for that one......

jonathanmedd avatar Jan 29 '18 16:01 jonathanmedd

Reported an issue via the communities here: https://communities.vmware.com/message/2741369#2741369

jonathanmedd avatar Jan 31 '18 12:01 jonathanmedd

@jonathanmedd I'm experiencing similar issues. After doing some research I found that it might be an issue with PowervRA itself. get-vrareservation and Invoke-vRARestMethod return different values. The values returned by Invoke-vRARestMethod are correct.

$ResultCmdlet = get-vrareservation -name "reservation_name"

$ReservationId=$ResultCmdlet.id
$URI = "/reservation-service/api/reservations/$ReservationId"

$ResultInvoke = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference    

$ResultCmdlet.extensiondata.entries[1].value.items.values.entries
$ResultInvoke.extensiondata.entries[1].value.items.values.entries

basvinken avatar Oct 24 '18 08:10 basvinken

@basvinken I just tried that on a reservation in my lab and get the same results for both of the approaches you suggest.

Resultcmdlet:

key                                  value
---                                  -----
storageReservedSizeGB                @{type=integer; value=2500}
storageReservationPriority           @{type=integer; value=1}
permissible_value_selected           @{type=boolean; value=True}
storageAllocatedSizeGB               @{type=integer; value=1894}
computeResourceStorageTotalSizeGB    @{type=integer; value=1900}
isStorageCluster                     @{type=boolean; value=False}
storagePath                          @{type=entityRef; classId=Storage; id=2e33bd35-3983-4d16-aa49-6ea79129cee6; componentId=; label=ISCSI01}
storageEnabled                       @{type=boolean; value=True}
computeResourceStorageReservedSizeGB @{type=integer; value=2500}
isSDRSEnabled                        @{type=boolean; value=False}
computeResourceStorageFreeSizeGB     @{type=integer; value=802}
diskCost                             @{type=integer; value=0}
storageReservedSizeGB                @{type=integer; value=1900}
storageReservationPriority           @{type=integer; value=2}
permissible_value_selected           @{type=boolean; value=True}
storageAllocatedSizeGB               @{type=integer; value=1872}
computeResourceStorageTotalSizeGB    @{type=integer; value=1900}
isStorageCluster                     @{type=boolean; value=False}
storagePath                          @{type=entityRef; classId=Storage; id=1a43bb73-2449-4d4c-a07a-aad6b1a5f5b5; componentId=; label=ISCSI02}
storageEnabled                       @{type=boolean; value=True}
computeResourceStorageReservedSizeGB @{type=integer; value=1900}
isSDRSEnabled                        @{type=boolean; value=False}
computeResourceStorageFreeSizeGB     @{type=integer; value=516}
diskCost                             @{type=integer; value=0}

ResultInvoke:

key                                  value
---                                  -----
storageReservedSizeGB                @{type=integer; value=2500}
storageReservationPriority           @{type=integer; value=1}
permissible_value_selected           @{type=boolean; value=True}
storageAllocatedSizeGB               @{type=integer; value=1894}
computeResourceStorageTotalSizeGB    @{type=integer; value=1900}
isStorageCluster                     @{type=boolean; value=False}
storagePath                          @{type=entityRef; classId=Storage; id=2e33bd35-3983-4d16-aa49-6ea79129cee6; componentId=; label=ISCSI01}
storageEnabled                       @{type=boolean; value=True}
computeResourceStorageReservedSizeGB @{type=integer; value=2500}
isSDRSEnabled                        @{type=boolean; value=False}
computeResourceStorageFreeSizeGB     @{type=integer; value=802}
diskCost                             @{type=integer; value=0}
storageReservedSizeGB                @{type=integer; value=1900}
storageReservationPriority           @{type=integer; value=2}
permissible_value_selected           @{type=boolean; value=True}
storageAllocatedSizeGB               @{type=integer; value=1872}
computeResourceStorageTotalSizeGB    @{type=integer; value=1900}
isStorageCluster                     @{type=boolean; value=False}
storagePath                          @{type=entityRef; classId=Storage; id=1a43bb73-2449-4d4c-a07a-aad6b1a5f5b5; componentId=; label=ISCSI02}
storageEnabled                       @{type=boolean; value=True}
computeResourceStorageReservedSizeGB @{type=integer; value=1900}
isSDRSEnabled                        @{type=boolean; value=False}
computeResourceStorageFreeSizeGB     @{type=integer; value=516}
diskCost                             @{type=integer; value=0}

Could you be more specific about which values you find to be different?

jonathanmedd avatar Jan 09 '19 19:01 jonathanmedd

@jonathanmedd storageAllocatedSizeGB, computeResourceStorageTotalSizeGB, computeResourceStorageReservedSizeGB are different. I noticed that in your situation you don't use a Storagecluster which might explain the difference between your and mine output.

image

basvinken avatar Jan 10 '19 09:01 basvinken

@jonathanmedd

There's a problem with the api If you call $URI = "/reservation-service/api/reservations?`$filter=name%20eq%20'$($ReservationName)'" You will retrieve all reservations and then filter the result. If you call $URI = "/reservation-service/api/reservations/$ReservationId" You will only retrieve the data for the specific reservation. VMware has confirmed that both methods will return different results. VROPS suffers from this issue as well

To workarround the issue you could rewrite get-vrareservation and use $URI = "/reservation-service/api/reservations/$ReservationId"

basvinken avatar Jan 10 '19 13:01 basvinken

@basvinken Interesting. Is there any public information published about that problem?

jonathanmedd avatar Jan 11 '19 11:01 jonathanmedd

@jonathanmedd No information is still not public. I received this information as answer to a VMware case I opened.

basvinken avatar Jan 21 '19 12:01 basvinken