Fix general comments by @phinze
This commit is contained in:
parent
f011462e30
commit
2e37784065
|
@ -111,7 +111,7 @@ func resourceBlockStorageVolumeV1Create(d *schema.ResourceData, meta interface{}
|
||||||
Metadata: resourceContainerMetadataV2(d),
|
Metadata: resourceContainerMetadataV2(d),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting volume creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
v, err := volumes.Create(blockStorageClient, createOpts).Extract()
|
v, err := volumes.Create(blockStorageClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack volume: %s", err)
|
return fmt.Errorf("Error creating OpenStack volume: %s", err)
|
||||||
|
@ -156,48 +156,15 @@ func resourceBlockStorageVolumeV1Read(d *schema.ResourceData, meta interface{})
|
||||||
return CheckDeleted(d, err, "volume")
|
return CheckDeleted(d, err, "volume")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("\n\ngot volume: %+v\n\n", v)
|
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived volume %s: %+v", d.Id(), v)
|
log.Printf("[DEBUG] Retreived volume %s: %+v", d.Id(), v)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("size", v.Size)
|
d.Set("size", v.Size)
|
||||||
|
|
||||||
if t, exists := d.GetOk("description"); exists && t != "" {
|
|
||||||
d.Set("description", v.Description)
|
d.Set("description", v.Description)
|
||||||
} else {
|
|
||||||
d.Set("description", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
|
||||||
d.Set("name", v.Name)
|
d.Set("name", v.Name)
|
||||||
} else {
|
|
||||||
d.Set("name", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("snapshot_id"); exists && t != "" {
|
|
||||||
d.Set("snapshot_id", v.SnapshotID)
|
d.Set("snapshot_id", v.SnapshotID)
|
||||||
} else {
|
|
||||||
d.Set("snapshot_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("source_vol_id"); exists && t != "" {
|
|
||||||
d.Set("source_vol_id", v.SourceVolID)
|
d.Set("source_vol_id", v.SourceVolID)
|
||||||
} else {
|
|
||||||
d.Set("source_vol_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("volume_type"); exists && t != "" {
|
|
||||||
d.Set("volume_type", v.VolumeType)
|
d.Set("volume_type", v.VolumeType)
|
||||||
} else {
|
|
||||||
d.Set("volume_type", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("metadata"); exists && t != "" {
|
|
||||||
d.Set("metadata", v.Metadata)
|
d.Set("metadata", v.Metadata)
|
||||||
} else {
|
|
||||||
d.Set("metadata", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(v.Attachments) > 0 {
|
if len(v.Attachments) > 0 {
|
||||||
attachments := make([]map[string]interface{}, len(v.Attachments))
|
attachments := make([]map[string]interface{}, len(v.Attachments))
|
||||||
|
|
|
@ -30,12 +30,6 @@ func resourceComputeFloatingIPV2() *schema.Resource {
|
||||||
DefaultFunc: envDefaultFunc("OS_POOL_NAME"),
|
DefaultFunc: envDefaultFunc("OS_POOL_NAME"),
|
||||||
},
|
},
|
||||||
|
|
||||||
// exported
|
|
||||||
"id": &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
"address": &schema.Schema{
|
"address": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
@ -64,6 +58,7 @@ func resourceComputeFloatingIPV2Create(d *schema.ResourceData, meta interface{})
|
||||||
createOpts := &floatingip.CreateOpts{
|
createOpts := &floatingip.CreateOpts{
|
||||||
Pool: d.Get("pool").(string),
|
Pool: d.Get("pool").(string),
|
||||||
}
|
}
|
||||||
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
newFip, err := floatingip.Create(computeClient, createOpts).Extract()
|
newFip, err := floatingip.Create(computeClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating Floating IP: %s", err)
|
return fmt.Errorf("Error creating Floating IP: %s", err)
|
||||||
|
@ -88,8 +83,6 @@ func resourceComputeFloatingIPV2Read(d *schema.ResourceData, meta interface{}) e
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retrieved Floating IP %s: %+v", d.Id(), fip)
|
log.Printf("[DEBUG] Retrieved Floating IP %s: %+v", d.Id(), fip)
|
||||||
|
|
||||||
d.Set("id", d.Id())
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("pool", fip.Pool)
|
d.Set("pool", fip.Pool)
|
||||||
d.Set("instance_id", fip.InstanceID)
|
d.Set("instance_id", fip.InstanceID)
|
||||||
d.Set("address", fip.IP)
|
d.Set("address", fip.IP)
|
||||||
|
|
|
@ -241,7 +241,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting instance creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
server, err := servers.Create(computeClient, createOpts).Extract()
|
server, err := servers.Create(computeClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack server: %s", err)
|
return fmt.Errorf("Error creating OpenStack server: %s", err)
|
||||||
|
@ -320,7 +320,6 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived Server %s: %+v", d.Id(), server)
|
log.Printf("[DEBUG] Retreived Server %s: %+v", d.Id(), server)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("name", server.Name)
|
d.Set("name", server.Name)
|
||||||
d.Set("access_ip_v4", server.AccessIPv4)
|
d.Set("access_ip_v4", server.AccessIPv4)
|
||||||
d.Set("access_ip_v6", server.AccessIPv6)
|
d.Set("access_ip_v6", server.AccessIPv6)
|
||||||
|
@ -360,7 +359,7 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
|
||||||
publicAddresses := publicAddressesRaw.([]interface{})
|
publicAddresses := publicAddressesRaw.([]interface{})
|
||||||
for _, paRaw := range publicAddresses {
|
for _, paRaw := range publicAddresses {
|
||||||
pa := paRaw.(map[string]interface{})
|
pa := paRaw.(map[string]interface{})
|
||||||
if pa["version"].(float64) == 4 {
|
if pa["version"].(float64) == 6 {
|
||||||
hostv6 = fmt.Sprintf("[%s]", pa["addr"].(string))
|
hostv6 = fmt.Sprintf("[%s]", pa["addr"].(string))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -594,6 +593,7 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
|
||||||
resizeOpts := &servers.ResizeOpts{
|
resizeOpts := &servers.ResizeOpts{
|
||||||
FlavorRef: flavorId,
|
FlavorRef: flavorId,
|
||||||
}
|
}
|
||||||
|
log.Printf("[DEBUG] Resize configuration: %#v", resizeOpts)
|
||||||
err = servers.Resize(computeClient, d.Id(), resizeOpts).ExtractErr()
|
err = servers.Resize(computeClient, d.Id(), resizeOpts).ExtractErr()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error resizing OpenStack server: %s", err)
|
return fmt.Errorf("Error resizing OpenStack server: %s", err)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package openstack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs"
|
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs"
|
||||||
|
@ -46,6 +47,7 @@ func resourceComputeKeypairV2Create(d *schema.ResourceData, meta interface{}) er
|
||||||
PublicKey: d.Get("public_key").(string),
|
PublicKey: d.Get("public_key").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
kp, err := keypairs.Create(computeClient, createOpts).Extract()
|
kp, err := keypairs.Create(computeClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack keypair: %s", err)
|
return fmt.Errorf("Error creating OpenStack keypair: %s", err)
|
||||||
|
@ -68,7 +70,6 @@ func resourceComputeKeypairV2Read(d *schema.ResourceData, meta interface{}) erro
|
||||||
return CheckDeleted(d, err, "keypair")
|
return CheckDeleted(d, err, "keypair")
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("name", kp.Name)
|
d.Set("name", kp.Name)
|
||||||
d.Set("public_key", kp.PublicKey)
|
d.Set("public_key", kp.PublicKey)
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ func resourceComputeSecGroupV2Create(d *schema.ResourceData, meta interface{}) e
|
||||||
Description: d.Get("description").(string),
|
Description: d.Get("description").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
sg, err := secgroups.Create(computeClient, createOpts).Extract()
|
sg, err := secgroups.Create(computeClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack security group: %s", err)
|
return fmt.Errorf("Error creating OpenStack security group: %s", err)
|
||||||
|
@ -124,7 +125,6 @@ func resourceComputeSecGroupV2Read(d *schema.ResourceData, meta interface{}) err
|
||||||
return CheckDeleted(d, err, "security group")
|
return CheckDeleted(d, err, "security group")
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("name", sg.Name)
|
d.Set("name", sg.Name)
|
||||||
d.Set("description", sg.Description)
|
d.Set("description", sg.Description)
|
||||||
rtm := rulesToMap(sg.Rules)
|
rtm := rulesToMap(sg.Rules)
|
||||||
|
|
|
@ -109,35 +109,11 @@ func resourceFWFirewallV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||||
return CheckDeleted(d, err, "LB pool")
|
return CheckDeleted(d, err, "LB pool")
|
||||||
}
|
}
|
||||||
|
|
||||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
|
||||||
d.Set("name", firewall.Name)
|
d.Set("name", firewall.Name)
|
||||||
} else {
|
|
||||||
d.Set("name", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("description"); exists && t != "" {
|
|
||||||
d.Set("description", firewall.Description)
|
d.Set("description", firewall.Description)
|
||||||
} else {
|
|
||||||
d.Set("description", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("policy_id"); exists && t != "" {
|
|
||||||
d.Set("policy_id", firewall.PolicyID)
|
d.Set("policy_id", firewall.PolicyID)
|
||||||
} else {
|
|
||||||
d.Set("policy_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("admin_state_up"); exists && t != "" {
|
|
||||||
d.Set("admin_state_up", firewall.AdminStateUp)
|
d.Set("admin_state_up", firewall.AdminStateUp)
|
||||||
} else {
|
|
||||||
d.Set("admin_state_up", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("tenant_id"); exists && t != "" {
|
|
||||||
d.Set("tenant_id", firewall.TenantID)
|
d.Set("tenant_id", firewall.TenantID)
|
||||||
} else {
|
|
||||||
d.Set("tenant_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ func resourceFWPolicyV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Firewall policy craeted: %#v", policy)
|
log.Printf("[DEBUG] Firewall policy created: %#v", policy)
|
||||||
|
|
||||||
d.SetId(policy.ID)
|
d.SetId(policy.ID)
|
||||||
|
|
||||||
|
@ -119,36 +119,11 @@ func resourceFWPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||||
return CheckDeleted(d, err, "LB pool")
|
return CheckDeleted(d, err, "LB pool")
|
||||||
}
|
}
|
||||||
|
|
||||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
|
||||||
d.Set("name", policy.Name)
|
d.Set("name", policy.Name)
|
||||||
} else {
|
|
||||||
d.Set("name", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("description"); exists && t != "" {
|
|
||||||
d.Set("description", policy.Description)
|
d.Set("description", policy.Description)
|
||||||
} else {
|
|
||||||
d.Set("description", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("shared"); exists && t != "" {
|
|
||||||
d.Set("shared", policy.Shared)
|
d.Set("shared", policy.Shared)
|
||||||
} else {
|
|
||||||
d.Set("shared", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("audited"); exists && t != "" {
|
|
||||||
d.Set("audited", policy.Audited)
|
d.Set("audited", policy.Audited)
|
||||||
} else {
|
|
||||||
d.Set("audited", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("tenant_id"); exists && t != "" {
|
|
||||||
d.Set("tenant_id", policy.TenantID)
|
d.Set("tenant_id", policy.TenantID)
|
||||||
} else {
|
|
||||||
d.Set("tenant_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,53 +131,14 @@ func resourceFWRuleV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||||
d.Set("protocol", rule.Protocol)
|
d.Set("protocol", rule.Protocol)
|
||||||
d.Set("action", rule.Action)
|
d.Set("action", rule.Action)
|
||||||
|
|
||||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
|
||||||
d.Set("name", rule.Name)
|
d.Set("name", rule.Name)
|
||||||
} else {
|
|
||||||
d.Set("name", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("description"); exists && t != "" {
|
|
||||||
d.Set("description", rule.Description)
|
d.Set("description", rule.Description)
|
||||||
} else {
|
|
||||||
d.Set("description", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("ip_version"); exists && t != "" {
|
|
||||||
d.Set("ip_version", rule.IPVersion)
|
d.Set("ip_version", rule.IPVersion)
|
||||||
} else {
|
|
||||||
d.Set("ip_version", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("source_ip_address"); exists && t != "" {
|
|
||||||
d.Set("source_ip_address", rule.SourceIPAddress)
|
d.Set("source_ip_address", rule.SourceIPAddress)
|
||||||
} else {
|
|
||||||
d.Set("source_ip_address", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("destination_ip_address"); exists && t != "" {
|
|
||||||
d.Set("destination_ip_address", rule.DestinationIPAddress)
|
d.Set("destination_ip_address", rule.DestinationIPAddress)
|
||||||
} else {
|
|
||||||
d.Set("destination_ip_address", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("source_port"); exists && t != "" {
|
|
||||||
d.Set("source_port", rule.SourcePort)
|
d.Set("source_port", rule.SourcePort)
|
||||||
} else {
|
|
||||||
d.Set("source_port", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("destination_port"); exists && t != "" {
|
|
||||||
d.Set("destination_port", rule.DestinationPort)
|
d.Set("destination_port", rule.DestinationPort)
|
||||||
} else {
|
|
||||||
d.Set("destination_port", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("enabled"); exists && t != "" {
|
|
||||||
d.Set("enabled", rule.Enabled)
|
d.Set("enabled", rule.Enabled)
|
||||||
} else {
|
|
||||||
d.Set("enabled", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ func resourceLBMonitorV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||||
createOpts.AdminStateUp = &asu
|
createOpts.AdminStateUp = &asu
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting lb monitor creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
m, err := monitors.Create(networkingClient, createOpts).Extract()
|
m, err := monitors.Create(networkingClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack LB Monitor: %s", err)
|
return fmt.Errorf("Error creating OpenStack LB Monitor: %s", err)
|
||||||
|
@ -125,41 +125,15 @@ func resourceLBMonitorV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived OpenStack LB Monitor %s: %+v", d.Id(), m)
|
log.Printf("[DEBUG] Retreived OpenStack LB Monitor %s: %+v", d.Id(), m)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("type", m.Type)
|
d.Set("type", m.Type)
|
||||||
d.Set("delay", m.Delay)
|
d.Set("delay", m.Delay)
|
||||||
d.Set("timeout", m.Timeout)
|
d.Set("timeout", m.Timeout)
|
||||||
d.Set("max_retries", m.MaxRetries)
|
d.Set("max_retries", m.MaxRetries)
|
||||||
|
|
||||||
if t, exists := d.GetOk("tenant_id"); exists && t != "" {
|
|
||||||
d.Set("tenant_id", m.TenantID)
|
d.Set("tenant_id", m.TenantID)
|
||||||
} else {
|
|
||||||
d.Set("tenant_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("url_path"); exists && t != "" {
|
|
||||||
d.Set("url_path", m.URLPath)
|
d.Set("url_path", m.URLPath)
|
||||||
} else {
|
|
||||||
d.Set("url_path", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("http_method"); exists && t != "" {
|
|
||||||
d.Set("http_method", m.HTTPMethod)
|
d.Set("http_method", m.HTTPMethod)
|
||||||
} else {
|
|
||||||
d.Set("http_method", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("expected_codes"); exists && t != "" {
|
|
||||||
d.Set("expected_codes", m.ExpectedCodes)
|
d.Set("expected_codes", m.ExpectedCodes)
|
||||||
} else {
|
|
||||||
d.Set("expected_codes", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("admin_state_up"); exists && t != "" {
|
|
||||||
d.Set("admin_state_up", strconv.FormatBool(m.AdminStateUp))
|
d.Set("admin_state_up", strconv.FormatBool(m.AdminStateUp))
|
||||||
} else {
|
|
||||||
d.Set("admin_state_up", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ func resourceLBPoolV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||||
TenantID: d.Get("tenant_id").(string),
|
TenantID: d.Get("tenant_id").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting lb pool creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
p, err := pools.Create(networkingClient, createOpts).Extract()
|
p, err := pools.Create(networkingClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack LB pool: %s", err)
|
return fmt.Errorf("Error creating OpenStack LB pool: %s", err)
|
||||||
|
@ -159,18 +159,11 @@ func resourceLBPoolV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived OpenStack LB Pool %s: %+v", d.Id(), p)
|
log.Printf("[DEBUG] Retreived OpenStack LB Pool %s: %+v", d.Id(), p)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("name", p.Name)
|
d.Set("name", p.Name)
|
||||||
d.Set("protocol", p.Protocol)
|
d.Set("protocol", p.Protocol)
|
||||||
d.Set("subnet_id", p.SubnetID)
|
d.Set("subnet_id", p.SubnetID)
|
||||||
d.Set("lb_method", p.LBMethod)
|
d.Set("lb_method", p.LBMethod)
|
||||||
|
|
||||||
if t, exists := d.GetOk("tenant_id"); exists && t != "" {
|
|
||||||
d.Set("tenant_id", p.TenantID)
|
d.Set("tenant_id", p.TenantID)
|
||||||
} else {
|
|
||||||
d.Set("tenant_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Set("monitor_ids", p.MonitorIDs)
|
d.Set("monitor_ids", p.MonitorIDs)
|
||||||
d.Set("member_ids", p.MemberIDs)
|
d.Set("member_ids", p.MemberIDs)
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ func resourceLBVipV1Create(d *schema.ResourceData, meta interface{}) error {
|
||||||
createOpts.AdminStateUp = &asu
|
createOpts.AdminStateUp = &asu
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting lb vip creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
p, err := vips.Create(networkingClient, createOpts).Extract()
|
p, err := vips.Create(networkingClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack LB VIP: %s", err)
|
return fmt.Errorf("Error creating OpenStack LB VIP: %s", err)
|
||||||
|
@ -138,7 +138,6 @@ func resourceLBVipV1Read(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived OpenStack LB VIP %s: %+v", d.Id(), p)
|
log.Printf("[DEBUG] Retreived OpenStack LB VIP %s: %+v", d.Id(), p)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("name", p.Name)
|
d.Set("name", p.Name)
|
||||||
d.Set("subnet_id", p.SubnetID)
|
d.Set("subnet_id", p.SubnetID)
|
||||||
d.Set("protocol", p.Protocol)
|
d.Set("protocol", p.Protocol)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package openstack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
|
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
|
||||||
|
@ -49,9 +50,11 @@ func resourceNetworkFloatingIPV2Create(d *schema.ResourceData, meta interface{})
|
||||||
if len(poolID) == 0 {
|
if len(poolID) == 0 {
|
||||||
return fmt.Errorf("No network found with name: %s", d.Get("pool").(string))
|
return fmt.Errorf("No network found with name: %s", d.Get("pool").(string))
|
||||||
}
|
}
|
||||||
floatingIP, err := floatingips.Create(networkClient, floatingips.CreateOpts{
|
createOpts := floatingips.CreateOpts{
|
||||||
FloatingNetworkID: poolID,
|
FloatingNetworkID: poolID,
|
||||||
}).Extract()
|
}
|
||||||
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
|
floatingIP, err := floatingips.Create(networkClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error allocating floating IP: %s", err)
|
return fmt.Errorf("Error allocating floating IP: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +76,6 @@ func resourceNetworkFloatingIPV2Read(d *schema.ResourceData, meta interface{}) e
|
||||||
return CheckDeleted(d, err, "floating IP")
|
return CheckDeleted(d, err, "floating IP")
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("address", floatingIP.FloatingIP)
|
d.Set("address", floatingIP.FloatingIP)
|
||||||
poolName, err := getNetworkName(d, meta, floatingIP.FloatingNetworkID)
|
poolName, err := getNetworkName(d, meta, floatingIP.FloatingNetworkID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -77,7 +77,7 @@ func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{})
|
||||||
createOpts.Shared = &shared
|
createOpts.Shared = &shared
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting network creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
n, err := networks.Create(networkingClient, createOpts).Extract()
|
n, err := networks.Create(networkingClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack Neutron network: %s", err)
|
return fmt.Errorf("Error creating OpenStack Neutron network: %s", err)
|
||||||
|
@ -103,31 +103,10 @@ func resourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{}) e
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived Network %s: %+v", d.Id(), n)
|
log.Printf("[DEBUG] Retreived Network %s: %+v", d.Id(), n)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
|
||||||
d.Set("name", n.Name)
|
d.Set("name", n.Name)
|
||||||
} else {
|
|
||||||
d.Set("name", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("admin_state_up"); exists && t != "" {
|
|
||||||
d.Set("admin_state_up", strconv.FormatBool(n.AdminStateUp))
|
d.Set("admin_state_up", strconv.FormatBool(n.AdminStateUp))
|
||||||
} else {
|
|
||||||
d.Set("admin_state_up", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("shared"); exists && t != "" {
|
|
||||||
d.Set("shared", strconv.FormatBool(n.Shared))
|
d.Set("shared", strconv.FormatBool(n.Shared))
|
||||||
} else {
|
|
||||||
d.Set("shared", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("tenant_id"); exists && t != "" {
|
|
||||||
d.Set("tenant_id", n.TenantID)
|
d.Set("tenant_id", n.TenantID)
|
||||||
} else {
|
|
||||||
d.Set("tenant_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ func resourceNetworkingRouterInterfaceV2Create(d *schema.ResourceData, meta inte
|
||||||
SubnetID: d.Get("subnet_id").(string),
|
SubnetID: d.Get("subnet_id").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting router interface creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
n, err := routers.AddInterface(networkingClient, d.Get("router_id").(string), createOpts).Extract()
|
n, err := routers.AddInterface(networkingClient, d.Get("router_id").(string), createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack Neutron router interface: %s", err)
|
return fmt.Errorf("Error creating OpenStack Neutron router interface: %s", err)
|
||||||
|
@ -83,8 +83,6 @@ func resourceNetworkingRouterInterfaceV2Read(d *schema.ResourceData, meta interf
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived Router Interface %s: %+v", d.Id(), n)
|
log.Printf("[DEBUG] Retreived Router Interface %s: %+v", d.Id(), n)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ func resourceNetworkingRouterV2Create(d *schema.ResourceData, meta interface{})
|
||||||
createOpts.GatewayInfo = &gatewayInfo
|
createOpts.GatewayInfo = &gatewayInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting router creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
n, err := routers.Create(networkingClient, createOpts).Extract()
|
n, err := routers.Create(networkingClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack Neutron router: %s", err)
|
return fmt.Errorf("Error creating OpenStack Neutron router: %s", err)
|
||||||
|
@ -112,31 +112,10 @@ func resourceNetworkingRouterV2Read(d *schema.ResourceData, meta interface{}) er
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived Router %s: %+v", d.Id(), n)
|
log.Printf("[DEBUG] Retreived Router %s: %+v", d.Id(), n)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
|
||||||
d.Set("name", n.Name)
|
d.Set("name", n.Name)
|
||||||
} else {
|
|
||||||
d.Set("name", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("admin_state_up"); exists && t != "" {
|
|
||||||
d.Set("admin_state_up", strconv.FormatBool(n.AdminStateUp))
|
d.Set("admin_state_up", strconv.FormatBool(n.AdminStateUp))
|
||||||
} else {
|
|
||||||
d.Set("admin_state_up", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("tenant_id"); exists && t != "" {
|
|
||||||
d.Set("tenant_id", n.TenantID)
|
d.Set("tenant_id", n.TenantID)
|
||||||
} else {
|
|
||||||
d.Set("tenant_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("external_gateway"); exists && t != "" {
|
|
||||||
d.Set("external_gateway", n.GatewayInfo.NetworkID)
|
d.Set("external_gateway", n.GatewayInfo.NetworkID)
|
||||||
} else {
|
|
||||||
d.Set("external_gateway", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{})
|
||||||
createOpts.EnableDHCP = &ed
|
createOpts.EnableDHCP = &ed
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting subnet creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
s, err := subnets.Create(networkingClient, createOpts).Extract()
|
s, err := subnets.Create(networkingClient, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack Neutron subnet: %s", err)
|
return fmt.Errorf("Error creating OpenStack Neutron subnet: %s", err)
|
||||||
|
@ -160,46 +160,16 @@ func resourceNetworkingSubnetV2Read(d *schema.ResourceData, meta interface{}) er
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retreived Subnet %s: %+v", d.Id(), s)
|
log.Printf("[DEBUG] Retreived Subnet %s: %+v", d.Id(), s)
|
||||||
|
|
||||||
d.Set("region", d.Get("region").(string))
|
|
||||||
d.Set("newtork_id", s.NetworkID)
|
d.Set("newtork_id", s.NetworkID)
|
||||||
d.Set("cidr", s.CIDR)
|
d.Set("cidr", s.CIDR)
|
||||||
d.Set("ip_version", s.IPVersion)
|
d.Set("ip_version", s.IPVersion)
|
||||||
|
|
||||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
|
||||||
d.Set("name", s.Name)
|
d.Set("name", s.Name)
|
||||||
} else {
|
|
||||||
d.Set("name", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("tenant_id"); exists && t != "" {
|
|
||||||
d.Set("tenant_id", s.TenantID)
|
d.Set("tenant_id", s.TenantID)
|
||||||
} else {
|
|
||||||
d.Set("tenant_id", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exists := d.GetOk("allocation_pools"); exists {
|
|
||||||
d.Set("allocation_pools", s.AllocationPools)
|
d.Set("allocation_pools", s.AllocationPools)
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("gateway_ip"); exists && t != "" {
|
|
||||||
d.Set("gateway_ip", s.GatewayIP)
|
d.Set("gateway_ip", s.GatewayIP)
|
||||||
} else {
|
|
||||||
d.Set("gateway_ip", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, exists := d.GetOk("enable_dhcp"); exists && t != "" {
|
|
||||||
d.Set("enable_dhcp", strconv.FormatBool(s.EnableDHCP))
|
d.Set("enable_dhcp", strconv.FormatBool(s.EnableDHCP))
|
||||||
} else {
|
|
||||||
d.Set("enable_dhcp", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exists := d.GetOk("dns_nameservers"); exists {
|
|
||||||
d.Set("dns_nameservers", s.DNSNameservers)
|
d.Set("dns_nameservers", s.DNSNameservers)
|
||||||
}
|
|
||||||
|
|
||||||
if _, exists := d.GetOk("host_routes"); exists {
|
|
||||||
d.Set("host_routes", s.HostRoutes)
|
d.Set("host_routes", s.HostRoutes)
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ func resourceObjectStorageContainerV1Create(d *schema.ResourceData, meta interfa
|
||||||
Metadata: resourceContainerMetadataV2(d),
|
Metadata: resourceContainerMetadataV2(d),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Requesting container creation")
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
_, err = containers.Create(objectStorageClient, cn, createOpts).Extract()
|
_, err = containers.Create(objectStorageClient, cn, createOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating OpenStack container: %s", err)
|
return fmt.Errorf("Error creating OpenStack container: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue