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
458bfd18
Commit
458bfd18
authored
Dec 24, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: move driver out of ISO
parent
d73cbd37
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
60 additions
and
67 deletions
+60
-67
builder/vmware/common/ssh.go
builder/vmware/common/ssh.go
+2
-2
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+1
-1
builder/vmware/iso/driver.go
builder/vmware/iso/driver.go
+8
-45
builder/vmware/iso/driver_esx5_test.go
builder/vmware/iso/driver_esx5_test.go
+2
-1
builder/vmware/iso/driver_fusion5.go
builder/vmware/iso/driver_fusion5.go
+7
-2
builder/vmware/iso/driver_player5.go
builder/vmware/iso/driver_player5.go
+7
-2
builder/vmware/iso/driver_workstation9.go
builder/vmware/iso/driver_workstation9.go
+7
-2
builder/vmware/iso/guest_ip.go
builder/vmware/iso/guest_ip.go
+3
-1
builder/vmware/iso/remote_driver.go
builder/vmware/iso/remote_driver.go
+5
-1
builder/vmware/iso/step_compact_disk.go
builder/vmware/iso/step_compact_disk.go
+2
-1
builder/vmware/iso/step_configure_vnc.go
builder/vmware/iso/step_configure_vnc.go
+1
-1
builder/vmware/iso/step_create_disk.go
builder/vmware/iso/step_create_disk.go
+2
-1
builder/vmware/iso/step_prepare_tools.go
builder/vmware/iso/step_prepare_tools.go
+2
-1
builder/vmware/iso/step_remote_upload.go
builder/vmware/iso/step_remote_upload.go
+2
-1
builder/vmware/iso/step_run.go
builder/vmware/iso/step_run.go
+3
-2
builder/vmware/iso/step_shutdown.go
builder/vmware/iso/step_shutdown.go
+2
-1
builder/vmware/iso/step_suppress_messages.go
builder/vmware/iso/step_suppress_messages.go
+2
-1
builder/vmware/iso/step_type_boot_command.go
builder/vmware/iso/step_type_boot_command.go
+2
-1
No files found.
builder/vmware/common/ssh.go
View file @
458bfd18
...
...
@@ -12,7 +12,7 @@ import (
"github.com/mitchellh/packer/communicator/ssh"
)
func
sshAddress
(
config
*
SSHConfig
)
func
(
multistep
.
StateBag
)
(
string
,
error
)
{
func
SSHAddressFunc
(
config
*
SSHConfig
)
func
(
multistep
.
StateBag
)
(
string
,
error
)
{
return
func
(
state
multistep
.
StateBag
)
(
string
,
error
)
{
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
...
...
@@ -61,7 +61,7 @@ func sshAddress(config *SSHConfig) func(multistep.StateBag) (string, error) {
}
}
func
sshConfig
(
config
*
SSHConfig
)
func
(
multistep
.
StateBag
)
(
*
gossh
.
ClientConfig
,
error
)
{
func
SSHConfigFunc
(
config
*
SSHConfig
)
func
(
multistep
.
StateBag
)
(
*
gossh
.
ClientConfig
,
error
)
{
return
func
(
state
multistep
.
StateBag
)
(
*
gossh
.
ClientConfig
,
error
)
{
auth
:=
[]
gossh
.
ClientAuth
{
gossh
.
ClientAuthPassword
(
ssh
.
Password
(
config
.
SSHPassword
)),
...
...
builder/vmware/iso/builder.go
View file @
458bfd18
...
...
@@ -399,7 +399,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
stepTypeBootCommand
{},
&
common
.
StepConnectSSH
{
SSHAddress
:
driver
.
SSHAddress
,
SSHConfig
:
sshConfig
,
SSHConfig
:
vmwcommon
.
SSHConfigFunc
(
&
b
.
config
.
SSHConfig
)
,
SSHWaitTimeout
:
b
.
config
.
SSHWaitTimeout
,
NoPty
:
b
.
config
.
SSHSkipRequestPty
,
},
...
...
builder/vmware/iso/driver.go
View file @
458bfd18
...
...
@@ -3,58 +3,21 @@ package iso
import
(
"bytes"
"fmt"
"github.com/mitchellh/multistep"
"log"
"os/exec"
"runtime"
"strings"
)
// A driver is able to talk to VMware, control virtual machines, etc.
type
Driver
interface
{
// CompactDisk compacts a virtual disk.
CompactDisk
(
string
)
error
// CreateDisk creates a virtual disk with the given size.
CreateDisk
(
string
,
string
,
string
)
error
// Checks if the VMX file at the given path is running.
IsRunning
(
string
)
(
bool
,
error
)
// SSHAddress returns the SSH address for the VM that is being
// managed by this driver.
SSHAddress
(
multistep
.
StateBag
)
(
string
,
error
)
// Start starts a VM specified by the path to the VMX given.
Start
(
string
,
bool
)
error
// Stop stops a VM specified by the path to the VMX given.
Stop
(
string
)
error
// SuppressMessages modifies the VMX or surrounding directory so that
// VMware doesn't show any annoying messages.
SuppressMessages
(
string
)
error
// Get the path to the VMware ISO for the given flavor.
ToolsIsoPath
(
string
)
string
// Get the path to the DHCP leases file for the given device.
DhcpLeasesPath
(
string
)
string
// Verify checks to make sure that this driver should function
// properly. This should check that all the files it will use
// appear to exist and so on. If everything is okay, this doesn't
// return an error. Otherwise, this returns an error.
Verify
()
error
}
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
)
// NewDriver returns a new driver implementation for this operating
// system, or an error if the driver couldn't be initialized.
func
NewDriver
(
config
*
config
)
(
Driver
,
error
)
{
drivers
:=
[]
Driver
{}
func
NewDriver
(
config
*
config
)
(
vmwcommon
.
Driver
,
error
)
{
drivers
:=
[]
vmwcommon
.
Driver
{}
if
config
.
RemoteType
!=
""
{
drivers
=
[]
Driver
{
drivers
=
[]
vmwcommon
.
Driver
{
&
ESX5Driver
{
Host
:
config
.
RemoteHost
,
Port
:
config
.
RemotePort
,
...
...
@@ -66,18 +29,18 @@ func NewDriver(config *config) (Driver, error) {
}
else
{
switch
runtime
.
GOOS
{
case
"darwin"
:
drivers
=
[]
Driver
{
drivers
=
[]
vmwcommon
.
Driver
{
&
Fusion5Driver
{
AppPath
:
"/Applications/VMware Fusion.app"
,
},
}
case
"linux"
:
drivers
=
[]
Driver
{
drivers
=
[]
vmwcommon
.
Driver
{
new
(
Workstation9Driver
),
new
(
Player5LinuxDriver
),
}
case
"windows"
:
drivers
=
[]
Driver
{
drivers
=
[]
vmwcommon
.
Driver
{
new
(
Workstation9Driver
),
}
default
:
...
...
builder/vmware/iso/driver_esx5_test.go
View file @
458bfd18
package
iso
import
(
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"testing"
)
func
TestESX5Driver_implDriver
(
t
*
testing
.
T
)
{
var
_
Driver
=
new
(
ESX5Driver
)
var
_
vmwcommon
.
Driver
=
new
(
ESX5Driver
)
}
func
TestESX5Driver_implRemoteDriver
(
t
*
testing
.
T
)
{
...
...
builder/vmware/iso/driver_fusion5.go
View file @
458bfd18
...
...
@@ -2,18 +2,23 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
)
// Fusion5Driver is a driver that can run VMWare Fusion 5.
type
Fusion5Driver
struct
{
// This is the path to the "VMware Fusion.app"
AppPath
string
// SSHConfig are the SSH settings for the Fusion VM
SSHConfig
*
vmwcommon
.
SSHConfig
}
func
(
d
*
Fusion5Driver
)
CompactDisk
(
diskPath
string
)
error
{
...
...
@@ -61,7 +66,7 @@ func (d *Fusion5Driver) IsRunning(vmxPath string) (bool, error) {
}
func
(
d
*
Fusion5Driver
)
SSHAddress
(
state
multistep
.
StateBag
)
(
string
,
error
)
{
return
sshAddress
(
state
)
return
vmwcommon
.
SSHAddressFunc
(
d
.
SSHConfig
)
(
state
)
}
func
(
d
*
Fusion5Driver
)
Start
(
vmxPath
string
,
headless
bool
)
error
{
...
...
builder/vmware/iso/driver_player5.go
View file @
458bfd18
...
...
@@ -2,11 +2,13 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
)
// Player5LinuxDriver is a driver that can run VMware Player 5 on Linux.
...
...
@@ -15,6 +17,9 @@ type Player5LinuxDriver struct {
VdiskManagerPath
string
QemuImgPath
string
VmrunPath
string
// SSHConfig are the SSH settings for the Fusion VM
SSHConfig
*
vmwcommon
.
SSHConfig
}
func
(
d
*
Player5LinuxDriver
)
CompactDisk
(
diskPath
string
)
error
{
...
...
@@ -88,7 +93,7 @@ func (d *Player5LinuxDriver) IsRunning(vmxPath string) (bool, error) {
}
func
(
d
*
Player5LinuxDriver
)
SSHAddress
(
state
multistep
.
StateBag
)
(
string
,
error
)
{
return
sshAddress
(
state
)
return
vmwcommon
.
SSHAddressFunc
(
d
.
SSHConfig
)
(
state
)
}
func
(
d
*
Player5LinuxDriver
)
Start
(
vmxPath
string
,
headless
bool
)
error
{
...
...
builder/vmware/iso/driver_workstation9.go
View file @
458bfd18
...
...
@@ -2,12 +2,14 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
)
// Workstation9Driver is a driver that can run VMware Workstation 9
...
...
@@ -16,6 +18,9 @@ type Workstation9Driver struct {
AppPath
string
VdiskManagerPath
string
VmrunPath
string
// SSHConfig are the SSH settings for the Fusion VM
SSHConfig
*
vmwcommon
.
SSHConfig
}
func
(
d
*
Workstation9Driver
)
CompactDisk
(
diskPath
string
)
error
{
...
...
@@ -63,7 +68,7 @@ func (d *Workstation9Driver) IsRunning(vmxPath string) (bool, error) {
}
func
(
d
*
Workstation9Driver
)
SSHAddress
(
state
multistep
.
StateBag
)
(
string
,
error
)
{
return
sshAddress
(
state
)
return
vmwcommon
.
SSHAddressFunc
(
d
.
SSHConfig
)
(
state
)
}
func
(
d
*
Workstation9Driver
)
Start
(
vmxPath
string
,
headless
bool
)
error
{
...
...
builder/vmware/iso/guest_ip.go
View file @
458bfd18
...
...
@@ -8,6 +8,8 @@ import (
"regexp"
"strings"
"time"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
)
// Interface to help find the IP address of a running virtual machine.
...
...
@@ -19,7 +21,7 @@ type GuestIPFinder interface {
// lease information from the VMware network devices.
type
DHCPLeaseGuestLookup
struct
{
// Driver that is being used (to find leases path)
Driver
Driver
Driver
vmwcommon
.
Driver
// Device that the guest is connected to.
Device
string
...
...
builder/vmware/iso/remote_driver.go
View file @
458bfd18
package
iso
import
(
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
)
type
RemoteDriver
interface
{
Driver
vmwcommon
.
Driver
// UploadISO uploads a local ISO to the remote side and returns the
// new path that should be used in the VMX along with an error if it
...
...
builder/vmware/iso/step_compact_disk.go
View file @
458bfd18
...
...
@@ -3,6 +3,7 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"log"
)
...
...
@@ -22,7 +23,7 @@ type stepCompactDisk struct{}
func
(
stepCompactDisk
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
full_disk_path
:=
state
.
Get
(
"full_disk_path"
)
.
(
string
)
...
...
builder/vmware/iso/step_configure_vnc.go
View file @
458bfd18
...
...
@@ -47,7 +47,7 @@ func (stepConfigureVNC) VNCAddress(portMin, portMax uint) (string, uint) {
func
(
s
*
stepConfigureVNC
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
...
...
builder/vmware/iso/step_create_disk.go
View file @
458bfd18
...
...
@@ -3,6 +3,7 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"path/filepath"
)
...
...
@@ -20,7 +21,7 @@ type stepCreateDisk struct{}
func
(
stepCreateDisk
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
"Creating virtual machine disk"
)
...
...
builder/vmware/iso/step_prepare_tools.go
View file @
458bfd18
...
...
@@ -3,6 +3,7 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"os"
)
...
...
@@ -10,7 +11,7 @@ type stepPrepareTools struct{}
func
(
*
stepPrepareTools
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
if
config
.
ToolsUploadFlavor
==
""
{
return
multistep
.
ActionContinue
...
...
builder/vmware/iso/step_remote_upload.go
View file @
458bfd18
...
...
@@ -3,6 +3,7 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"log"
)
...
...
@@ -15,7 +16,7 @@ type stepRemoteUpload struct {
}
func
(
s
*
stepRemoteUpload
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
remote
,
ok
:=
driver
.
(
RemoteDriver
)
...
...
builder/vmware/iso/step_run.go
View file @
458bfd18
...
...
@@ -3,6 +3,7 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"time"
)
...
...
@@ -26,7 +27,7 @@ type stepRun struct {
func
(
s
*
stepRun
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
vncIp
:=
state
.
Get
(
"vnc_ip"
)
.
(
string
)
...
...
@@ -84,7 +85,7 @@ func (s *stepRun) Run(state multistep.StateBag) multistep.StepAction {
}
func
(
s
*
stepRun
)
Cleanup
(
state
multistep
.
StateBag
)
{
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
// If we started the machine... stop it.
...
...
builder/vmware/iso/step_shutdown.go
View file @
458bfd18
...
...
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"log"
"path/filepath"
...
...
@@ -30,7 +31,7 @@ type stepShutdown struct{}
func
(
s
*
stepShutdown
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
comm
:=
state
.
Get
(
"communicator"
)
.
(
packer
.
Communicator
)
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
...
...
builder/vmware/iso/step_suppress_messages.go
View file @
458bfd18
...
...
@@ -3,6 +3,7 @@ package iso
import
(
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"log"
)
...
...
@@ -11,7 +12,7 @@ import (
type
stepSuppressMessages
struct
{}
func
(
s
*
stepSuppressMessages
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
...
...
builder/vmware/iso/step_type_boot_command.go
View file @
458bfd18
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/mitchellh/go-vnc"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"log"
"net"
...
...
@@ -36,7 +37,7 @@ type stepTypeBootCommand struct{}
func
(
s
*
stepTypeBootCommand
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
httpPort
:=
state
.
Get
(
"http_port"
)
.
(
uint
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vncIp
:=
state
.
Get
(
"vnc_ip"
)
.
(
string
)
...
...
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