Esempio n. 1
0
// Info - return info about donut configuration
func (donut API) Info() (nodeDiskMap map[string][]string, err error) {
	nodeDiskMap = make(map[string][]string)
	for nodeName, node := range donut.nodes {
		disks, err := node.ListDisks()
		if err != nil {
			return nil, iodine.New(err, nil)
		}
		diskList := make([]string, len(disks))
		for diskOrder, disk := range disks {
			diskList[diskOrder] = disk.GetPath()
		}
		nodeDiskMap[nodeName] = diskList
	}
	return nodeDiskMap, nil
}
Esempio n. 2
0
// Info - return info about donut configuration
func (donut API) Info() (nodeDiskMap map[string][]string, err *probe.Error) {
	nodeDiskMap = make(map[string][]string)
	for nodeName, n := range donut.nodes {
		disks, err := n.ListDisks()
		if err != nil {
			return nil, err.Trace()
		}
		diskList := make([]string, len(disks))
		for diskOrder, disk := range disks {
			diskList[diskOrder] = disk.GetPath()
		}
		nodeDiskMap[nodeName] = diskList
	}
	return nodeDiskMap, nil
}
Esempio n. 3
0
// SaveConfig - save donut configuration
func (donut API) SaveConfig() error {
	nodeDiskMap := make(map[string][]string)
	for hostname, node := range donut.nodes {
		disks, err := node.ListDisks()
		if err != nil {
			return iodine.New(err, nil)
		}
		for order, disk := range disks {
			donutConfigPath := filepath.Join(donut.config.DonutName, donutConfig)
			donutConfigWriter, err := disk.CreateFile(donutConfigPath)
			defer donutConfigWriter.Close()
			if err != nil {
				return iodine.New(err, nil)
			}
			nodeDiskMap[hostname][order] = disk.GetPath()
			jenc := json.NewEncoder(donutConfigWriter)
			if err := jenc.Encode(nodeDiskMap); err != nil {
				return iodine.New(err, nil)
			}
		}
	}
	return nil
}