Merge pull request #13871 from fatmcgav/swift_move_to_backend
Move Swift remote state to backend
This commit is contained in:
commit
5066fa2151
|
@ -13,6 +13,7 @@ import (
|
|||
backendconsul "github.com/hashicorp/terraform/backend/remote-state/consul"
|
||||
backendinmem "github.com/hashicorp/terraform/backend/remote-state/inmem"
|
||||
backendS3 "github.com/hashicorp/terraform/backend/remote-state/s3"
|
||||
backendSwift "github.com/hashicorp/terraform/backend/remote-state/swift"
|
||||
)
|
||||
|
||||
// backends is the list of available backends. This is a global variable
|
||||
|
@ -37,6 +38,7 @@ func init() {
|
|||
"local": func() backend.Backend { return &backendlocal.Local{} },
|
||||
"consul": func() backend.Backend { return backendconsul.New() },
|
||||
"inmem": func() backend.Backend { return backendinmem.New() },
|
||||
"swift": func() backend.Backend { return backendSwift.New() },
|
||||
"s3": func() backend.Backend { return backendS3.New() },
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,325 @@
|
|||
package swift
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack"
|
||||
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
tf_openstack "github.com/terraform-providers/terraform-provider-openstack/openstack"
|
||||
)
|
||||
|
||||
// New creates a new backend for Swift remote state.
|
||||
func New() backend.Backend {
|
||||
s := &schema.Backend{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"auth_url": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_AUTH_URL", nil),
|
||||
Description: descriptions["auth_url"],
|
||||
},
|
||||
|
||||
"user_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_USER_ID", ""),
|
||||
Description: descriptions["user_name"],
|
||||
},
|
||||
|
||||
"user_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_USERNAME", ""),
|
||||
Description: descriptions["user_name"],
|
||||
},
|
||||
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
||||
"OS_TENANT_ID",
|
||||
"OS_PROJECT_ID",
|
||||
}, ""),
|
||||
Description: descriptions["tenant_id"],
|
||||
},
|
||||
|
||||
"tenant_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
||||
"OS_TENANT_NAME",
|
||||
"OS_PROJECT_NAME",
|
||||
}, ""),
|
||||
Description: descriptions["tenant_name"],
|
||||
},
|
||||
|
||||
"password": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Sensitive: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_PASSWORD", ""),
|
||||
Description: descriptions["password"],
|
||||
},
|
||||
|
||||
"token": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_AUTH_TOKEN", ""),
|
||||
Description: descriptions["token"],
|
||||
},
|
||||
|
||||
"domain_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
||||
"OS_USER_DOMAIN_ID",
|
||||
"OS_PROJECT_DOMAIN_ID",
|
||||
"OS_DOMAIN_ID",
|
||||
}, ""),
|
||||
Description: descriptions["domain_id"],
|
||||
},
|
||||
|
||||
"domain_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
||||
"OS_USER_DOMAIN_NAME",
|
||||
"OS_PROJECT_DOMAIN_NAME",
|
||||
"OS_DOMAIN_NAME",
|
||||
"OS_DEFAULT_DOMAIN",
|
||||
}, ""),
|
||||
Description: descriptions["domain_name"],
|
||||
},
|
||||
|
||||
"region_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Description: descriptions["region_name"],
|
||||
},
|
||||
|
||||
"insecure": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_INSECURE", ""),
|
||||
Description: descriptions["insecure"],
|
||||
},
|
||||
|
||||
"endpoint_type": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_ENDPOINT_TYPE", ""),
|
||||
},
|
||||
|
||||
"cacert_file": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_CACERT", ""),
|
||||
Description: descriptions["cacert_file"],
|
||||
},
|
||||
|
||||
"cert": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_CERT", ""),
|
||||
Description: descriptions["cert"],
|
||||
},
|
||||
|
||||
"key": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_KEY", ""),
|
||||
Description: descriptions["key"],
|
||||
},
|
||||
|
||||
"path": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: descriptions["path"],
|
||||
Deprecated: "Use container instead",
|
||||
ConflictsWith: []string{"container"},
|
||||
},
|
||||
|
||||
"container": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: descriptions["container"],
|
||||
},
|
||||
|
||||
"archive_path": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: descriptions["archive_path"],
|
||||
Deprecated: "Use archive_container instead",
|
||||
ConflictsWith: []string{"archive_container"},
|
||||
},
|
||||
|
||||
"archive_container": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: descriptions["archive_container"],
|
||||
},
|
||||
|
||||
"expire_after": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: descriptions["expire_after"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
result := &Backend{Backend: s}
|
||||
result.Backend.ConfigureFunc = result.configure
|
||||
return result
|
||||
}
|
||||
|
||||
var descriptions map[string]string
|
||||
|
||||
func init() {
|
||||
descriptions = map[string]string{
|
||||
"auth_url": "The Identity authentication URL.",
|
||||
|
||||
"user_name": "Username to login with.",
|
||||
|
||||
"user_id": "User ID to login with.",
|
||||
|
||||
"tenant_id": "The ID of the Tenant (Identity v2) or Project (Identity v3)\n" +
|
||||
"to login with.",
|
||||
|
||||
"tenant_name": "The name of the Tenant (Identity v2) or Project (Identity v3)\n" +
|
||||
"to login with.",
|
||||
|
||||
"password": "Password to login with.",
|
||||
|
||||
"token": "Authentication token to use as an alternative to username/password.",
|
||||
|
||||
"domain_id": "The ID of the Domain to scope to (Identity v3).",
|
||||
|
||||
"domain_name": "The name of the Domain to scope to (Identity v3).",
|
||||
|
||||
"region_name": "The name of the Region to use.",
|
||||
|
||||
"insecure": "Trust self-signed certificates.",
|
||||
|
||||
"cacert_file": "A Custom CA certificate.",
|
||||
|
||||
"endpoint_type": "The catalog endpoint type to use.",
|
||||
|
||||
"cert": "A client certificate to authenticate with.",
|
||||
|
||||
"key": "A client private key to authenticate with.",
|
||||
|
||||
"path": "Swift container path to use.",
|
||||
|
||||
"container": "Swift container to create",
|
||||
|
||||
"archive_path": "Swift container path to archive state to.",
|
||||
|
||||
"archive_container": "Swift container to archive state to.",
|
||||
|
||||
"expire_after": "Archive object expiry duration.",
|
||||
}
|
||||
}
|
||||
|
||||
type Backend struct {
|
||||
*schema.Backend
|
||||
|
||||
// Fields below are set from configure
|
||||
client *gophercloud.ServiceClient
|
||||
archive bool
|
||||
archiveContainer string
|
||||
expireSecs int
|
||||
container string
|
||||
}
|
||||
|
||||
func (b *Backend) configure(ctx context.Context) error {
|
||||
if b.client != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Grab the resource data
|
||||
data := schema.FromContextBackendConfig(ctx)
|
||||
|
||||
config := &tf_openstack.Config{
|
||||
CACertFile: data.Get("cacert_file").(string),
|
||||
ClientCertFile: data.Get("cert").(string),
|
||||
ClientKeyFile: data.Get("key").(string),
|
||||
DomainID: data.Get("domain_id").(string),
|
||||
DomainName: data.Get("domain_name").(string),
|
||||
EndpointType: data.Get("endpoint_type").(string),
|
||||
IdentityEndpoint: data.Get("auth_url").(string),
|
||||
Insecure: data.Get("insecure").(bool),
|
||||
Password: data.Get("password").(string),
|
||||
Token: data.Get("token").(string),
|
||||
TenantID: data.Get("tenant_id").(string),
|
||||
TenantName: data.Get("tenant_name").(string),
|
||||
Username: data.Get("user_name").(string),
|
||||
UserID: data.Get("user_id").(string),
|
||||
}
|
||||
|
||||
if err := config.LoadAndValidate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Assign Container
|
||||
b.container = data.Get("container").(string)
|
||||
if b.container == "" {
|
||||
// Check deprecated field
|
||||
b.container = data.Get("path").(string)
|
||||
}
|
||||
|
||||
// Enable object archiving?
|
||||
if archiveContainer, ok := data.GetOk("archive_container"); ok {
|
||||
log.Printf("[DEBUG] Archive_container set, enabling object versioning")
|
||||
b.archive = true
|
||||
b.archiveContainer = archiveContainer.(string)
|
||||
} else if archivePath, ok := data.GetOk("archive_path"); ok {
|
||||
log.Printf("[DEBUG] Archive_path set, enabling object versioning")
|
||||
b.archive = true
|
||||
b.archiveContainer = archivePath.(string)
|
||||
}
|
||||
|
||||
// Enable object expiry?
|
||||
if expireRaw, ok := data.GetOk("expire_after"); ok {
|
||||
expire := expireRaw.(string)
|
||||
log.Printf("[DEBUG] Requested that remote state expires after %s", expire)
|
||||
|
||||
if strings.HasSuffix(expire, "d") {
|
||||
log.Printf("[DEBUG] Got a days expire after duration. Converting to hours")
|
||||
days, err := strconv.Atoi(expire[:len(expire)-1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error converting expire_after value %s to int: %s", expire, err)
|
||||
}
|
||||
|
||||
expire = fmt.Sprintf("%dh", days*24)
|
||||
log.Printf("[DEBUG] Expire after %s hours", expire)
|
||||
}
|
||||
|
||||
expireDur, err := time.ParseDuration(expire)
|
||||
if err != nil {
|
||||
log.Printf("[DEBUG] Error parsing duration %s: %s", expire, err)
|
||||
return fmt.Errorf("Error parsing expire_after duration '%s': %s", expire, err)
|
||||
}
|
||||
log.Printf("[DEBUG] Seconds duration = %d", int(expireDur.Seconds()))
|
||||
b.expireSecs = int(expireDur.Seconds())
|
||||
}
|
||||
|
||||
objClient, err := openstack.NewObjectStorageV1(config.OsClient, gophercloud.EndpointOpts{
|
||||
Region: data.Get("region_name").(string),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.client = objClient
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package swift
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/state"
|
||||
"github.com/hashicorp/terraform/state/remote"
|
||||
)
|
||||
|
||||
func (b *Backend) States() ([]string, error) {
|
||||
return nil, backend.ErrNamedStatesNotSupported
|
||||
}
|
||||
|
||||
func (b *Backend) DeleteState(name string) error {
|
||||
return backend.ErrNamedStatesNotSupported
|
||||
}
|
||||
|
||||
func (b *Backend) State(name string) (state.State, error) {
|
||||
if name != backend.DefaultStateName {
|
||||
return nil, backend.ErrNamedStatesNotSupported
|
||||
}
|
||||
|
||||
client := &RemoteClient{
|
||||
client: b.client,
|
||||
container: b.container,
|
||||
archive: b.archive,
|
||||
archiveContainer: b.archiveContainer,
|
||||
expireSecs: b.expireSecs,
|
||||
}
|
||||
|
||||
return &remote.State{Client: client}, nil
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
package swift
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers"
|
||||
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/state/remote"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
// verify that we are doing ACC tests or the Swift tests specifically
|
||||
func testACC(t *testing.T) {
|
||||
skip := os.Getenv("TF_ACC") == "" && os.Getenv("TF_SWIFT_TEST") == ""
|
||||
if skip {
|
||||
t.Log("swift backend tests require setting TF_ACC or TF_SWIFT_TEST")
|
||||
t.Skip()
|
||||
}
|
||||
t.Log("swift backend acceptance tests enabled")
|
||||
}
|
||||
|
||||
func TestBackend_impl(t *testing.T) {
|
||||
var _ backend.Backend = new(Backend)
|
||||
}
|
||||
|
||||
func testAccPreCheck(t *testing.T) {
|
||||
v := os.Getenv("OS_AUTH_URL")
|
||||
if v == "" {
|
||||
t.Fatal("OS_AUTH_URL must be set for acceptance tests")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackendConfig(t *testing.T) {
|
||||
testACC(t)
|
||||
|
||||
// Build config
|
||||
config := map[string]interface{}{
|
||||
"archive_container": "test-tfstate-archive",
|
||||
"container": "test-tfstate",
|
||||
}
|
||||
|
||||
b := backend.TestBackendConfig(t, New(), config).(*Backend)
|
||||
|
||||
if b.container != "test-tfstate" {
|
||||
t.Fatal("Incorrect path was provided.")
|
||||
}
|
||||
if b.archiveContainer != "test-tfstate-archive" {
|
||||
t.Fatal("Incorrect archivepath was provided.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackend(t *testing.T) {
|
||||
testACC(t)
|
||||
|
||||
container := fmt.Sprintf("terraform-state-swift-test-%x", time.Now().Unix())
|
||||
|
||||
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
|
||||
"container": container,
|
||||
}).(*Backend)
|
||||
|
||||
defer deleteSwiftContainer(t, b.client, container)
|
||||
|
||||
backend.TestBackend(t, b, nil)
|
||||
}
|
||||
|
||||
func TestBackendPath(t *testing.T) {
|
||||
testACC(t)
|
||||
|
||||
path := fmt.Sprintf("terraform-state-swift-test-%x", time.Now().Unix())
|
||||
t.Logf("[DEBUG] Generating backend config")
|
||||
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
|
||||
"path": path,
|
||||
}).(*Backend)
|
||||
t.Logf("[DEBUG] Backend configured")
|
||||
|
||||
defer deleteSwiftContainer(t, b.client, path)
|
||||
|
||||
t.Logf("[DEBUG] Testing Backend")
|
||||
|
||||
// Generate some state
|
||||
state1 := terraform.NewState()
|
||||
// state1Lineage := state1.Lineage
|
||||
t.Logf("state1 lineage = %s, serial = %d", state1.Lineage, state1.Serial)
|
||||
|
||||
// RemoteClient to test with
|
||||
client := &RemoteClient{
|
||||
client: b.client,
|
||||
archive: b.archive,
|
||||
archiveContainer: b.archiveContainer,
|
||||
container: b.container,
|
||||
}
|
||||
|
||||
stateMgr := &remote.State{Client: client}
|
||||
stateMgr.WriteState(state1)
|
||||
if err := stateMgr.PersistState(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := stateMgr.RefreshState(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Add some state
|
||||
state1.AddModuleState(&terraform.ModuleState{
|
||||
Path: []string{"root"},
|
||||
Outputs: map[string]*terraform.OutputState{
|
||||
"bar": &terraform.OutputState{
|
||||
Type: "string",
|
||||
Sensitive: false,
|
||||
Value: "baz",
|
||||
},
|
||||
},
|
||||
})
|
||||
stateMgr.WriteState(state1)
|
||||
if err := stateMgr.PersistState(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestBackendArchive(t *testing.T) {
|
||||
testACC(t)
|
||||
|
||||
container := fmt.Sprintf("terraform-state-swift-test-%x", time.Now().Unix())
|
||||
archiveContainer := fmt.Sprintf("%s_archive", container)
|
||||
|
||||
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
|
||||
"archive_container": archiveContainer,
|
||||
"container": container,
|
||||
}).(*Backend)
|
||||
|
||||
defer deleteSwiftContainer(t, b.client, container)
|
||||
defer deleteSwiftContainer(t, b.client, archiveContainer)
|
||||
|
||||
// Generate some state
|
||||
state1 := terraform.NewState()
|
||||
// state1Lineage := state1.Lineage
|
||||
t.Logf("state1 lineage = %s, serial = %d", state1.Lineage, state1.Serial)
|
||||
|
||||
// RemoteClient to test with
|
||||
client := &RemoteClient{
|
||||
client: b.client,
|
||||
archive: b.archive,
|
||||
archiveContainer: b.archiveContainer,
|
||||
container: b.container,
|
||||
}
|
||||
|
||||
stateMgr := &remote.State{Client: client}
|
||||
stateMgr.WriteState(state1)
|
||||
if err := stateMgr.PersistState(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := stateMgr.RefreshState(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Add some state
|
||||
state1.AddModuleState(&terraform.ModuleState{
|
||||
Path: []string{"root"},
|
||||
Outputs: map[string]*terraform.OutputState{
|
||||
"bar": &terraform.OutputState{
|
||||
Type: "string",
|
||||
Sensitive: false,
|
||||
Value: "baz",
|
||||
},
|
||||
},
|
||||
})
|
||||
stateMgr.WriteState(state1)
|
||||
if err := stateMgr.PersistState(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
archiveObjects := getSwiftObjectNames(t, b.client, archiveContainer)
|
||||
t.Logf("archiveObjects len = %d. Contents = %+v", len(archiveObjects), archiveObjects)
|
||||
if len(archiveObjects) != 1 {
|
||||
t.Fatalf("Invalid number of archive objects. Expected 1, got %d", len(archiveObjects))
|
||||
}
|
||||
|
||||
// Download archive state to validate
|
||||
archiveData := downloadSwiftObject(t, b.client, archiveContainer, archiveObjects[0])
|
||||
t.Logf("Archive data downloaded... Looks like: %+v", archiveData)
|
||||
archiveState, err := terraform.ReadState(archiveData)
|
||||
if err != nil {
|
||||
t.Fatalf("Error Reading State: %s", err)
|
||||
}
|
||||
|
||||
t.Logf("Archive state lineage = %s, serial = %d, lineage match = %t", archiveState.Lineage, archiveState.Serial, stateMgr.State().SameLineage(archiveState))
|
||||
if !stateMgr.State().SameLineage(archiveState) {
|
||||
t.Fatal("Got a different lineage")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Helper function to download an object in a Swift container
|
||||
func downloadSwiftObject(t *testing.T, osClient *gophercloud.ServiceClient, container, object string) (data io.Reader) {
|
||||
t.Logf("Attempting to download object %s from container %s", object, container)
|
||||
res := objects.Download(osClient, container, object, nil)
|
||||
if res.Err != nil {
|
||||
t.Fatalf("Error downloading object: %s", res.Err)
|
||||
}
|
||||
data = res.Body
|
||||
return
|
||||
}
|
||||
|
||||
// Helper function to get a list of objects in a Swift container
|
||||
func getSwiftObjectNames(t *testing.T, osClient *gophercloud.ServiceClient, container string) (objectNames []string) {
|
||||
_ = objects.List(osClient, container, nil).EachPage(func(page pagination.Page) (bool, error) {
|
||||
|
||||
// Get a slice of object names
|
||||
names, err := objects.ExtractNames(page)
|
||||
if err != nil {
|
||||
t.Fatalf("Error extracting object names from page: %s", err)
|
||||
}
|
||||
for _, object := range names {
|
||||
objectNames = append(objectNames, object)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Helper function to delete Swift container
|
||||
func deleteSwiftContainer(t *testing.T, osClient *gophercloud.ServiceClient, container string) {
|
||||
warning := "WARNING: Failed to delete the test Swift container. It may have been left in your Openstack account and may incur storage charges. (error was %s)"
|
||||
|
||||
// Remove any objects
|
||||
deleteSwiftObjects(t, osClient, container)
|
||||
|
||||
// Delete the container
|
||||
deleteResult := containers.Delete(osClient, container)
|
||||
if deleteResult.Err != nil {
|
||||
if _, ok := deleteResult.Err.(gophercloud.ErrDefault404); !ok {
|
||||
t.Fatalf(warning, deleteResult.Err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to delete Swift objects within a container
|
||||
func deleteSwiftObjects(t *testing.T, osClient *gophercloud.ServiceClient, container string) {
|
||||
// Get a slice of object names
|
||||
objectNames := getSwiftObjectNames(t, osClient, container)
|
||||
|
||||
for _, object := range objectNames {
|
||||
result := objects.Delete(osClient, container, object, nil)
|
||||
if result.Err != nil {
|
||||
t.Fatalf("Error deleting object %s from container %s: %s", object, container, result.Err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package swift
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers"
|
||||
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects"
|
||||
|
||||
"github.com/hashicorp/terraform/state/remote"
|
||||
)
|
||||
|
||||
const (
|
||||
TFSTATE_NAME = "tfstate.tf"
|
||||
TFSTATE_LOCK_NAME = "tfstate.lock"
|
||||
)
|
||||
|
||||
// RemoteClient implements the Client interface for an Openstack Swift server.
|
||||
type RemoteClient struct {
|
||||
client *gophercloud.ServiceClient
|
||||
container string
|
||||
archive bool
|
||||
archiveContainer string
|
||||
expireSecs int
|
||||
}
|
||||
|
||||
func (c *RemoteClient) Get() (*remote.Payload, error) {
|
||||
log.Printf("[DEBUG] Getting object %s in container %s", TFSTATE_NAME, c.container)
|
||||
result := objects.Download(c.client, c.container, TFSTATE_NAME, nil)
|
||||
|
||||
// Extract any errors from result
|
||||
_, err := result.Extract()
|
||||
|
||||
// 404 response is to be expected if the object doesn't already exist!
|
||||
if _, ok := err.(gophercloud.ErrDefault404); ok {
|
||||
log.Println("[DEBUG] Object doesn't exist to download.")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
bytes, err := result.ExtractContent()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hash := md5.Sum(bytes)
|
||||
payload := &remote.Payload{
|
||||
Data: bytes,
|
||||
MD5: hash[:md5.Size],
|
||||
}
|
||||
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
func (c *RemoteClient) Put(data []byte) error {
|
||||
if err := c.ensureContainerExists(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Putting object %s in container %s", TFSTATE_NAME, c.container)
|
||||
reader := bytes.NewReader(data)
|
||||
createOpts := objects.CreateOpts{
|
||||
Content: reader,
|
||||
}
|
||||
|
||||
if c.expireSecs != 0 {
|
||||
log.Printf("[DEBUG] ExpireSecs = %d", c.expireSecs)
|
||||
createOpts.DeleteAfter = c.expireSecs
|
||||
}
|
||||
|
||||
result := objects.Create(c.client, c.container, TFSTATE_NAME, createOpts)
|
||||
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func (c *RemoteClient) Delete() error {
|
||||
log.Printf("[DEBUG] Deleting object %s in container %s", TFSTATE_NAME, c.container)
|
||||
result := objects.Delete(c.client, c.container, TFSTATE_NAME, nil)
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func (c *RemoteClient) ensureContainerExists() error {
|
||||
containerOpts := &containers.CreateOpts{}
|
||||
|
||||
if c.archive {
|
||||
log.Printf("[DEBUG] Creating archive container %s", c.archiveContainer)
|
||||
result := containers.Create(c.client, c.archiveContainer, nil)
|
||||
if result.Err != nil {
|
||||
log.Printf("[DEBUG] Error creating archive container %s: %s", c.archiveContainer, result.Err)
|
||||
return result.Err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Enabling Versioning on container %s", c.container)
|
||||
containerOpts.VersionsLocation = c.archiveContainer
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating container %s", c.container)
|
||||
result := containers.Create(c.client, c.container, containerOpts)
|
||||
if result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func multiEnv(ks []string) string {
|
||||
for _, k := range ks {
|
||||
if v := os.Getenv(k); v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package swift
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/state/remote"
|
||||
)
|
||||
|
||||
func TestRemoteClient_impl(t *testing.T) {
|
||||
var _ remote.Client = new(RemoteClient)
|
||||
}
|
||||
|
||||
func TestRemoteClient(t *testing.T) {
|
||||
testACC(t)
|
||||
|
||||
container := fmt.Sprintf("terraform-state-swift-test-%x", time.Now().Unix())
|
||||
|
||||
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
|
||||
"container": container,
|
||||
}).(*Backend)
|
||||
|
||||
state, err := b.State(backend.DefaultStateName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defer deleteSwiftContainer(t, b.client, container)
|
||||
|
||||
remote.TestClient(t, state.(*remote.State).Client)
|
||||
}
|
|
@ -51,6 +51,5 @@ var BuiltinClients = map[string]Factory{
|
|||
"gcs": gcsFactory,
|
||||
"http": httpFactory,
|
||||
"local": fileFactory,
|
||||
"swift": swiftFactory,
|
||||
"manta": mantaFactory,
|
||||
}
|
||||
|
|
|
@ -1,362 +0,0 @@
|
|||
package remote
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack"
|
||||
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers"
|
||||
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects"
|
||||
tf_openstack "github.com/terraform-providers/terraform-provider-openstack/openstack"
|
||||
)
|
||||
|
||||
const TFSTATE_NAME = "tfstate.tf"
|
||||
|
||||
// SwiftClient implements the Client interface for an Openstack Swift server.
|
||||
type SwiftClient struct {
|
||||
client *gophercloud.ServiceClient
|
||||
authurl string
|
||||
cacert string
|
||||
cert string
|
||||
domainid string
|
||||
domainname string
|
||||
insecure bool
|
||||
key string
|
||||
password string
|
||||
path string
|
||||
region string
|
||||
tenantid string
|
||||
tenantname string
|
||||
userid string
|
||||
username string
|
||||
token string
|
||||
archive bool
|
||||
archivepath string
|
||||
expireSecs int
|
||||
}
|
||||
|
||||
func swiftFactory(conf map[string]string) (Client, error) {
|
||||
client := &SwiftClient{}
|
||||
|
||||
if err := client.validateConfig(conf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (c *SwiftClient) validateConfig(conf map[string]string) (err error) {
|
||||
authUrl, ok := conf["auth_url"]
|
||||
if !ok {
|
||||
authUrl = os.Getenv("OS_AUTH_URL")
|
||||
if authUrl == "" {
|
||||
return fmt.Errorf("missing 'auth_url' configuration or OS_AUTH_URL environment variable")
|
||||
}
|
||||
}
|
||||
c.authurl = authUrl
|
||||
|
||||
username, ok := conf["user_name"]
|
||||
if !ok {
|
||||
username = os.Getenv("OS_USERNAME")
|
||||
}
|
||||
c.username = username
|
||||
|
||||
userID, ok := conf["user_id"]
|
||||
if !ok {
|
||||
userID = os.Getenv("OS_USER_ID")
|
||||
}
|
||||
c.userid = userID
|
||||
|
||||
token, ok := conf["token"]
|
||||
if !ok {
|
||||
token = os.Getenv("OS_AUTH_TOKEN")
|
||||
}
|
||||
c.token = token
|
||||
|
||||
password, ok := conf["password"]
|
||||
if !ok {
|
||||
password = os.Getenv("OS_PASSWORD")
|
||||
|
||||
}
|
||||
c.password = password
|
||||
if password == "" && token == "" {
|
||||
return fmt.Errorf("missing either password or token configuration or OS_PASSWORD or OS_AUTH_TOKEN environment variable")
|
||||
}
|
||||
|
||||
region, ok := conf["region_name"]
|
||||
if !ok {
|
||||
region = os.Getenv("OS_REGION_NAME")
|
||||
}
|
||||
c.region = region
|
||||
|
||||
tenantID, ok := conf["tenant_id"]
|
||||
if !ok {
|
||||
tenantID = multiEnv([]string{
|
||||
"OS_TENANT_ID",
|
||||
"OS_PROJECT_ID",
|
||||
})
|
||||
}
|
||||
c.tenantid = tenantID
|
||||
|
||||
tenantName, ok := conf["tenant_name"]
|
||||
if !ok {
|
||||
tenantName = multiEnv([]string{
|
||||
"OS_TENANT_NAME",
|
||||
"OS_PROJECT_NAME",
|
||||
})
|
||||
}
|
||||
c.tenantname = tenantName
|
||||
|
||||
domainID, ok := conf["domain_id"]
|
||||
if !ok {
|
||||
domainID = multiEnv([]string{
|
||||
"OS_USER_DOMAIN_ID",
|
||||
"OS_PROJECT_DOMAIN_ID",
|
||||
"OS_DOMAIN_ID",
|
||||
})
|
||||
}
|
||||
c.domainid = domainID
|
||||
|
||||
domainName, ok := conf["domain_name"]
|
||||
if !ok {
|
||||
domainName = multiEnv([]string{
|
||||
"OS_USER_DOMAIN_NAME",
|
||||
"OS_PROJECT_DOMAIN_NAME",
|
||||
"OS_DOMAIN_NAME",
|
||||
"DEFAULT_DOMAIN",
|
||||
})
|
||||
}
|
||||
c.domainname = domainName
|
||||
|
||||
path, ok := conf["path"]
|
||||
if !ok || path == "" {
|
||||
return fmt.Errorf("missing 'path' configuration")
|
||||
}
|
||||
c.path = path
|
||||
|
||||
if archivepath, ok := conf["archive_path"]; ok {
|
||||
log.Printf("[DEBUG] Archivepath set, enabling object versioning")
|
||||
c.archive = true
|
||||
c.archivepath = archivepath
|
||||
}
|
||||
|
||||
if expire, ok := conf["expire_after"]; ok {
|
||||
log.Printf("[DEBUG] Requested that remote state expires after %s", expire)
|
||||
|
||||
if strings.HasSuffix(expire, "d") {
|
||||
log.Printf("[DEBUG] Got a days expire after duration. Converting to hours")
|
||||
days, err := strconv.Atoi(expire[:len(expire)-1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error converting expire_after value %s to int: %s", expire, err)
|
||||
}
|
||||
|
||||
expire = fmt.Sprintf("%dh", days*24)
|
||||
log.Printf("[DEBUG] Expire after %s hours", expire)
|
||||
}
|
||||
|
||||
expireDur, err := time.ParseDuration(expire)
|
||||
if err != nil {
|
||||
log.Printf("[DEBUG] Error parsing duration %s: %s", expire, err)
|
||||
return fmt.Errorf("Error parsing expire_after duration '%s': %s", expire, err)
|
||||
}
|
||||
log.Printf("[DEBUG] Seconds duration = %d", int(expireDur.Seconds()))
|
||||
c.expireSecs = int(expireDur.Seconds())
|
||||
}
|
||||
|
||||
c.insecure = false
|
||||
raw, ok := conf["insecure"]
|
||||
if !ok {
|
||||
raw = os.Getenv("OS_INSECURE")
|
||||
}
|
||||
if raw != "" {
|
||||
v, err := strconv.ParseBool(raw)
|
||||
if err != nil {
|
||||
return fmt.Errorf("'insecure' and 'OS_INSECURE' could not be parsed as bool: %s", err)
|
||||
}
|
||||
c.insecure = v
|
||||
}
|
||||
|
||||
cacertFile, ok := conf["cacert_file"]
|
||||
if !ok {
|
||||
cacertFile = os.Getenv("OS_CACERT")
|
||||
}
|
||||
c.cacert = cacertFile
|
||||
|
||||
cert, ok := conf["cert"]
|
||||
if !ok {
|
||||
cert = os.Getenv("OS_CERT")
|
||||
}
|
||||
c.cert = cert
|
||||
|
||||
key, ok := conf["key"]
|
||||
if !ok {
|
||||
key = os.Getenv("OS_KEY")
|
||||
}
|
||||
c.key = key
|
||||
|
||||
ao := gophercloud.AuthOptions{
|
||||
IdentityEndpoint: c.authurl,
|
||||
UserID: c.userid,
|
||||
Username: c.username,
|
||||
TenantID: c.tenantid,
|
||||
TenantName: c.tenantname,
|
||||
Password: c.password,
|
||||
TokenID: c.token,
|
||||
DomainID: c.domainid,
|
||||
DomainName: c.domainname,
|
||||
}
|
||||
|
||||
provider, err := openstack.NewClient(ao.IdentityEndpoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config := &tls.Config{}
|
||||
|
||||
if c.cacert != "" {
|
||||
caCert, err := ioutil.ReadFile(c.cacert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
caCertPool := x509.NewCertPool()
|
||||
caCertPool.AppendCertsFromPEM(caCert)
|
||||
config.RootCAs = caCertPool
|
||||
}
|
||||
|
||||
if c.insecure {
|
||||
log.Printf("[DEBUG] Insecure mode set")
|
||||
config.InsecureSkipVerify = true
|
||||
}
|
||||
|
||||
if c.cert != "" && c.key != "" {
|
||||
cert, err := tls.LoadX509KeyPair(c.cert, c.key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config.Certificates = []tls.Certificate{cert}
|
||||
config.BuildNameToCertificate()
|
||||
}
|
||||
|
||||
// if OS_DEBUG is set, log the requests and responses
|
||||
var osDebug bool
|
||||
if os.Getenv("OS_DEBUG") != "" {
|
||||
osDebug = true
|
||||
}
|
||||
|
||||
transport := &http.Transport{Proxy: http.ProxyFromEnvironment, TLSClientConfig: config}
|
||||
provider.HTTPClient = http.Client{
|
||||
Transport: &tf_openstack.LogRoundTripper{
|
||||
Rt: transport,
|
||||
OsDebug: osDebug,
|
||||
},
|
||||
}
|
||||
|
||||
err = openstack.Authenticate(provider, ao)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.client, err = openstack.NewObjectStorageV1(provider, gophercloud.EndpointOpts{
|
||||
Region: c.region,
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *SwiftClient) Get() (*Payload, error) {
|
||||
result := objects.Download(c.client, c.path, TFSTATE_NAME, nil)
|
||||
|
||||
// Extract any errors from result
|
||||
_, err := result.Extract()
|
||||
|
||||
// 404 response is to be expected if the object doesn't already exist!
|
||||
if _, ok := err.(gophercloud.ErrDefault404); ok {
|
||||
log.Printf("[DEBUG] Container doesn't exist to download.")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
bytes, err := result.ExtractContent()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hash := md5.Sum(bytes)
|
||||
payload := &Payload{
|
||||
Data: bytes,
|
||||
MD5: hash[:md5.Size],
|
||||
}
|
||||
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
func (c *SwiftClient) Put(data []byte) error {
|
||||
if err := c.ensureContainerExists(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating object %s at path %s", TFSTATE_NAME, c.path)
|
||||
reader := bytes.NewReader(data)
|
||||
createOpts := objects.CreateOpts{
|
||||
Content: reader,
|
||||
}
|
||||
|
||||
if c.expireSecs != 0 {
|
||||
log.Printf("[DEBUG] ExpireSecs = %d", c.expireSecs)
|
||||
createOpts.DeleteAfter = c.expireSecs
|
||||
}
|
||||
|
||||
result := objects.Create(c.client, c.path, TFSTATE_NAME, createOpts)
|
||||
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func (c *SwiftClient) Delete() error {
|
||||
result := objects.Delete(c.client, c.path, TFSTATE_NAME, nil)
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func (c *SwiftClient) ensureContainerExists() error {
|
||||
containerOpts := &containers.CreateOpts{}
|
||||
|
||||
if c.archive {
|
||||
log.Printf("[DEBUG] Creating container %s", c.archivepath)
|
||||
result := containers.Create(c.client, c.archivepath, nil)
|
||||
if result.Err != nil {
|
||||
log.Printf("[DEBUG] Error creating container %s: %s", c.archivepath, result.Err)
|
||||
return result.Err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Enabling Versioning on container %s", c.path)
|
||||
containerOpts.VersionsLocation = c.archivepath
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating container %s", c.path)
|
||||
result := containers.Create(c.client, c.path, containerOpts)
|
||||
if result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func multiEnv(ks []string) string {
|
||||
for _, k := range ks {
|
||||
if v := os.Getenv(k); v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package remote
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSwiftClient_impl(t *testing.T) {
|
||||
var _ Client = new(SwiftClient)
|
||||
}
|
||||
|
||||
func TestSwiftClient(t *testing.T) {
|
||||
os_auth_url := os.Getenv("OS_AUTH_URL")
|
||||
if os_auth_url == "" {
|
||||
t.Skipf("skipping, OS_AUTH_URL and friends must be set")
|
||||
}
|
||||
|
||||
if _, err := http.Get(os_auth_url); err != nil {
|
||||
t.Skipf("skipping, unable to reach %s: %s", os_auth_url, err)
|
||||
}
|
||||
|
||||
client, err := swiftFactory(map[string]string{
|
||||
"path": "swift_test",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("bad: %s", err)
|
||||
}
|
||||
|
||||
testClient(t, client)
|
||||
}
|
49
vendor/github.com/terraform-providers/terraform-provider-openstack/openstack/config.go
generated
vendored
49
vendor/github.com/terraform-providers/terraform-provider-openstack/openstack/config.go
generated
vendored
|
@ -4,6 +4,7 @@ import (
|
|||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
|
@ -24,6 +25,7 @@ type Config struct {
|
|||
IdentityEndpoint string
|
||||
Insecure bool
|
||||
Password string
|
||||
Region string
|
||||
Swauth bool
|
||||
TenantID string
|
||||
TenantName string
|
||||
|
@ -31,10 +33,10 @@ type Config struct {
|
|||
Username string
|
||||
UserID string
|
||||
|
||||
osClient *gophercloud.ProviderClient
|
||||
OsClient *gophercloud.ProviderClient
|
||||
}
|
||||
|
||||
func (c *Config) loadAndValidate() error {
|
||||
func (c *Config) LoadAndValidate() error {
|
||||
validEndpoint := false
|
||||
validEndpoints := []string{
|
||||
"internal", "internalURL",
|
||||
|
@ -130,49 +132,60 @@ func (c *Config) loadAndValidate() error {
|
|||
}
|
||||
}
|
||||
|
||||
c.osClient = client
|
||||
c.OsClient = client
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) determineRegion(region string) string {
|
||||
// If a resource-level region was not specified, and a provider-level region was set,
|
||||
// use the provider-level region.
|
||||
if region == "" && c.Region != "" {
|
||||
region = c.Region
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] OpenStack Region is: %s", region)
|
||||
return region
|
||||
}
|
||||
|
||||
func (c *Config) blockStorageV1Client(region string) (*gophercloud.ServiceClient, error) {
|
||||
return openstack.NewBlockStorageV1(c.osClient, gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
return openstack.NewBlockStorageV1(c.OsClient, gophercloud.EndpointOpts{
|
||||
Region: c.determineRegion(region),
|
||||
Availability: c.getEndpointType(),
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Config) blockStorageV2Client(region string) (*gophercloud.ServiceClient, error) {
|
||||
return openstack.NewBlockStorageV2(c.osClient, gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
return openstack.NewBlockStorageV2(c.OsClient, gophercloud.EndpointOpts{
|
||||
Region: c.determineRegion(region),
|
||||
Availability: c.getEndpointType(),
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Config) computeV2Client(region string) (*gophercloud.ServiceClient, error) {
|
||||
return openstack.NewComputeV2(c.osClient, gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
return openstack.NewComputeV2(c.OsClient, gophercloud.EndpointOpts{
|
||||
Region: c.determineRegion(region),
|
||||
Availability: c.getEndpointType(),
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Config) dnsV2Client(region string) (*gophercloud.ServiceClient, error) {
|
||||
return openstack.NewDNSV2(c.osClient, gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
return openstack.NewDNSV2(c.OsClient, gophercloud.EndpointOpts{
|
||||
Region: c.determineRegion(region),
|
||||
Availability: c.getEndpointType(),
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Config) imageV2Client(region string) (*gophercloud.ServiceClient, error) {
|
||||
return openstack.NewImageServiceV2(c.osClient, gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
return openstack.NewImageServiceV2(c.OsClient, gophercloud.EndpointOpts{
|
||||
Region: c.determineRegion(region),
|
||||
Availability: c.getEndpointType(),
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Config) networkingV2Client(region string) (*gophercloud.ServiceClient, error) {
|
||||
return openstack.NewNetworkV2(c.osClient, gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
return openstack.NewNetworkV2(c.OsClient, gophercloud.EndpointOpts{
|
||||
Region: c.determineRegion(region),
|
||||
Availability: c.getEndpointType(),
|
||||
})
|
||||
}
|
||||
|
@ -180,14 +193,14 @@ func (c *Config) networkingV2Client(region string) (*gophercloud.ServiceClient,
|
|||
func (c *Config) objectStorageV1Client(region string) (*gophercloud.ServiceClient, error) {
|
||||
// If Swift Authentication is being used, return a swauth client.
|
||||
if c.Swauth {
|
||||
return swauth.NewObjectStorageV1(c.osClient, swauth.AuthOpts{
|
||||
return swauth.NewObjectStorageV1(c.OsClient, swauth.AuthOpts{
|
||||
User: c.Username,
|
||||
Key: c.Password,
|
||||
})
|
||||
}
|
||||
|
||||
return openstack.NewObjectStorageV1(c.osClient, gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
return openstack.NewObjectStorageV1(c.OsClient, gophercloud.EndpointOpts{
|
||||
Region: c.determineRegion(region),
|
||||
Availability: c.getEndpointType(),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ func dataSourceImagesImageV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"name": {
|
||||
|
@ -143,7 +143,7 @@ func dataSourceImagesImageV2() *schema.Resource {
|
|||
// dataSourceImagesImageV2Read performs the image lookup.
|
||||
func dataSourceImagesImageV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
imageClient, err := config.imageV2Client(GetRegion(d))
|
||||
imageClient, err := config.imageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack image client: %s", err)
|
||||
}
|
||||
|
|
|
@ -17,6 +17,12 @@ func dataSourceNetworkingNetworkV2() *schema.Resource {
|
|||
Read: dataSourceNetworkingNetworkV2Read,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"network_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
|
@ -29,11 +35,6 @@ func dataSourceNetworkingNetworkV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
|
@ -57,7 +58,7 @@ func dataSourceNetworkingNetworkV2() *schema.Resource {
|
|||
|
||||
func dataSourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
|
||||
listOpts := networks.ListOpts{
|
||||
ID: d.Get("network_id").(string),
|
||||
|
@ -111,7 +112,7 @@ func dataSourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{})
|
|||
d.Set("admin_state_up", strconv.FormatBool(network.AdminStateUp))
|
||||
d.Set("shared", strconv.FormatBool(network.Shared))
|
||||
d.Set("tenant_id", network.TenantID)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
12
vendor/github.com/terraform-providers/terraform-provider-openstack/openstack/provider.go
generated
vendored
12
vendor/github.com/terraform-providers/terraform-provider-openstack/openstack/provider.go
generated
vendored
|
@ -20,6 +20,13 @@ func Provider() terraform.ResourceProvider {
|
|||
Description: descriptions["auth_url"],
|
||||
},
|
||||
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: descriptions["region"],
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
},
|
||||
|
||||
"user_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
|
@ -187,6 +194,8 @@ func init() {
|
|||
descriptions = map[string]string{
|
||||
"auth_url": "The Identity authentication URL.",
|
||||
|
||||
"region": "The OpenStack region to connect to.",
|
||||
|
||||
"user_name": "Username to login with.",
|
||||
|
||||
"user_id": "User ID to login with.",
|
||||
|
@ -231,6 +240,7 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) {
|
|||
IdentityEndpoint: d.Get("auth_url").(string),
|
||||
Insecure: d.Get("insecure").(bool),
|
||||
Password: d.Get("password").(string),
|
||||
Region: d.Get("region").(string),
|
||||
Swauth: d.Get("swauth").(bool),
|
||||
Token: d.Get("token").(string),
|
||||
TenantID: d.Get("tenant_id").(string),
|
||||
|
@ -239,7 +249,7 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) {
|
|||
UserID: d.Get("user_id").(string),
|
||||
}
|
||||
|
||||
if err := config.loadAndValidate(); err != nil {
|
||||
if err := config.LoadAndValidate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@ func resourceBlockStorageVolumeAttachV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"volume_id": &schema.Schema{
|
||||
|
@ -136,7 +136,7 @@ func resourceBlockStorageVolumeAttachV2() *schema.Resource {
|
|||
|
||||
func resourceBlockStorageVolumeAttachV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
client, err := config.blockStorageV2Client(GetRegion(d))
|
||||
client, err := config.blockStorageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ func resourceBlockStorageVolumeAttachV2Create(d *schema.ResourceData, meta inter
|
|||
|
||||
func resourceBlockStorageVolumeAttachV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
client, err := config.blockStorageV2Client(GetRegion(d))
|
||||
client, err := config.blockStorageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ func resourceBlockStorageVolumeAttachV2Read(d *schema.ResourceData, meta interfa
|
|||
|
||||
func resourceBlockStorageVolumeAttachV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
client, err := config.blockStorageV2Client(GetRegion(d))
|
||||
client, err := config.blockStorageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
|
|
@ -31,11 +31,12 @@ func resourceBlockStorageVolumeV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"size": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
|
@ -111,7 +112,7 @@ func resourceBlockStorageVolumeV1() *schema.Resource {
|
|||
|
||||
func resourceBlockStorageVolumeV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ func resourceBlockStorageVolumeV1Create(d *schema.ResourceData, meta interface{}
|
|||
func resourceBlockStorageVolumeV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -185,7 +186,7 @@ func resourceBlockStorageVolumeV1Read(d *schema.ResourceData, meta interface{})
|
|||
d.Set("source_vol_id", v.SourceVolID)
|
||||
d.Set("volume_type", v.VolumeType)
|
||||
d.Set("metadata", v.Metadata)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
attachments := make([]map[string]interface{}, len(v.Attachments))
|
||||
for i, attachment := range v.Attachments {
|
||||
|
@ -202,7 +203,7 @@ func resourceBlockStorageVolumeV1Read(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceBlockStorageVolumeV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -226,7 +227,7 @@ func resourceBlockStorageVolumeV1Update(d *schema.ResourceData, meta interface{}
|
|||
|
||||
func resourceBlockStorageVolumeV1Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV1Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -239,7 +240,7 @@ func resourceBlockStorageVolumeV1Delete(d *schema.ResourceData, meta interface{}
|
|||
// make sure this volume is detached from all instances before deleting
|
||||
if len(v.Attachments) > 0 {
|
||||
log.Printf("[DEBUG] detaching volumes")
|
||||
if computeClient, err := config.computeV2Client(GetRegion(d)); err != nil {
|
||||
if computeClient, err := config.computeV2Client(GetRegion(d, config)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
for _, volumeAttachment := range v.Attachments {
|
||||
|
|
|
@ -31,11 +31,12 @@ func resourceBlockStorageVolumeV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"size": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
|
@ -121,7 +122,7 @@ func resourceBlockStorageVolumeV2() *schema.Resource {
|
|||
|
||||
func resourceBlockStorageVolumeV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -176,7 +177,7 @@ func resourceBlockStorageVolumeV2Create(d *schema.ResourceData, meta interface{}
|
|||
|
||||
func resourceBlockStorageVolumeV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -196,7 +197,7 @@ func resourceBlockStorageVolumeV2Read(d *schema.ResourceData, meta interface{})
|
|||
d.Set("source_vol_id", v.SourceVolID)
|
||||
d.Set("volume_type", v.VolumeType)
|
||||
d.Set("metadata", v.Metadata)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
attachments := make([]map[string]interface{}, len(v.Attachments))
|
||||
for i, attachment := range v.Attachments {
|
||||
|
@ -213,7 +214,7 @@ func resourceBlockStorageVolumeV2Read(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceBlockStorageVolumeV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -237,7 +238,7 @@ func resourceBlockStorageVolumeV2Update(d *schema.ResourceData, meta interface{}
|
|||
|
||||
func resourceBlockStorageVolumeV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d))
|
||||
blockStorageClient, err := config.blockStorageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
}
|
||||
|
@ -250,7 +251,7 @@ func resourceBlockStorageVolumeV2Delete(d *schema.ResourceData, meta interface{}
|
|||
// make sure this volume is detached from all instances before deleting
|
||||
if len(v.Attachments) > 0 {
|
||||
log.Printf("[DEBUG] detaching volumes")
|
||||
if computeClient, err := config.computeV2Client(GetRegion(d)); err != nil {
|
||||
if computeClient, err := config.computeV2Client(GetRegion(d, config)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
for _, volumeAttachment := range v.Attachments {
|
||||
|
|
|
@ -23,11 +23,12 @@ func resourceComputeFloatingIPAssociateV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"floating_ip": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
|
@ -49,7 +50,7 @@ func resourceComputeFloatingIPAssociateV2() *schema.Resource {
|
|||
|
||||
func resourceComputeFloatingIPAssociateV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ func resourceComputeFloatingIPAssociateV2Create(d *schema.ResourceData, meta int
|
|||
|
||||
func resourceComputeFloatingIPAssociateV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -97,7 +98,7 @@ func resourceComputeFloatingIPAssociateV2Read(d *schema.ResourceData, meta inter
|
|||
// Now check and see whether the floating IP still exists.
|
||||
// First try to do this by querying the Network API.
|
||||
networkEnabled := true
|
||||
networkClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
networkEnabled = false
|
||||
}
|
||||
|
@ -146,14 +147,14 @@ func resourceComputeFloatingIPAssociateV2Read(d *schema.ResourceData, meta inter
|
|||
d.Set("floating_ip", floatingIP)
|
||||
d.Set("instance_id", instanceId)
|
||||
d.Set("fixed_ip", fixedIP)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeFloatingIPAssociateV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ func resourceComputeFloatingIPV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"pool": &schema.Schema{
|
||||
|
@ -53,7 +53,7 @@ func resourceComputeFloatingIPV2() *schema.Resource {
|
|||
|
||||
func resourceComputeFloatingIPV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func resourceComputeFloatingIPV2Create(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceComputeFloatingIPV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -90,14 +90,14 @@ func resourceComputeFloatingIPV2Read(d *schema.ResourceData, meta interface{}) e
|
|||
d.Set("instance_id", fip.InstanceID)
|
||||
d.Set("address", fip.IP)
|
||||
d.Set("fixed_ip", fip.FixedIP)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeFloatingIPV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
|
|
@ -42,11 +42,12 @@ func resourceComputeInstanceV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
|
@ -348,7 +349,7 @@ func resourceComputeInstanceV2() *schema.Resource {
|
|||
|
||||
func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -495,7 +496,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
|
|||
// if volumes were specified, attach them after the instance has launched.
|
||||
if v, ok := d.GetOk("volume"); ok {
|
||||
vols := v.(*schema.Set).List()
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d)); err != nil {
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d, config)); err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack block storage client: %s", err)
|
||||
} else {
|
||||
if err := attachVolumesToInstance(computeClient, blockClient, d.Id(), vols); err != nil {
|
||||
|
@ -509,7 +510,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
|
|||
|
||||
func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -606,12 +607,15 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
|
|||
// Set the availability zone
|
||||
d.Set("availability_zone", serverWithAZ.AvailabilityZone)
|
||||
|
||||
// Set the region
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -771,7 +775,7 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
|
|||
oldAttachmentSet := oldAttachments.(*schema.Set).List()
|
||||
|
||||
log.Printf("[DEBUG] Attempting to detach the following volumes: %#v", oldAttachmentSet)
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d)); err != nil {
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d, config)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if err := detachVolumesFromInstance(computeClient, blockClient, d.Id(), oldAttachmentSet); err != nil {
|
||||
|
@ -781,7 +785,7 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
|
|||
|
||||
// for each new attachment, attach the volume
|
||||
newAttachmentSet := newAttachments.(*schema.Set).List()
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d)); err != nil {
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d, config)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if err := attachVolumesToInstance(computeClient, blockClient, d.Id(), newAttachmentSet); err != nil {
|
||||
|
@ -858,7 +862,7 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
|
|||
|
||||
func resourceComputeInstanceV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -869,7 +873,7 @@ func resourceComputeInstanceV2Delete(d *schema.ResourceData, meta interface{}) e
|
|||
volumeList := volumeSet.List()
|
||||
if len(volumeList) > 0 {
|
||||
log.Printf("[DEBUG] Attempting to detach the following volumes: %#v", volumeList)
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d)); err != nil {
|
||||
if blockClient, err := config.blockStorageV1Client(GetRegion(d, config)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if err := detachVolumesFromInstance(computeClient, blockClient, d.Id(), volumeList); err != nil {
|
||||
|
|
|
@ -19,11 +19,12 @@ func resourceComputeKeypairV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
|
@ -45,7 +46,7 @@ func resourceComputeKeypairV2() *schema.Resource {
|
|||
|
||||
func resourceComputeKeypairV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ func resourceComputeKeypairV2Create(d *schema.ResourceData, meta interface{}) er
|
|||
|
||||
func resourceComputeKeypairV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -83,14 +84,14 @@ func resourceComputeKeypairV2Read(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
d.Set("name", kp.Name)
|
||||
d.Set("public_key", kp.PublicKey)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeKeypairV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
|
|
@ -30,11 +30,12 @@ func resourceComputeSecGroupV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
|
@ -99,7 +100,7 @@ func resourceComputeSecGroupV2() *schema.Resource {
|
|||
|
||||
func resourceComputeSecGroupV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -137,7 +138,7 @@ func resourceComputeSecGroupV2Create(d *schema.ResourceData, meta interface{}) e
|
|||
|
||||
func resourceComputeSecGroupV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -157,14 +158,14 @@ func resourceComputeSecGroupV2Read(d *schema.ResourceData, meta interface{}) err
|
|||
log.Printf("[DEBUG] rulesToMap(sg.Rules): %+v", rtm)
|
||||
d.Set("rule", rtm)
|
||||
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeSecGroupV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -219,7 +220,7 @@ func resourceComputeSecGroupV2Update(d *schema.ResourceData, meta interface{}) e
|
|||
|
||||
func resourceComputeSecGroupV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@ func resourceComputeServerGroupV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
ForceNew: true,
|
||||
|
@ -52,7 +53,7 @@ func resourceComputeServerGroupV2() *schema.Resource {
|
|||
|
||||
func resourceComputeServerGroupV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ func resourceComputeServerGroupV2Create(d *schema.ResourceData, meta interface{}
|
|||
|
||||
func resourceComputeServerGroupV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -107,14 +108,14 @@ func resourceComputeServerGroupV2Read(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
d.Set("members", members)
|
||||
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeServerGroupV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ func resourceComputeVolumeAttachV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"instance_id": &schema.Schema{
|
||||
|
@ -58,7 +58,7 @@ func resourceComputeVolumeAttachV2() *schema.Resource {
|
|||
|
||||
func resourceComputeVolumeAttachV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func resourceComputeVolumeAttachV2Create(d *schema.ResourceData, meta interface{
|
|||
|
||||
func resourceComputeVolumeAttachV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
@ -129,14 +129,14 @@ func resourceComputeVolumeAttachV2Read(d *schema.ResourceData, meta interface{})
|
|||
d.Set("instance_id", attachment.ServerID)
|
||||
d.Set("volume_id", attachment.VolumeID)
|
||||
d.Set("device", attachment.Device)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeVolumeAttachV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
computeClient, err := config.computeV2Client(GetRegion(d))
|
||||
computeClient, err := config.computeV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ func resourceDNSRecordSetV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -80,7 +80,7 @@ func resourceDNSRecordSetV2() *schema.Resource {
|
|||
|
||||
func resourceDNSRecordSetV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func resourceDNSRecordSetV2Create(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
func resourceDNSRecordSetV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func resourceDNSRecordSetV2Read(d *schema.ResourceData, meta interface{}) error
|
|||
d.Set("ttl", n.TTL)
|
||||
d.Set("type", n.Type)
|
||||
d.Set("records", n.Records)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
d.Set("zone_id", zoneID)
|
||||
|
||||
return nil
|
||||
|
@ -162,7 +162,7 @@ func resourceDNSRecordSetV2Read(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
func resourceDNSRecordSetV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ func resourceDNSRecordSetV2Update(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
func resourceDNSRecordSetV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ func resourceDNSZoneV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -85,7 +85,7 @@ func resourceDNSZoneV2() *schema.Resource {
|
|||
|
||||
func resourceDNSZoneV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func resourceDNSZoneV2Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceDNSZoneV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
@ -160,14 +160,14 @@ func resourceDNSZoneV2Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("type", n.Type)
|
||||
d.Set("attributes", n.Attributes)
|
||||
d.Set("masters", n.Masters)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceDNSZoneV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ func resourceDNSZoneV2Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceDNSZoneV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d))
|
||||
dnsClient, err := config.dnsV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack DNS client: %s", err)
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ func resourceFWFirewallV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -82,7 +82,7 @@ func resourceFWFirewallV1() *schema.Resource {
|
|||
func resourceFWFirewallV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ func resourceFWFirewallV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[DEBUG] Retrieve information about firewall: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -175,8 +175,8 @@ func resourceFWFirewallV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("policy_id", firewall.PolicyID)
|
||||
d.Set("admin_state_up", firewall.AdminStateUp)
|
||||
d.Set("tenant_id", firewall.TenantID)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("associated_routers", firewall.RouterIDs)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ func resourceFWFirewallV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
func resourceFWFirewallV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ func resourceFWFirewallV1Delete(d *schema.ResourceData, meta interface{}) error
|
|||
log.Printf("[DEBUG] Destroy firewall: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ func resourceFWPolicyV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -71,7 +71,7 @@ func resourceFWPolicyV1() *schema.Resource {
|
|||
|
||||
func resourceFWPolicyV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func resourceFWPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[DEBUG] Retrieve information about firewall policy: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -140,14 +140,14 @@ func resourceFWPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("audited", policy.Audited)
|
||||
d.Set("tenant_id", policy.TenantID)
|
||||
d.Set("rules", policy.Rules)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceFWPolicyV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ func resourceFWPolicyV1Delete(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[DEBUG] Destroy firewall policy: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ func resourceFWRuleV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -86,7 +86,7 @@ func resourceFWRuleV1() *schema.Resource {
|
|||
func resourceFWRuleV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func resourceFWRuleV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[DEBUG] Retrieve information about firewall rule: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -159,14 +159,14 @@ func resourceFWRuleV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("protocol", rule.Protocol)
|
||||
}
|
||||
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceFWRuleV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ func resourceFWRuleV1Delete(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[DEBUG] Destroy firewall rule: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -34,6 +34,13 @@ func resourceImagesImageV2() *schema.Resource {
|
|||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"checksum": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -122,13 +129,6 @@ func resourceImagesImageV2() *schema.Resource {
|
|||
Default: false,
|
||||
},
|
||||
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
},
|
||||
|
||||
"schema": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -169,7 +169,7 @@ func resourceImagesImageV2() *schema.Resource {
|
|||
|
||||
func resourceImagesImageV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
imageClient, err := config.imageV2Client(GetRegion(d))
|
||||
imageClient, err := config.imageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack image client: %s", err)
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ func resourceImagesImageV2Create(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
func resourceImagesImageV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
imageClient, err := config.imageV2Client(GetRegion(d))
|
||||
imageClient, err := config.imageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack image client: %s", err)
|
||||
}
|
||||
|
@ -277,12 +277,14 @@ func resourceImagesImageV2Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("size_bytes", img.SizeBytes)
|
||||
d.Set("tags", img.Tags)
|
||||
d.Set("visibility", img.Visibility)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceImagesImageV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
imageClient, err := config.imageV2Client(GetRegion(d))
|
||||
imageClient, err := config.imageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack image client: %s", err)
|
||||
}
|
||||
|
@ -320,7 +322,7 @@ func resourceImagesImageV2Update(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
func resourceImagesImageV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
imageClient, err := config.imageV2Client(GetRegion(d))
|
||||
imageClient, err := config.imageV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack image client: %s", err)
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ func resourceListenerV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"protocol": &schema.Schema{
|
||||
|
@ -111,7 +111,7 @@ func resourceListenerV2() *schema.Resource {
|
|||
|
||||
func resourceListenerV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func resourceListenerV2Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceListenerV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -191,13 +191,14 @@ func resourceListenerV2Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("connection_limit", listener.ConnLimit)
|
||||
d.Set("sni_container_refs", listener.SniContainerRefs)
|
||||
d.Set("default_tls_container_ref", listener.DefaultTlsContainerRef)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceListenerV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -243,7 +244,7 @@ func resourceListenerV2Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceListenerV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ func resourceLoadBalancerV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"name": &schema.Schema{
|
||||
|
@ -108,7 +108,7 @@ func resourceLoadBalancerV2() *schema.Resource {
|
|||
|
||||
func resourceLoadBalancerV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ func resourceLoadBalancerV2Create(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
func resourceLoadBalancerV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -188,6 +188,7 @@ func resourceLoadBalancerV2Read(d *schema.ResourceData, meta interface{}) error
|
|||
d.Set("admin_state_up", lb.AdminStateUp)
|
||||
d.Set("flavor", lb.Flavor)
|
||||
d.Set("loadbalancer_provider", lb.Provider)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
// Get any security groups on the VIP Port
|
||||
if lb.VipPortID != "" {
|
||||
|
@ -204,7 +205,7 @@ func resourceLoadBalancerV2Read(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
func resourceLoadBalancerV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -241,7 +242,7 @@ func resourceLoadBalancerV2Update(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
func resourceLoadBalancerV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ func resourceLBMemberV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -71,7 +71,7 @@ func resourceLBMemberV1() *schema.Resource {
|
|||
|
||||
func resourceLBMemberV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func resourceLBMemberV1Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBMemberV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -142,14 +142,14 @@ func resourceLBMemberV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("port", m.ProtocolPort)
|
||||
d.Set("weight", m.Weight)
|
||||
d.Set("admin_state_up", m.AdminStateUp)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBMemberV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ func resourceLBMemberV1Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBMemberV1Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ func resourceMemberV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"name": &schema.Schema{
|
||||
|
@ -99,7 +99,7 @@ func resourceMemberV2() *schema.Resource {
|
|||
|
||||
func resourceMemberV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ func resourceMemberV2Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceMemberV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -194,13 +194,14 @@ func resourceMemberV2Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("address", member.Address)
|
||||
d.Set("protocol_port", member.ProtocolPort)
|
||||
d.Set("id", member.ID)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceMemberV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -229,7 +230,7 @@ func resourceMemberV2Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceMemberV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ func resourceLBMonitorV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -88,7 +88,7 @@ func resourceLBMonitorV1() *schema.Resource {
|
|||
|
||||
func resourceLBMonitorV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ func resourceLBMonitorV1Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBMonitorV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -168,14 +168,14 @@ func resourceLBMonitorV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("http_method", m.HTTPMethod)
|
||||
d.Set("expected_codes", m.ExpectedCodes)
|
||||
d.Set("admin_state_up", strconv.FormatBool(m.AdminStateUp))
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBMonitorV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ func resourceLBMonitorV1Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBMonitorV1Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ func resourceMonitorV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"pool_id": &schema.Schema{
|
||||
|
@ -99,7 +99,7 @@ func resourceMonitorV2() *schema.Resource {
|
|||
|
||||
func resourceMonitorV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ func resourceMonitorV2Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceMonitorV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -172,13 +172,14 @@ func resourceMonitorV2Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("expected_codes", monitor.ExpectedCodes)
|
||||
d.Set("admin_state_up", monitor.AdminStateUp)
|
||||
d.Set("name", monitor.Name)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceMonitorV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -222,7 +223,7 @@ func resourceMonitorV2Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceMonitorV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -33,10 +33,10 @@ func resourceLBPoolV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -120,7 +120,7 @@ func resourceLBPoolV1() *schema.Resource {
|
|||
|
||||
func resourceLBPoolV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ func resourceLBPoolV1Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBPoolV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -210,14 +210,14 @@ func resourceLBPoolV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("tenant_id", p.TenantID)
|
||||
d.Set("monitor_ids", p.MonitorIDs)
|
||||
d.Set("member_ids", p.MemberIDs)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBPoolV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ func resourceLBPoolV1Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBPoolV1Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ func resourcePoolV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"tenant_id": &schema.Schema{
|
||||
|
@ -136,7 +136,7 @@ func resourcePoolV2() *schema.Resource {
|
|||
|
||||
func resourcePoolV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ func resourcePoolV2Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourcePoolV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -239,13 +239,14 @@ func resourcePoolV2Read(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("name", pool.Name)
|
||||
d.Set("id", pool.ID)
|
||||
d.Set("persistence", pool.Persistence)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourcePoolV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -277,7 +278,7 @@ func resourcePoolV2Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourcePoolV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ func resourceLBVipV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -110,7 +110,7 @@ func resourceLBVipV1() *schema.Resource {
|
|||
|
||||
func resourceLBVipV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func resourceLBVipV1Create(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBVipV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -200,14 +200,14 @@ func resourceLBVipV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
d.Set("persistence", persistence)
|
||||
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBVipV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ func resourceLBVipV1Update(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
func resourceLBVipV1Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ func resourceNetworkingFloatingIPV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"address": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -73,7 +73,7 @@ func resourceNetworkingFloatingIPV2() *schema.Resource {
|
|||
|
||||
func resourceNetworkFloatingIPV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack network client: %s", err)
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ func resourceNetworkFloatingIPV2Create(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkFloatingIPV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack network client: %s", err)
|
||||
}
|
||||
|
@ -140,14 +140,14 @@ func resourceNetworkFloatingIPV2Read(d *schema.ResourceData, meta interface{}) e
|
|||
d.Set("pool", poolName)
|
||||
d.Set("tenant_id", floatingIP.TenantID)
|
||||
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceNetworkFloatingIPV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack network client: %s", err)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ func resourceNetworkFloatingIPV2Update(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkFloatingIPV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack network client: %s", err)
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ func resourceNetworkFloatingIPV2Delete(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func getNetworkID(d *schema.ResourceData, meta interface{}, networkName string) (string, error) {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Error creating OpenStack network client: %s", err)
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ func getNetworkID(d *schema.ResourceData, meta interface{}, networkName string)
|
|||
|
||||
func getNetworkName(d *schema.ResourceData, meta interface{}, networkID string) (string, error) {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Error creating OpenStack network client: %s", err)
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ func resourceNetworkingNetworkV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -94,7 +94,7 @@ func resourceNetworkingNetworkV2() *schema.Resource {
|
|||
|
||||
func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -182,14 +182,14 @@ func resourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{}) e
|
|||
d.Set("admin_state_up", strconv.FormatBool(n.AdminStateUp))
|
||||
d.Set("shared", strconv.FormatBool(n.Shared))
|
||||
d.Set("tenant_id", n.TenantID)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceNetworkingNetworkV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ func resourceNetworkingNetworkV2Update(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkingNetworkV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ func resourceNetworkingPortV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -137,7 +137,7 @@ func resourceNetworkingPortV2() *schema.Resource {
|
|||
|
||||
func resourceNetworkingPortV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ func resourceNetworkingPortV2Create(d *schema.ResourceData, meta interface{}) er
|
|||
|
||||
func resourceNetworkingPortV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -224,14 +224,14 @@ func resourceNetworkingPortV2Read(d *schema.ResourceData, meta interface{}) erro
|
|||
}
|
||||
d.Set("allowed_address_pairs", pairs)
|
||||
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceNetworkingPortV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ func resourceNetworkingPortV2Update(d *schema.ResourceData, meta interface{}) er
|
|||
|
||||
func resourceNetworkingPortV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ func resourceNetworkingRouterInterfaceV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"router_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -52,7 +52,7 @@ func resourceNetworkingRouterInterfaceV2() *schema.Resource {
|
|||
|
||||
func resourceNetworkingRouterInterfaceV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func resourceNetworkingRouterInterfaceV2Create(d *schema.ResourceData, meta inte
|
|||
|
||||
func resourceNetworkingRouterInterfaceV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -106,12 +106,14 @@ func resourceNetworkingRouterInterfaceV2Read(d *schema.ResourceData, meta interf
|
|||
|
||||
log.Printf("[DEBUG] Retrieved Router Interface %s: %+v", d.Id(), n)
|
||||
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceNetworkingRouterInterfaceV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ func resourceNetworkingRouterRouteV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"router_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -52,7 +52,7 @@ func resourceNetworkingRouterRouteV2Create(d *schema.ResourceData, meta interfac
|
|||
var nextHop string = d.Get("next_hop").(string)
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ func resourceNetworkingRouterRouteV2Read(d *schema.ResourceData, meta interface{
|
|||
routerId := d.Get("router_id").(string)
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -142,6 +142,8 @@ func resourceNetworkingRouterRouteV2Read(d *schema.ResourceData, meta interface{
|
|||
}
|
||||
}
|
||||
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -153,7 +155,7 @@ func resourceNetworkingRouterRouteV2Delete(d *schema.ResourceData, meta interfac
|
|||
|
||||
config := meta.(*Config)
|
||||
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ func resourceNetworkingRouterV2() *schema.Resource {
|
|||
|
||||
func resourceNetworkingRouterV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func resourceNetworkingRouterV2Create(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkingRouterV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -149,6 +149,7 @@ func resourceNetworkingRouterV2Read(d *schema.ResourceData, meta interface{}) er
|
|||
d.Set("distributed", n.Distributed)
|
||||
d.Set("tenant_id", n.TenantID)
|
||||
d.Set("external_gateway", n.GatewayInfo.NetworkID)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -159,7 +160,7 @@ func resourceNetworkingRouterV2Update(d *schema.ResourceData, meta interface{})
|
|||
defer osMutexKV.Unlock(routerId)
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -194,7 +195,7 @@ func resourceNetworkingRouterV2Update(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkingRouterV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ func resourceNetworkingSecGroupRuleV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"direction": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -95,7 +95,7 @@ func resourceNetworkingSecGroupRuleV2() *schema.Resource {
|
|||
func resourceNetworkingSecGroupRuleV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ func resourceNetworkingSecGroupRuleV2Read(d *schema.ResourceData, meta interface
|
|||
log.Printf("[DEBUG] Retrieve information about security group rule: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ func resourceNetworkingSecGroupRuleV2Read(d *schema.ResourceData, meta interface
|
|||
d.Set("remote_ip_prefix", security_group_rule.RemoteIPPrefix)
|
||||
d.Set("security_group_id", security_group_rule.SecGroupID)
|
||||
d.Set("tenant_id", security_group_rule.TenantID)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ func resourceNetworkingSecGroupRuleV2Delete(d *schema.ResourceData, meta interfa
|
|||
log.Printf("[DEBUG] Destroy security group rule: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ func resourceNetworkingSecGroupV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -61,7 +61,7 @@ func resourceNetworkingSecGroupV2() *schema.Resource {
|
|||
func resourceNetworkingSecGroupV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func resourceNetworkingSecGroupV2Read(d *schema.ResourceData, meta interface{})
|
|||
log.Printf("[DEBUG] Retrieve information about security group: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -115,14 +115,14 @@ func resourceNetworkingSecGroupV2Read(d *schema.ResourceData, meta interface{})
|
|||
d.Set("description", security_group.Description)
|
||||
d.Set("tenant_id", security_group.TenantID)
|
||||
d.Set("name", security_group.Name)
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceNetworkingSecGroupV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ func resourceNetworkingSecGroupV2Delete(d *schema.ResourceData, meta interface{}
|
|||
log.Printf("[DEBUG] Destroy security group: %s", d.Id())
|
||||
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ func resourceNetworkingSubnetV2() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"network_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -130,7 +130,7 @@ func resourceNetworkingSubnetV2() *schema.Resource {
|
|||
|
||||
func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkingSubnetV2Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -231,14 +231,14 @@ func resourceNetworkingSubnetV2Read(d *schema.ResourceData, meta interface{}) er
|
|||
}
|
||||
d.Set("allocation_pools", allocationPools)
|
||||
|
||||
d.Set("region", GetRegion(d))
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceNetworkingSubnetV2Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d))
|
||||
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ func resourceObjectStorageContainerV1() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""),
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -63,7 +63,7 @@ func resourceObjectStorageContainerV1() *schema.Resource {
|
|||
|
||||
func resourceObjectStorageContainerV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
objectStorageClient, err := config.objectStorageV1Client(GetRegion(d))
|
||||
objectStorageClient, err := config.objectStorageV1Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack object storage client: %s", err)
|
||||
}
|
||||
|
@ -93,12 +93,15 @@ func resourceObjectStorageContainerV1Create(d *schema.ResourceData, meta interfa
|
|||
}
|
||||
|
||||
func resourceObjectStorageContainerV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
d.Set("region", GetRegion(d, config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceObjectStorageContainerV1Update(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
objectStorageClient, err := config.objectStorageV1Client(GetRegion(d))
|
||||
objectStorageClient, err := config.objectStorageV1Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack object storage client: %s", err)
|
||||
}
|
||||
|
@ -125,7 +128,7 @@ func resourceObjectStorageContainerV1Update(d *schema.ResourceData, meta interfa
|
|||
|
||||
func resourceObjectStorageContainerV1Delete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
objectStorageClient, err := config.objectStorageV1Client(GetRegion(d))
|
||||
objectStorageClient, err := config.objectStorageV1Client(GetRegion(d, config))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating OpenStack object storage client: %s", err)
|
||||
}
|
||||
|
|
13
vendor/github.com/terraform-providers/terraform-provider-openstack/openstack/util.go
generated
vendored
13
vendor/github.com/terraform-providers/terraform-provider-openstack/openstack/util.go
generated
vendored
|
@ -3,7 +3,6 @@ package openstack
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
|
@ -36,17 +35,15 @@ func CheckDeleted(d *schema.ResourceData, err error, msg string) error {
|
|||
return fmt.Errorf("%s: %s", msg, err)
|
||||
}
|
||||
|
||||
// GetRegion returns the region from either d.Get("region") or OS_REGION_NAME
|
||||
func GetRegion(d *schema.ResourceData) string {
|
||||
// GetRegion returns the region that was specified in the resource. If a
|
||||
// region was not set, the provider-level region is checked. The provider-level
|
||||
// region can either be set by the region argument or by OS_REGION_NAME.
|
||||
func GetRegion(d *schema.ResourceData, config *Config) string {
|
||||
if v, ok := d.GetOk("region"); ok {
|
||||
return v.(string)
|
||||
}
|
||||
|
||||
if v := os.Getenv("OS_REGION_NAME"); v != "" {
|
||||
return v
|
||||
}
|
||||
|
||||
return ""
|
||||
return config.Region
|
||||
}
|
||||
|
||||
// AddValueSpecs expands the 'value_specs' object and removes 'value_specs'
|
||||
|
|
|
@ -1685,10 +1685,10 @@
|
|||
"revisionTime": "2017-06-12T09:08:25Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "+LOuwysQ27JLjJNWSPKF/yXTMEc=",
|
||||
"checksumSHA1": "7WDq0VsOJmABPUCEvfuerEp7mBg=",
|
||||
"path": "github.com/terraform-providers/terraform-provider-openstack/openstack",
|
||||
"revision": "6278902610d3077274146559ef10fbb5455e5129",
|
||||
"revisionTime": "2017-06-09T18:33:54Z"
|
||||
"revision": "4080a521c6ea4872f38bae658ac17b774eefcfe1",
|
||||
"revisionTime": "2017-06-13T14:56:00Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "iHiMTBffQvWYlOLu3130JXuQpgQ=",
|
||||
|
|
|
@ -12,6 +12,8 @@ description: |-
|
|||
|
||||
Stores the state as an artifact in [Swift](http://docs.openstack.org/developer/swift/).
|
||||
|
||||
~> Warning! It is highly recommended that you enable [Object Versioning](https://docs.openstack.org/developer/swift/overview_object_versioning.html) by setting the [`expire_after`](https://www.terraform.io/docs/backends/types/swift.html#archive_path) configuration. This allows for state recovery in the case of accidental deletions and human error.
|
||||
|
||||
## Example Configuration
|
||||
|
||||
```hcl
|
||||
|
@ -21,8 +23,11 @@ terraform {
|
|||
}
|
||||
}
|
||||
```
|
||||
This will create a container called `terraform-state` and an object within that container called `tfstate.tf`.
|
||||
|
||||
Note that for the access credentials we recommend using a
|
||||
-> Note: Currently, the object name is statically defined as 'tfstate.tf'. Therefore Swift [pseudo-folders](https://docs.openstack.org/user-guide/cli-swift-pseudo-hierarchical-folders-directories.html) are not currently supported.
|
||||
|
||||
For the access credentials we recommend using a
|
||||
[partial configuration](/docs/backends/config.html).
|
||||
|
||||
## Example Referencing
|
||||
|
@ -43,7 +48,12 @@ The following configuration options are supported:
|
|||
* `auth_url` - (Required) The Identity authentication URL. If omitted, the
|
||||
`OS_AUTH_URL` environment variable is used.
|
||||
|
||||
* `path` - (Required) The path where to store `terraform.tfstate`.
|
||||
* `container` - (Required) The name of the container to create for storing
|
||||
the Terraform state file.
|
||||
|
||||
* `path` - (Optional) DEPRECATED: Use `container` instead.
|
||||
The name of the container to create in order to store the state file.
|
||||
|
||||
* `user_name` - (Optional) The Username to login with. If omitted, the
|
||||
`OS_USERNAME` environment variable is used.
|
||||
|
||||
|
@ -68,7 +78,7 @@ The following configuration options are supported:
|
|||
`OS_PROJECT_NAME` environment variable are used.
|
||||
|
||||
* `domain_id` - (Optional) The ID of the Domain to scope to (Identity v3). If
|
||||
If omitted, the following environment variables are checked (in this order):
|
||||
omitted, the following environment variables are checked (in this order):
|
||||
`OS_USER_DOMAIN_ID`, `OS_PROJECT_DOMAIN_ID`, `OS_DOMAIN_ID`.
|
||||
|
||||
* `domain_name` - (Optional) The Name of the Domain to scope to (Identity v3).
|
||||
|
@ -82,14 +92,18 @@ The following configuration options are supported:
|
|||
* `cacert_file` - (Optional) Specify a custom CA certificate when communicating
|
||||
over SSL. If omitted, the `OS_CACERT` environment variable is used.
|
||||
|
||||
* `cert` - (Optional) Specify client certificate file for SSL client
|
||||
authentication. If omitted the `OS_CERT` environment variable is used.
|
||||
* `cert` - (Optional) Specify client certificate file for SSL client authentication.
|
||||
If omitted the `OS_CERT` environment variable is used.
|
||||
|
||||
* `key` - (Optional) Specify client private key file for SSL client
|
||||
authentication. If omitted the `OS_KEY` environment variable is used.
|
||||
* `key` - (Optional) Specify client private key file for SSL client authentication.
|
||||
If omitted the `OS_KEY` environment variable is used.
|
||||
|
||||
* `archive_path` - (Optional) The path to store archived copied of `terraform.tfstate`.
|
||||
If specified, Swift object versioning is enabled on the container created at `path`.
|
||||
* `archive_container` - (Optional) The container to create to store archived copies
|
||||
of the Terraform state file. If specified, Swift [object versioning](https://docs.openstack.org/developer/swift/overview_object_versioning.html) is enabled on the container created at `container`.
|
||||
|
||||
* `archive_path` - (Optional) DEPRECATED: Use `archive_container` instead.
|
||||
The path to store archived copied of `terraform.tfstate`. If specified,
|
||||
Swift [object versioning](https://docs.openstack.org/developer/swift/overview_object_versioning.html) is enabled on the container created at `path`.
|
||||
|
||||
* `expire_after` - (Optional) How long should the `terraform.tfstate` created at `path`
|
||||
be retained for? Supported durations: `m` - Minutes, `h` - Hours, `d` - Days.
|
||||
|
|
Loading…
Reference in New Issue