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
7fc69828
Commit
7fc69828
authored
Jun 14, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: fix forwarding to work with WinRM
parent
cf570a71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
builder/virtualbox/common/step_forward_ssh.go
builder/virtualbox/common/step_forward_ssh.go
+11
-8
builder/virtualbox/iso/builder.go
builder/virtualbox/iso/builder.go
+1
-1
builder/virtualbox/ovf/builder.go
builder/virtualbox/ovf/builder.go
+1
-1
No files found.
builder/virtualbox/common/step_forward_ssh.go
View file @
7fc69828
...
...
@@ -2,11 +2,13 @@ package common
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
"math/rand"
"net"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/packer"
)
// This step adds a NAT port forwarding definition so that SSH is available
...
...
@@ -19,7 +21,7 @@ import (
//
// Produces:
type
StepForwardSSH
struct
{
GuestPort
uint
CommConfig
*
communicator
.
Config
HostPortMin
uint
HostPortMax
uint
SkipNatMapping
bool
...
...
@@ -30,20 +32,21 @@ func (s *StepForwardSSH) Run(state multistep.StateBag) multistep.StepAction {
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
sshHostPort
:=
s
.
GuestPort
guestPort
:=
s
.
CommConfig
.
Port
()
sshHostPort
:=
guestPort
if
!
s
.
SkipNatMapping
{
log
.
Printf
(
"Looking for available SSH port between %d and %d"
,
s
.
HostPortMin
,
s
.
HostPortMax
)
var
offset
uint
=
0
offset
:
=
0
portRange
:=
int
(
s
.
HostPortMax
-
s
.
HostPortMin
)
if
portRange
>
0
{
// Have to check if > 0 to avoid a panic
offset
=
uint
(
rand
.
Intn
(
portRange
)
)
offset
=
rand
.
Intn
(
portRange
)
}
for
{
sshHostPort
=
offset
+
s
.
HostPortMin
sshHostPort
=
offset
+
int
(
s
.
HostPortMin
)
log
.
Printf
(
"Trying port: %d"
,
sshHostPort
)
l
,
err
:=
net
.
Listen
(
"tcp"
,
fmt
.
Sprintf
(
"127.0.0.1:%d"
,
sshHostPort
))
if
err
==
nil
{
...
...
@@ -57,7 +60,7 @@ func (s *StepForwardSSH) Run(state multistep.StateBag) multistep.StepAction {
command
:=
[]
string
{
"modifyvm"
,
vmName
,
"--natpf1"
,
fmt
.
Sprintf
(
"packerssh,tcp,127.0.0.1,%d,,%d"
,
sshHostPort
,
s
.
G
uestPort
),
fmt
.
Sprintf
(
"packerssh,tcp,127.0.0.1,%d,,%d"
,
sshHostPort
,
g
uestPort
),
}
if
err
:=
driver
.
VBoxManage
(
command
...
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error creating port forwarding rule: %s"
,
err
)
...
...
builder/virtualbox/iso/builder.go
View file @
7fc69828
...
...
@@ -254,7 +254,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
new
(
vboxcommon
.
StepAttachFloppy
),
&
vboxcommon
.
StepForwardSSH
{
GuestPort
:
uint
(
b
.
config
.
SSHConfig
.
Comm
.
SSHPort
)
,
CommConfig
:
&
b
.
config
.
SSHConfig
.
Comm
,
HostPortMin
:
b
.
config
.
SSHHostPortMin
,
HostPortMax
:
b
.
config
.
SSHHostPortMax
,
SkipNatMapping
:
b
.
config
.
SSHSkipNatMapping
,
...
...
builder/virtualbox/ovf/builder.go
View file @
7fc69828
...
...
@@ -83,7 +83,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
new
(
vboxcommon
.
StepAttachFloppy
),
&
vboxcommon
.
StepForwardSSH
{
GuestPort
:
uint
(
b
.
config
.
SSHConfig
.
Comm
.
SSHPort
)
,
CommConfig
:
&
b
.
config
.
SSHConfig
.
Comm
,
HostPortMin
:
b
.
config
.
SSHHostPortMin
,
HostPortMax
:
b
.
config
.
SSHHostPortMax
,
SkipNatMapping
:
b
.
config
.
SSHSkipNatMapping
,
...
...
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