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
fa92377a
Commit
fa92377a
authored
Jul 29, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/chroot: create the volume
parent
e24cbc18
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+1
-0
builder/amazon/chroot/step_create_volume.go
builder/amazon/chroot/step_create_volume.go
+66
-0
No files found.
builder/amazon/chroot/builder.go
View file @
fa92377a
...
...
@@ -74,6 +74,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
steps
:=
[]
multistep
.
Step
{
&
StepCheckEC2
{},
&
StepSourceAMIInfo
{},
&
StepCreateVolume
{},
}
// Run!
...
...
builder/amazon/chroot/step_create_volume.go
0 → 100644
View file @
fa92377a
package
chroot
import
(
"fmt"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
)
// StepCreateVolume creates a new volume from the snapshot of the root
// device of the AMI.
//
// Produces:
// volume_id string - The ID of the created volume
type
StepCreateVolume
struct
{
volumeId
string
}
func
(
s
*
StepCreateVolume
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
ec2conn
:=
state
[
"ec2"
]
.
(
*
ec2
.
EC2
)
image
:=
state
[
"source_image"
]
.
(
*
ec2
.
Image
)
instance
:=
state
[
"instance"
]
.
(
*
ec2
.
Instance
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
// Determine the root device snapshot
log
.
Printf
(
"Searching for root device of the image (%s)"
,
image
.
RootDeviceName
)
var
rootDevice
*
ec2
.
BlockDeviceMapping
for
_
,
device
:=
range
image
.
BlockDevices
{
if
device
.
DeviceName
==
image
.
RootDeviceName
{
rootDevice
=
&
device
break
}
}
if
rootDevice
==
nil
{
err
:=
fmt
.
Errorf
(
"Couldn't find root device!"
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
ui
.
Say
(
"Creating the root volume..."
)
createVolume
:=
&
ec2
.
CreateVolume
{
AvailZone
:
instance
.
AvailZone
,
Size
:
rootDevice
.
VolumeSize
,
SnapshotId
:
rootDevice
.
SnapshotId
,
VolumeType
:
rootDevice
.
VolumeType
,
IOPS
:
rootDevice
.
IOPS
,
}
createVolumeResp
,
err
:=
ec2conn
.
CreateVolume
(
createVolume
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error creating root volume: %s"
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
// Set the volume ID so we remember to delete it later
s
.
volumeId
=
createVolumeResp
.
VolumeId
return
multistep
.
ActionContinue
}
func
(
s
*
StepCreateVolume
)
Cleanup
(
map
[
string
]
interface
{})
{}
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