예제 #1
0
파일: filestore.go 프로젝트: cheyang/scloud
func (this FileStore) save(host *host.Host) error {

	if rpcClientDriver, ok := host.Driver.(rpc.RpcClientDriver); ok {
		data, err := rpcClientDriver.GetConfigRaw()

		if err != nil {
			return fmt.Errorf("Error getting raw config for driver: %s", err)
		}

		host.RawDriver = data
	}

	data, err := json.MarshalIndent(host, "", "    ")

	if err != nil {
		return err
	}

	hostpath := filepath.Join(this.getMachinesDir(), host.Name)

	if err := os.MkdirAll(hostpath, 0700); err != nil {
		return err
	}

	return this.saveToFile(data, filepath.Join(hostpath, "config.json"))

}