Corsinvest / cv4pve-api-dotnet

Proxmox VE Client API .Net C#
https://www.corsinvest.it/cv4pve
GNU General Public License v3.0
61 stars 15 forks source link

Upload ISO Task fails #16

Closed soerenOsisa closed 3 months ago

soerenOsisa commented 1 year ago

What happened?

We got very far with our wrapping of this awesome package, but failed at the uploading of ISOs.

Our Code:

internal bool UploadISO(string hostname, string isoFile, string sha256, string? overrideFileName)
{
    var task = _client.Nodes[hostname].Storage["local"].Upload.Upload("iso", overrideFileName ?? Path.GetFileName(isoFile), checksum: sha256, checksum_algorithm: "sha256")
    task.Wait();
    var result = task.Result;
    return result.IsSuccessStatusCode;
}

Where isoFile is for example "C:/someISO.iso", overrideFileName would be "windowsXYZ.iso" or null and the sha matching.

We fail on the task.Wait() with the exception of: One or more errors occurred. (An error occurred while sending the request.)

Expected behavior

We would expect our file to be uploaded just as with the ui, but it's also unclear to us, how the file content is being uploaded. Maybe hence we get an error?

Relevant log output

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at osisa.SystemManagement.Proxmox.Proxmox.UploadISO(MachineName hostname, String isoFile, String sha256, String overrideFileName) in C:\git\main\netbase\src\osisa.SystemManagement.Proxmox\Proxmox.cs:line 291
   at osisa.SystemManagement.Proxmox.Host.UploadISO(String isoFile, String sha256, String overrideFileName) in C:\git\main\netbase\src\osisa.SystemManagement.Proxmox\Host.cs:line 195
   at osisa.SystemManagement.Proxmox.Tests.SpikeTests.UploadISO(String isoFile, String sha256) in C:\git\main\netbase\src\osisa.SystemManagement.Proxmox.Tests\SpikeTests.cs:line 188
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

   at System.Net.Http.HttpConnection.<SendAsyncCore>d__61.MoveNext()
   at System.Net.Http.HttpConnectionPool.<SendWithVersionDetectionAndRetryAsync>d__86.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.RedirectHandler.<SendAsync>d__4.MoveNext()
   at System.Net.Http.HttpClient.<<SendAsync>g__Core|83_0>d.MoveNext()
   at Corsinvest.ProxmoxVE.Api.PveClientBase.<ExecuteAction>d__36.MoveNext()
   at Corsinvest.ProxmoxVE.Api.PveClientBase.<Create>d__32.MoveNext()
   at Corsinvest.ProxmoxVE.Api.PveClient.PveNodes.PveNodeItem.PveStorage.PveStorageItem.PveUpload.<Upload>d__4.MoveNext()

The response ended prematurely.

   at System.Net.Http.HttpConnection.<SendAsyncCore>d__61.MoveNext()

Net Version

netstandard2.0

Proxmox VE Version

7.3-1

Version (bug)

8.0.0

Version (working)

No response

On what operating system are you experiencing the issue?

Windows

Pull Request

franklupo commented 1 year ago

HI, the current method doesn't work. What you request requires a new implementation to upload the file to ProxmoxVE.

If you are interested, we have subscription plans to help you with support by suggesting workarounds or implementing the code ourselves if deemed useful.

best regards

datacore-pshetty commented 5 months ago

Is this an issue from Proxmox or this API.

soerenOsisa commented 5 months ago

This API


From: Prajwal J @.> Sent: Monday, April 22, 2024 12:46:57 PM To: Corsinvest/cv4pve-api-dotnet @.> Cc: Sören Maske @.>; Author @.> Subject: Re: [Corsinvest/cv4pve-api-dotnet] Upload ISO Task fails (Issue #16)

Is this an issue from Proxmox or this API.

— Reply to this email directly, view it on GitHubhttps://github.com/Corsinvest/cv4pve-api-dotnet/issues/16#issuecomment-2069075268, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMYANRS3WQHVOLWPE5TUAWLY6TTCDAVCNFSM6AAAAAA3UD2PO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZGA3TKMRWHA. You are receiving this because you authored the thread.Message ID: @.***>

390620652 commented 3 months ago

Yes, it's a big problem! I spend a lot of time to make it work.

franklupo commented 3 months ago

Yes, it's a big problem! I spend a lot of time to make it work.

Can you post the solution?

390620652 commented 3 months ago

Can you post the solution? https://github.com/Corsinvest/cv4pve-api-dotnet/pull/21

franklupo commented 3 months ago

I created UploadFileToStorageAsync in the extension.