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
2e57496a
Commit
2e57496a
authored
Jun 04, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Start it. Creates disks so far...
parent
87e7f17a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
0 deletions
+111
-0
builder/vmware/builder.go
builder/vmware/builder.go
+47
-0
builder/vmware/step_create_disk.go
builder/vmware/step_create_disk.go
+33
-0
builder/vmware/step_prepare_output_dir.go
builder/vmware/step_prepare_output_dir.go
+20
-0
config.go
config.go
+1
-0
plugin/builder-vmware/main.go
plugin/builder-vmware/main.go
+10
-0
No files found.
builder/vmware/builder.go
0 → 100644
View file @
2e57496a
package
vmware
import
(
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
const
BuilderId
=
"mitchellh.vmware"
type
Builder
struct
{
config
config
runner
multistep
.
Runner
}
type
config
struct
{
OutputDir
string
`mapstructure:"output_directory"`
}
func
(
b
*
Builder
)
Prepare
(
raw
interface
{})
(
err
error
)
{
if
b
.
config
.
OutputDir
==
""
{
b
.
config
.
OutputDir
=
"vmware"
}
return
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
)
packer
.
Artifact
{
steps
:=
[]
multistep
.
Step
{
&
stepPrepareOutputDir
{},
&
stepCreateDisk
{},
}
// Setup the state bag
state
:=
make
(
map
[
string
]
interface
{})
state
[
"config"
]
=
&
b
.
config
state
[
"hook"
]
=
hook
state
[
"ui"
]
=
ui
// Run!
b
.
runner
=
&
multistep
.
BasicRunner
{
Steps
:
steps
}
b
.
runner
.
Run
(
state
)
return
nil
}
func
(
b
*
Builder
)
Cancel
()
{
}
builder/vmware/step_create_disk.go
0 → 100644
View file @
2e57496a
package
vmware
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"os/exec"
"path/filepath"
)
type
stepCreateDisk
struct
{}
func
(
stepCreateDisk
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
// TODO(mitchellh): Configurable disk size
// TODO(mitchellh): Capture error output in case things go wrong to report it
config
:=
state
[
"config"
]
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vdisk_manager
:=
"/Applications/VMware Fusion.app/Contents/Library/vmware-vdiskmanager"
output
:=
filepath
.
Join
(
config
.
OutputDir
,
"disk.vmdk"
)
ui
.
Say
(
"Creating virtual machine disk"
)
cmd
:=
exec
.
Command
(
vdisk_manager
,
"-c"
,
"-s"
,
"40000M"
,
"-a"
,
"lsilogic"
,
"-t"
,
"1"
,
output
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error creating VMware disk: %s"
,
err
))
return
multistep
.
ActionHalt
}
return
multistep
.
ActionContinue
}
func
(
stepCreateDisk
)
Cleanup
(
map
[
string
]
interface
{})
{}
builder/vmware/step_prepare_output_dir.go
0 → 100644
View file @
2e57496a
package
vmware
import
(
"github.com/mitchellh/multistep"
"os"
)
type
stepPrepareOutputDir
struct
{}
func
(
stepPrepareOutputDir
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
if
err
:=
os
.
MkdirAll
(
config
.
OutputDir
,
0755
);
err
!=
nil
{
return
multistep
.
ActionHalt
}
return
multistep
.
ActionContinue
}
func
(
stepPrepareOutputDir
)
Cleanup
(
map
[
string
]
interface
{})
{}
config.go
View file @
2e57496a
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
const
defaultConfig
=
`
const
defaultConfig
=
`
[builders]
[builders]
amazon-ebs = "packer-builder-amazon-ebs"
amazon-ebs = "packer-builder-amazon-ebs"
vmware = "packer-builder-vmware"
[commands]
[commands]
build = "packer-command-build"
build = "packer-command-build"
...
...
plugin/builder-vmware/main.go
0 → 100644
View file @
2e57496a
package
main
import
(
"github.com/mitchellh/packer/builder/vmware"
"github.com/mitchellh/packer/packer/plugin"
)
func
main
()
{
plugin
.
ServeBuilder
(
new
(
vmware
.
Builder
))
}
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