Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create proxmox Vm using c#

Tags:

c#

I am totally new to proxmox VE and i want to create a Vitual Machine inside proxmox using C# console application.

I have search a lot and i only found an API program which has all the functionality but i don't know how to use it. https://github.com/EnterpriseVE/eve2pve-api-dotnet

Can someone help me how to create and delete a vm in proxmox using this API in detail or anyone have any different approach to do this

like image 896
Muhammad Fahad Avatar asked Jan 24 '26 21:01

Muhammad Fahad


1 Answers

Usage:

var client = new Client("10.92.90.91");
if (client.Login("root", "password"))
{
    var vm = client.Nodes["pve1"].Qemu[100];

    //config vm
    var config = vm.Config.VmConfig();
    Console.WriteLine(Client.ObjectToJson(config.Response));

    //create snapshot
    var response = vm.Snapshot.Snapshot("pippo2311");

    //update snapshot description
    vm.Snapshot["pippo2311"].Config.UpdateSnapshotConfig("descr");

    //delete snapshot
    vm.Snapshot["pippo2311"].Delsnapshot();

    //list of snapshot
    foreach (var snapshot in vm.Snapshot.SnapshotList().Response.data)
    {
        Console.WriteLine(Client.ObjectToJson(snapshot));
        Console.WriteLine(snapshot.name);
    }

    client.ResponseType = "png";
    var dataImg = client.Nodes["pve1"].Rrd.Rrd("cpu", "day").Response;
    Console.WriteLine("<img src=\"{dataImg}\" \>");
}
  • Get the project from github
  • Compile the project
  • Add reference to the project's dll
  • Use it just like the example above
like image 197
Barr J Avatar answered Jan 26 '26 12:01

Barr J