Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/openstack: Enforce ForceNew on Instance Block Device #6921

Merged
merged 1 commit into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,37 +193,43 @@ func resourceComputeInstanceV2() *schema.Resource {
"block_device": &schema.Schema{
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"source_type": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"uuid": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"volume_size": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"destination_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"boot_index": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"delete_on_termination": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
},
"guest_format": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,61 @@ func TestAccComputeV2Instance_bootFromVolumeVolume(t *testing.T) {
})
}

func TestAccComputeV2Instance_bootFromVolumeForceNew(t *testing.T) {
var instance1_1 servers.Server
var instance1_2 servers.Server
var testAccComputeV2Instance_bootFromVolumeForceNew_1 = fmt.Sprintf(`
resource "openstack_compute_instance_v2" "instance_1" {
name = "instance_1"
security_groups = ["default"]
block_device {
uuid = "%s"
source_type = "image"
volume_size = 5
boot_index = 0
destination_type = "volume"
delete_on_termination = true
}
}`,
os.Getenv("OS_IMAGE_ID"))

var testAccComputeV2Instance_bootFromVolumeForceNew_2 = fmt.Sprintf(`
resource "openstack_compute_instance_v2" "instance_1" {
name = "instance_1"
security_groups = ["default"]
block_device {
uuid = "%s"
source_type = "image"
volume_size = 4
boot_index = 0
destination_type = "volume"
delete_on_termination = true
}
}`,
os.Getenv("OS_IMAGE_ID"))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeV2InstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeV2Instance_bootFromVolumeForceNew_1,
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_1", &instance1_1),
),
},
resource.TestStep{
Config: testAccComputeV2Instance_bootFromVolumeForceNew_2,
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_1", &instance1_2),
testAccCheckComputeV2InstanceInstanceIDsDoNotMatch(&instance1_1, &instance1_2),
),
},
},
})
}

// TODO: verify the personality really exists on the instance.
func TestAccComputeV2Instance_personality(t *testing.T) {
var instance servers.Server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,26 @@ The `network` block supports:

The `block_device` block supports:

* `uuid` - (Required unless `source_type` is set to `"blank"` ) The UUID of the image, volume, or snapshot.
* `uuid` - (Required unless `source_type` is set to `"blank"` ) The UUID of
the image, volume, or snapshot. Changing this creates a new server.

* `source_type` - (Required) The source type of the device. Must be one of
"blank", "image", "volume", or "snapshot".
"blank", "image", "volume", or "snapshot". Changing this creates a new
server.

* `volume_size` - The size of the volume to create (in gigabytes). Required
in the following combinations: source=image and destination=volume,
source=blank and destination=local.
source=blank and destination=local. Changing this creates a new server.

* `boot_index` - (Optional) The boot index of the volume. It defaults to 0.
Changing this creates a new server.

* `destination_type` - (Optional) The type that gets created. Possible values
are "volume" and "local".
are "volume" and "local". Changing this creates a new server.

* `delete_on_termination` - (Optional) Delete the volume / block device upon
termination of the instance. Defaults to false.
termination of the instance. Defaults to false. Changing this creates a
new server.

The `volume` block supports:

Expand Down