PowerShell script exchange
Post Reply
jcolonfzenpr
Veeam Vanguard
Posts: 50
Liked: 33 times
Joined: Dec 30, 2021 1:16 am
Full Name: Jonathan Colon
Location: Puerto Rico
Contact:

Cloud Connect tenant utilization storage units

Post by jcolonfzenpr »

Hi,

I have an issue request in the AsBuiltReport.Veeam.VBR github repository that references using Cloud Connect Tenant not displaying the correct numbers. Looking in the PowerShell module for Veeam VBR I find that the values returned by the 'Get-VBRCloudTenant' module are of type 'Int64'.

Example:

Code: Select all

PS C:\Users\jocolon> $CloudTenant = Get-VBRCloudTenant | Sort-Object -Property Name
PS C:\Users\jocolon> $CloudTenant.Resources.RepositoryQuota
2048
10240
2097152
1048576
10240
10240
102400
10737418240
PS C:\Users\jocolon>
PS C:\Users\jocolon> $CloudTenant[0].Resources.RepositoryQuota
2048
PS C:\Users\jocolon> $CloudTenant[0].Resources.RepositoryQuota.GetType()
IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Int64                                    System.ValueType
Other resources of the utilization metric are shown as type 'VMemorySize' and with this object type I can convert the value to any required unit (KB, MB, GB, TB, etc..).

Code: Select all

PS C:\Users\jocolon> $CloudObjects = (Get-VBRCloudTenant).Resources
PS C:\Users\jocolon> $CloudObjects[0].Repository.GetContainer().CachedTotalSpace

InBytes            : 1209435947008
InKilobytes        : 1181089792
InMegabytes        : 1153408
InGigabytes        : 1126
InTerabytes        : 1
InPetabytes        : 0
InBytesAsInt32     :
InKilobytesAsInt32 : 1181089792
InMegabytesAsInt32 : 1153408
InGigabytesAsInt32 : 1126
InTerabytesAsInt32 : 1
InPetabytesAsInt32 : 0
InBytesAsUInt64    : 1209435947008
IsInvalid          : False

PS C:\Users\jocolon>
PS C:\Users\jocolon> $CloudObjects[0].Repository.GetContainer().CachedTotalSpace.gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     VMemorySize                              System.ValueType

PS C:\Users\jocolon>
Is this behavior a bug?

With Int64 type how can I know what is the unit of the value (KB, MB, GB, TB, etc.)?

Thanks!
Jonathan Colon
https://techmyth.blog/
david.domask
Veeam Software
Posts: 2454
Liked: 580 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Cloud Connect tenant utilization storage units

Post by david.domask » 1 person likes this post

Hi Johnathan,

It is a bit strange and right now I don't have an explanation -- in most places I recall in the configuration database, the value is just bigInt and you are to assume the value is in bytes, but for some reason the cmdlet looks to return the values very strangely. Divide the returned Int64 value by 1024 and it will tell you the correct quota value in GiB, but I don't think this is correct behavior, so let me check a bit internally before you commit to using that in the script.

I'll update the thread when I have more information.
David Domask | Product Management: Principal Analyst
david.domask
Veeam Software
Posts: 2454
Liked: 580 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Cloud Connect tenant utilization storage units

Post by david.domask » 1 person likes this post

Hi Jonathan,

Discussed this with our RND, and behavior is expected.

RepositoryQuota is returned in MiB for Powershell for historical reasons. The type itself is not so relevant here as it's changed to MB as presented in powershell.

So for now just divide the result from ResourceQuota by 1024 to get the value in GiB (I tried to find a convenient way to use the byte math tooling with MB and GB but not immediately sure how to make PS consider the variable in MB instead of bytes by default)
David Domask | Product Management: Principal Analyst
jcolonfzenpr
Veeam Vanguard
Posts: 50
Liked: 33 times
Joined: Dec 30, 2021 1:16 am
Full Name: Jonathan Colon
Location: Puerto Rico
Contact:

Re: Cloud Connect tenant utilization storage units

Post by jcolonfzenpr » 1 person likes this post

Well, after playing with the code I found that it is easier to convert the value from MB to Byte and then use any function to manipulate the conversion back to the desired storage unit.

Code: Select all

PS C:\Users\jocolon> $RepoQuota = 2048
PS C:\Users\jocolon> Convert-Size -From MB -To Bytes -Value $RepoQuota
2147483648
PS C:\Users\jocolon> ConvertTo-FileSizeString -Size (Convert-Size -From MB -To Bytes -Value $RepoQuota) -RoundUnits 0
2 GB
PS C:\Users\jocolon>
Many thanks for your help!
Jonathan Colon
https://techmyth.blog/
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests