Example #1
0
File: image.go Project: vmware/vic
func NewImageStore(op trace.Operation, s *session.Session, u *url.URL) (*ImageStore, error) {
	dm, err := disk.NewDiskManager(op, s)
	if err != nil {
		return nil, err
	}

	datastores, err := s.Finder.DatastoreList(op, u.Host)
	if err != nil {
		return nil, fmt.Errorf("Host returned error when trying to locate provided datastore %s: %s", u.String(), err.Error())
	}

	if len(datastores) != 1 {
		return nil, fmt.Errorf("Found %d datastores with provided datastore path %s. Cannot create image store.", len(datastores), u)
	}

	ds, err := datastore.NewHelper(op, s, datastores[0], path.Join(u.Path, StorageParentDir))
	if err != nil {
		return nil, err
	}

	vis := &ImageStore{
		dm: dm,
		ds: ds,
		s:  s,
	}

	return vis, nil
}
Example #2
0
File: volume.go Project: vmware/vic
func NewVolumeStore(op trace.Operation, s *session.Session) (*VolumeStore, error) {
	dm, err := disk.NewDiskManager(op, s)
	if err != nil {
		return nil, err
	}

	v := &VolumeStore{
		dm:   dm,
		sess: s,
		ds:   make(map[url.URL]*datastore.Helper),
	}

	return v, nil
}
Example #3
0
func NewVolumeStore(ctx context.Context, s *session.Session) (*VolumeStore, error) {
	dm, err := disk.NewDiskManager(ctx, s)
	if err != nil {
		return nil, err
	}

	v := &VolumeStore{
		dm:   dm,
		sess: s,
		ds:   make(map[url.URL]*datastore.Helper),
	}

	return v, nil
}