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
Hide 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:
*
builder/virtualbox-ovf: Boot commands and the HTTP server are supported.
[GH-1169]
*
builder/vmware: VMware Player 6 is now supported. [GH-1168]
*
builder/vmware-vmx: Boot commands and the HTTP server are supported.
[GH-1169]
IMPROVEMENTS:
...
...
builder/vmware/common/run_config.go
View file @
759c4648
package
common
import
(
"errors"
"fmt"
"time"
...
...
@@ -11,6 +12,10 @@ type RunConfig struct {
Headless
bool
`mapstructure:"headless"`
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
``
}
...
...
@@ -19,8 +24,17 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
c
.
RawBootWait
=
"10s"
}
if
c
.
HTTPPortMin
==
0
{
c
.
HTTPPortMin
=
8000
}
if
c
.
HTTPPortMax
==
0
{
c
.
HTTPPortMax
=
9000
}
templates
:=
map
[
string
]
*
string
{
"boot_wait"
:
&
c
.
RawBootWait
,
"boot_wait"
:
&
c
.
RawBootWait
,
"http_directory"
:
&
c
.
HTTPDir
,
}
var
err
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
}
builder/vmware/
iso
/step_http_server.go
→
builder/vmware/
common
/step_http_server.go
View file @
759c4648
package
iso
package
common
import
(
"fmt"
...
...
@@ -15,28 +15,30 @@ import (
// template.
//
// Uses:
// config *config
// ui packer.Ui
//
// Produces:
// 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
}
func
(
s
*
stepHTTPServer
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
func
(
s
*
StepHTTPServer
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
var
httpPort
uint
=
0
if
config
.
HTTPDir
==
""
{
if
s
.
HTTPDir
==
""
{
state
.
Put
(
"http_port"
,
httpPort
)
return
multistep
.
ActionContinue
}
// Find an available TCP port for our HTTP server
var
httpAddr
string
portRange
:=
int
(
config
.
HTTPPortMax
-
config
.
HTTPPortMin
)
portRange
:=
int
(
s
.
HTTPPortMax
-
s
.
HTTPPortMin
)
for
{
var
err
error
var
offset
uint
=
0
...
...
@@ -46,7 +48,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
offset
=
uint
(
rand
.
Intn
(
portRange
))
}
httpPort
=
offset
+
config
.
HTTPPortMin
httpPort
=
offset
+
s
.
HTTPPortMin
httpAddr
=
fmt
.
Sprintf
(
":%d"
,
httpPort
)
log
.
Printf
(
"Trying port: %d"
,
httpPort
)
s
.
l
,
err
=
net
.
Listen
(
"tcp"
,
httpAddr
)
...
...
@@ -58,7 +60,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Say
(
fmt
.
Sprintf
(
"Starting HTTP server on port %d"
,
httpPort
))
// 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
}
go
server
.
Serve
(
s
.
l
)
...
...
@@ -68,7 +70,7 @@ func (s *stepHTTPServer) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionContinue
}
func
(
s
*
s
tepHTTPServer
)
Cleanup
(
multistep
.
StateBag
)
{
func
(
s
*
S
tepHTTPServer
)
Cleanup
(
multistep
.
StateBag
)
{
if
s
.
l
!=
nil
{
// Close the listener so that the HTTP server stops
s
.
l
.
Close
()
...
...
builder/vmware/iso/builder.go
View file @
759c4648
...
...
@@ -41,9 +41,6 @@ type config struct {
ISOChecksumType
string
`mapstructure:"iso_checksum_type"`
ISOUrls
[]
string
`mapstructure:"iso_urls"`
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"`
SkipCompaction
bool
`mapstructure:"skip_compaction"`
VMXTemplatePath
string
`mapstructure:"vmx_template_path"`
...
...
@@ -115,14 +112,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
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
{
b
.
config
.
VNCPortMin
=
5900
}
...
...
@@ -147,7 +136,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
templates
:=
map
[
string
]
*
string
{
"disk_name"
:
&
b
.
config
.
DiskName
,
"guest_os_type"
:
&
b
.
config
.
GuestOSType
,
"http_directory"
:
&
b
.
config
.
HTTPDir
,
"iso_checksum"
:
&
b
.
config
.
ISOChecksum
,
"iso_checksum_type"
:
&
b
.
config
.
ISOChecksumType
,
"iso_url"
:
&
b
.
config
.
RawSingleISOUrl
,
...
...
@@ -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
==
""
{
errs
=
packer
.
MultiErrorAppend
(
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
CustomData
:
b
.
config
.
VMXData
,
},
&
vmwcommon
.
StepSuppressMessages
{},
&
stepHTTPServer
{},
&
vmwcommon
.
StepHTTPServer
{
HTTPDir
:
b
.
config
.
HTTPDir
,
HTTPPortMin
:
b
.
config
.
HTTPPortMin
,
HTTPPortMax
:
b
.
config
.
HTTPPortMax
,
},
&
stepConfigureVNC
{},
&
StepRegister
{},
&
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
&
common
.
StepCreateFloppy
{
Files
:
b
.
config
.
FloppyFiles
,
},
&
vmwcommon
.
StepHTTPServer
{
HTTPDir
:
b
.
config
.
HTTPDir
,
HTTPPortMin
:
b
.
config
.
HTTPPortMin
,
HTTPPortMax
:
b
.
config
.
HTTPPortMax
,
},
&
StepCloneVMX
{
OutputDir
:
b
.
config
.
OutputDir
,
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