2013-12-24 00:58:41 -05:00
|
|
|
package iso
|
2013-06-06 15:19:38 -04:00
|
|
|
|
|
|
|
import (
|
2013-06-08 00:46:59 -04:00
|
|
|
"fmt"
|
2013-06-06 15:19:38 -04:00
|
|
|
|
2013-12-24 13:31:57 -05:00
|
|
|
vmwcommon "github.com/mitchellh/packer/builder/vmware/common"
|
|
|
|
)
|
2013-06-06 15:19:38 -04:00
|
|
|
|
2013-07-16 17:23:01 -04:00
|
|
|
// NewDriver returns a new driver implementation for this operating
|
|
|
|
// system, or an error if the driver couldn't be initialized.
|
2013-12-24 13:31:57 -05:00
|
|
|
func NewDriver(config *config) (vmwcommon.Driver, error) {
|
|
|
|
drivers := []vmwcommon.Driver{}
|
2013-06-08 00:46:59 -04:00
|
|
|
|
2013-12-25 17:50:12 -05:00
|
|
|
if config.RemoteType == "" {
|
2013-12-27 10:37:39 -05:00
|
|
|
return vmwcommon.NewDriver(&config.DriverConfig, &config.SSHConfig)
|
2013-12-25 17:50:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
drivers = []vmwcommon.Driver{
|
|
|
|
&ESX5Driver{
|
|
|
|
Host: config.RemoteHost,
|
|
|
|
Port: config.RemotePort,
|
|
|
|
Username: config.RemoteUser,
|
|
|
|
Password: config.RemotePassword,
|
|
|
|
Datastore: config.RemoteDatastore,
|
|
|
|
},
|
2013-06-08 00:46:59 -04:00
|
|
|
}
|
|
|
|
|
2013-07-12 19:03:32 -04:00
|
|
|
errs := ""
|
|
|
|
for _, driver := range drivers {
|
|
|
|
err := driver.Verify()
|
|
|
|
if err == nil {
|
|
|
|
return driver, nil
|
|
|
|
}
|
2013-08-01 01:52:36 -04:00
|
|
|
errs += "* " + err.Error() + "\n"
|
2013-06-08 00:46:59 -04:00
|
|
|
}
|
|
|
|
|
2013-08-01 01:52:36 -04:00
|
|
|
return nil, fmt.Errorf(
|
|
|
|
"Unable to initialize any driver for this platform. The errors\n"+
|
|
|
|
"from each driver are shown below. Please fix at least one driver\n"+
|
|
|
|
"to continue:\n%s", errs)
|
2013-07-01 15:17:47 -04:00
|
|
|
}
|