Skip to content

Commit 2ca7452

Browse files
committed
add storage svc
1 parent 44088d9 commit 2ca7452

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

proxmox/qemu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (s *Service) VirtualMachines(ctx context.Context) ([]*api.VirtualMachine, e
3939
return vms, nil
4040
}
4141

42-
func (s *Service) NewVirtualMachine(ctx context.Context, vmid int) (*VirtualMachine, error) {
42+
func (s *Service) VirtualMachine(ctx context.Context, vmid int) (*VirtualMachine, error) {
4343
nodes, err := s.Nodes(ctx)
4444
if err != nil {
4545
return nil, err

proxmox/storage.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package proxmox
2+
3+
import (
4+
"context"
5+
6+
"github.com/sp-yduck/proxmox-go/api"
7+
"github.com/sp-yduck/proxmox-go/rest"
8+
)
9+
10+
type Storage struct {
11+
restclient *rest.RESTClient
12+
Storage *api.Storage
13+
}
14+
15+
func (s *Service) Storage(ctx context.Context, name string) (*Storage, error) {
16+
storage, err := s.restclient.GetStorage(ctx, name)
17+
if err != nil {
18+
return nil, err
19+
}
20+
return &Storage{restclient: s.restclient, Storage: storage}, nil
21+
}
22+
23+
func (s *Service) CreateStorage(ctx context.Context, name, storageType string, options api.StorageCreateOptions) (*Storage, error) {
24+
var storage *api.Storage
25+
options.Storage = name
26+
options.StorageType = storageType
27+
if err := s.restclient.Post(ctx, "/storage", options, &storage); err != nil {
28+
return nil, err
29+
}
30+
return &Storage{restclient: s.restclient, Storage: storage}, nil
31+
}

0 commit comments

Comments
 (0)