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
0db6cd35
Commit
0db6cd35
authored
Oct 28, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1330 from qur/qemu-vagrant
Qemu vagrant
parents
eedf5672
660e82e6
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
177 additions
and
8 deletions
+177
-8
builder/amazon/common/artifact.go
builder/amazon/common/artifact.go
+4
-0
builder/digitalocean/artifact.go
builder/digitalocean/artifact.go
+4
-0
builder/docker/artifact_export.go
builder/docker/artifact_export.go
+4
-0
builder/docker/artifact_import.go
builder/docker/artifact_import.go
+4
-0
builder/googlecompute/artifact.go
builder/googlecompute/artifact.go
+4
-0
builder/null/artifact_export.go
builder/null/artifact_export.go
+4
-0
builder/openstack/artifact.go
builder/openstack/artifact.go
+4
-0
builder/parallels/common/artifact.go
builder/parallels/common/artifact.go
+4
-0
builder/qemu/artifact.go
builder/qemu/artifact.go
+7
-2
builder/qemu/builder.go
builder/qemu/builder.go
+6
-0
builder/qemu/step_create_disk.go
builder/qemu/step_create_disk.go
+4
-2
builder/virtualbox/common/artifact.go
builder/virtualbox/common/artifact.go
+4
-0
builder/vmware/common/artifact.go
builder/vmware/common/artifact.go
+4
-0
builder/vmware/iso/artifact.go
builder/vmware/iso/artifact.go
+4
-0
packer/artifact.go
packer/artifact.go
+4
-0
packer/artifact_mock.go
packer/artifact_mock.go
+6
-0
packer/artifact_test.go
packer/artifact_test.go
+6
-0
packer/rpc/artifact.go
packer/rpc/artifact.go
+10
-0
packer/rpc/client.go
packer/rpc/client.go
+5
-2
packer/rpc/server.go
packer/rpc/server.go
+5
-2
post-processor/compress/artifact.go
post-processor/compress/artifact.go
+4
-0
post-processor/vagrant-cloud/artifact.go
post-processor/vagrant-cloud/artifact.go
+4
-0
post-processor/vagrant/artifact.go
post-processor/vagrant/artifact.go
+4
-0
post-processor/vagrant/libvirt.go
post-processor/vagrant/libvirt.go
+64
-0
post-processor/vagrant/post-processor.go
post-processor/vagrant/post-processor.go
+3
-0
website/source/docs/post-processors/vagrant.html.markdown
website/source/docs/post-processors/vagrant.html.markdown
+1
-0
No files found.
builder/amazon/common/artifact.go
View file @
0db6cd35
...
...
@@ -52,6 +52,10 @@ func (a *Artifact) String() string {
return
fmt
.
Sprintf
(
"AMIs were created:
\n\n
%s"
,
strings
.
Join
(
amiStrings
,
"
\n
"
))
}
func
(
a
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
Artifact
)
Destroy
()
error
{
errors
:=
make
([]
error
,
0
)
...
...
builder/digitalocean/artifact.go
View file @
0db6cd35
...
...
@@ -37,6 +37,10 @@ func (a *Artifact) String() string {
return
fmt
.
Sprintf
(
"A snapshot was created: '%v' in region '%v'"
,
a
.
snapshotName
,
a
.
regionName
)
}
func
(
a
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
Artifact
)
Destroy
()
error
{
log
.
Printf
(
"Destroying image: %d (%s)"
,
a
.
snapshotId
,
a
.
snapshotName
)
return
a
.
client
.
DestroyImage
(
a
.
snapshotId
)
...
...
builder/docker/artifact_export.go
View file @
0db6cd35
...
...
@@ -27,6 +27,10 @@ func (a *ExportArtifact) String() string {
return
fmt
.
Sprintf
(
"Exported Docker file: %s"
,
a
.
path
)
}
func
(
a
*
ExportArtifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
ExportArtifact
)
Destroy
()
error
{
return
os
.
Remove
(
a
.
path
)
}
builder/docker/artifact_import.go
View file @
0db6cd35
...
...
@@ -28,6 +28,10 @@ func (a *ImportArtifact) String() string {
return
fmt
.
Sprintf
(
"Imported Docker image: %s"
,
a
.
Id
())
}
func
(
*
ImportArtifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
ImportArtifact
)
Destroy
()
error
{
return
a
.
Driver
.
DeleteImage
(
a
.
Id
())
}
builder/googlecompute/artifact.go
View file @
0db6cd35
...
...
@@ -37,3 +37,7 @@ func (a *Artifact) Id() string {
func
(
a
*
Artifact
)
String
()
string
{
return
fmt
.
Sprintf
(
"A disk image was created: %v"
,
a
.
imageName
)
}
func
(
a
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
builder/null/artifact_export.go
View file @
0db6cd35
...
...
@@ -24,6 +24,10 @@ func (a *NullArtifact) String() string {
return
fmt
.
Sprintf
(
"Did not export anything. This is the null builder"
)
}
func
(
a
*
NullArtifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
NullArtifact
)
Destroy
()
error
{
return
nil
}
builder/openstack/artifact.go
View file @
0db6cd35
...
...
@@ -36,6 +36,10 @@ func (a *Artifact) String() string {
return
fmt
.
Sprintf
(
"An image was created: %v"
,
a
.
ImageId
)
}
func
(
a
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
Artifact
)
Destroy
()
error
{
log
.
Printf
(
"Destroying image: %d"
,
a
.
ImageId
)
return
a
.
Conn
.
DeleteImageById
(
a
.
ImageId
)
...
...
builder/parallels/common/artifact.go
View file @
0db6cd35
...
...
@@ -66,6 +66,10 @@ func (a *artifact) String() string {
return
fmt
.
Sprintf
(
"VM files in directory: %s"
,
a
.
dir
)
}
func
(
a
*
artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
artifact
)
Destroy
()
error
{
return
os
.
RemoveAll
(
a
.
dir
)
}
builder/qemu/artifact.go
View file @
0db6cd35
...
...
@@ -10,6 +10,7 @@ import (
type
Artifact
struct
{
dir
string
f
[]
string
state
map
[
string
]
interface
{}
}
func
(
*
Artifact
)
BuilderId
()
string
{
...
...
@@ -28,6 +29,10 @@ func (a *Artifact) String() string {
return
fmt
.
Sprintf
(
"VM files in directory: %s"
,
a
.
dir
)
}
func
(
a
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
a
.
state
[
name
]
}
func
(
a
*
Artifact
)
Destroy
()
error
{
return
os
.
RemoveAll
(
a
.
dir
)
}
builder/qemu/builder.go
View file @
0db6cd35
...
...
@@ -502,8 +502,14 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
artifact
:=
&
Artifact
{
dir
:
b
.
config
.
OutputDir
,
f
:
files
,
state
:
make
(
map
[
string
]
interface
{}),
}
artifact
.
state
[
"diskName"
]
=
state
.
Get
(
"disk_filename"
)
.
(
string
)
artifact
.
state
[
"diskType"
]
=
b
.
config
.
Format
artifact
.
state
[
"diskSize"
]
=
uint64
(
b
.
config
.
DiskSize
)
artifact
.
state
[
"domainType"
]
=
b
.
config
.
Accelerator
return
artifact
,
nil
}
...
...
builder/qemu/step_create_disk.go
View file @
0db6cd35
...
...
@@ -16,8 +16,8 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
path
:=
filepath
.
Join
(
config
.
OutputDir
,
fmt
.
Sprintf
(
"%s.%s"
,
config
.
VMName
,
strings
.
ToLower
(
config
.
Format
))
)
name
:=
config
.
VMName
+
"."
+
strings
.
ToLower
(
config
.
Format
)
path
:=
filepath
.
Join
(
config
.
OutputDir
,
name
)
command
:=
[]
string
{
"create"
,
...
...
@@ -38,6 +38,8 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
}
state
.
Put
(
"disk_filename"
,
name
)
return
multistep
.
ActionContinue
}
...
...
builder/virtualbox/common/artifact.go
View file @
0db6cd35
...
...
@@ -56,6 +56,10 @@ func (a *artifact) String() string {
return
fmt
.
Sprintf
(
"VM files in directory: %s"
,
a
.
dir
)
}
func
(
a
*
artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
artifact
)
Destroy
()
error
{
return
os
.
RemoveAll
(
a
.
dir
)
}
builder/vmware/common/artifact.go
View file @
0db6cd35
...
...
@@ -56,6 +56,10 @@ func (a *localArtifact) String() string {
return
fmt
.
Sprintf
(
"VM files in directory: %s"
,
a
.
dir
)
}
func
(
a
*
localArtifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
localArtifact
)
Destroy
()
error
{
return
os
.
RemoveAll
(
a
.
dir
)
}
builder/vmware/iso/artifact.go
View file @
0db6cd35
...
...
@@ -28,6 +28,10 @@ func (a *Artifact) String() string {
return
fmt
.
Sprintf
(
"VM files in directory: %s"
,
a
.
dir
)
}
func
(
a
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
Artifact
)
Destroy
()
error
{
return
a
.
dir
.
RemoveAll
()
}
packer/artifact.go
View file @
0db6cd35
...
...
@@ -25,6 +25,10 @@ type Artifact interface {
// This is used for UI output. It can be multiple lines.
String
()
string
// State allows the caller to ask for builder specific state information
// relating to the artifact instance.
State
(
name
string
)
interface
{}
// Destroy deletes the artifact. Packer calls this for various reasons,
// such as if a post-processor has processed this artifact and it is
// no longer needed.
...
...
packer/artifact_mock.go
View file @
0db6cd35
...
...
@@ -5,6 +5,7 @@ type MockArtifact struct {
BuilderIdValue
string
FilesValue
[]
string
IdValue
string
StateValues
map
[
string
]
interface
{}
DestroyCalled
bool
}
...
...
@@ -37,6 +38,11 @@ func (*MockArtifact) String() string {
return
"string"
}
func
(
a
*
MockArtifact
)
State
(
name
string
)
interface
{}
{
value
,
_
:=
a
.
StateValues
[
name
]
return
value
}
func
(
a
*
MockArtifact
)
Destroy
()
error
{
a
.
DestroyCalled
=
true
return
nil
...
...
packer/artifact_test.go
View file @
0db6cd35
...
...
@@ -2,6 +2,7 @@ package packer
type
TestArtifact
struct
{
id
string
state
map
[
string
]
interface
{}
destroyCalled
bool
}
...
...
@@ -26,6 +27,11 @@ func (*TestArtifact) String() string {
return
"string"
}
func
(
a
*
TestArtifact
)
State
(
name
string
)
interface
{}
{
value
,
_
:=
a
.
state
[
name
]
return
value
}
func
(
a
*
TestArtifact
)
Destroy
()
error
{
a
.
destroyCalled
=
true
return
nil
...
...
packer/rpc/artifact.go
View file @
0db6cd35
...
...
@@ -38,6 +38,11 @@ func (a *artifact) String() (result string) {
return
}
func
(
a
*
artifact
)
State
(
name
string
)
(
result
interface
{})
{
a
.
client
.
Call
(
a
.
endpoint
+
".State"
,
name
,
&
result
)
return
}
func
(
a
*
artifact
)
Destroy
()
error
{
var
result
error
if
err
:=
a
.
client
.
Call
(
a
.
endpoint
+
".Destroy"
,
new
(
interface
{}),
&
result
);
err
!=
nil
{
...
...
@@ -67,6 +72,11 @@ func (s *ArtifactServer) String(args *interface{}, reply *string) error {
return
nil
}
func
(
s
*
ArtifactServer
)
State
(
name
string
,
reply
*
interface
{})
error
{
*
reply
=
s
.
artifact
.
State
(
name
)
return
nil
}
func
(
s
*
ArtifactServer
)
Destroy
(
args
*
interface
{},
reply
*
error
)
error
{
err
:=
s
.
artifact
.
Destroy
()
if
err
!=
nil
{
...
...
packer/rpc/client.go
View file @
0db6cd35
...
...
@@ -40,8 +40,11 @@ func newClientWithMux(mux *muxBroker, streamId uint32) (*Client, error) {
return
nil
,
err
}
var
h
codec
.
MsgpackHandle
clientCodec
:=
codec
.
GoRpc
.
ClientCodec
(
clientConn
,
&
h
)
h
:=
&
codec
.
MsgpackHandle
{
RawToString
:
true
,
WriteExt
:
true
,
}
clientCodec
:=
codec
.
GoRpc
.
ClientCodec
(
clientConn
,
h
)
return
&
Client
{
mux
:
mux
,
...
...
packer/rpc/server.go
View file @
0db6cd35
...
...
@@ -148,8 +148,11 @@ func (s *Server) Serve() {
}
defer
stream
.
Close
()
var
h
codec
.
MsgpackHandle
rpcCodec
:=
codec
.
GoRpc
.
ServerCodec
(
stream
,
&
h
)
h
:=
&
codec
.
MsgpackHandle
{
RawToString
:
true
,
WriteExt
:
true
,
}
rpcCodec
:=
codec
.
GoRpc
.
ServerCodec
(
stream
,
h
)
s
.
server
.
ServeCodec
(
rpcCodec
)
}
...
...
post-processor/compress/artifact.go
View file @
0db6cd35
...
...
@@ -35,6 +35,10 @@ func (self *Artifact) String() string {
return
fmt
.
Sprintf
(
"'%s' compressing: %s"
,
self
.
Provider
,
self
.
Path
)
}
func
(
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
self
*
Artifact
)
Destroy
()
error
{
return
os
.
Remove
(
self
.
Path
)
}
post-processor/vagrant-cloud/artifact.go
View file @
0db6cd35
...
...
@@ -34,6 +34,10 @@ func (a *Artifact) String() string {
return
fmt
.
Sprintf
(
"'%s': %s"
,
a
.
Provider
,
a
.
Tag
)
}
func
(
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
Artifact
)
Destroy
()
error
{
return
nil
}
post-processor/vagrant/artifact.go
View file @
0db6cd35
...
...
@@ -35,6 +35,10 @@ func (a *Artifact) String() string {
return
fmt
.
Sprintf
(
"'%s' provider box: %s"
,
a
.
Provider
,
a
.
Path
)
}
func
(
a
*
Artifact
)
State
(
name
string
)
interface
{}
{
return
nil
}
func
(
a
*
Artifact
)
Destroy
()
error
{
return
os
.
Remove
(
a
.
Path
)
}
post-processor/vagrant/libvirt.go
0 → 100644
View file @
0db6cd35
package
vagrant
import
(
"fmt"
"github.com/mitchellh/packer/packer"
"path/filepath"
"strings"
)
type
LibVirtProvider
struct
{}
func
(
p
*
LibVirtProvider
)
KeepInputArtifact
()
bool
{
return
false
}
func
(
p
*
LibVirtProvider
)
Process
(
ui
packer
.
Ui
,
artifact
packer
.
Artifact
,
dir
string
)
(
vagrantfile
string
,
metadata
map
[
string
]
interface
{},
err
error
)
{
diskName
:=
artifact
.
State
(
"diskName"
)
.
(
string
)
// Copy the disk image into the temporary directory (as box.img)
for
_
,
path
:=
range
artifact
.
Files
()
{
if
strings
.
HasSuffix
(
path
,
"/"
+
diskName
)
{
ui
.
Message
(
fmt
.
Sprintf
(
"Copying from artifact: %s"
,
path
))
dstPath
:=
filepath
.
Join
(
dir
,
"box.img"
)
if
err
=
CopyContents
(
dstPath
,
path
);
err
!=
nil
{
return
}
}
}
format
:=
artifact
.
State
(
"diskType"
)
.
(
string
)
origSize
:=
artifact
.
State
(
"diskSize"
)
.
(
uint64
)
size
:=
origSize
/
1024
// In MB, want GB
if
origSize
%
1024
>
0
{
// Make sure we don't make the size smaller
size
++
}
domainType
:=
artifact
.
State
(
"domainType"
)
.
(
string
)
// Convert domain type to libvirt driver
var
driver
string
switch
domainType
{
case
"kvm"
,
"qemu"
:
driver
=
domainType
default
:
return
""
,
nil
,
fmt
.
Errorf
(
"Unknown libvirt domain type: %s"
,
domainType
)
}
// Create the metadata
metadata
=
map
[
string
]
interface
{}{
"provider"
:
"libvirt"
,
"format"
:
format
,
"virtual_size"
:
size
,
}
vagrantfile
=
fmt
.
Sprintf
(
libvirtVagrantfile
,
driver
)
return
}
var
libvirtVagrantfile
=
`
Vagrant.configure("2") do |config|
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "%s"
end
end
`
post-processor/vagrant/post-processor.go
View file @
0db6cd35
...
...
@@ -23,6 +23,7 @@ var builtins = map[string]string{
"pearkes.digitalocean"
:
"digitalocean"
,
"packer.parallels"
:
"parallels"
,
"MSOpenTech.hyperv"
:
"hyperv"
,
"transcend.qemu"
:
"libvirt"
,
}
type
Config
struct
{
...
...
@@ -228,6 +229,8 @@ func providerForName(name string) Provider {
return
new
(
ParallelsProvider
)
case
"hyperv"
:
return
new
(
HypervProvider
)
case
"libvirt"
:
return
new
(
LibVirtProvider
)
default
:
return
nil
}
...
...
website/source/docs/post-processors/vagrant.html.markdown
View file @
0db6cd35
...
...
@@ -32,6 +32,7 @@ providers.
*
DigitalOcean
*
Hyper-V
*
Parallels
*
QEMU
*
VirtualBox
*
VMware
...
...
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