This project provides a Go client for interacting with the Cloud Hypervisor API. It includes a simple example of creating a virtual machine (VM) with specified CPU and memory configurations.
Before you begin, ensure you have the following installed:
- Go 1.22 or higher
To use the cloud-hypervisor-go client import the dependency into your project
go get github.com/afritzler/cloud-hypervisor-go
Here is a code sample to create a VM
// Initialize the API client
c, err := client.NewClient("http://localhost:8080")
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
// Create a VM with specific CPU and memory configuration
res, err := c.CreateVM(context.TODO(), client.CreateVMJSONRequestBody{
Cpus: &client.CpusConfig{
MaxVcpus: 1, // Configure the VM with 1 CPU
},
Memory: &client.MemoryConfig{
Size: 1024 * 1024 * 1024, // Configure the VM with 1 GB of RAM
},
})
if err != nil {
log.Fatalf("Failed to create VM: %v", err)
}
Clone this repository to your local machine to get started:
git clone https://github.com/afritzler/cloud-hypervisor-go.git
cd cloud-hypervisor-go
Run the generation via
make generate
I'd love to get feedback from you. Please report bugs, suggestions or post questions by opening a GitHub issue.