Ejemplo n.º 1
0
func fetch(cmd *cobra.Command, specs []string) {
	c := cli.NewClient(getServerURL())
	if len(specs) == 0 {
		specs = cli.Read(os.Stdin)
	}
	for _, spec := range specs {
		cli.AssertSpec(spec)
		image, _ := c.Post("image", "images", spec)
		cli.JMap(image).Print(jsonout)
	}
}
Ejemplo n.º 2
0
func create(cmd *cobra.Command, specs []string) {
	c := cli.NewClient(server)
	if len(specs) == 0 {
		specs = cli.Read(os.Stdin)
	}

	for _, spec := range specs {
		cli.AssertSpec(spec)
		j := createGuest(c, spec)
		j.Print(jsonout)
	}
}
Ejemplo n.º 3
0
func modify(cmd *cobra.Command, args []string) {
	c := cli.NewClient(server)
	if len(args) == 0 {
		args = cli.Read(os.Stdin)
	}
	if len(args)%2 != 0 {
		log.WithField("num", len(args)).Fatal("expected an even number of args")
	}

	for i := 0; i < len(args); i += 2 {
		id := args[i]
		cli.AssertID(id)
		spec := args[i+1]
		cli.AssertSpec(spec)

		guest := modifyGuest(c, id, spec)
		guest.Print(jsonout)
	}
}
Ejemplo n.º 4
0
func subnetsModify(cmd *cobra.Command, args []string) {
	c := cli.NewClient(server)
	if len(args) == 0 {
		args = cli.Read(os.Stdin)
	}
	if len(args)%2 != 0 {
		log.WithField("num", len(args)).Fatal("expected an even amount of args")
	}

	for i := 0; i < len(args); i += 2 {
		id := args[i]
		cli.AssertID(id)
		spec := args[i+1]
		cli.AssertSpec(spec)

		subnet := modifySubnets(c, id, spec)
		printTreeMap(id, "subnet", subnet)
	}
}