diff options
Diffstat (limited to 'libvirt')
-rw-r--r-- | libvirt/config.go | 12 | ||||
-rw-r--r-- | libvirt/provider.go | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/libvirt/config.go b/libvirt/config.go index 41edc021..6c16e114 100644 --- a/libvirt/config.go +++ b/libvirt/config.go @@ -18,13 +18,17 @@ type Client struct { // Client libvirt, generate libvirt client given URI func (c *Config) Client() (*Client, error) { - conn, err := libvirt.NewConnect(c.URI) - if err != nil { - return nil, err + var err error + + if LibvirtClient == nil { + LibvirtClient, err = libvirt.NewConnect(c.URI) + if err != nil { + return nil, err + } } client := &Client{ - libvirt: conn, + libvirt: LibvirtClient, } log.Println("[INFO] Created libvirt client") diff --git a/libvirt/provider.go b/libvirt/provider.go index 07b0c72e..cbe9ab95 100644 --- a/libvirt/provider.go +++ b/libvirt/provider.go @@ -4,10 +4,13 @@ import ( "github.com/hashicorp/terraform/helper/mutexkv" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" + + libvirt "github.com/libvirt/libvirt-go" ) // Global poolMutexKV var poolMutexKV = mutexkv.NewMutexKV() +var LibvirtClient *libvirt.Connect // Provider libvirt func Provider() terraform.ResourceProvider { |