Quantcast
Channel: VMware Communities : Discussion List - VMware {code}
Viewing all articles
Browse latest Browse all 2738

VB.net CreateImportSpec VMDK File over 2GB.

$
0
0

Hi Everyone,

     When I call this function with an end goal of uploading a .VMDK file to an ESX host, I get an Arithmetic Overflow due to the amount of memory trying to be allocated by .NET frame over 2GB (My VM is approx 8GB) on line CreateImportSpec.

When taking a look at Java examples of this API it seems Java is able to commit to the allocation of the VMDK thus having it succeed. Does anyone know how to translate this over correctly in .NET?

Thanks!

 

[code]

Public Sub ImportToESX(pathToOVF As String, VMName As String, HostIP As String)

        '#Region "Check input"

        If String.IsNullOrEmpty(pathToOVF) Then

            Throw New ArgumentNullException()

        End If

        If String.IsNullOrEmpty(VMName) Then

            Throw New ArgumentNullException()

        End If

        If String.IsNullOrEmpty(HostIP) Then

            Throw New ArgumentNullException()

        End If

        If Not pathToOVF.ToUpper().EndsWith(".OVF") And Not pathToOVF.ToUpper().EndsWith(".VMDK") Then

            Throw New ArgumentException("pathToOVF must contain a .OVF/.VMDK file")

        End If

        '#End Region

 

 

        Dim importSpecParams As New OvfCreateImportSpecParams()

        importSpecParams.DiskProvisioning = OvfCreateImportSpecParamsDiskProvisioningType.thin.ToString()

        importSpecParams.EntityName = VMName

        importSpecParams.HostSystem = _hostSystem.MoRef

        importSpecParams.Locale = "US"

        importSpecParams.DeploymentOption = String.Empty

 

 

        Dim ovfDescriptor As String = read_ovf_content(pathToOVF)

        If String.IsNullOrEmpty(ovfDescriptor) Then

            Throw New ApplicationException("Error loading OVF descriptor")

        End If

 

 

        Dim resourcePool As ResourcePool = DirectCast(_vimClient.FindEntityView(GetType(ResourcePool), Nothing, Nothing, Nothing), ResourcePool)

 

 

        Dim ovfImportResult As OvfCreateImportSpecResult = _ovfManager.CreateImportSpec(ovfDescriptor, resourcePool.MoRef, _hostSystem.Datastore(0), importSpecParams)

 

 

        If ovfImportResult Is Nothing Then

            Throw New ApplicationException("Error creating import spec")

        ElseIf ovfImportResult.[Error] IsNot Nothing Then

            ' this fault means user has earlier version of ESXi

            ' than what OVF was created with.

            If TypeOf ovfImportResult.[Error](0).Fault Is OvfNoSupportedHardwareFamily Then

                Throw New ApplicationException("The ESXi server is not compatable with this OVF")

            End If

 

 

            Throw New ApplicationException(ovfImportResult.[Error](0).LocalizedMessage)

        End If[/code]


Viewing all articles
Browse latest Browse all 2738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>