2013-08-15 17:05:08 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/goamz/ec2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BlockDevice
|
|
|
|
type BlockDevice struct {
|
|
|
|
DeviceName string `mapstructure:"device_name"`
|
|
|
|
VirtualName string `mapstructure:"virtual_name"`
|
|
|
|
SnapshotId string `mapstructure:"snapshot_id"`
|
|
|
|
VolumeType string `mapstructure:"volume_type"`
|
|
|
|
VolumeSize int64 `mapstructure:"volume_size"`
|
|
|
|
DeleteOnTermination bool `mapstructure:"delete_on_termination"`
|
|
|
|
IOPS int64 `mapstructure:"iops"`
|
2013-09-06 14:44:57 -04:00
|
|
|
NoDevice bool `mapstructure:"no_device"`
|
2013-08-15 17:05:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type BlockDevices struct {
|
2013-09-06 14:48:38 -04:00
|
|
|
AMIMappings []BlockDevice `mapstructure:"ami_block_device_mappings"`
|
|
|
|
LaunchMappings []BlockDevice `mapstructure:"launch_block_device_mappings"`
|
2013-08-15 17:05:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func buildBlockDevices(b []BlockDevice) []ec2.BlockDeviceMapping {
|
|
|
|
var blockDevices []ec2.BlockDeviceMapping
|
|
|
|
|
|
|
|
for _, blockDevice := range b {
|
|
|
|
blockDevices = append(blockDevices, ec2.BlockDeviceMapping{
|
|
|
|
DeviceName: blockDevice.DeviceName,
|
|
|
|
VirtualName: blockDevice.VirtualName,
|
|
|
|
SnapshotId: blockDevice.SnapshotId,
|
|
|
|
VolumeType: blockDevice.VolumeType,
|
|
|
|
VolumeSize: blockDevice.VolumeSize,
|
|
|
|
DeleteOnTermination: blockDevice.DeleteOnTermination,
|
|
|
|
IOPS: blockDevice.IOPS,
|
2013-09-06 14:44:57 -04:00
|
|
|
NoDevice: blockDevice.NoDevice,
|
2013-08-15 17:05:08 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return blockDevices
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *BlockDevices) BuildAMIDevices() []ec2.BlockDeviceMapping {
|
|
|
|
return buildBlockDevices(b.AMIMappings)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *BlockDevices) BuildLaunchDevices() []ec2.BlockDeviceMapping {
|
|
|
|
return buildBlockDevices(b.LaunchMappings)
|
|
|
|
}
|