builder/vmware: Fusion suppresses upgrade requests
This commit is contained in:
parent
781332b297
commit
e4f1dcb6f9
|
@ -19,6 +19,7 @@ BUG FIXES:
|
|||
* builder/amazon/chroot: Copying empty directories works. [GH-588]
|
||||
* builder/amazon/chroot: Chroot commands work with shell provisioners. [GH-581]
|
||||
* builder/vmware: VMX modifications are now case-insensitive. [GH-608]
|
||||
* builder/vmware: VMware Fusion won't ask for VM upgrade.
|
||||
|
||||
## 0.3.11 (November 4, 2013)
|
||||
|
||||
|
|
|
@ -405,6 +405,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
},
|
||||
&stepCreateDisk{},
|
||||
&stepCreateVMX{},
|
||||
&stepSuppressMessages{},
|
||||
&stepHTTPServer{},
|
||||
&stepConfigureVNC{},
|
||||
&stepRun{},
|
||||
|
|
|
@ -31,6 +31,10 @@ type Driver interface {
|
|||
// 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
|
||||
|
||||
|
|
|
@ -68,6 +68,10 @@ func (d *ESX5Driver) Register(vmxPathLocal string) error {
|
|||
return d.sh("vim-cmd", "solo/registervm", vmxPath)
|
||||
}
|
||||
|
||||
func (d *ESX5Driver) SuppressMessages(vmxPath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *ESX5Driver) Unregister(vmxPathLocal string) error {
|
||||
vmxPath := filepath.Join(d.outputDir, filepath.Base(vmxPathLocal))
|
||||
return d.sh("vim-cmd", "vmsvc/unregister", vmxPath)
|
||||
|
|
|
@ -3,6 +3,7 @@ package vmware
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
@ -86,6 +87,15 @@ func (d *Fusion5Driver) Stop(vmxPath string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *Fusion5Driver) SuppressMessages(vmxPath string) error {
|
||||
dir := filepath.Dir(vmxPath)
|
||||
base := filepath.Base(vmxPath)
|
||||
base = strings.Replace(base, ".vmx", "", -1)
|
||||
|
||||
plistPath := filepath.Join(dir, base+".plist")
|
||||
return ioutil.WriteFile(plistPath, []byte(fusionSuppressPlist), 0644)
|
||||
}
|
||||
|
||||
func (d *Fusion5Driver) Verify() error {
|
||||
if _, err := os.Stat(d.AppPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -129,3 +139,12 @@ func (d *Fusion5Driver) ToolsIsoPath(k string) string {
|
|||
func (d *Fusion5Driver) DhcpLeasesPath(device string) string {
|
||||
return "/var/db/vmware/vmnet-dhcpd-" + device + ".leases"
|
||||
}
|
||||
|
||||
const fusionSuppressPlist = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>disallowUpgrade</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>`
|
||||
|
|
|
@ -114,6 +114,10 @@ func (d *Player5LinuxDriver) Stop(vmxPath string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *Player5LinuxDriver) SuppressMessages(vmxPath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Player5LinuxDriver) Verify() error {
|
||||
if err := d.findApp(); err != nil {
|
||||
return fmt.Errorf("VMware Player application ('vmplayer') not found in path.")
|
||||
|
|
|
@ -89,6 +89,10 @@ func (d *Workstation9Driver) Stop(vmxPath string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *Workstation9Driver) SuppressMessages(vmxPath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Workstation9Driver) Verify() error {
|
||||
var err error
|
||||
if d.AppPath == "" {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package vmware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"log"
|
||||
)
|
||||
|
||||
// This step suppresses any messages that VMware product might show.
|
||||
type stepSuppressMessages struct{}
|
||||
|
||||
func (s *stepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
|
||||
driver := state.Get("driver").(Driver)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
vmxPath := state.Get("vmx_path").(string)
|
||||
|
||||
log.Println("Suppressing messages in VMX")
|
||||
if err := driver.SuppressMessages(vmxPath); err != nil {
|
||||
err := fmt.Errorf("Error suppressing messages: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
func (s *stepSuppressMessages) Cleanup(state multistep.StateBag) {}
|
Loading…
Reference in New Issue