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
37b92dff
Commit
37b92dff
authored
Apr 22, 2014
by
higebu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unknown command and syntax error of the ESX5Driver
parent
da7dd7f8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
31 deletions
+57
-31
builder/vmware/common/driver.go
builder/vmware/common/driver.go
+3
-0
builder/vmware/common/driver_fusion5.go
builder/vmware/common/driver_fusion5.go
+4
-0
builder/vmware/common/driver_mock.go
builder/vmware/common/driver_mock.go
+8
-0
builder/vmware/common/driver_player5.go
builder/vmware/common/driver_player5.go
+4
-0
builder/vmware/common/driver_workstation9.go
builder/vmware/common/driver_workstation9.go
+4
-0
builder/vmware/iso/driver_esx5.go
builder/vmware/iso/driver_esx5.go
+20
-31
builder/vmware/iso/step_prepare_tools.go
builder/vmware/iso/step_prepare_tools.go
+4
-0
builder/vmware/iso/step_upload_tools.go
builder/vmware/iso/step_upload_tools.go
+10
-0
No files found.
builder/vmware/common/driver.go
View file @
37b92dff
...
@@ -45,6 +45,9 @@ type Driver interface {
...
@@ -45,6 +45,9 @@ type Driver interface {
// Get the path to the VMware ISO for the given flavor.
// Get the path to the VMware ISO for the given flavor.
ToolsIsoPath
(
string
)
string
ToolsIsoPath
(
string
)
string
// Attach the VMware tools ISO
ToolsInstall
()
error
// Get the path to the DHCP leases file for the given device.
// Get the path to the DHCP leases file for the given device.
DhcpLeasesPath
(
string
)
string
DhcpLeasesPath
(
string
)
string
...
...
builder/vmware/common/driver_fusion5.go
View file @
37b92dff
...
@@ -148,6 +148,10 @@ func (d *Fusion5Driver) ToolsIsoPath(k string) string {
...
@@ -148,6 +148,10 @@ func (d *Fusion5Driver) ToolsIsoPath(k string) string {
return
filepath
.
Join
(
d
.
AppPath
,
"Contents"
,
"Library"
,
"isoimages"
,
k
+
".iso"
)
return
filepath
.
Join
(
d
.
AppPath
,
"Contents"
,
"Library"
,
"isoimages"
,
k
+
".iso"
)
}
}
func
(
d
*
Fusion5Driver
)
ToolsInstall
()
error
{
return
nil
}
func
(
d
*
Fusion5Driver
)
DhcpLeasesPath
(
device
string
)
string
{
func
(
d
*
Fusion5Driver
)
DhcpLeasesPath
(
device
string
)
string
{
return
"/var/db/vmware/vmnet-dhcpd-"
+
device
+
".leases"
return
"/var/db/vmware/vmnet-dhcpd-"
+
device
+
".leases"
}
}
...
...
builder/vmware/common/driver_mock.go
View file @
37b92dff
...
@@ -51,6 +51,9 @@ type DriverMock struct {
...
@@ -51,6 +51,9 @@ type DriverMock struct {
ToolsIsoPathFlavor
string
ToolsIsoPathFlavor
string
ToolsIsoPathResult
string
ToolsIsoPathResult
string
ToolsInstallCalled
bool
ToolsInstallErr
error
DhcpLeasesPathCalled
bool
DhcpLeasesPathCalled
bool
DhcpLeasesPathDevice
string
DhcpLeasesPathDevice
string
DhcpLeasesPathResult
string
DhcpLeasesPathResult
string
...
@@ -120,6 +123,11 @@ func (d *DriverMock) ToolsIsoPath(flavor string) string {
...
@@ -120,6 +123,11 @@ func (d *DriverMock) ToolsIsoPath(flavor string) string {
return
d
.
ToolsIsoPathResult
return
d
.
ToolsIsoPathResult
}
}
func
(
d
*
DriverMock
)
ToolsInstall
()
error
{
d
.
ToolsInstallCalled
=
true
return
d
.
ToolsInstallErr
}
func
(
d
*
DriverMock
)
DhcpLeasesPath
(
device
string
)
string
{
func
(
d
*
DriverMock
)
DhcpLeasesPath
(
device
string
)
string
{
d
.
DhcpLeasesPathCalled
=
true
d
.
DhcpLeasesPathCalled
=
true
d
.
DhcpLeasesPathDevice
=
device
d
.
DhcpLeasesPathDevice
=
device
...
...
builder/vmware/common/driver_player5.go
View file @
37b92dff
...
@@ -187,6 +187,10 @@ func (d *Player5LinuxDriver) ToolsIsoPath(flavor string) string {
...
@@ -187,6 +187,10 @@ func (d *Player5LinuxDriver) ToolsIsoPath(flavor string) string {
return
"/usr/lib/vmware/isoimages/"
+
flavor
+
".iso"
return
"/usr/lib/vmware/isoimages/"
+
flavor
+
".iso"
}
}
func
(
d
*
Player5LinuxDriver
)
ToolsInstall
()
error
{
return
nil
}
func
(
d
*
Player5LinuxDriver
)
DhcpLeasesPath
(
device
string
)
string
{
func
(
d
*
Player5LinuxDriver
)
DhcpLeasesPath
(
device
string
)
string
{
return
"/etc/vmware/"
+
device
+
"/dhcpd/dhcpd.leases"
return
"/etc/vmware/"
+
device
+
"/dhcpd/dhcpd.leases"
}
}
builder/vmware/common/driver_workstation9.go
View file @
37b92dff
...
@@ -149,6 +149,10 @@ func (d *Workstation9Driver) ToolsIsoPath(flavor string) string {
...
@@ -149,6 +149,10 @@ func (d *Workstation9Driver) ToolsIsoPath(flavor string) string {
return
workstationToolsIsoPath
(
flavor
)
return
workstationToolsIsoPath
(
flavor
)
}
}
func
(
d
*
Workstation9Driver
)
ToolsInstall
()
error
{
return
nil
}
func
(
d
*
Workstation9Driver
)
DhcpLeasesPath
(
device
string
)
string
{
func
(
d
*
Workstation9Driver
)
DhcpLeasesPath
(
device
string
)
string
{
return
workstationDhcpLeasesPath
(
device
)
return
workstationDhcpLeasesPath
(
device
)
}
}
...
...
builder/vmware/iso/driver_esx5.go
View file @
37b92dff
...
@@ -31,6 +31,7 @@ type ESX5Driver struct {
...
@@ -31,6 +31,7 @@ type ESX5Driver struct {
comm
packer
.
Communicator
comm
packer
.
Communicator
outputDir
string
outputDir
string
vmId
string
}
}
func
(
d
*
ESX5Driver
)
Clone
(
dst
,
src
string
)
error
{
func
(
d
*
ESX5Driver
)
Clone
(
dst
,
src
string
)
error
{
...
@@ -46,9 +47,8 @@ func (d *ESX5Driver) CreateDisk(diskPathLocal string, size string, typeId string
...
@@ -46,9 +47,8 @@ func (d *ESX5Driver) CreateDisk(diskPathLocal string, size string, typeId string
return
d
.
sh
(
"vmkfstools"
,
"-c"
,
size
,
"-d"
,
typeId
,
"-a"
,
"lsilogic"
,
diskPath
)
return
d
.
sh
(
"vmkfstools"
,
"-c"
,
size
,
"-d"
,
typeId
,
"-a"
,
"lsilogic"
,
diskPath
)
}
}
func
(
d
*
ESX5Driver
)
IsRunning
(
vmxPathLocal
string
)
(
bool
,
error
)
{
func
(
d
*
ESX5Driver
)
IsRunning
(
string
)
(
bool
,
error
)
{
vmxPath
:=
filepath
.
Join
(
d
.
outputDir
,
filepath
.
Base
(
vmxPathLocal
))
state
,
err
:=
d
.
run
(
nil
,
"vim-cmd"
,
"vmsvc/power.getstate"
,
d
.
vmId
)
state
,
err
:=
d
.
run
(
nil
,
"vim-cmd"
,
"vmsvc/power.getstate"
,
vmxPath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
...
@@ -56,13 +56,11 @@ func (d *ESX5Driver) IsRunning(vmxPathLocal string) (bool, error) {
...
@@ -56,13 +56,11 @@ func (d *ESX5Driver) IsRunning(vmxPathLocal string) (bool, error) {
}
}
func
(
d
*
ESX5Driver
)
Start
(
vmxPathLocal
string
,
headless
bool
)
error
{
func
(
d
*
ESX5Driver
)
Start
(
vmxPathLocal
string
,
headless
bool
)
error
{
vmxPath
:=
filepath
.
Join
(
d
.
outputDir
,
filepath
.
Base
(
vmxPathLocal
))
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/power.on"
,
d
.
vmId
)
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/power.on"
,
vmxPath
)
}
}
func
(
d
*
ESX5Driver
)
Stop
(
vmxPathLocal
string
)
error
{
func
(
d
*
ESX5Driver
)
Stop
(
vmxPathLocal
string
)
error
{
vmxPath
:=
filepath
.
Join
(
d
.
outputDir
,
filepath
.
Base
(
vmxPathLocal
))
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/power.off"
,
d
.
vmId
)
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/power.off"
,
vmxPath
)
}
}
func
(
d
*
ESX5Driver
)
Register
(
vmxPathLocal
string
)
error
{
func
(
d
*
ESX5Driver
)
Register
(
vmxPathLocal
string
)
error
{
...
@@ -70,7 +68,12 @@ func (d *ESX5Driver) Register(vmxPathLocal string) error {
...
@@ -70,7 +68,12 @@ func (d *ESX5Driver) Register(vmxPathLocal string) error {
if
err
:=
d
.
upload
(
vmxPath
,
vmxPathLocal
);
err
!=
nil
{
if
err
:=
d
.
upload
(
vmxPath
,
vmxPathLocal
);
err
!=
nil
{
return
err
return
err
}
}
return
d
.
sh
(
"vim-cmd"
,
"solo/registervm"
,
vmxPath
)
r
,
err
:=
d
.
run
(
nil
,
"vim-cmd"
,
"solo/registervm"
,
vmxPath
)
if
err
!=
nil
{
return
err
}
d
.
vmId
=
strings
.
TrimRight
(
r
,
"
\n
"
)
return
nil
}
}
func
(
d
*
ESX5Driver
)
SuppressMessages
(
vmxPath
string
)
error
{
func
(
d
*
ESX5Driver
)
SuppressMessages
(
vmxPath
string
)
error
{
...
@@ -78,8 +81,7 @@ func (d *ESX5Driver) SuppressMessages(vmxPath string) error {
...
@@ -78,8 +81,7 @@ func (d *ESX5Driver) SuppressMessages(vmxPath string) error {
}
}
func
(
d
*
ESX5Driver
)
Unregister
(
vmxPathLocal
string
)
error
{
func
(
d
*
ESX5Driver
)
Unregister
(
vmxPathLocal
string
)
error
{
vmxPath
:=
filepath
.
Join
(
d
.
outputDir
,
filepath
.
Base
(
vmxPathLocal
))
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/unregister"
,
d
.
vmId
)
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/unregister"
,
vmxPath
)
}
}
func
(
d
*
ESX5Driver
)
UploadISO
(
localPath
string
)
(
string
,
error
)
{
func
(
d
*
ESX5Driver
)
UploadISO
(
localPath
string
)
(
string
,
error
)
{
...
@@ -105,6 +107,10 @@ func (d *ESX5Driver) ToolsIsoPath(string) string {
...
@@ -105,6 +107,10 @@ func (d *ESX5Driver) ToolsIsoPath(string) string {
return
""
return
""
}
}
func
(
d
*
ESX5Driver
)
ToolsInstall
()
error
{
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/tools.install"
,
d
.
vmId
)
}
func
(
d
*
ESX5Driver
)
DhcpLeasesPath
(
string
)
string
{
func
(
d
*
ESX5Driver
)
DhcpLeasesPath
(
string
)
string
{
return
""
return
""
}
}
...
@@ -168,35 +174,18 @@ func (d *ESX5Driver) SSHAddress(state multistep.StateBag) (string, error) {
...
@@ -168,35 +174,18 @@ func (d *ESX5Driver) SSHAddress(state multistep.StateBag) (string, error) {
return
address
.
(
string
),
nil
return
address
.
(
string
),
nil
}
}
r
,
err
:=
d
.
esxcli
(
"network"
,
"vm"
,
"list"
)
r
,
err
:=
d
.
run
(
nil
,
"vim-cmd"
,
"vmsvc/get.guest"
,
d
.
vmId
,
" | grep -m 1 ipAddress | awk -F'
\"
' '{print $2}'"
)
if
err
!=
nil
{
return
""
,
err
}
record
,
err
:=
r
.
find
(
"Name"
,
config
.
VMName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
wid
:=
record
[
"WorldID"
]
if
wid
==
""
{
return
""
,
errors
.
New
(
"VM WorldID not found"
)
}
r
,
err
=
d
.
esxcli
(
"network"
,
"vm"
,
"port"
,
"list"
,
"-w"
,
wid
)
ipAddress
:=
strings
.
TrimRight
(
r
,
"
\n
"
)
if
err
!=
nil
{
return
""
,
err
}
record
,
err
=
r
.
read
()
if
err
!=
nil
{
return
""
,
err
}
if
record
[
"IPAddress"
]
==
"0.0.0.0
"
{
if
ipAddress
==
"
"
{
return
""
,
errors
.
New
(
"VM network port found, but no IP address"
)
return
""
,
errors
.
New
(
"VM network port found, but no IP address"
)
}
}
address
:=
fmt
.
Sprintf
(
"%s:%d"
,
record
[
"IPAddress"
]
,
config
.
SSHPort
)
address
:=
fmt
.
Sprintf
(
"%s:%d"
,
ipAddress
,
config
.
SSHPort
)
state
.
Put
(
"vm_address"
,
address
)
state
.
Put
(
"vm_address"
,
address
)
return
address
,
nil
return
address
,
nil
}
}
...
...
builder/vmware/iso/step_prepare_tools.go
View file @
37b92dff
...
@@ -13,6 +13,10 @@ func (*stepPrepareTools) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -13,6 +13,10 @@ func (*stepPrepareTools) Run(state multistep.StateBag) multistep.StepAction {
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
if
config
.
RemoteType
==
"esx5"
{
return
multistep
.
ActionContinue
}
if
config
.
ToolsUploadFlavor
==
""
{
if
config
.
ToolsUploadFlavor
==
""
{
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
...
builder/vmware/iso/step_upload_tools.go
View file @
37b92dff
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"fmt"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"os"
"os"
)
)
...
@@ -15,6 +16,15 @@ type stepUploadTools struct{}
...
@@ -15,6 +16,15 @@ type stepUploadTools struct{}
func
(
*
stepUploadTools
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
*
stepUploadTools
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
if
config
.
RemoteType
==
"esx5"
{
if
err
:=
driver
.
ToolsInstall
();
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Couldn't mount VMware tools ISO."
))
}
return
multistep
.
ActionContinue
}
if
config
.
ToolsUploadFlavor
==
""
{
if
config
.
ToolsUploadFlavor
==
""
{
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
...
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