Ejemplo n.º 1
0
// runWaypointPut invokes the configured plugins to put waypoint data from source to dest.
func runWaypointPut(cmd *commander.Command, args []string) {
	var err error
	if len(args) != 1 {
		fmt.Fprintf(os.Stderr, "failed to put waypoint data :: no destination given\n")
		return
	}
	cfg, _ := config.Get()
	pluginID := args[0]
	destPlugin, err := plugin.GetWaypointer(pluginID, cfg)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get plugin '%v' :: %v\n", pluginID, err)
		return
	}
	wpoint, _ := plugin.GetWaypointer("", cfg)
	waypoints, err := wpoint.(waypoint.Waypointer).GetWaypoint(strings.Split(*region, ","), time.Time{})
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get waypoint :: %v\n", err)
		return
	}
	glog.V(5).Infof("putting %v waypoints", len(waypoints))
	glog.V(20).Infof("%v", waypoints)
	if len(waypoints) > 0 {
		err = destPlugin.(waypoint.Waypointer).PutWaypoint(waypoints)
		if err != nil {
			fmt.Fprintf(os.Stderr, "failed to put waypoints :: %v\n", err)
			return
		}
	}
	fmt.Printf("pushed %v waypoints into %v\n", len(waypoints), pluginID)
}
Ejemplo n.º 2
0
// runWaypointGet invokes the configured plugin and outputs waypoint data.
func runWaypointGet(cmd *commander.Command, args []string) {
	var err error
	cfg, _ := config.Get()
	wpoint, _ := plugin.GetWaypointer("", cfg)

	tafter := time.Time{}
	if *after != "" {
		tafter, err = time.Parse("2006-01-02", *after)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed to get waypoint :: %v\n", err)
			return
		}
	}
	waypoints, err := wpoint.(waypoint.Waypointer).GetWaypoint(strings.Split(*region, ","), tafter)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to get waypoint :: %v", err)
		// FIXME: must return -1, but no way now to check this in test
	}
	glog.V(5).Infof("waypoint get with args '%v' got %d results", args, len(waypoints))
	glog.V(20).Infof("%+v", waypoints)
	fmt.Printf("%v", util.Struct2CSV(waypoints))
}