Пример #1
0
func SoftCheck() {
	sanity_map := BuildSanitymap()
	for _, check := range sanity_map {
		fmt.Printf("Checking %s...\n", termcolor.Colorize(check.name, termcolor.Cyan, false))
		_, err := Execute(check.cmd_exist, false)
		if err != nil {
			fmt.Printf("%s\n", termcolor.FailureColor("  [ERROR] No "+check.name+" found in your path"))
		} else {
			fmt.Printf("%s\n", termcolor.SuccessColor("  Found "+check.name+" installed"))
			out, err := Execute(check.cmd_version, false)
			if err != nil {
				fmt.Printf("%s\n", termcolor.FailureColor("  [ERROR] Not able to determine your "+check.name+" version"))
			}

			var cur_version string
			if len(string(out)) > 1 {
				cur_version = string(out[:len(string(out))-1])
			} else {
				cur_version = "NIL"
			}
			if cur_version == "NIL" {
				fmt.Printf("%s\n", termcolor.WarnColor("  [Warnning] "+check.name+" version unknown, try install "+check.expect_version+" or newer"))
			} else if IsVersionNewer(cur_version, check.expect_version) {
				fmt.Printf("%s\n", termcolor.SuccessColor("  Detect "+check.name+" version ("+cur_version+") fulfill expected version ("+check.expect_version+")"))
			} else {
				fmt.Printf("%s\n", termcolor.WarnColor("  [Warnning] Detect "+check.name+" version ("+cur_version+") lower than expected ("+check.expect_version+")"))
			}
		}
	}
}
Пример #2
0
func main() {
	app := cli.NewApp()
	app.Name = "bosh-lite"
	app.Usage = "A command line tool to facilitate using Bosh-Lite deployment"
	app.Version = "1.0.0.alpha"
	app.Commands = []cli.Command{
		{
			Name:      "add-route",
			ShortName: "ar",
			Usage:     "add a system route to access the bosh-lite deployed vms",
			Action: func(c *cli.Context) {
				config := configuration.Default()

				fmt.Printf("Adding route for %s through Bosh lite gateway: %s \n",
					termcolor.Colorize(config.IpRange, termcolor.Yellow, true),
					termcolor.Colorize(config.Gateway, termcolor.Cyan, true))

				util.Addroute(config)
			},
		},
		{
			Name:      "check-version",
			ShortName: "cv",
			Usage:     "check all the software required for running bosh-lite and give suggestions",
			Action: func(c *cli.Context) {
				fmt.Printf("%s\n", termcolor.Colorize("Start Checking all your installed software", termcolor.Green, true))
				util.SoftCheck()
			},
		},
		{
			Name:      "generate-manifest",
			ShortName: "gm",
			Usage:     "generate and setup bosh lite manifest(target your bosh-lite director before use this)",
			Action: func(c *cli.Context) {
				fmt.Printf("%s\n", termcolor.Colorize("Start setting up bosh-lite manifest", termcolor.Green, true))
				util.SetupManifest()
			},
		},
	}
	app.Run(os.Args)
}