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
e93697ab
Commit
e93697ab
authored
May 12, 2014
by
Ross Smith II
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox-ovf,vmware-vmx: add `boot_command` support
Fixes #1082
parent
38d1d7fd
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
73 additions
and
39 deletions
+73
-39
builder/virtualbox/common/step_type_boot_command.go
builder/virtualbox/common/step_type_boot_command.go
+12
-11
builder/virtualbox/iso/builder.go
builder/virtualbox/iso/builder.go
+5
-1
builder/virtualbox/ovf/builder.go
builder/virtualbox/ovf/builder.go
+5
-0
builder/virtualbox/ovf/config.go
builder/virtualbox/ovf/config.go
+15
-7
builder/vmware/common/host_ip.go
builder/vmware/common/host_ip.go
+1
-1
builder/vmware/common/host_ip_ifconfig.go
builder/vmware/common/host_ip_ifconfig.go
+1
-1
builder/vmware/common/host_ip_ifconfig_test.go
builder/vmware/common/host_ip_ifconfig_test.go
+1
-1
builder/vmware/common/host_ip_vmnetnatconf.go
builder/vmware/common/host_ip_vmnetnatconf.go
+2
-4
builder/vmware/common/host_ip_vmnetnatconf_test.go
builder/vmware/common/host_ip_vmnetnatconf_test.go
+1
-1
builder/vmware/common/step_type_boot_command.go
builder/vmware/common/step_type_boot_command.go
+12
-11
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+5
-1
builder/vmware/vmx/builder.go
builder/vmware/vmx/builder.go
+5
-0
builder/vmware/vmx/config.go
builder/vmware/vmx/config.go
+8
-0
No files found.
builder/virtualbox/
iso
/step_type_boot_command.go
→
builder/virtualbox/
common
/step_type_boot_command.go
View file @
e93697ab
package
iso
package
common
import
(
import
(
"fmt"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
vboxcommon
"github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"log"
"log"
"strings"
"strings"
...
@@ -23,7 +22,6 @@ type bootCommandTemplateData struct {
...
@@ -23,7 +22,6 @@ type bootCommandTemplateData struct {
// This step "types" the boot command into the VM over VNC.
// This step "types" the boot command into the VM over VNC.
//
//
// Uses:
// Uses:
// config *config
// driver Driver
// driver Driver
// http_port int
// http_port int
// ui packer.Ui
// ui packer.Ui
...
@@ -31,11 +29,14 @@ type bootCommandTemplateData struct {
...
@@ -31,11 +29,14 @@ type bootCommandTemplateData struct {
//
//
// Produces:
// Produces:
// <nothing>
// <nothing>
type
stepTypeBootCommand
struct
{}
type
StepTypeBootCommand
struct
{
BootCommand
[]
string
VMName
string
Tpl
*
packer
.
ConfigTemplate
}
func
(
s
*
stepTypeBootCommand
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
StepTypeBootCommand
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vboxcommon
.
Driver
)
httpPort
:=
state
.
Get
(
"http_port"
)
.
(
uint
)
httpPort
:=
state
.
Get
(
"http_port"
)
.
(
uint
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
...
@@ -43,12 +44,12 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
...
@@ -43,12 +44,12 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
tplData
:=
&
bootCommandTemplateData
{
tplData
:=
&
bootCommandTemplateData
{
"10.0.2.2"
,
"10.0.2.2"
,
httpPort
,
httpPort
,
config
.
VMName
,
s
.
VMName
,
}
}
ui
.
Say
(
"Typing the boot command..."
)
ui
.
Say
(
"Typing the boot command..."
)
for
_
,
command
:=
range
config
.
BootCommand
{
for
_
,
command
:=
range
s
.
BootCommand
{
command
,
err
:=
config
.
t
pl
.
Process
(
command
,
tplData
)
command
,
err
:=
s
.
T
pl
.
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
.
Put
(
"error"
,
err
)
state
.
Put
(
"error"
,
err
)
...
@@ -90,7 +91,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
...
@@ -90,7 +91,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
*
s
tepTypeBootCommand
)
Cleanup
(
multistep
.
StateBag
)
{}
func
(
*
S
tepTypeBootCommand
)
Cleanup
(
multistep
.
StateBag
)
{}
func
scancodes
(
message
string
)
[]
string
{
func
scancodes
(
message
string
)
[]
string
{
// Scancodes reference: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
// Scancodes reference: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
...
...
builder/virtualbox/iso/builder.go
View file @
e93697ab
...
@@ -303,7 +303,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -303,7 +303,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
BootWait
:
b
.
config
.
BootWait
,
BootWait
:
b
.
config
.
BootWait
,
Headless
:
b
.
config
.
Headless
,
Headless
:
b
.
config
.
Headless
,
},
},
new
(
stepTypeBootCommand
),
&
vboxcommon
.
StepTypeBootCommand
{
BootCommand
:
b
.
config
.
BootCommand
,
VMName
:
b
.
config
.
VMName
,
Tpl
:
b
.
config
.
tpl
,
},
&
common
.
StepConnectSSH
{
&
common
.
StepConnectSSH
{
SSHAddress
:
vboxcommon
.
SSHAddress
,
SSHAddress
:
vboxcommon
.
SSHAddress
,
SSHConfig
:
vboxcommon
.
SSHConfigFunc
(
b
.
config
.
SSHConfig
),
SSHConfig
:
vboxcommon
.
SSHConfigFunc
(
b
.
config
.
SSHConfig
),
...
...
builder/virtualbox/ovf/builder.go
View file @
e93697ab
...
@@ -84,6 +84,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -84,6 +84,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
BootWait
:
b
.
config
.
BootWait
,
BootWait
:
b
.
config
.
BootWait
,
Headless
:
b
.
config
.
Headless
,
Headless
:
b
.
config
.
Headless
,
},
},
&
vboxcommon
.
StepTypeBootCommand
{
BootCommand
:
b
.
config
.
BootCommand
,
VMName
:
b
.
config
.
VMName
,
Tpl
:
b
.
config
.
tpl
,
},
&
common
.
StepConnectSSH
{
&
common
.
StepConnectSSH
{
SSHAddress
:
vboxcommon
.
SSHAddress
,
SSHAddress
:
vboxcommon
.
SSHAddress
,
SSHConfig
:
vboxcommon
.
SSHConfigFunc
(
b
.
config
.
SSHConfig
),
SSHConfig
:
vboxcommon
.
SSHConfigFunc
(
b
.
config
.
SSHConfig
),
...
...
builder/virtualbox/ovf/config.go
View file @
e93697ab
...
@@ -24,13 +24,14 @@ type Config struct {
...
@@ -24,13 +24,14 @@ type Config struct {
vboxcommon
.
VBoxManagePostConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxManagePostConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxVersionConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxVersionConfig
`mapstructure:",squash"`
SourcePath
string
`mapstructure:"source_path"`
BootCommand
[]
string
`mapstructure:"boot_command"`
GuestAdditionsMode
string
`mapstructure:"guest_additions_mode"`
SourcePath
string
`mapstructure:"source_path"`
GuestAdditionsPath
string
`mapstructure:"guest_additions_path"`
GuestAdditionsMode
string
`mapstructure:"guest_additions_mode"`
GuestAdditionsURL
string
`mapstructure:"guest_additions_url"`
GuestAdditionsPath
string
`mapstructure:"guest_additions_path"`
GuestAdditionsSHA256
string
`mapstructure:"guest_additions_sha256"`
GuestAdditionsURL
string
`mapstructure:"guest_additions_url"`
VMName
string
`mapstructure:"vm_name"`
GuestAdditionsSHA256
string
`mapstructure:"guest_additions_sha256"`
ImportOpts
string
`mapstructure:"import_opts"`
VMName
string
`mapstructure:"vm_name"`
ImportOpts
string
`mapstructure:"import_opts"`
tpl
*
packer
.
ConfigTemplate
tpl
*
packer
.
ConfigTemplate
}
}
...
@@ -99,6 +100,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
...
@@ -99,6 +100,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
}
}
}
for
i
,
command
:=
range
c
.
BootCommand
{
if
err
:=
c
.
tpl
.
Validate
(
command
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing boot_command[%d]: %s"
,
i
,
err
))
}
}
validates
:=
map
[
string
]
*
string
{
validates
:=
map
[
string
]
*
string
{
"guest_additions_path"
:
&
c
.
GuestAdditionsPath
,
"guest_additions_path"
:
&
c
.
GuestAdditionsPath
,
"guest_additions_url"
:
&
c
.
GuestAdditionsURL
,
"guest_additions_url"
:
&
c
.
GuestAdditionsURL
,
...
...
builder/vmware/
iso
/host_ip.go
→
builder/vmware/
common
/host_ip.go
View file @
e93697ab
package
iso
package
common
// Interface to help find the host IP that is available from within
// Interface to help find the host IP that is available from within
// the VMware virtual machines.
// the VMware virtual machines.
...
...
builder/vmware/
iso
/host_ip_ifconfig.go
→
builder/vmware/
common
/host_ip_ifconfig.go
View file @
e93697ab
package
iso
package
common
import
(
import
(
"bytes"
"bytes"
...
...
builder/vmware/
iso
/host_ip_ifconfig_test.go
→
builder/vmware/
common
/host_ip_ifconfig_test.go
View file @
e93697ab
package
iso
package
common
import
"testing"
import
"testing"
...
...
builder/vmware/
iso
/host_ip_vmnetnatconf.go
→
builder/vmware/
common
/host_ip_vmnetnatconf.go
View file @
e93697ab
package
iso
package
common
import
(
import
(
"bufio"
"bufio"
...
@@ -8,8 +8,6 @@ import (
...
@@ -8,8 +8,6 @@ import (
"os"
"os"
"regexp"
"regexp"
"strings"
"strings"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
)
)
// VMnetNatConfIPFinder finds the IP address of the host machine by
// VMnetNatConfIPFinder finds the IP address of the host machine by
...
@@ -18,7 +16,7 @@ import (
...
@@ -18,7 +16,7 @@ import (
type
VMnetNatConfIPFinder
struct
{}
type
VMnetNatConfIPFinder
struct
{}
func
(
*
VMnetNatConfIPFinder
)
HostIP
()
(
string
,
error
)
{
func
(
*
VMnetNatConfIPFinder
)
HostIP
()
(
string
,
error
)
{
driver
:=
&
vmwcommon
.
Workstation9Driver
{}
driver
:=
&
Workstation9Driver
{}
vmnetnat
:=
driver
.
VmnetnatConfPath
()
vmnetnat
:=
driver
.
VmnetnatConfPath
()
if
vmnetnat
==
""
{
if
vmnetnat
==
""
{
...
...
builder/vmware/
iso
/host_ip_vmnetnatconf_test.go
→
builder/vmware/
common
/host_ip_vmnetnatconf_test.go
View file @
e93697ab
package
iso
package
common
import
"testing"
import
"testing"
...
...
builder/vmware/
iso
/step_type_boot_command.go
→
builder/vmware/
common
/step_type_boot_command.go
View file @
e93697ab
package
iso
package
common
import
(
import
(
"fmt"
"fmt"
"github.com/mitchellh/go-vnc"
"github.com/mitchellh/go-vnc"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"log"
"log"
"net"
"net"
...
@@ -26,18 +25,20 @@ type bootCommandTemplateData struct {
...
@@ -26,18 +25,20 @@ type bootCommandTemplateData struct {
// This step "types" the boot command into the VM over VNC.
// This step "types" the boot command into the VM over VNC.
//
//
// Uses:
// Uses:
// config *config
// http_port int
// http_port int
// ui packer.Ui
// ui packer.Ui
// vnc_port uint
// vnc_port uint
//
//
// Produces:
// Produces:
// <nothing>
// <nothing>
type
stepTypeBootCommand
struct
{}
type
StepTypeBootCommand
struct
{
BootCommand
[]
string
VMName
string
Tpl
*
packer
.
ConfigTemplate
}
func
(
s
*
stepTypeBootCommand
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
StepTypeBootCommand
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
httpPort
:=
state
.
Get
(
"http_port"
)
.
(
uint
)
httpPort
:=
state
.
Get
(
"http_port"
)
.
(
uint
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vncIp
:=
state
.
Get
(
"vnc_ip"
)
.
(
string
)
vncIp
:=
state
.
Get
(
"vnc_ip"
)
.
(
string
)
...
@@ -88,12 +89,12 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
...
@@ -88,12 +89,12 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
tplData
:=
&
bootCommandTemplateData
{
tplData
:=
&
bootCommandTemplateData
{
hostIp
,
hostIp
,
httpPort
,
httpPort
,
config
.
VMName
,
s
.
VMName
,
}
}
ui
.
Say
(
"Typing the boot command over VNC..."
)
ui
.
Say
(
"Typing the boot command over VNC..."
)
for
_
,
command
:=
range
config
.
BootCommand
{
for
_
,
command
:=
range
s
.
BootCommand
{
command
,
err
:=
config
.
t
pl
.
Process
(
command
,
tplData
)
command
,
err
:=
s
.
T
pl
.
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
.
Put
(
"error"
,
err
)
state
.
Put
(
"error"
,
err
)
...
@@ -113,7 +114,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
...
@@ -113,7 +114,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
*
s
tepTypeBootCommand
)
Cleanup
(
multistep
.
StateBag
)
{}
func
(
*
S
tepTypeBootCommand
)
Cleanup
(
multistep
.
StateBag
)
{}
func
vncSendString
(
c
*
vnc
.
ClientConn
,
original
string
)
{
func
vncSendString
(
c
*
vnc
.
ClientConn
,
original
string
)
{
// Scancodes reference: https://github.com/qemu/qemu/blob/master/ui/vnc_keysym.h
// Scancodes reference: https://github.com/qemu/qemu/blob/master/ui/vnc_keysym.h
...
...
builder/vmware/iso/builder.go
View file @
e93697ab
...
@@ -348,7 +348,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -348,7 +348,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
DurationBeforeStop
:
5
*
time
.
Second
,
DurationBeforeStop
:
5
*
time
.
Second
,
Headless
:
b
.
config
.
Headless
,
Headless
:
b
.
config
.
Headless
,
},
},
&
stepTypeBootCommand
{},
&
vmwcommon
.
StepTypeBootCommand
{
BootCommand
:
b
.
config
.
BootCommand
,
VMName
:
b
.
config
.
VMName
,
Tpl
:
b
.
config
.
tpl
,
},
&
common
.
StepConnectSSH
{
&
common
.
StepConnectSSH
{
SSHAddress
:
driver
.
SSHAddress
,
SSHAddress
:
driver
.
SSHAddress
,
SSHConfig
:
vmwcommon
.
SSHConfigFunc
(
&
b
.
config
.
SSHConfig
),
SSHConfig
:
vmwcommon
.
SSHConfigFunc
(
&
b
.
config
.
SSHConfig
),
...
...
builder/vmware/vmx/builder.go
View file @
e93697ab
...
@@ -76,6 +76,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -76,6 +76,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
DurationBeforeStop
:
5
*
time
.
Second
,
DurationBeforeStop
:
5
*
time
.
Second
,
Headless
:
b
.
config
.
Headless
,
Headless
:
b
.
config
.
Headless
,
},
},
&
vmwcommon
.
StepTypeBootCommand
{
BootCommand
:
b
.
config
.
BootCommand
,
VMName
:
b
.
config
.
VMName
,
Tpl
:
b
.
config
.
tpl
,
},
&
common
.
StepConnectSSH
{
&
common
.
StepConnectSSH
{
SSHAddress
:
driver
.
SSHAddress
,
SSHAddress
:
driver
.
SSHAddress
,
SSHConfig
:
vmwcommon
.
SSHConfigFunc
(
&
b
.
config
.
SSHConfig
),
SSHConfig
:
vmwcommon
.
SSHConfigFunc
(
&
b
.
config
.
SSHConfig
),
...
...
builder/vmware/vmx/config.go
View file @
e93697ab
...
@@ -20,6 +20,7 @@ type Config struct {
...
@@ -20,6 +20,7 @@ type Config struct {
vmwcommon
.
ToolsConfig
`mapstructure:",squash"`
vmwcommon
.
ToolsConfig
`mapstructure:",squash"`
vmwcommon
.
VMXConfig
`mapstructure:",squash"`
vmwcommon
.
VMXConfig
`mapstructure:",squash"`
BootCommand
[]
string
`mapstructure:"boot_command"`
FloppyFiles
[]
string
`mapstructure:"floppy_files"`
FloppyFiles
[]
string
`mapstructure:"floppy_files"`
RemoteType
string
`mapstructure:"remote_type"`
RemoteType
string
`mapstructure:"remote_type"`
SkipCompaction
bool
`mapstructure:"skip_compaction"`
SkipCompaction
bool
`mapstructure:"skip_compaction"`
...
@@ -72,6 +73,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
...
@@ -72,6 +73,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
}
}
}
for
i
,
command
:=
range
c
.
BootCommand
{
if
err
:=
c
.
tpl
.
Validate
(
command
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing boot_command[%d]: %s"
,
i
,
err
))
}
}
if
c
.
SourcePath
==
""
{
if
c
.
SourcePath
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"source_path is required"
))
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"source_path is required"
))
}
else
{
}
else
{
...
...
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