github.phpd.cn/hashicorp/packer@v1.3.2/builder/vmware/iso/driver.go (about) 1 package iso 2 3 import ( 4 "fmt" 5 6 vmwcommon "github.com/hashicorp/packer/builder/vmware/common" 7 ) 8 9 // NewDriver returns a new driver implementation for this operating 10 // system, or an error if the driver couldn't be initialized. 11 func NewDriver(config *Config) (vmwcommon.Driver, error) { 12 drivers := []vmwcommon.Driver{} 13 14 if config.RemoteType == "" { 15 return vmwcommon.NewDriver(&config.DriverConfig, &config.SSHConfig) 16 } 17 18 drivers = []vmwcommon.Driver{ 19 &ESX5Driver{ 20 Host: config.RemoteHost, 21 Port: config.RemotePort, 22 Username: config.RemoteUser, 23 Password: config.RemotePassword, 24 PrivateKeyFile: config.RemotePrivateKey, 25 Datastore: config.RemoteDatastore, 26 CacheDatastore: config.RemoteCacheDatastore, 27 CacheDirectory: config.RemoteCacheDirectory, 28 }, 29 } 30 31 errs := "" 32 for _, driver := range drivers { 33 err := driver.Verify() 34 if err == nil { 35 return driver, nil 36 } 37 errs += "* " + err.Error() + "\n" 38 } 39 40 return nil, fmt.Errorf( 41 "Unable to initialize any driver for this platform. The errors\n"+ 42 "from each driver are shown below. Please fix at least one driver\n"+ 43 "to continue:\n%s", errs) 44 }