switch from virtbuf to virtpb
This commit is contained in:
parent
72af75ceaa
commit
cf708182ac
|
@ -8,7 +8,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
pb "go.wit.com/lib/protobuf/virtpb"
|
||||
"go.wit.com/log"
|
||||
"libvirt.org/go/libvirtxml"
|
||||
)
|
||||
|
|
20
cloud.go
20
cloud.go
|
@ -12,7 +12,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
|
||||
"go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/lib/protobuf/virtpb"
|
||||
)
|
||||
|
||||
var ctx context.Context
|
||||
|
@ -22,23 +22,23 @@ var myClient cloudAPI
|
|||
type CloudManager struct {
|
||||
// client represents a hypothetical API client for interacting with the cloud.
|
||||
client cloudAPI
|
||||
cluster *virtbuf.Cluster
|
||||
cluster *virtpb.Cluster
|
||||
}
|
||||
|
||||
// cloudAPIt defines the methods required from the API client.
|
||||
// This is useful if you want to mock this client for testing.
|
||||
type cloudAPI interface {
|
||||
GetDropletByName(name string) *virtbuf.Droplet
|
||||
GetDropletByName(name string) *virtpb.Droplet
|
||||
|
||||
StartCluster(clusterID string) error
|
||||
StopCluster(clusterID string) error
|
||||
ListDroplets() ([]*virtbuf.Droplet, error)
|
||||
ListDroplets() ([]*virtpb.Droplet, error)
|
||||
|
||||
GetClusterStatus(clusterID string) (string, error)
|
||||
}
|
||||
|
||||
func NewCloud() *CloudManager {
|
||||
// client := virtbuf.NewRealCloudAPIClient()
|
||||
// client := virtpb.NewRealCloudAPIClient()
|
||||
// clusterManager := NewCloudManager(myClient)
|
||||
newCloudManager := &CloudManager{client: myClient}
|
||||
|
||||
|
@ -53,7 +53,7 @@ func NewCloud() *CloudManager {
|
|||
// }
|
||||
|
||||
// FindByName retrieves a cluster by name.
|
||||
func (m *CloudManager) FindDropletByName(name string) (*virtbuf.Droplet, error) {
|
||||
func (m *CloudManager) FindDropletByName(name string) (*virtpb.Droplet, error) {
|
||||
if m.cluster == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func (m *CloudManager) FindDropletByName(name string) (*virtbuf.Droplet, error)
|
|||
}
|
||||
|
||||
// Start initiates the startup process for the specified cluster.
|
||||
func (m *CloudManager) Start(cluster *virtbuf.Cluster) error {
|
||||
func (m *CloudManager) Start(cluster *virtpb.Cluster) error {
|
||||
if cluster == nil {
|
||||
return errors.New("cluster cannot be nil")
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (m *CloudManager) Start(cluster *virtbuf.Cluster) error {
|
|||
}
|
||||
|
||||
// Stop halts the specified cluster.
|
||||
func (m *CloudManager) Stop(cluster *virtbuf.Cluster) error {
|
||||
func (m *CloudManager) Stop(cluster *virtpb.Cluster) error {
|
||||
if cluster == nil {
|
||||
return errors.New("cluster cannot be nil")
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func (m *CloudManager) Stop(cluster *virtbuf.Cluster) error {
|
|||
}
|
||||
|
||||
// List retrieves all available clusters.
|
||||
func (m *CloudManager) List() ([]*virtbuf.Cluster, error) {
|
||||
func (m *CloudManager) List() ([]*virtpb.Cluster, error) {
|
||||
/*
|
||||
clusters, err := m.client.ListClusters(ctx)
|
||||
if err != nil {
|
||||
|
@ -102,7 +102,7 @@ func (m *CloudManager) List() ([]*virtbuf.Cluster, error) {
|
|||
}
|
||||
|
||||
// Status checks the current status of a specified cluster.
|
||||
func (m *CloudManager) Status(cluster *virtbuf.Cluster) (string, error) {
|
||||
func (m *CloudManager) Status(cluster *virtpb.Cluster) (string, error) {
|
||||
if cluster == nil {
|
||||
return "", errors.New("cluster cannot be nil")
|
||||
}
|
||||
|
|
8
disks.go
8
disks.go
|
@ -10,11 +10,11 @@ package virtigolib
|
|||
import (
|
||||
"path/filepath"
|
||||
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/lib/protobuf/virtpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func InsertFilename(d *pb.Droplet, filename string) (*pb.Event, error) {
|
||||
func InsertFilename(d *virtpb.Droplet, filename string) (*virtpb.Event, error) {
|
||||
filebase := filepath.Base(filename)
|
||||
dir := filepath.Dir(filename)
|
||||
for _, disk := range d.Disks {
|
||||
|
@ -27,8 +27,8 @@ func InsertFilename(d *pb.Droplet, filename string) (*pb.Event, error) {
|
|||
e := d.NewChangeEvent("Add Disk", "", filename)
|
||||
|
||||
// add the disk protobuf entry
|
||||
var disk *pb.Disk
|
||||
disk = new(pb.Disk)
|
||||
var disk *virtpb.Disk
|
||||
disk = new(virtpb.Disk)
|
||||
disk.Filename = filebase
|
||||
disk.Filepath = dir
|
||||
d.Disks = append(d.Disks, disk)
|
||||
|
|
|
@ -6,15 +6,15 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/lib/protobuf/virtpb"
|
||||
"go.wit.com/log"
|
||||
"libvirt.org/go/libvirtxml"
|
||||
)
|
||||
|
||||
// do a test import of a libvirt xml domain
|
||||
func TestLibvirtDomain(domcfg *libvirtxml.Domain) (*pb.Droplet, error) {
|
||||
d := new(pb.Droplet)
|
||||
d.Current = new(pb.Current)
|
||||
func TestLibvirtDomain(domcfg *libvirtxml.Domain) (*virtpb.Droplet, error) {
|
||||
d := new(virtpb.Droplet)
|
||||
d.Current = new(virtpb.Current)
|
||||
if domcfg == nil {
|
||||
return d, errors.New("domcfg == nil")
|
||||
}
|
||||
|
|
4
spice.go
4
spice.go
|
@ -6,11 +6,11 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/lib/protobuf/virtpb"
|
||||
"libvirt.org/go/libvirtxml"
|
||||
)
|
||||
|
||||
func SetSpicePort(d *pb.Droplet, domcfg *libvirtxml.Domain) error {
|
||||
func SetSpicePort(d *virtpb.Droplet, domcfg *libvirtxml.Domain) error {
|
||||
if domcfg.Devices.Graphics == nil {
|
||||
return errors.New("no graphics")
|
||||
}
|
||||
|
|
4
start.go
4
start.go
|
@ -10,12 +10,12 @@ import (
|
|||
|
||||
"libvirt.org/go/libvirtxml"
|
||||
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/lib/protobuf/virtpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// generate the XML for 'virsh create'
|
||||
func GenerateDropletXml(dirs []string, d *pb.Droplet, domcfg *libvirtxml.Domain, hostname string) error {
|
||||
func GenerateDropletXml(dirs []string, d *virtpb.Droplet, domcfg *libvirtxml.Domain, hostname string) error {
|
||||
if d == nil {
|
||||
return errors.New("*droplet == nil")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue