add versioning to identity; add generic 'client' function
diff --git a/openstack/compute/flavors/client.go b/openstack/compute/flavors/client.go
index 2c64908..5676d36 100644
--- a/openstack/compute/flavors/client.go
+++ b/openstack/compute/flavors/client.go
@@ -2,8 +2,8 @@
 
 import (
 	"fmt"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 	"net/url"
-	"github.com/rackspace/gophercloud/openstack/identity"
 	"strconv"
 )
 
diff --git a/openstack/compute/images/client.go b/openstack/compute/images/client.go
index c5f1897..3390b99 100644
--- a/openstack/compute/images/client.go
+++ b/openstack/compute/images/client.go
@@ -1,7 +1,7 @@
 package images
 
 import (
-	"github.com/rackspace/gophercloud/openstack/identity"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 )
 
 type Client struct {
diff --git a/openstack/compute/servers/client.go b/openstack/compute/servers/client.go
index 3ce6965..611ff22 100644
--- a/openstack/compute/servers/client.go
+++ b/openstack/compute/servers/client.go
@@ -2,7 +2,7 @@
 
 import (
 	"fmt"
-	"github.com/rackspace/gophercloud/openstack/identity"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 )
 
 // Client abstracts the connection information needed to make API requests for OpenStack compute endpoints.
diff --git a/openstack/identity/v2/client.go b/openstack/identity/v2/client.go
new file mode 100644
index 0000000..c736833
--- /dev/null
+++ b/openstack/identity/v2/client.go
@@ -0,0 +1,80 @@
+package identity
+
+import (
+	"os"
+)
+
+type Client struct {
+	Endpoint  string
+	Authority AuthResults
+	Options   AuthOptions
+}
+
+type ClientOpts struct {
+	Type    string
+	Name    string
+	Region  string
+	URLType string
+}
+
+func (ao AuthOptions) NewClient(opts ClientOpts) (Client, error) {
+	client := Client{
+		Options: ao,
+	}
+
+	ar, err := Authenticate(ao)
+	if err != nil {
+		return client, err
+	}
+
+	client.Authority = ar
+
+	sc, err := GetServiceCatalog(ar)
+	if err != nil {
+		return client, err
+	}
+
+	ces, err := sc.CatalogEntries()
+	if err != nil {
+		return client, err
+	}
+
+	var eps []Endpoint
+
+	if opts.Name != "" {
+		for _, ce := range ces {
+			if ce.Type == opts.Type && ce.Name == opts.Name {
+				eps = ce.Endpoints
+			}
+		}
+	} else {
+		for _, ce := range ces {
+			if ce.Type == opts.Type {
+				eps = ce.Endpoints
+			}
+		}
+	}
+
+	region := os.Getenv("OS_REGION_NAME")
+	if opts.Region != "" {
+		region = opts.Region
+	}
+
+	var rep string
+	for _, ep := range eps {
+		if ep.Region == region {
+			switch opts.URLType {
+			case "public":
+				rep = ep.PublicURL
+			case "private":
+				rep = ep.InternalURL
+			default:
+				rep = ep.PublicURL
+			}
+		}
+	}
+
+	client.Endpoint = rep
+
+	return client, nil
+}
diff --git a/openstack/identity/common_test.go b/openstack/identity/v2/common_test.go
similarity index 100%
rename from openstack/identity/common_test.go
rename to openstack/identity/v2/common_test.go
diff --git a/openstack/identity/doc.go b/openstack/identity/v2/doc.go
similarity index 100%
rename from openstack/identity/doc.go
rename to openstack/identity/v2/doc.go
diff --git a/openstack/identity/errors.go b/openstack/identity/v2/errors.go
similarity index 100%
rename from openstack/identity/errors.go
rename to openstack/identity/v2/errors.go
diff --git a/openstack/identity/extensions.go b/openstack/identity/v2/extensions.go
similarity index 100%
rename from openstack/identity/extensions.go
rename to openstack/identity/v2/extensions.go
diff --git a/openstack/identity/extensions_test.go b/openstack/identity/v2/extensions_test.go
similarity index 100%
rename from openstack/identity/extensions_test.go
rename to openstack/identity/v2/extensions_test.go
diff --git a/openstack/identity/requests.go b/openstack/identity/v2/requests.go
similarity index 100%
rename from openstack/identity/requests.go
rename to openstack/identity/v2/requests.go
diff --git a/openstack/identity/service_catalog.go b/openstack/identity/v2/service_catalog.go
similarity index 100%
rename from openstack/identity/service_catalog.go
rename to openstack/identity/v2/service_catalog.go
diff --git a/openstack/identity/service_catalog_test.go b/openstack/identity/v2/service_catalog_test.go
similarity index 100%
rename from openstack/identity/service_catalog_test.go
rename to openstack/identity/v2/service_catalog_test.go
diff --git a/openstack/identity/token.go b/openstack/identity/v2/token.go
similarity index 100%
rename from openstack/identity/token.go
rename to openstack/identity/v2/token.go
diff --git a/openstack/identity/token_test.go b/openstack/identity/v2/token_test.go
similarity index 100%
rename from openstack/identity/token_test.go
rename to openstack/identity/v2/token_test.go
diff --git a/openstack/storage/v1/client.go b/openstack/storage/v1/client.go
index f616038..a457a74 100644
--- a/openstack/storage/v1/client.go
+++ b/openstack/storage/v1/client.go
@@ -2,7 +2,7 @@
 
 import (
 	"fmt"
-	"github.com/rackspace/gophercloud/openstack/identity"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 )
 
 // Client is a structure that contains information for communicating with a provider.
diff --git a/openstack/utils/utils.go b/openstack/utils/utils.go
index a814c7e..99b0977 100644
--- a/openstack/utils/utils.go
+++ b/openstack/utils/utils.go
@@ -3,7 +3,7 @@
 
 import (
 	"fmt"
-	"github.com/rackspace/gophercloud/openstack/identity"
+	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
 	"os"
 )