blob: b48855b6e954af18f1e1af5b134a6474989b82b0 [file] [log] [blame]
Jamie Hannaford5e45ccb2014-09-22 15:41:10 +02001package v2
2
3import (
4 "os"
5 "testing"
6
Jon Perritt27249f42016-02-18 10:35:59 -06007 "github.com/gophercloud/gophercloud"
8 "github.com/gophercloud/gophercloud/openstack"
9 th "github.com/gophercloud/gophercloud/testhelper"
Jamie Hannaford5e45ccb2014-09-22 15:41:10 +020010)
11
12var Client *gophercloud.ServiceClient
13
14func NewClient() (*gophercloud.ServiceClient, error) {
Jamie Hannaford390555a2014-10-22 17:04:03 +020015 opts, err := openstack.AuthOptionsFromEnv()
Jamie Hannaford5e45ccb2014-09-22 15:41:10 +020016 if err != nil {
17 return nil, err
18 }
19
20 provider, err := openstack.AuthenticatedClient(opts)
21 if err != nil {
22 return nil, err
23 }
24
25 return openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
26 Name: "neutron",
27 Region: os.Getenv("OS_REGION_NAME"),
28 })
29}
30
31func Setup(t *testing.T) {
32 client, err := NewClient()
33 th.AssertNoErr(t, err)
34 Client = client
35}
36
37func Teardown() {
38 Client = nil
39}