Example #1
0
func generateVolfiles(c transaction.TxnCtx) error {
	var vol volume.Volinfo
	e := c.Get("volinfo", &vol)
	if e != nil {
		return errors.New("failed to get volinfo from context")
	}

	// Creating client and server volfile
	e = volgen.GenerateVolfileFunc(&vol)
	if e != nil {
		c.Logger().WithFields(log.Fields{"error": e.Error(),
			"volume": vol.Name,
		}).Error("failed to generate volfile")
		return e
	}
	return nil
}
Example #2
0
func commitVolumeCreate(vol *volume.Volinfo) (int, error) {
	// Creating client and server volfile
	e := volgen.GenerateVolfileFunc(vol)
	if e != nil {
		log.WithFields(log.Fields{"error": e.Error(),
			"volume": vol.Name,
		}).Error("Failed to generate volfile")
		return http.StatusInternalServerError, e
	}

	e = volume.AddOrUpdateVolumeFunc(vol)
	if e != nil {
		log.WithFields(log.Fields{"error": e.Error(),
			"volume": vol.Name,
		}).Error("Failed to create volume")
		return http.StatusInternalServerError, e
	}
	log.WithField("volume", vol.Name).Debug("NewVolume added to store")
	return 0, nil
}