forked from TrueCloudLab/distribution
Add support for Openstack Identity v3 API
Signed-off-by: Li Wenquan <wenquan.li@hp.com>
This commit is contained in:
parent
3ff9f9b9cc
commit
af99dbd6bf
4 changed files with 105 additions and 21 deletions
|
@ -49,7 +49,6 @@ This section lists all the registry configuration options. Some options in
|
||||||
the list are mutually exclusive. So, make sure to read the detailed reference
|
the list are mutually exclusive. So, make sure to read the detailed reference
|
||||||
information about each option that appears later in this page.
|
information about each option that appears later in this page.
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
version: 0.1
|
version: 0.1
|
||||||
log:
|
log:
|
||||||
level: debug
|
level: debug
|
||||||
|
@ -96,8 +95,12 @@ information about each option that appears later in this page.
|
||||||
swift:
|
swift:
|
||||||
username: username
|
username: username
|
||||||
password: password
|
password: password
|
||||||
authurl: https://storage.myprovider.com/v2.0
|
authurl: https://storage.myprovider.com/v2.0 or https://storage.myprovider.com/v3/auth
|
||||||
tenant: tenantname
|
tenant: tenantname
|
||||||
|
tenantid: tenantid
|
||||||
|
domain: domain name for Openstack Identity v3 API
|
||||||
|
domainid: domain id for Openstack Identity v3 API
|
||||||
|
insecureskipverify: true
|
||||||
region: fr
|
region: fr
|
||||||
container: containername
|
container: containername
|
||||||
rootdirectory: /swift/object/name/prefix
|
rootdirectory: /swift/object/name/prefix
|
||||||
|
@ -665,6 +668,50 @@ This storage backend uses Openstack Swift object storage.
|
||||||
Your Openstack tenant name.
|
Your Openstack tenant name.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<code>tenantid</code>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
no
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Your Openstack tenant id.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<code>domain</code>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
no
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Your Openstack domain name for Identity v3 API.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<code>domainid</code>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
no
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Your Openstack domain id for Identity v3 API.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<code>insecureskipverify</code>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
no
|
||||||
|
</td>
|
||||||
|
true for skip TLS verification, false by default.
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<code>chunksize</code>
|
<code>chunksize</code>
|
||||||
|
|
|
@ -12,7 +12,15 @@ An implementation of the `storagedriver.StorageDriver` interface which uses [Ope
|
||||||
|
|
||||||
`container`: The name of your Swift container where you wish to store objects. An additional container - named `<container>_segments` to store the data will be used. The driver will try to create both containers during its initialization.
|
`container`: The name of your Swift container where you wish to store objects. An additional container - named `<container>_segments` to store the data will be used. The driver will try to create both containers during its initialization.
|
||||||
|
|
||||||
`tenant`: (optional) Your Openstack tenant name.
|
`tenant`: (optional) Your Openstack tenant name. You can either use `tenant` or `tenantid`.
|
||||||
|
|
||||||
|
`tenantid`: (optional) Your Openstack tenant id. You can either use `tenant` or `tenantid`.
|
||||||
|
|
||||||
|
`domain`: (Optional) Your Openstack domain name for Identity v3 API. You can either use `domain` or `domainid`.
|
||||||
|
|
||||||
|
`domainid`: (Optional) Your Openstack domain id for Identity v3 API. You can either use `domain` or `domainid`.
|
||||||
|
|
||||||
|
`insecureskipverify`: (Optional) insecureskipverify can be set to true to skip TLS verification for your openstack provider. Default is false.
|
||||||
|
|
||||||
`region`: (optional) The name of the Openstack region in which you would like to store objects (for example `fr`).
|
`region`: (optional) The name of the Openstack region in which you would like to store objects (for example `fr`).
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ package swift
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -40,14 +41,18 @@ const directoryMimeType = "application/directory"
|
||||||
|
|
||||||
//DriverParameters A struct that encapsulates all of the driver parameters after all values have been set
|
//DriverParameters A struct that encapsulates all of the driver parameters after all values have been set
|
||||||
type DriverParameters struct {
|
type DriverParameters struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
AuthURL string
|
AuthURL string
|
||||||
Tenant string
|
Tenant string
|
||||||
Region string
|
TenantID string
|
||||||
Container string
|
Domain string
|
||||||
Prefix string
|
DomainID string
|
||||||
ChunkSize int
|
Region string
|
||||||
|
Container string
|
||||||
|
Prefix string
|
||||||
|
InsecureSkipVerify bool
|
||||||
|
ChunkSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
type swiftInfo map[string]interface{}
|
type swiftInfo map[string]interface{}
|
||||||
|
@ -89,7 +94,8 @@ type Driver struct {
|
||||||
// - container
|
// - container
|
||||||
func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||||
params := DriverParameters{
|
params := DriverParameters{
|
||||||
ChunkSize: defaultChunkSize,
|
ChunkSize: defaultChunkSize,
|
||||||
|
InsecureSkipVerify: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mapstructure.Decode(parameters, ¶ms); err != nil {
|
if err := mapstructure.Decode(parameters, ¶ms); err != nil {
|
||||||
|
@ -121,6 +127,12 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||||
|
|
||||||
// New constructs a new Driver with the given Openstack Swift credentials and container name
|
// New constructs a new Driver with the given Openstack Swift credentials and container name
|
||||||
func New(params DriverParameters) (*Driver, error) {
|
func New(params DriverParameters) (*Driver, error) {
|
||||||
|
transport := &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
MaxIdleConnsPerHost: 2048,
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: params.InsecureSkipVerify},
|
||||||
|
}
|
||||||
|
|
||||||
ct := swift.Connection{
|
ct := swift.Connection{
|
||||||
UserName: params.Username,
|
UserName: params.Username,
|
||||||
ApiKey: params.Password,
|
ApiKey: params.Password,
|
||||||
|
@ -128,6 +140,10 @@ func New(params DriverParameters) (*Driver, error) {
|
||||||
Region: params.Region,
|
Region: params.Region,
|
||||||
UserAgent: "distribution",
|
UserAgent: "distribution",
|
||||||
Tenant: params.Tenant,
|
Tenant: params.Tenant,
|
||||||
|
TenantId: params.TenantID,
|
||||||
|
Domain: params.Domain,
|
||||||
|
DomainId: params.DomainID,
|
||||||
|
Transport: transport,
|
||||||
ConnectTimeout: 60 * time.Second,
|
ConnectTimeout: 60 * time.Second,
|
||||||
Timeout: 15 * 60 * time.Second,
|
Timeout: 15 * 60 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package swift
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ncw/swift/swifttest"
|
"github.com/ncw/swift/swifttest"
|
||||||
|
@ -21,15 +22,19 @@ type SwiftDriverConstructor func(rootDirectory string) (*Driver, error)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var (
|
var (
|
||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
authURL string
|
authURL string
|
||||||
tenant string
|
tenant string
|
||||||
container string
|
tenantID string
|
||||||
region string
|
domain string
|
||||||
prefix string
|
domainID string
|
||||||
swiftServer *swifttest.SwiftServer
|
container string
|
||||||
err error
|
region string
|
||||||
|
prefix string
|
||||||
|
insecureSkipVerify bool
|
||||||
|
swiftServer *swifttest.SwiftServer
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
if username = os.Getenv("OS_USERNAME"); username == "" {
|
if username = os.Getenv("OS_USERNAME"); username == "" {
|
||||||
username = os.Getenv("ST_USER")
|
username = os.Getenv("ST_USER")
|
||||||
|
@ -41,9 +46,13 @@ func init() {
|
||||||
authURL = os.Getenv("ST_AUTH")
|
authURL = os.Getenv("ST_AUTH")
|
||||||
}
|
}
|
||||||
tenant = os.Getenv("OS_TENANT_NAME")
|
tenant = os.Getenv("OS_TENANT_NAME")
|
||||||
|
tenantID = os.Getenv("OS_TENANT_ID")
|
||||||
|
domain = os.Getenv("OS_DOMAIN_NAME")
|
||||||
|
domainID = os.Getenv("OS_DOMAIN_ID")
|
||||||
container = os.Getenv("OS_CONTAINER_NAME")
|
container = os.Getenv("OS_CONTAINER_NAME")
|
||||||
region = os.Getenv("OS_REGION_NAME")
|
region = os.Getenv("OS_REGION_NAME")
|
||||||
prefix = os.Getenv("OS_CONTAINER_PREFIX")
|
prefix = os.Getenv("OS_CONTAINER_PREFIX")
|
||||||
|
insecureSkipVerify, _ = strconv.ParseBool(os.Getenv("ST_INSECURESKIPVERIFY"))
|
||||||
|
|
||||||
if username == "" || password == "" || authURL == "" || container == "" {
|
if username == "" || password == "" || authURL == "" || container == "" {
|
||||||
if swiftServer, err = swifttest.NewSwiftServer("localhost"); err != nil {
|
if swiftServer, err = swifttest.NewSwiftServer("localhost"); err != nil {
|
||||||
|
@ -67,9 +76,13 @@ func init() {
|
||||||
password,
|
password,
|
||||||
authURL,
|
authURL,
|
||||||
tenant,
|
tenant,
|
||||||
|
tenantID,
|
||||||
|
domain,
|
||||||
|
domainID,
|
||||||
region,
|
region,
|
||||||
container,
|
container,
|
||||||
prefix,
|
prefix,
|
||||||
|
insecureSkipVerify,
|
||||||
defaultChunkSize,
|
defaultChunkSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue