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
759c4648
Commit
759c4648
authored
Sep 05, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware-vmx: support http files
parent
bf42ff9e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
29 deletions
+44
-29
CHANGELOG.md
CHANGELOG.md
+2
-0
builder/vmware/common/run_config.go
builder/vmware/common/run_config.go
+20
-1
builder/vmware/common/step_http_server.go
builder/vmware/common/step_http_server.go
+12
-10
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+5
-18
builder/vmware/vmx/builder.go
builder/vmware/vmx/builder.go
+5
-0
No files found.
CHANGELOG.md
View file @
759c4648
...
@@ -21,6 +21,8 @@ FEATURES:
...
@@ -21,6 +21,8 @@ FEATURES:
*
builder/virtualbox-ovf: Boot commands and the HTTP server are supported.
*
builder/virtualbox-ovf: Boot commands and the HTTP server are supported.
[GH-1169]
[GH-1169]
*
builder/vmware: VMware Player 6 is now supported. [GH-1168]
*
builder/vmware: VMware Player 6 is now supported. [GH-1168]
*
builder/vmware-vmx: Boot commands and the HTTP server are supported.
[GH-1169]
IMPROVEMENTS:
IMPROVEMENTS:
...
...
builder/vmware/common/run_config.go
View file @
759c4648
package
common
package
common
import
(
import
(
"errors"
"fmt"
"fmt"
"time"
"time"
...
@@ -11,6 +12,10 @@ type RunConfig struct {
...
@@ -11,6 +12,10 @@ type RunConfig struct {
Headless
bool
`mapstructure:"headless"`
Headless
bool
`mapstructure:"headless"`
RawBootWait
string
`mapstructure:"boot_wait"`
RawBootWait
string
`mapstructure:"boot_wait"`
HTTPDir
string
`mapstructure:"http_directory"`
HTTPPortMin
uint
`mapstructure:"http_port_min"`
HTTPPortMax
uint
`mapstructure:"http_port_max"`
BootWait
time
.
Duration
``
BootWait
time
.
Duration
``
}
}
...
@@ -19,8 +24,17 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
...
@@ -19,8 +24,17 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
c
.
RawBootWait
=
"10s"
c
.
RawBootWait
=
"10s"
}
}
if
c
.
HTTPPortMin
==
0
{
c
.
HTTPPortMin
=
8000
}
if
c
.
HTTPPortMax
==
0
{
c
.
HTTPPortMax
=
9000
}
templates
:=
map
[
string
]
*
string
{
templates
:=
map
[
string
]
*
string
{
"boot_wait"
:
&
c
.
RawBootWait
,
"boot_wait"
:
&
c
.
RawBootWait
,
"http_directory"
:
&
c
.
HTTPDir
,
}
}
var
err
error
var
err
error
...
@@ -40,5 +54,10 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
...
@@ -40,5 +54,10 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
}
}
}
}
if
c
.
HTTPPortMin
>
c
.
HTTPPortMax
{
errs
=
append
(
errs
,
errors
.
New
(
"http_port_min must be less than http_port_max"
))
}
return
errs
return
errs
}
}
builder/vmware/
iso
/step_http_server.go
→
builder/vmware/
common
/step_http_server.go
View file @
759c4648
package
iso
package
common
import
(
import
(
"fmt"
"fmt"
...
@@ -15,28 +15,30 @@ import (
...
@@ -15,28 +15,30 @@ import (
// template.
// template.
//
//
// Uses:
// Uses:
// config *config
// ui packer.Ui
// ui packer.Ui
//
//
// Produces:
// Produces:
// http_port int - The port the HTTP server started on.
// http_port int - The port the HTTP server started on.
type
stepHTTPServer
struct
{
type
StepHTTPServer
struct
{
HTTPDir
string
HTTPPortMin
uint
HTTPPortMax
uint
l
net
.
Listener
l
net
.
Listener
}
}
func
(
s
*
stepHTTPServer
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
StepHTTPServer
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
var
httpPort
uint
=
0
var
httpPort
uint
=
0
if
config
.
HTTPDir
==
""
{
if
s
.
HTTPDir
==
""
{
state
.
Put
(
"http_port"
,
httpPort
)
state
.
Put
(
"http_port"
,
httpPort
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
// Find an available TCP port for our HTTP server
// Find an available TCP port for our HTTP server
var
httpAddr
string
var
httpAddr
string
portRange
:=
int
(
config
.
HTTPPortMax
-
config
.
HTTPPortMin
)
portRange
:=
int
(
s
.
HTTPPortMax
-
s
.
HTTPPortMin
)
for
{
for
{
var
err
error
var
err
error
var
offset
uint
=
0
var
offset
uint
=
0
...
@@ -46,7 +48,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -46,7 +48,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
offset
=
uint
(
rand
.
Intn
(
portRange
))
offset
=
uint
(
rand
.
Intn
(
portRange
))
}
}
httpPort
=
offset
+
config
.
HTTPPortMin
httpPort
=
offset
+
s
.
HTTPPortMin
httpAddr
=
fmt
.
Sprintf
(
":%d"
,
httpPort
)
httpAddr
=
fmt
.
Sprintf
(
":%d"
,
httpPort
)
log
.
Printf
(
"Trying port: %d"
,
httpPort
)
log
.
Printf
(
"Trying port: %d"
,
httpPort
)
s
.
l
,
err
=
net
.
Listen
(
"tcp"
,
httpAddr
)
s
.
l
,
err
=
net
.
Listen
(
"tcp"
,
httpAddr
)
...
@@ -58,7 +60,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -58,7 +60,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Say
(
fmt
.
Sprintf
(
"Starting HTTP server on port %d"
,
httpPort
))
ui
.
Say
(
fmt
.
Sprintf
(
"Starting HTTP server on port %d"
,
httpPort
))
// Start the HTTP server and run it in the background
// Start the HTTP server and run it in the background
fileServer
:=
http
.
FileServer
(
http
.
Dir
(
config
.
HTTPDir
))
fileServer
:=
http
.
FileServer
(
http
.
Dir
(
s
.
HTTPDir
))
server
:=
&
http
.
Server
{
Addr
:
httpAddr
,
Handler
:
fileServer
}
server
:=
&
http
.
Server
{
Addr
:
httpAddr
,
Handler
:
fileServer
}
go
server
.
Serve
(
s
.
l
)
go
server
.
Serve
(
s
.
l
)
...
@@ -68,7 +70,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -68,7 +70,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
s
*
s
tepHTTPServer
)
Cleanup
(
multistep
.
StateBag
)
{
func
(
s
*
S
tepHTTPServer
)
Cleanup
(
multistep
.
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/iso/builder.go
View file @
759c4648
...
@@ -41,9 +41,6 @@ type config struct {
...
@@ -41,9 +41,6 @@ type config struct {
ISOChecksumType
string
`mapstructure:"iso_checksum_type"`
ISOChecksumType
string
`mapstructure:"iso_checksum_type"`
ISOUrls
[]
string
`mapstructure:"iso_urls"`
ISOUrls
[]
string
`mapstructure:"iso_urls"`
VMName
string
`mapstructure:"vm_name"`
VMName
string
`mapstructure:"vm_name"`
HTTPDir
string
`mapstructure:"http_directory"`
HTTPPortMin
uint
`mapstructure:"http_port_min"`
HTTPPortMax
uint
`mapstructure:"http_port_max"`
BootCommand
[]
string
`mapstructure:"boot_command"`
BootCommand
[]
string
`mapstructure:"boot_command"`
SkipCompaction
bool
`mapstructure:"skip_compaction"`
SkipCompaction
bool
`mapstructure:"skip_compaction"`
VMXTemplatePath
string
`mapstructure:"vmx_template_path"`
VMXTemplatePath
string
`mapstructure:"vmx_template_path"`
...
@@ -115,14 +112,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
...
@@ -115,14 +112,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
b
.
config
.
VMName
=
fmt
.
Sprintf
(
"packer-%s"
,
b
.
config
.
PackerBuildName
)
b
.
config
.
VMName
=
fmt
.
Sprintf
(
"packer-%s"
,
b
.
config
.
PackerBuildName
)
}
}
if
b
.
config
.
HTTPPortMin
==
0
{
b
.
config
.
HTTPPortMin
=
8000
}
if
b
.
config
.
HTTPPortMax
==
0
{
b
.
config
.
HTTPPortMax
=
9000
}
if
b
.
config
.
VNCPortMin
==
0
{
if
b
.
config
.
VNCPortMin
==
0
{
b
.
config
.
VNCPortMin
=
5900
b
.
config
.
VNCPortMin
=
5900
}
}
...
@@ -147,7 +136,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
...
@@ -147,7 +136,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
templates
:=
map
[
string
]
*
string
{
templates
:=
map
[
string
]
*
string
{
"disk_name"
:
&
b
.
config
.
DiskName
,
"disk_name"
:
&
b
.
config
.
DiskName
,
"guest_os_type"
:
&
b
.
config
.
GuestOSType
,
"guest_os_type"
:
&
b
.
config
.
GuestOSType
,
"http_directory"
:
&
b
.
config
.
HTTPDir
,
"iso_checksum"
:
&
b
.
config
.
ISOChecksum
,
"iso_checksum"
:
&
b
.
config
.
ISOChecksum
,
"iso_checksum_type"
:
&
b
.
config
.
ISOChecksumType
,
"iso_checksum_type"
:
&
b
.
config
.
ISOChecksumType
,
"iso_url"
:
&
b
.
config
.
RawSingleISOUrl
,
"iso_url"
:
&
b
.
config
.
RawSingleISOUrl
,
...
@@ -195,11 +183,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
...
@@ -195,11 +183,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
}
}
}
}
if
b
.
config
.
HTTPPortMin
>
b
.
config
.
HTTPPortMax
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"http_port_min must be less than http_port_max"
))
}
if
b
.
config
.
ISOChecksumType
==
""
{
if
b
.
config
.
ISOChecksumType
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"The iso_checksum_type must be specified."
))
errs
,
errors
.
New
(
"The iso_checksum_type must be specified."
))
...
@@ -340,7 +323,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -340,7 +323,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
CustomData
:
b
.
config
.
VMXData
,
CustomData
:
b
.
config
.
VMXData
,
},
},
&
vmwcommon
.
StepSuppressMessages
{},
&
vmwcommon
.
StepSuppressMessages
{},
&
stepHTTPServer
{},
&
vmwcommon
.
StepHTTPServer
{
HTTPDir
:
b
.
config
.
HTTPDir
,
HTTPPortMin
:
b
.
config
.
HTTPPortMin
,
HTTPPortMax
:
b
.
config
.
HTTPPortMax
,
},
&
stepConfigureVNC
{},
&
stepConfigureVNC
{},
&
StepRegister
{},
&
StepRegister
{},
&
vmwcommon
.
StepRun
{
&
vmwcommon
.
StepRun
{
...
...
builder/vmware/vmx/builder.go
View file @
759c4648
...
@@ -62,6 +62,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -62,6 +62,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
common
.
StepCreateFloppy
{
&
common
.
StepCreateFloppy
{
Files
:
b
.
config
.
FloppyFiles
,
Files
:
b
.
config
.
FloppyFiles
,
},
},
&
vmwcommon
.
StepHTTPServer
{
HTTPDir
:
b
.
config
.
HTTPDir
,
HTTPPortMin
:
b
.
config
.
HTTPPortMin
,
HTTPPortMax
:
b
.
config
.
HTTPPortMax
,
},
&
StepCloneVMX
{
&
StepCloneVMX
{
OutputDir
:
b
.
config
.
OutputDir
,
OutputDir
:
b
.
config
.
OutputDir
,
Path
:
b
.
config
.
SourcePath
,
Path
:
b
.
config
.
SourcePath
,
...
...
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