Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
39a8ba13
Commit
39a8ba13
authored
Jul 16, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2459 from mitchellh/b-2360
Don't add ephemeral block devices to the EBS mapping
parents
f2750562
241903d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
builder/amazon/common/block_device.go
builder/amazon/common/block_device.go
+6
-1
builder/amazon/common/block_device_test.go
builder/amazon/common/block_device_test.go
+18
-7
No files found.
builder/amazon/common/block_device.go
View file @
39a8ba13
package
common
package
common
import
(
import
(
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/template/interpolate"
"github.com/mitchellh/packer/template/interpolate"
...
@@ -47,11 +49,14 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
...
@@ -47,11 +49,14 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
}
}
mapping
:=
&
ec2
.
BlockDeviceMapping
{
mapping
:=
&
ec2
.
BlockDeviceMapping
{
EBS
:
ebsBlockDevice
,
DeviceName
:
aws
.
String
(
blockDevice
.
DeviceName
),
DeviceName
:
aws
.
String
(
blockDevice
.
DeviceName
),
VirtualName
:
aws
.
String
(
blockDevice
.
VirtualName
),
VirtualName
:
aws
.
String
(
blockDevice
.
VirtualName
),
}
}
if
!
strings
.
HasPrefix
(
blockDevice
.
VirtualName
,
"ephemeral"
)
{
mapping
.
EBS
=
ebsBlockDevice
}
if
blockDevice
.
NoDevice
{
if
blockDevice
.
NoDevice
{
mapping
.
NoDevice
=
aws
.
String
(
""
)
mapping
.
NoDevice
=
aws
.
String
(
""
)
}
}
...
...
builder/amazon/common/block_device_test.go
View file @
39a8ba13
...
@@ -17,17 +17,15 @@ func TestBlockDevice(t *testing.T) {
...
@@ -17,17 +17,15 @@ func TestBlockDevice(t *testing.T) {
{
{
Config
:
&
BlockDevice
{
Config
:
&
BlockDevice
{
DeviceName
:
"/dev/sdb"
,
DeviceName
:
"/dev/sdb"
,
VirtualName
:
"ephemeral0"
,
SnapshotId
:
"snap-1234"
,
SnapshotId
:
"snap-1234"
,
VolumeType
:
"standard"
,
VolumeType
:
"standard"
,
VolumeSize
:
8
,
VolumeSize
:
8
,
DeleteOnTermination
:
true
,
DeleteOnTermination
:
true
,
IOPS
:
1000
,
},
},
Result
:
&
ec2
.
BlockDeviceMapping
{
Result
:
&
ec2
.
BlockDeviceMapping
{
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
VirtualName
:
aws
.
String
(
"
ephemeral0
"
),
VirtualName
:
aws
.
String
(
""
),
EBS
:
&
ec2
.
EBSBlockDevice
{
EBS
:
&
ec2
.
EBSBlockDevice
{
SnapshotID
:
aws
.
String
(
"snap-1234"
),
SnapshotID
:
aws
.
String
(
"snap-1234"
),
VolumeType
:
aws
.
String
(
"standard"
),
VolumeType
:
aws
.
String
(
"standard"
),
...
@@ -55,7 +53,6 @@ func TestBlockDevice(t *testing.T) {
...
@@ -55,7 +53,6 @@ func TestBlockDevice(t *testing.T) {
{
{
Config
:
&
BlockDevice
{
Config
:
&
BlockDevice
{
DeviceName
:
"/dev/sdb"
,
DeviceName
:
"/dev/sdb"
,
VirtualName
:
"ephemeral0"
,
VolumeType
:
"io1"
,
VolumeType
:
"io1"
,
VolumeSize
:
8
,
VolumeSize
:
8
,
DeleteOnTermination
:
true
,
DeleteOnTermination
:
true
,
...
@@ -64,7 +61,7 @@ func TestBlockDevice(t *testing.T) {
...
@@ -64,7 +61,7 @@ func TestBlockDevice(t *testing.T) {
Result
:
&
ec2
.
BlockDeviceMapping
{
Result
:
&
ec2
.
BlockDeviceMapping
{
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
VirtualName
:
aws
.
String
(
"
ephemeral0
"
),
VirtualName
:
aws
.
String
(
""
),
EBS
:
&
ec2
.
EBSBlockDevice
{
EBS
:
&
ec2
.
EBSBlockDevice
{
VolumeType
:
aws
.
String
(
"io1"
),
VolumeType
:
aws
.
String
(
"io1"
),
VolumeSize
:
aws
.
Long
(
8
),
VolumeSize
:
aws
.
Long
(
8
),
...
@@ -73,6 +70,17 @@ func TestBlockDevice(t *testing.T) {
...
@@ -73,6 +70,17 @@ func TestBlockDevice(t *testing.T) {
},
},
},
},
},
},
{
Config
:
&
BlockDevice
{
DeviceName
:
"/dev/sdb"
,
VirtualName
:
"ephemeral0"
,
},
Result
:
&
ec2
.
BlockDeviceMapping
{
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
VirtualName
:
aws
.
String
(
"ephemeral0"
),
},
},
}
}
for
_
,
tc
:=
range
cases
{
for
_
,
tc
:=
range
cases
{
...
@@ -84,11 +92,14 @@ func TestBlockDevice(t *testing.T) {
...
@@ -84,11 +92,14 @@ func TestBlockDevice(t *testing.T) {
expected
:=
[]
*
ec2
.
BlockDeviceMapping
{
tc
.
Result
}
expected
:=
[]
*
ec2
.
BlockDeviceMapping
{
tc
.
Result
}
got
:=
blockDevices
.
BuildAMIDevices
()
got
:=
blockDevices
.
BuildAMIDevices
()
if
!
reflect
.
DeepEqual
(
expected
,
got
)
{
if
!
reflect
.
DeepEqual
(
expected
,
got
)
{
t
.
Fatalf
(
"Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
),
awsutil
.
StringValue
(
got
))
t
.
Fatalf
(
"Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
),
awsutil
.
StringValue
(
got
))
}
}
if
!
reflect
.
DeepEqual
(
expected
,
blockDevices
.
BuildLaunchDevices
())
{
if
!
reflect
.
DeepEqual
(
expected
,
blockDevices
.
BuildLaunchDevices
())
{
t
.
Fatalf
(
"Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
),
awsutil
.
StringValue
(
blockDevices
.
BuildLaunchDevices
()))
t
.
Fatalf
(
"Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
),
awsutil
.
StringValue
(
blockDevices
.
BuildLaunchDevices
()))
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment