diff --git a/proxmox/qemu.go b/proxmox/qemu.go index f344a72..4c496bd 100644 --- a/proxmox/qemu.go +++ b/proxmox/qemu.go @@ -39,7 +39,7 @@ func (s *Service) VirtualMachines(ctx context.Context) ([]*api.VirtualMachine, e return vms, nil } -func (s *Service) NewVirtualMachine(ctx context.Context, vmid int) (*VirtualMachine, error) { +func (s *Service) VirtualMachine(ctx context.Context, vmid int) (*VirtualMachine, error) { nodes, err := s.Nodes(ctx) if err != nil { return nil, err diff --git a/proxmox/storage.go b/proxmox/storage.go new file mode 100644 index 0000000..9f7360b --- /dev/null +++ b/proxmox/storage.go @@ -0,0 +1,31 @@ +package proxmox + +import ( + "context" + + "github.com/sp-yduck/proxmox-go/api" + "github.com/sp-yduck/proxmox-go/rest" +) + +type Storage struct { + restclient *rest.RESTClient + Storage *api.Storage +} + +func (s *Service) Storage(ctx context.Context, name string) (*Storage, error) { + storage, err := s.restclient.GetStorage(ctx, name) + if err != nil { + return nil, err + } + return &Storage{restclient: s.restclient, Storage: storage}, nil +} + +func (s *Service) CreateStorage(ctx context.Context, name, storageType string, options api.StorageCreateOptions) (*Storage, error) { + var storage *api.Storage + options.Storage = name + options.StorageType = storageType + if err := s.restclient.Post(ctx, "/storage", options, &storage); err != nil { + return nil, err + } + return &Storage{restclient: s.restclient, Storage: storage}, nil +}