Esempio n. 1
0
func (conn VcConn) DatastoreMkdir(dirName string) error {
	_, err := conn.DatastoreLs(dirName)
	if err == nil {
		return nil
	}

	log.Infof("Creating directory %s on datastore %s of vCenter %s... ",
		dirName, conn.driver.Datastore, conn.driver.IP)

	args := []string{"datastore.mkdir"}
	args = conn.AppendConnectionString(args)
	args = append(args, fmt.Sprintf("--ds=%s", conn.driver.Datastore))
	args = append(args, fmt.Sprintf("--dc=%s", conn.driver.Datacenter))
	args = append(args, dirName)
	_, stderr, err := govcOutErr(args...)

	if stderr != "" {
		return errors.NewDatastoreError(conn.driver.Datastore, "mkdir", stderr)
	}

	if err != nil {
		return err
	}

	return nil
}
Esempio n. 2
0
func (conn VcConn) DatastoreLs(path string) (string, error) {
	args := []string{"datastore.ls"}
	args = conn.AppendConnectionString(args)
	args = append(args, fmt.Sprintf("--ds=%s", conn.driver.Datastore))
	args = append(args, fmt.Sprintf("--dc=%s", conn.driver.Datacenter))
	args = append(args, path)
	stdout, stderr, err := govcOutErr(args...)
	if stderr == "" && err == nil {
		return stdout, nil
	}
	return "", errors.NewDatastoreError(conn.driver.Datastore, "ls", stderr)
}
Esempio n. 3
0
func (conn VcConn) DatastoreUpload(localPath, destination string) error {
	stdout, err := conn.DatastoreLs(destination)
	if err == nil && strings.Contains(stdout, B2DISOName) {
		log.Infof("boot2docker ISO already uploaded, skipping upload... ")
		return nil
	}

	log.Infof("Uploading %s to %s on datastore %s of vCenter %s... ",
		localPath, destination, conn.driver.Datastore, conn.driver.IP)

	dsPath := fmt.Sprintf("%s/%s", destination, B2DISOName)
	args := []string{"datastore.upload"}
	args = conn.AppendConnectionString(args)
	args = append(args, fmt.Sprintf("--ds=%s", conn.driver.Datastore))
	args = append(args, fmt.Sprintf("--dc=%s", conn.driver.Datacenter))
	args = append(args, localPath)
	args = append(args, dsPath)
	_, stderr, err := govcOutErr(args...)
	if stderr == "" && err == nil {
		return nil
	}
	return errors.NewDatastoreError(conn.driver.Datacenter, "upload", stderr)
}