a more general way of generating provider clients
This commit is contained in:
parent
b1b693e461
commit
b0e8cd5dd3
|
@ -0,0 +1,25 @@
|
||||||
|
package openstack
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rackspace/gophercloud"
|
||||||
|
"github.com/rackspace/gophercloud/openstack"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newClient(c *Config, service, region string, version int) (*gophercloud.ServiceClient, error) {
|
||||||
|
var serviceClient *gophercloud.ServiceClient
|
||||||
|
switch service {
|
||||||
|
case "compute":
|
||||||
|
if version == 2 {
|
||||||
|
serviceClient, err = openstack.NewComputeV2(c.osClient, gophercloud.EndpointOpts{
|
||||||
|
Region: region,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
case "networking":
|
||||||
|
if version == 2 {
|
||||||
|
serviceClient, err = openstack.NewNetworkV2(c.osClient, gophercloud.EndpointOpts{
|
||||||
|
Region: region,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return serviceClient, err
|
||||||
|
}
|
Loading…
Reference in New Issue