https://github.com/afritzler/cloud-hypervisor-go
Go SDK to interact with the Cloud Hypervisor API
https://github.com/afritzler/cloud-hypervisor-go
cloud-hypervisor golang hypervisor rust-vm sdk-go
Last synced: 11 months ago
JSON representation
Go SDK to interact with the Cloud Hypervisor API
- Host: GitHub
- URL: https://github.com/afritzler/cloud-hypervisor-go
- Owner: afritzler
- License: apache-2.0
- Created: 2024-04-16T15:39:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-16T15:44:16.000Z (about 2 years ago)
- Last Synced: 2025-01-06T21:31:06.897Z (over 1 year ago)
- Topics: cloud-hypervisor, golang, hypervisor, rust-vm, sdk-go
- Language: Makefile
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cloud-hypervisor-go
[](https://goreportcard.com/report/github.com/afritzler/cloud-hypervisor-go)
[](https://pkg.go.dev/github.com/afritzler/cloud-hypervisor-go)
[](LICENSE)
[](https://makeapullrequest.com)
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.
## Prerequisites
Before you begin, ensure you have the following installed:
- Go 1.22 or higher
## Usage
To use the cloud-hypervisor-go client import the dependency into your project
```bash
go get github.com/afritzler/cloud-hypervisor-go
```
Here is a code sample to create a VM
```go
// 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)
}
```
## Generate client
Clone this repository to your local machine to get started:
```bash
git clone https://github.com/afritzler/cloud-hypervisor-go.git
cd cloud-hypervisor-go
```
Run the generation via
```bash
make generate
```
## Contributing
I'd love to get feedback from you. Please report bugs, suggestions or post questions by opening a GitHub issue.
## License
[Apache-2.0](LICENSE)