Skip to content

Commit

Permalink
add storage svc
Browse files Browse the repository at this point in the history
  • Loading branch information
sp-yduck committed Jul 27, 2023
1 parent 44088d9 commit 2ca7452
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion proxmox/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions proxmox/storage.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 2ca7452

Please sign in to comment.