Exemple #1
0
// AttachNode - attach node
func (donut API) AttachNode(hostname string, disks []string) *probe.Error {
	if hostname == "" || len(disks) == 0 {
		return probe.NewError(InvalidArgument{})
	}
	n, err := newNode(hostname)
	if err != nil {
		return err.Trace()
	}
	donut.nodes[hostname] = n
	for i, d := range disks {
		newDisk, err := disk.New(d)
		if err != nil {
			continue
		}
		if err := newDisk.MakeDir(donut.config.DonutName); err != nil {
			return err.Trace()
		}
		if err := n.AttachDisk(newDisk, i); err != nil {
			return err.Trace()
		}
	}
	return nil
}
Exemple #2
0
// AttachNode - attach node
func (donut API) AttachNode(hostname string, disks []string) error {
	if hostname == "" || len(disks) == 0 {
		return iodine.New(InvalidArgument{}, nil)
	}
	node, err := newNode(hostname)
	if err != nil {
		return iodine.New(err, nil)
	}
	donut.nodes[hostname] = node
	for i, d := range disks {
		newDisk, err := disk.New(d)
		if err != nil {
			continue
		}
		if err := newDisk.MakeDir(donut.config.DonutName); err != nil {
			return iodine.New(err, nil)
		}
		if err := node.AttachDisk(newDisk, i); err != nil {
			return iodine.New(err, nil)
		}
	}
	return nil
}