Ejemplo n.º 1
0
// Info - return info about donut configuration
func (dt donut) Info() (nodeDiskMap map[string][]string, err error) {
	nodeDiskMap = make(map[string][]string)
	for nodeName, node := range dt.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
}
Ejemplo n.º 2
0
// SaveConfig - save donut configuration
func (dt donut) SaveConfig() error {
	nodeDiskMap := make(map[string][]string)
	for hostname, node := range dt.nodes {
		disks, err := node.ListDisks()
		if err != nil {
			return iodine.New(err, nil)
		}
		for order, disk := range disks {
			donutConfigPath := filepath.Join(dt.name, 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
}