本文整理匯總了Golang中github.com/docker/machine/drivers/vmwarevsphere/errors.NewIncompleteVsphereConfigError函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewIncompleteVsphereConfigError函數的具體用法?Golang NewIncompleteVsphereConfigError怎麽用?Golang NewIncompleteVsphereConfigError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewIncompleteVsphereConfigError函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UpgradeISO
func (d *Driver) UpgradeISO() error {
vcConn := NewVcConn(d)
if _, err := os.Stat(d.ISO); os.IsNotExist(err) {
log.Errorf("Unable to find boot2docker ISO at %s", d.ISO)
return errors.NewIncompleteVsphereConfigError(d.ISO)
}
if err := vcConn.DatastoreUpload(d.ISO, d.MachineName); err != nil {
return err
}
return nil
}
示例2: checkVsphereConfig
func (d *Driver) checkVsphereConfig() error {
if d.IP == "" {
return errors.NewIncompleteVsphereConfigError("vSphere IP")
}
if d.Username == "" {
return errors.NewIncompleteVsphereConfigError("vSphere username")
}
if d.Password == "" {
return errors.NewIncompleteVsphereConfigError("vSphere password")
}
if d.Network == "" {
return errors.NewIncompleteVsphereConfigError("vSphere network")
}
if d.Datastore == "" {
return errors.NewIncompleteVsphereConfigError("vSphere datastore")
}
if d.Datacenter == "" {
return errors.NewIncompleteVsphereConfigError("vSphere datacenter")
}
return nil
}
示例3: Create
// the current implementation does the following:
// 1. check whether the docker directory contains the boot2docker ISO
// 2. generate an SSH keypair and bundle it in a tar.
// 3. create a virtual machine with the boot2docker ISO mounted;
// 4. reconfigure the virtual machine network and disk size;
func (d *Driver) Create() error {
if err := d.checkVsphereConfig(); err != nil {
return err
}
b2dutils := utils.NewB2dUtils("", "")
if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil {
return err
}
log.Infof("Generating SSH Keypair...")
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
return err
}
vcConn := NewVcConn(d)
log.Infof("Uploading Boot2docker ISO ...")
if err := vcConn.DatastoreMkdir(d.MachineName); err != nil {
return err
}
if _, err := os.Stat(d.ISO); os.IsNotExist(err) {
log.Errorf("Unable to find boot2docker ISO at %s", d.ISO)
return errors.NewIncompleteVsphereConfigError(d.ISO)
}
if err := vcConn.DatastoreUpload(d.ISO, d.MachineName); err != nil {
return err
}
isoPath := fmt.Sprintf("%s/%s", d.MachineName, isoFilename)
if err := vcConn.VMCreate(isoPath); err != nil {
return err
}
log.Infof("Configuring the virtual machine %s... ", d.MachineName)
if err := vcConn.VMDiskCreate(); err != nil {
return err
}
if err := vcConn.VMAttachNetwork(); err != nil {
return err
}
if err := d.Start(); err != nil {
return err
}
// Generate a tar keys bundle
if err := d.generateKeyBundle(); err != nil {
return err
}
// Copy SSH keys bundle
if err := vcConn.GuestUpload(B2DUser, B2DPass, path.Join(d.storePath, "userdata.tar"), "/home/docker/userdata.tar"); err != nil {
return err
}
// Expand tar file.
if err := vcConn.GuestStart(B2DUser, B2DPass, "/usr/bin/sudo", "/bin/mv /home/docker/userdata.tar /var/lib/boot2docker/userdata.tar && /usr/bin/sudo tar xf /var/lib/boot2docker/userdata.tar -C /home/docker/ > /var/log/userdata.log 2>&1 && /usr/bin/sudo chown -R docker:staff /home/docker"); err != nil {
return err
}
return nil
}
示例4: Create
// the current implementation does the following:
// 1. check whether the docker directory contains the boot2docker ISO
// 2. generate an SSH keypair and bundle it in a tar.
// 3. create a virtual machine with the boot2docker ISO mounted;
// 4. reconfigure the virtual machine network and disk size;
func (d *Driver) Create() error {
if err := d.checkVsphereConfig(); err != nil {
return err
}
var (
isoURL string
)
b2dutils := utils.NewB2dUtils("", "")
imgPath := utils.GetMachineCacheDir()
commonIsoPath := filepath.Join(imgPath, isoFilename)
// just in case boot2docker.iso has been manually deleted
if _, err := os.Stat(imgPath); os.IsNotExist(err) {
if err := os.Mkdir(imgPath, 0700); err != nil {
return err
}
}
if d.Boot2DockerURL != "" {
isoURL = d.Boot2DockerURL
log.Infof("Downloading boot2docker.iso from %s...", isoURL)
if err := b2dutils.DownloadISO(commonIsoPath, isoFilename, isoURL); err != nil {
return err
}
} else {
// TODO: until vmw tools are merged into b2d master
// we will use the iso from the vmware team
//// todo: check latest release URL, download if it's new
//// until then always use "latest"
//isoURL, err = b2dutils.GetLatestBoot2DockerReleaseURL()
//if err != nil {
// log.Warnf("Unable to check for the latest release: %s", err)
//}
// see https://github.com/boot2docker/boot2docker/pull/747
isoURL := "https://github.com/cloudnativeapps/boot2docker/releases/download/1.5.0-GH747/boot2docker-1.5.0-GH747.iso"
if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) {
log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath)
// just in case boot2docker.iso has been manually deleted
if _, err := os.Stat(imgPath); os.IsNotExist(err) {
if err := os.Mkdir(imgPath, 0700); err != nil {
return err
}
}
if err := b2dutils.DownloadISO(imgPath, isoFilename, isoURL); err != nil {
return err
}
}
isoDest := filepath.Join(d.storePath, isoFilename)
if err := utils.CopyFile(commonIsoPath, isoDest); err != nil {
return err
}
}
log.Infof("Generating SSH Keypair...")
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
return err
}
vcConn := NewVcConn(d)
log.Infof("Uploading Boot2docker ISO ...")
if err := vcConn.DatastoreMkdir(DATASTORE_DIR); err != nil {
return err
}
if _, err := os.Stat(d.ISO); os.IsNotExist(err) {
log.Errorf("Unable to find boot2docker ISO at %s", d.ISO)
return errors.NewIncompleteVsphereConfigError(d.ISO)
}
if err := vcConn.DatastoreUpload(d.ISO); err != nil {
return err
}
isoPath := fmt.Sprintf("%s/%s", DATASTORE_DIR, isoFilename)
if err := vcConn.VmCreate(isoPath); err != nil {
return err
}
log.Infof("Configuring the virtual machine %s... ", d.MachineName)
if err := vcConn.VmDiskCreate(); err != nil {
return err
//.........這裏部分代碼省略.........