Beispiel #1
0
// nodesForVolCreate returns a list of Nodes which volume create touches
func nodesForVolCreate(req *volume.VolCreateRequest) ([]uuid.UUID, error) {
	var nodes []uuid.UUID

	for _, b := range req.Bricks {

		// Bricks specified can have one of the following formats:
		// <peer-uuid>:<brick-path>
		// <ip>:<port>:<brick-path>
		// <ip>:<brick-path>
		// TODO: Peer names, as of today, aren't unique. Support it ?
		// TODO: Change API to have host and path as separate fields

		host, _, err := utils.ParseHostAndBrickPath(b)
		if err != nil {
			return nil, err
		}

		id := uuid.Parse(host)
		if id == nil {
			// Host specified is IP or IP:port
			id, err = peer.GetPeerIDByAddrF(host)
			if err != nil {
				return nil, err
			}
		}

		nodes = append(nodes, id)
	}
	return nodes, nil
}
Beispiel #2
0
// NewBrickEntries creates the brick list
func NewBrickEntries(bricks []string) ([]Brickinfo, error) {
	var b []Brickinfo
	var b1 Brickinfo
	var e error
	for _, brick := range bricks {
		hostname, path, err := utils.ParseHostAndBrickPath(brick)
		if err != nil {
			return nil, err
		}
		b1.Hostname = hostname
		b1.Path, e = absFilePath(path)
		if e != nil {
			log.Error("Failed to convert the brickpath to absolute path")
			return nil, errors.ErrBrickPathConvertFail
		}

		b = append(b, b1)
	}
	return b, nil
}
Beispiel #3
0
// NewBrickEntries creates the brick list
func NewBrickEntries(bricks []string) ([]brick.Brickinfo, error) {
	var brickInfos []brick.Brickinfo
	var binfo brick.Brickinfo

	for _, b := range bricks {
		host, path, e := utils.ParseHostAndBrickPath(b)
		if e != nil {
			return nil, e
		}

		binfo.Path, e = absFilePath(path)
		if e != nil {
			log.Error("Failed to convert the brickpath to absolute path")
			return nil, e
		}

		u := uuid.Parse(host)
		if u != nil {
			// Host specified is UUID
			binfo.ID = u
			p, e := peer.GetPeerF(host)
			if e != nil {
				return nil, e
			}
			binfo.Hostname = p.Addresses[0]
		} else {
			binfo.ID, e = peer.GetPeerIDByAddrF(host)
			if e != nil {
				return nil, e
			}
			binfo.Hostname = host
		}

		brickInfos = append(brickInfos, binfo)
	}
	return brickInfos, nil
}