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
f74ff911
Commit
f74ff911
authored
Aug 31, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: new multistep API
parent
1a3620d7
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
127 additions
and
126 deletions
+127
-126
builder/vmware/builder.go
builder/vmware/builder.go
+9
-9
builder/vmware/ssh.go
builder/vmware/ssh.go
+7
-6
builder/vmware/step_clean_files.go
builder/vmware/step_clean_files.go
+5
-5
builder/vmware/step_clean_vmx.go
builder/vmware/step_clean_vmx.go
+8
-8
builder/vmware/step_compact_disk.go
builder/vmware/step_compact_disk.go
+7
-7
builder/vmware/step_configure_vnc.go
builder/vmware/step_configure_vnc.go
+9
-9
builder/vmware/step_create_disk.go
builder/vmware/step_create_disk.go
+7
-7
builder/vmware/step_create_vmx.go
builder/vmware/step_create_vmx.go
+11
-11
builder/vmware/step_http_server.go
builder/vmware/step_http_server.go
+6
-6
builder/vmware/step_prepare_output_dir.go
builder/vmware/step_prepare_output_dir.go
+9
-9
builder/vmware/step_prepare_tools.go
builder/vmware/step_prepare_tools.go
+7
-7
builder/vmware/step_run.go
builder/vmware/step_run.go
+10
-10
builder/vmware/step_shutdown.go
builder/vmware/step_shutdown.go
+12
-12
builder/vmware/step_type_boot_command.go
builder/vmware/step_type_boot_command.go
+11
-11
builder/vmware/step_upload_tools.go
builder/vmware/step_upload_tools.go
+9
-9
No files found.
builder/vmware/builder.go
View file @
f74ff911
...
@@ -376,12 +376,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -376,12 +376,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
}
}
// Setup the state bag
// Setup the state bag
state
:=
make
(
map
[
string
]
interface
{}
)
state
:=
new
(
multistep
.
BasicStateBag
)
state
[
"cache"
]
=
cache
state
.
Put
(
"cache"
,
cache
)
state
[
"config"
]
=
&
b
.
config
state
.
Put
(
"config"
,
&
b
.
config
)
state
[
"driver"
]
=
driver
state
.
Put
(
"driver"
,
driver
)
state
[
"hook"
]
=
hook
state
.
Put
(
"hook"
,
hook
)
state
[
"ui"
]
=
ui
state
.
Put
(
"ui"
,
ui
)
// Run!
// Run!
if
b
.
config
.
PackerDebug
{
if
b
.
config
.
PackerDebug
{
...
@@ -396,16 +396,16 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -396,16 +396,16 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
b
.
runner
.
Run
(
state
)
b
.
runner
.
Run
(
state
)
// If there was an error, return that
// If there was an error, return that
if
rawErr
,
ok
:=
state
[
"error"
]
;
ok
{
if
rawErr
,
ok
:=
state
.
GetOk
(
"error"
)
;
ok
{
return
nil
,
rawErr
.
(
error
)
return
nil
,
rawErr
.
(
error
)
}
}
// If we were interrupted or cancelled, then just exit.
// If we were interrupted or cancelled, then just exit.
if
_
,
ok
:=
state
[
multistep
.
StateCancelled
]
;
ok
{
if
_
,
ok
:=
state
.
GetOk
(
multistep
.
StateCancelled
)
;
ok
{
return
nil
,
errors
.
New
(
"Build was cancelled."
)
return
nil
,
errors
.
New
(
"Build was cancelled."
)
}
}
if
_
,
ok
:=
state
[
multistep
.
StateHalted
]
;
ok
{
if
_
,
ok
:=
state
.
GetOk
(
multistep
.
StateHalted
)
;
ok
{
return
nil
,
errors
.
New
(
"Build was halted."
)
return
nil
,
errors
.
New
(
"Build was halted."
)
}
}
...
...
builder/vmware/ssh.go
View file @
f74ff911
...
@@ -4,16 +4,17 @@ import (
...
@@ -4,16 +4,17 @@ import (
gossh
"code.google.com/p/go.crypto/ssh"
gossh
"code.google.com/p/go.crypto/ssh"
"errors"
"errors"
"fmt"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/communicator/ssh"
"github.com/mitchellh/packer/communicator/ssh"
"io/ioutil"
"io/ioutil"
"log"
"log"
"os"
"os"
)
)
func
sshAddress
(
state
m
ap
[
string
]
interface
{}
)
(
string
,
error
)
{
func
sshAddress
(
state
m
ultistep
.
StateBag
)
(
string
,
error
)
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
vmxPath
:=
state
[
"vmx_path"
]
.
(
string
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
log
.
Println
(
"Lookup up IP information..."
)
log
.
Println
(
"Lookup up IP information..."
)
f
,
err
:=
os
.
Open
(
vmxPath
)
f
,
err
:=
os
.
Open
(
vmxPath
)
...
@@ -58,8 +59,8 @@ func sshAddress(state map[string]interface{}) (string, error) {
...
@@ -58,8 +59,8 @@ func sshAddress(state map[string]interface{}) (string, error) {
return
fmt
.
Sprintf
(
"%s:%d"
,
ipAddress
,
config
.
SSHPort
),
nil
return
fmt
.
Sprintf
(
"%s:%d"
,
ipAddress
,
config
.
SSHPort
),
nil
}
}
func
sshConfig
(
state
m
ap
[
string
]
interface
{}
)
(
*
gossh
.
ClientConfig
,
error
)
{
func
sshConfig
(
state
m
ultistep
.
StateBag
)
(
*
gossh
.
ClientConfig
,
error
)
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
auth
:=
[]
gossh
.
ClientAuth
{
auth
:=
[]
gossh
.
ClientAuth
{
gossh
.
ClientAuthPassword
(
ssh
.
Password
(
config
.
SSHPassword
)),
gossh
.
ClientAuthPassword
(
ssh
.
Password
(
config
.
SSHPassword
)),
...
...
builder/vmware/step_clean_files.go
View file @
f74ff911
...
@@ -23,9 +23,9 @@ var KeepFileExtensions = []string{".nvram", ".vmdk", ".vmsd", ".vmx", ".vmxf"}
...
@@ -23,9 +23,9 @@ var KeepFileExtensions = []string{".nvram", ".vmdk", ".vmsd", ".vmx", ".vmxf"}
// <nothing>
// <nothing>
type
stepCleanFiles
struct
{}
type
stepCleanFiles
struct
{}
func
(
stepCleanFiles
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
stepCleanFiles
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
"Deleting unnecessary VMware files..."
)
ui
.
Say
(
"Deleting unnecessary VMware files..."
)
visit
:=
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
visit
:=
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
...
@@ -55,11 +55,11 @@ func (stepCleanFiles) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -55,11 +55,11 @@ func (stepCleanFiles) Run(state map[string]interface{}) multistep.StepAction {
}
}
if
err
:=
filepath
.
Walk
(
config
.
OutputDir
,
visit
);
err
!=
nil
{
if
err
:=
filepath
.
Walk
(
config
.
OutputDir
,
visit
);
err
!=
nil
{
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
stepCleanFiles
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{}
func
(
stepCleanFiles
)
Cleanup
(
m
ultistep
.
StateBag
)
{}
builder/vmware/step_clean_vmx.go
View file @
f74ff911
...
@@ -22,20 +22,20 @@ import (
...
@@ -22,20 +22,20 @@ import (
// <nothing>
// <nothing>
type
stepCleanVMX
struct
{}
type
stepCleanVMX
struct
{}
func
(
s
stepCleanVMX
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
s
stepCleanVMX
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
isoPath
:=
state
[
"iso_path"
]
.
(
string
)
isoPath
:=
state
.
Get
(
"iso_path"
)
.
(
string
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
[
"vmx_path"
]
.
(
string
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
ui
.
Say
(
"Cleaning VMX prior to finishing up..."
)
ui
.
Say
(
"Cleaning VMX prior to finishing up..."
)
vmxData
,
err
:=
s
.
readVMX
(
vmxPath
)
vmxData
,
err
:=
s
.
readVMX
(
vmxPath
)
if
err
!=
nil
{
if
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error reading VMX: %s"
,
err
)
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error reading VMX: %s"
,
err
)
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
if
_
,
ok
:=
state
[
"floppy_path"
]
;
ok
{
if
_
,
ok
:=
state
.
GetOk
(
"floppy_path"
)
;
ok
{
// Delete the floppy0 entries so the floppy is no longer mounted
// Delete the floppy0 entries so the floppy is no longer mounted
ui
.
Message
(
"Unmounting floppy from VMX..."
)
ui
.
Message
(
"Unmounting floppy from VMX..."
)
for
k
,
_
:=
range
vmxData
{
for
k
,
_
:=
range
vmxData
{
...
@@ -67,14 +67,14 @@ func (s stepCleanVMX) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -67,14 +67,14 @@ func (s stepCleanVMX) Run(state map[string]interface{}) multistep.StepAction {
// Rewrite the VMX
// Rewrite the VMX
if
err
:=
WriteVMX
(
vmxPath
,
vmxData
);
err
!=
nil
{
if
err
:=
WriteVMX
(
vmxPath
,
vmxData
);
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error writing VMX: %s"
,
err
)
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error writing VMX: %s"
,
err
)
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
stepCleanVMX
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{}
func
(
stepCleanVMX
)
Cleanup
(
m
ultistep
.
StateBag
)
{}
func
(
stepCleanVMX
)
readVMX
(
vmxPath
string
)
(
map
[
string
]
string
,
error
)
{
func
(
stepCleanVMX
)
readVMX
(
vmxPath
string
)
(
map
[
string
]
string
,
error
)
{
vmxF
,
err
:=
os
.
Open
(
vmxPath
)
vmxF
,
err
:=
os
.
Open
(
vmxPath
)
...
...
builder/vmware/step_compact_disk.go
View file @
f74ff911
...
@@ -20,11 +20,11 @@ import (
...
@@ -20,11 +20,11 @@ import (
// <nothing>
// <nothing>
type
stepCompactDisk
struct
{}
type
stepCompactDisk
struct
{}
func
(
stepCompactDisk
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
stepCompactDisk
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
full_disk_path
:=
state
[
"full_disk_path"
]
.
(
string
)
full_disk_path
:=
state
.
Get
(
"full_disk_path"
)
.
(
string
)
if
config
.
SkipCompaction
==
true
{
if
config
.
SkipCompaction
==
true
{
log
.
Println
(
"Skipping disk compaction step..."
)
log
.
Println
(
"Skipping disk compaction step..."
)
...
@@ -33,11 +33,11 @@ func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -33,11 +33,11 @@ func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction {
ui
.
Say
(
"Compacting the disk image"
)
ui
.
Say
(
"Compacting the disk image"
)
if
err
:=
driver
.
CompactDisk
(
full_disk_path
);
err
!=
nil
{
if
err
:=
driver
.
CompactDisk
(
full_disk_path
);
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error compacting disk: %s"
,
err
)
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error compacting disk: %s"
,
err
)
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
stepCompactDisk
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{}
func
(
stepCompactDisk
)
Cleanup
(
m
ultistep
.
StateBag
)
{}
builder/vmware/step_configure_vnc.go
View file @
f74ff911
...
@@ -22,15 +22,15 @@ import (
...
@@ -22,15 +22,15 @@ import (
// vnc_port uint - The port that VNC is configured to listen on.
// vnc_port uint - The port that VNC is configured to listen on.
type
stepConfigureVNC
struct
{}
type
stepConfigureVNC
struct
{}
func
(
stepConfigureVNC
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
stepConfigureVNC
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
[
"vmx_path"
]
.
(
string
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
f
,
err
:=
os
.
Open
(
vmxPath
)
f
,
err
:=
os
.
Open
(
vmxPath
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error reading VMX data: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error reading VMX data: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -38,7 +38,7 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -38,7 +38,7 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction {
vmxBytes
,
err
:=
ioutil
.
ReadAll
(
f
)
vmxBytes
,
err
:=
ioutil
.
ReadAll
(
f
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error reading VMX data: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error reading VMX data: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -67,15 +67,15 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -67,15 +67,15 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction {
if
err
:=
WriteVMX
(
vmxPath
,
vmxData
);
err
!=
nil
{
if
err
:=
WriteVMX
(
vmxPath
,
vmxData
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error writing VMX data: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error writing VMX data: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
state
[
"vnc_port"
]
=
vncPort
state
.
Put
(
"vnc_port"
,
vncPort
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
stepConfigureVNC
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{
func
(
stepConfigureVNC
)
Cleanup
(
m
ultistep
.
StateBag
)
{
}
}
builder/vmware/step_create_disk.go
View file @
f74ff911
...
@@ -18,23 +18,23 @@ import (
...
@@ -18,23 +18,23 @@ import (
// full_disk_path (string) - The full path to the created disk.
// full_disk_path (string) - The full path to the created disk.
type
stepCreateDisk
struct
{}
type
stepCreateDisk
struct
{}
func
(
stepCreateDisk
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
stepCreateDisk
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
"Creating virtual machine disk"
)
ui
.
Say
(
"Creating virtual machine disk"
)
full_disk_path
:=
filepath
.
Join
(
config
.
OutputDir
,
config
.
DiskName
+
".vmdk"
)
full_disk_path
:=
filepath
.
Join
(
config
.
OutputDir
,
config
.
DiskName
+
".vmdk"
)
if
err
:=
driver
.
CreateDisk
(
full_disk_path
,
fmt
.
Sprintf
(
"%dM"
,
config
.
DiskSize
),
config
.
DiskTypeId
);
err
!=
nil
{
if
err
:=
driver
.
CreateDisk
(
full_disk_path
,
fmt
.
Sprintf
(
"%dM"
,
config
.
DiskSize
),
config
.
DiskTypeId
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error creating disk: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error creating disk: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
state
[
"full_disk_path"
]
=
full_disk_path
state
.
Put
(
"full_disk_path"
,
full_disk_path
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
stepCreateDisk
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{}
func
(
stepCreateDisk
)
Cleanup
(
m
ultistep
.
StateBag
)
{}
builder/vmware/step_create_vmx.go
View file @
f74ff911
...
@@ -28,10 +28,10 @@ type vmxTemplateData struct {
...
@@ -28,10 +28,10 @@ type vmxTemplateData struct {
// vmx_path string - The path to the VMX file.
// vmx_path string - The path to the VMX file.
type
stepCreateVMX
struct
{}
type
stepCreateVMX
struct
{}
func
(
stepCreateVMX
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
stepCreateVMX
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
isoPath
:=
state
[
"iso_path"
]
.
(
string
)
isoPath
:=
state
.
Get
(
"iso_path"
)
.
(
string
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
"Building and writing VMX file"
)
ui
.
Say
(
"Building and writing VMX file"
)
...
@@ -47,7 +47,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -47,7 +47,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
f
,
err
:=
os
.
Open
(
config
.
VMXTemplatePath
)
f
,
err
:=
os
.
Open
(
config
.
VMXTemplatePath
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error reading VMX template: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error reading VMX template: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -56,7 +56,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -56,7 +56,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
rawBytes
,
err
:=
ioutil
.
ReadAll
(
f
)
rawBytes
,
err
:=
ioutil
.
ReadAll
(
f
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error reading VMX template: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error reading VMX template: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -67,7 +67,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -67,7 +67,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
vmxContents
,
err
:=
config
.
tpl
.
Process
(
vmxTemplate
,
tplData
)
vmxContents
,
err
:=
config
.
tpl
.
Process
(
vmxTemplate
,
tplData
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error procesing VMX template: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error procesing VMX template: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -81,7 +81,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -81,7 +81,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
}
}
}
}
if
floppyPathRaw
,
ok
:=
state
[
"floppy_path"
]
;
ok
{
if
floppyPathRaw
,
ok
:=
state
.
GetOk
(
"floppy_path"
)
;
ok
{
log
.
Println
(
"Floppy path present, setting in VMX"
)
log
.
Println
(
"Floppy path present, setting in VMX"
)
vmxData
[
"floppy0.present"
]
=
"TRUE"
vmxData
[
"floppy0.present"
]
=
"TRUE"
vmxData
[
"floppy0.fileType"
]
=
"file"
vmxData
[
"floppy0.fileType"
]
=
"file"
...
@@ -91,17 +91,17 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -91,17 +91,17 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
vmxPath
:=
filepath
.
Join
(
config
.
OutputDir
,
config
.
VMName
+
".vmx"
)
vmxPath
:=
filepath
.
Join
(
config
.
OutputDir
,
config
.
VMName
+
".vmx"
)
if
err
:=
WriteVMX
(
vmxPath
,
vmxData
);
err
!=
nil
{
if
err
:=
WriteVMX
(
vmxPath
,
vmxData
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error creating VMX file: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error creating VMX file: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
state
[
"vmx_path"
]
=
vmxPath
state
.
Put
(
"vmx_path"
,
vmxPath
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
stepCreateVMX
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{
func
(
stepCreateVMX
)
Cleanup
(
m
ultistep
.
StateBag
)
{
}
}
// This is the default VMX template used if no other template is given.
// This is the default VMX template used if no other template is given.
...
...
builder/vmware/step_http_server.go
View file @
f74ff911
...
@@ -23,13 +23,13 @@ type stepHTTPServer struct {
...
@@ -23,13 +23,13 @@ type stepHTTPServer struct {
l
net
.
Listener
l
net
.
Listener
}
}
func
(
s
*
stepHTTPServer
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
s
*
stepHTTPServer
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
var
httpPort
uint
=
0
var
httpPort
uint
=
0
if
config
.
HTTPDir
==
""
{
if
config
.
HTTPDir
==
""
{
state
[
"http_port"
]
=
httpPort
state
.
Put
(
"http_port"
,
httpPort
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
@@ -62,12 +62,12 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction
...
@@ -62,12 +62,12 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction
go
server
.
Serve
(
s
.
l
)
go
server
.
Serve
(
s
.
l
)
// Save the address into the state so it can be accessed in the future
// Save the address into the state so it can be accessed in the future
state
[
"http_port"
]
=
httpPort
state
.
Put
(
"http_port"
,
httpPort
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
s
*
stepHTTPServer
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{
func
(
s
*
stepHTTPServer
)
Cleanup
(
m
ultistep
.
StateBag
)
{
if
s
.
l
!=
nil
{
if
s
.
l
!=
nil
{
// Close the listener so that the HTTP server stops
// Close the listener so that the HTTP server stops
s
.
l
.
Close
()
s
.
l
.
Close
()
...
...
builder/vmware/step_prepare_output_dir.go
View file @
f74ff911
...
@@ -10,9 +10,9 @@ import (
...
@@ -10,9 +10,9 @@ import (
type
stepPrepareOutputDir
struct
{}
type
stepPrepareOutputDir
struct
{}
func
(
stepPrepareOutputDir
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
stepPrepareOutputDir
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
if
_
,
err
:=
os
.
Stat
(
config
.
OutputDir
);
err
==
nil
&&
config
.
PackerForce
{
if
_
,
err
:=
os
.
Stat
(
config
.
OutputDir
);
err
==
nil
&&
config
.
PackerForce
{
ui
.
Say
(
"Deleting previous output directory..."
)
ui
.
Say
(
"Deleting previous output directory..."
)
...
@@ -20,20 +20,20 @@ func (stepPrepareOutputDir) Run(state map[string]interface{}) multistep.StepActi
...
@@ -20,20 +20,20 @@ func (stepPrepareOutputDir) Run(state map[string]interface{}) multistep.StepActi
}
}
if
err
:=
os
.
MkdirAll
(
config
.
OutputDir
,
0755
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
config
.
OutputDir
,
0755
);
err
!=
nil
{
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
stepPrepareOutputDir
)
Cleanup
(
state
m
ap
[
string
]
interface
{}
)
{
func
(
stepPrepareOutputDir
)
Cleanup
(
state
m
ultistep
.
StateBag
)
{
_
,
cancelled
:=
state
[
multistep
.
StateCancelled
]
_
,
cancelled
:=
state
.
GetOk
(
multistep
.
StateCancelled
)
_
,
halted
:=
state
[
multistep
.
StateHalted
]
_
,
halted
:=
state
.
GetOk
(
multistep
.
StateHalted
)
if
cancelled
||
halted
{
if
cancelled
||
halted
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
"Deleting output directory..."
)
ui
.
Say
(
"Deleting output directory..."
)
for
i
:=
0
;
i
<
5
;
i
++
{
for
i
:=
0
;
i
<
5
;
i
++
{
...
...
builder/vmware/step_prepare_tools.go
View file @
f74ff911
...
@@ -8,9 +8,9 @@ import (
...
@@ -8,9 +8,9 @@ import (
type
stepPrepareTools
struct
{}
type
stepPrepareTools
struct
{}
func
(
*
stepPrepareTools
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
*
stepPrepareTools
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
if
config
.
ToolsUploadFlavor
==
""
{
if
config
.
ToolsUploadFlavor
==
""
{
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
...
@@ -18,16 +18,16 @@ func (*stepPrepareTools) Run(state map[string]interface{}) multistep.StepAction
...
@@ -18,16 +18,16 @@ func (*stepPrepareTools) Run(state map[string]interface{}) multistep.StepAction
path
:=
driver
.
ToolsIsoPath
(
config
.
ToolsUploadFlavor
)
path
:=
driver
.
ToolsIsoPath
(
config
.
ToolsUploadFlavor
)
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Couldn't find VMware tools for '%s'! VMware often downloads these
\n
"
+
"Couldn't find VMware tools for '%s'! VMware often downloads these
\n
"
+
"tools on-demand. However, to do this, you need to create a fake VM
\n
"
+
"tools on-demand. However, to do this, you need to create a fake VM
\n
"
+
"of the proper type then click the 'install tools' option in the
\n
"
+
"of the proper type then click the 'install tools' option in the
\n
"
+
"VMware GUI."
,
config
.
ToolsUploadFlavor
)
"VMware GUI."
,
config
.
ToolsUploadFlavor
)
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
state
[
"tools_upload_source"
]
=
path
state
.
Put
(
"tools_upload_source"
,
path
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
*
stepPrepareTools
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{}
func
(
*
stepPrepareTools
)
Cleanup
(
m
ultistep
.
StateBag
)
{}
builder/vmware/step_run.go
View file @
f74ff911
...
@@ -22,12 +22,12 @@ type stepRun struct {
...
@@ -22,12 +22,12 @@ type stepRun struct {
vmxPath
string
vmxPath
string
}
}
func
(
s
*
stepRun
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
s
*
stepRun
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
[
"vmx_path"
]
.
(
string
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
vncPort
:=
state
[
"vnc_port"
]
.
(
uint
)
vncPort
:=
state
.
Get
(
"vnc_port"
)
.
(
uint
)
// Set the VMX path so that we know we started the machine
// Set the VMX path so that we know we started the machine
s
.
bootTime
=
time
.
Now
()
s
.
bootTime
=
time
.
Now
()
...
@@ -43,7 +43,7 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -43,7 +43,7 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
if
err
:=
driver
.
Start
(
vmxPath
,
config
.
Headless
);
err
!=
nil
{
if
err
:=
driver
.
Start
(
vmxPath
,
config
.
Headless
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error starting VM: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error starting VM: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -57,9 +57,9 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -57,9 +57,9 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
s
*
stepRun
)
Cleanup
(
state
m
ap
[
string
]
interface
{}
)
{
func
(
s
*
stepRun
)
Cleanup
(
state
m
ultistep
.
StateBag
)
{
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
// If we started the machine... stop it.
// If we started the machine... stop it.
if
s
.
vmxPath
!=
""
{
if
s
.
vmxPath
!=
""
{
...
...
builder/vmware/step_shutdown.go
View file @
f74ff911
...
@@ -27,12 +27,12 @@ import (
...
@@ -27,12 +27,12 @@ import (
// <nothing>
// <nothing>
type
stepShutdown
struct
{}
type
stepShutdown
struct
{}
func
(
s
*
stepShutdown
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
s
*
stepShutdown
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
comm
:=
state
[
"communicator"
]
.
(
packer
.
Communicator
)
comm
:=
state
.
Get
(
"communicator"
)
.
(
packer
.
Communicator
)
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
[
"vmx_path"
]
.
(
string
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
if
config
.
ShutdownCommand
!=
""
{
if
config
.
ShutdownCommand
!=
""
{
ui
.
Say
(
"Gracefully halting virtual machine..."
)
ui
.
Say
(
"Gracefully halting virtual machine..."
)
...
@@ -46,7 +46,7 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -46,7 +46,7 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
}
}
if
err
:=
comm
.
Start
(
cmd
);
err
!=
nil
{
if
err
:=
comm
.
Start
(
cmd
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Failed to send shutdown command: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Failed to send shutdown command: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -56,9 +56,9 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -56,9 +56,9 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
// If the command failed to run, notify the user in some way.
// If the command failed to run, notify the user in some way.
if
cmd
.
ExitStatus
!=
0
{
if
cmd
.
ExitStatus
!=
0
{
state
[
"error"
]
=
fmt
.
Errorf
(
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Shutdown command has non-zero exit status.
\n\n
Stdout: %s
\n\n
Stderr: %s"
,
"Shutdown command has non-zero exit status.
\n\n
Stdout: %s
\n\n
Stderr: %s"
,
stdout
.
String
(),
stderr
.
String
())
stdout
.
String
(),
stderr
.
String
())
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -77,7 +77,7 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -77,7 +77,7 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
select
{
select
{
case
<-
shutdownTimer
:
case
<-
shutdownTimer
:
err
:=
errors
.
New
(
"Timeout while waiting for machine to shut down."
)
err
:=
errors
.
New
(
"Timeout while waiting for machine to shut down."
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
default
:
default
:
...
@@ -87,7 +87,7 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -87,7 +87,7 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
}
else
{
}
else
{
if
err
:=
driver
.
Stop
(
vmxPath
);
err
!=
nil
{
if
err
:=
driver
.
Stop
(
vmxPath
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error stopping VM: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error stopping VM: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -132,4 +132,4 @@ LockWaitLoop:
...
@@ -132,4 +132,4 @@ LockWaitLoop:
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
s
*
stepShutdown
)
Cleanup
(
state
m
ap
[
string
]
interface
{}
)
{}
func
(
s
*
stepShutdown
)
Cleanup
(
state
m
ultistep
.
StateBag
)
{}
builder/vmware/step_type_boot_command.go
View file @
f74ff911
...
@@ -34,18 +34,18 @@ type bootCommandTemplateData struct {
...
@@ -34,18 +34,18 @@ type bootCommandTemplateData struct {
// <nothing>
// <nothing>
type
stepTypeBootCommand
struct
{}
type
stepTypeBootCommand
struct
{}
func
(
s
*
stepTypeBootCommand
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
s
*
stepTypeBootCommand
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
httpPort
:=
state
[
"http_port"
]
.
(
uint
)
httpPort
:=
state
.
Get
(
"http_port"
)
.
(
uint
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vncPort
:=
state
[
"vnc_port"
]
.
(
uint
)
vncPort
:=
state
.
Get
(
"vnc_port"
)
.
(
uint
)
// Connect to VNC
// Connect to VNC
ui
.
Say
(
"Connecting to VM via VNC"
)
ui
.
Say
(
"Connecting to VM via VNC"
)
nc
,
err
:=
net
.
Dial
(
"tcp"
,
fmt
.
Sprintf
(
"127.0.0.1:%d"
,
vncPort
))
nc
,
err
:=
net
.
Dial
(
"tcp"
,
fmt
.
Sprintf
(
"127.0.0.1:%d"
,
vncPort
))
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error connecting to VNC: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error connecting to VNC: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -54,7 +54,7 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
...
@@ -54,7 +54,7 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
c
,
err
:=
vnc
.
Client
(
nc
,
&
vnc
.
ClientConfig
{
Exclusive
:
true
})
c
,
err
:=
vnc
.
Client
(
nc
,
&
vnc
.
ClientConfig
{
Exclusive
:
true
})
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error handshaking with VNC: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error handshaking with VNC: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -73,7 +73,7 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
...
@@ -73,7 +73,7 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
hostIp
,
err
:=
ipFinder
.
HostIP
()
hostIp
,
err
:=
ipFinder
.
HostIP
()
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error detecting host IP: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error detecting host IP: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -91,14 +91,14 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
...
@@ -91,14 +91,14 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
command
,
err
:=
config
.
tpl
.
Process
(
command
,
tplData
)
command
,
err
:=
config
.
tpl
.
Process
(
command
,
tplData
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error preparing boot command: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error preparing boot command: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
// Check for interrupts between typing things so we can cancel
// Check for interrupts between typing things so we can cancel
// since this isn't the fastest thing.
// since this isn't the fastest thing.
if
_
,
ok
:=
state
[
multistep
.
StateCancelled
]
;
ok
{
if
_
,
ok
:=
state
.
GetOk
(
multistep
.
StateCancelled
)
;
ok
{
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
@@ -108,7 +108,7 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
...
@@ -108,7 +108,7 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
*
stepTypeBootCommand
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{}
func
(
*
stepTypeBootCommand
)
Cleanup
(
m
ultistep
.
StateBag
)
{}
func
vncSendString
(
c
*
vnc
.
ClientConn
,
original
string
)
{
func
vncSendString
(
c
*
vnc
.
ClientConn
,
original
string
)
{
special
:=
make
(
map
[
string
]
uint32
)
special
:=
make
(
map
[
string
]
uint32
)
...
...
builder/vmware/step_upload_tools.go
View file @
f74ff911
...
@@ -13,20 +13,20 @@ type toolsUploadPathTemplate struct {
...
@@ -13,20 +13,20 @@ type toolsUploadPathTemplate struct {
type
stepUploadTools
struct
{}
type
stepUploadTools
struct
{}
func
(
*
stepUploadTools
)
Run
(
state
m
ap
[
string
]
interface
{}
)
multistep
.
StepAction
{
func
(
*
stepUploadTools
)
Run
(
state
m
ultistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
if
config
.
ToolsUploadFlavor
==
""
{
if
config
.
ToolsUploadFlavor
==
""
{
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
comm
:=
state
[
"communicator"
]
.
(
packer
.
Communicator
)
comm
:=
state
.
Get
(
"communicator"
)
.
(
packer
.
Communicator
)
tools_source
:=
state
[
"tools_upload_source"
]
.
(
string
)
tools_source
:=
state
.
Get
(
"tools_upload_source"
)
.
(
string
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
fmt
.
Sprintf
(
"Uploading the '%s' VMware Tools"
,
config
.
ToolsUploadFlavor
))
ui
.
Say
(
fmt
.
Sprintf
(
"Uploading the '%s' VMware Tools"
,
config
.
ToolsUploadFlavor
))
f
,
err
:=
os
.
Open
(
tools_source
)
f
,
err
:=
os
.
Open
(
tools_source
)
if
err
!=
nil
{
if
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error opening VMware Tools ISO: %s"
,
err
)
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error opening VMware Tools ISO: %s"
,
err
)
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
defer
f
.
Close
()
defer
f
.
Close
()
...
@@ -35,17 +35,17 @@ func (*stepUploadTools) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -35,17 +35,17 @@ func (*stepUploadTools) Run(state map[string]interface{}) multistep.StepAction {
config
.
ToolsUploadPath
,
err
=
config
.
tpl
.
Process
(
config
.
ToolsUploadPath
,
tplData
)
config
.
ToolsUploadPath
,
err
=
config
.
tpl
.
Process
(
config
.
ToolsUploadPath
,
tplData
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error preparing upload path: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error preparing upload path: %s"
,
err
)
state
[
"error"
]
=
err
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
if
err
:=
comm
.
Upload
(
config
.
ToolsUploadPath
,
f
);
err
!=
nil
{
if
err
:=
comm
.
Upload
(
config
.
ToolsUploadPath
,
f
);
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error uploading VMware Tools: %s"
,
err
)
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error uploading VMware Tools: %s"
,
err
)
)
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
*
stepUploadTools
)
Cleanup
(
m
ap
[
string
]
interface
{}
)
{}
func
(
*
stepUploadTools
)
Cleanup
(
m
ultistep
.
StateBag
)
{}
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