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
43085e47
Commit
43085e47
authored
Jun 23, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Ability to specify the SSH port with "ssh_port"
parent
9367df4a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
builder/vmware/builder.go
builder/vmware/builder.go
+5
-0
builder/vmware/builder_test.go
builder/vmware/builder_test.go
+28
-0
builder/vmware/step_wait_for_ssh.go
builder/vmware/step_wait_for_ssh.go
+1
-1
No files found.
builder/vmware/builder.go
View file @
43085e47
...
...
@@ -40,6 +40,7 @@ type config struct {
ShutdownTimeout
time
.
Duration
``
SSHUser
string
`mapstructure:"ssh_username"`
SSHPassword
string
`mapstructure:"ssh_password"`
SSHPort
uint
`mapstructure:"ssh_port"`
SSHWaitTimeout
time
.
Duration
``
VMXData
map
[
string
]
string
`mapstructure:"vmx_data"`
VNCPortMin
uint
`mapstructure:"vnc_port_min"`
...
...
@@ -92,6 +93,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b
.
config
.
OutputDir
=
"vmware"
}
if
b
.
config
.
SSHPort
==
0
{
b
.
config
.
SSHPort
=
22
}
// Accumulate any errors
var
err
error
errs
:=
make
([]
error
,
0
)
...
...
builder/vmware/builder_test.go
View file @
43085e47
...
...
@@ -200,6 +200,34 @@ func TestBuilderPrepare_SSHUser(t *testing.T) {
}
}
func
TestBuilderPrepare_SSHPort
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Test with a bad value
delete
(
config
,
"ssh_port"
)
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
if
b
.
config
.
SSHPort
!=
22
{
t
.
Fatalf
(
"bad ssh port: %d"
,
b
.
config
.
SSHPort
)
}
// Test with a good one
config
[
"ssh_port"
]
=
44
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
SSHPort
!=
44
{
t
.
Fatalf
(
"bad ssh port: %d"
,
b
.
config
.
SSHPort
)
}
}
func
TestBuilderPrepare_SSHWaitTimeout
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
builder/vmware/step_wait_for_ssh.go
View file @
43085e47
...
...
@@ -144,7 +144,7 @@ func (s *stepWaitForSSH) waitForSSH(state map[string]interface{}) (packer.Commun
log
.
Printf
(
"Detected IP: %s"
,
ip
)
// Attempt to connect to SSH port
nc
,
err
=
net
.
Dial
(
"tcp"
,
fmt
.
Sprintf
(
"%s:
22"
,
ip
))
nc
,
err
=
net
.
Dial
(
"tcp"
,
fmt
.
Sprintf
(
"%s:
%d"
,
ip
,
config
.
SSHPort
))
if
err
!=
nil
{
log
.
Printf
(
"TCP connection to SSH ip/port failed: %s"
,
err
)
continue
...
...
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