Пример #1
0
func main() {
	flag.Parse()

	if help {
		cli.Usage()
		os.Exit(0)
	}

	if len(flag.Args()) <= 0 {
		cli.Usage()
		os.Exit(0)
	}

	allocations := flag.Args()
	alloc, _ := strconv.ParseInt(allocations[0], 10, 64)

	err := freeAlloc(alloc)
	if err != nil {
		cli.PrintError(fmt.Sprintf("Unable to free allocation #%d. Allocation does not exsist.", alloc), err)
		os.Exit(1)
	} else {
		fmt.Println(fmt.Sprintf("Freed allocation #%d.", alloc))
	}

}
Пример #2
0
func main() {
	var error error
	if len(allocationList) != 0 && numNodes != 0 {
		hclient.PrintError("Cannot use node list, and number of nodes option at the same time.", errors.New("Flag contradiction"))
		os.Exit(1)
	} else if (len(allocationList) == 0 && numNodes == 0 && timeIncrease == 0 && freeAlloc == 0) || help {
		hclient.Usage()
		os.Exit(0)
	}

	if bs, error = hallocC.SetupClient("heckle"); error != nil {
		hclient.PrintError("Failed to setup client in halloc.", errors.New("Client Setup Failed"))
		os.Exit(1)
	}

	if timeIncrease != 0 {
		requestTimeIncrease()
	}

	if numNodes != 0 {
		allocationNumber = requestNumber()
		pollForStatus()
	} else if len(allocationList) != 0 {
		allocationNumber = requestList()
		pollForStatus()
	}
}
Пример #3
0
func main() {
	flag.Parse()
	if help || minutesTimeout < 1 {
		fclient.Usage()
		os.Exit(0)
	}

	comm, err := fclient.NewClient()
	if err != nil {
		fclient.PrintError("Failed to setup communcation", err)
		os.Exit(1)
	}

	secondsTimeout := minutesTimeout * 60 * 1000000000
	cancelTime := time.Now().Add(time.Duration(secondsTimeout))
	addresses := flag.Args()

	bs, err := comm.SetupClient("flunky")

	bs.DebugLog(fmt.Sprintf("Allocating hosts: %s", flag.Args()))

	if image == "" {
		fclient.PrintError("-i option is required\n", errors.New("wrong arg"))
		fclient.Usage()
		os.Exit(1)
	}

	cm := new(ctlmsg)
	cm.Image = image
	cm.Addresses = addresses
	// FIXME: need to add in extradata
	_, err = bs.PostServer("/ctl", cm)
	if err != nil {
		fclient.PrintError("Failed to allocate node", err)
		os.Exit(1)
	}

	pollForMessages(cancelTime, addresses, bs)
	fmt.Fprintf(os.Stdout, "Done allocating your nodes. Report failed builds to your system administrator.\n")
}
Пример #4
0
func main() {
	flag.Parse()

	if help {
		cli.Usage()
		os.Exit(0)
	}

	someBytes, err := getStatus()
	if err != nil {
		cli.PrintError("Cannot find the status of nodes in heckle.", err)
		os.Exit(1)
	}

	if len(someBytes) <= 0 {
		cli.PrintError("Your request does not exsist.", errors.New("no data"))
		os.Exit(1)
	}

	if user != " " {
		validList := findValues("OWNER", string(someBytes), user)
		if len(validList) > 0 {
			printStatus(validList)
		} else {
			cli.PrintError("User does not exist in the system", errors.New("Unknown user"))
			os.Exit(1)
		}

	}

	if node != " " {
		validList := findValues("NODE", string(someBytes), node)
		if len(validList) > 0 {
			printStatus(validList)
		} else {
			cli.PrintError("Node is not allocated or does not exsist", errors.New("Missing"))
			os.Exit(1)
		}
	}

	if alloc != " " {
		validList := findValues("ALLOCATION", string(someBytes), alloc)
		if len(validList) > 0 {
			printStatus(validList)
		} else {
			cli.PrintError("Allocation number does not exsist", errors.New("Allocation does not exsist"))
			os.Exit(1)
		}
	}

	if image != " " {
		validList := findValues("IMAGE", string(someBytes), image)
		if len(validList) > 0 {
			printStatus(validList)
		} else {
			cli.PrintError("Image does not exist.", errors.New("No image"))
			os.Exit(1)
		}
	}

	if len(os.Args) < 2 {
		printStatus(string(someBytes))
	}

}
Пример #5
0
func main() {
	flag.Parse()
	clientList := make(map[string]*fnet.BuildServer)

	if help {
		fmt.Println(fmt.Sprintf("Command syntax -- %s daemon1 daemon2 ...daemonN", os.Args[0]))
		fclient.Usage()
		os.Exit(0)
	}

	if len(os.Args) <= 1 {
		fclient.PrintError("No arguments provided", errors.New("no args"))
		fmt.Println(fmt.Sprintf("Command syntax -- %s daemon1 daemon2 ...daemonN", os.Args[0]))
		fclient.Usage()
		os.Exit(1)
	}

	components := flag.Args()
	if len(components) == 0 {
		fclient.PrintError("No clients specified", errors.New("no client"))
		os.Exit(1)
	}

	for _, name := range components {
		comm, err := fclient.NewClient()
		if err != nil {
			fclient.PrintError("Failed to setup communication", err)
			os.Exit(1)
		}
		client, err := comm.SetupClient(name)
		if err != nil {
			fclient.PrintError(fmt.Sprintf("Failed to lookup component %s", name), err)
			os.Exit(1)
		}
		clientList[name] = client
	}

	if stat {
		var statusType Status
		respList := make(map[string]Status)
		for name, client := range clientList {
			resp, err := client.Get("daemon")
			if err != nil {
				fclient.PrintError("Could not get daemon status", err)
				os.Exit(1)
			}
			err = json.Unmarshal(resp, &statusType)
			if err != nil {
				fclient.PrintError(err.Error(), err)
			}
			respList[name] = statusType
		}
		printStatus(respList)
	}

	if dump {
		for name, client := range clientList {
			resp, err := client.Get("dump")
			if err != nil {
				fclient.PrintError(fmt.Sprintf("Failed to contact component %s", name), err)
				os.Exit(1)
			}
			fmt.Println(string(resp))
		}
	}

	if log {
		for name, _ := range clientList {
			logging := logs(name)
			fmt.Println(logging)
		}
	}

	if error_ {
		for name, _ := range clientList {
			errorLogging := logs(name)
			if len(errorLogging) <= 0 {
				fmt.Println(fmt.Sprintf("No errors exsist in the logs for %s", name))
			} else {
				fmt.Println(errorLogging)
			}
		}
	}

}