aboutsummaryrefslogtreecommitdiff
path: root/libvirt/config.go
blob: 4fdfd501b93eed0cf384b1d19eafa9fd04a5b76e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package libvirt

import (
	"log"

	libvirt "github.com/libvirt/libvirt-go"
)

type Config struct {
	Uri string
}

type Client struct {
	libvirt *libvirt.Connect
}

func (c *Config) Client() (*Client, error) {
	conn, err := libvirt.NewConnect(c.Uri)
	if err != nil {
		return nil, err
	}

	client := &Client{
		libvirt: conn,
	}

	log.Println("[INFO] Created libvirt client")

	return client, nil
}