blob: 1efac2c081a7c98835fa5cf556f36a18c6e683af [file] [log] [blame]
Jamie Hannaford5e45ccb2014-09-22 15:41:10 +02001package v2
2
3import (
4 "os"
5 "testing"
6
7 "github.com/rackspace/gophercloud"
8 "github.com/rackspace/gophercloud/openstack"
Jamie Hannaford5e45ccb2014-09-22 15:41:10 +02009 th "github.com/rackspace/gophercloud/testhelper"
10)
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}