Beispiel #1
0
// InstallPlatform loads all components' definitions from local unit files.
// After InstallPlatform, all components will be available for StartPlatform.
func InstallPlatform(b backend.Backend, checkKeys func() error, stateless bool) error {

	if err := checkKeys(); err != nil {
		return err
	}

	if stateless {
		fmt.Println("Warning: With a stateless control plane, `deis logs` will be unavailable.")
		fmt.Println("Additionally, components will need to be configured to use external persistent stores.")
		fmt.Println("See the official Deis documentation for details on running a stateless control plane.")
	}

	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

	go printState(outchan, errchan, 500*time.Millisecond)

	outchan <- utils.DeisIfy("Installing Deis...")

	installDefaultServices(b, stateless, &wg, outchan, errchan)

	wg.Wait()
	close(outchan)

	fmt.Println("Done.")
	fmt.Println()
	if stateless {
		fmt.Println("Please run `deisctl start stateless-platform` to boot up Deis.")
	} else {
		fmt.Println("Please run `deisctl start platform` to boot up Deis.")
	}
	return nil
}
Beispiel #2
0
//UnInstallSwarm uninstall Swarm
func UnInstallSwarm(b backend.Backend) error {
	outchan := make(chan string)
	errchan := make(chan error)
	defer close(outchan)
	defer close(errchan)
	var wg sync.WaitGroup
	go printState(outchan, errchan, 500*time.Millisecond)
	outchan <- utils.DeisIfy("Destroying Swarm...")
	outchan <- fmt.Sprintf("swarm nodes and swarm manager...")
	b.Destroy([]string{"swarm-node", "swarm-manager"}, &wg, outchan, errchan)
	wg.Wait()
	fmt.Println("Done.")
	fmt.Println()
	return nil
}
Beispiel #3
0
//InstallSwarm Installs swarm
func InstallSwarm(b backend.Backend) error {
	outchan := make(chan string)
	errchan := make(chan error)
	defer close(outchan)
	defer close(errchan)
	var wg sync.WaitGroup
	go printState(outchan, errchan, 500*time.Millisecond)
	outchan <- utils.DeisIfy("Installing Swarm...")
	outchan <- fmt.Sprintf("Swarm node and Swarm Manager...")
	b.Create([]string{"swarm-node", "swarm-manager"}, &wg, outchan, errchan)
	wg.Wait()
	fmt.Println("Done.")
	fmt.Println()
	fmt.Println("Please run `deisctl start swarm` to start swarm.")
	return nil
}
Beispiel #4
0
// UninstallPlatform unloads all components' definitions.
// After UninstallPlatform, all components will be unavailable.
func UninstallPlatform(b backend.Backend) error {

	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

	go printState(outchan, errchan, 500*time.Millisecond)

	outchan <- utils.DeisIfy("Uninstalling Deis...")

	uninstallAllServices(b, &wg, outchan, errchan)

	wg.Wait()
	close(outchan)

	fmt.Println("Done.")
	return nil
}
Beispiel #5
0
//StartSwarm starts Swarm Schduler
func StartSwarm(b backend.Backend) error {
	outchan := make(chan string)
	errchan := make(chan error)
	defer close(outchan)
	defer close(errchan)
	var wg sync.WaitGroup
	go printState(outchan, errchan, 500*time.Millisecond)
	outchan <- utils.DeisIfy("Starting Swarm...")
	outchan <- fmt.Sprintf("swarm nodes...")
	b.Start([]string{"swarm-node"}, &wg, outchan, errchan)
	wg.Wait()
	outchan <- fmt.Sprintf("swarm manager...")
	b.Start([]string{"swarm-manager"}, &wg, outchan, errchan)
	wg.Wait()
	fmt.Println("Done.")
	fmt.Println("Please run `deisctl config controller set schedulerModule=swarm` to use the swarm scheduler.")
	return nil
}
Beispiel #6
0
// StopPlatform deactivates all components.
func StopPlatform(b backend.Backend) error {

	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

	go printState(outchan, errchan, 500*time.Millisecond)

	outchan <- utils.DeisIfy("Stopping Deis...")

	stopDefaultServices(b, &wg, outchan, errchan)

	wg.Wait()
	close(outchan)

	fmt.Println("Done.")
	fmt.Println()
	fmt.Println("Please run `deisctl start platform` to restart Deis.")
	return nil
}
Beispiel #7
0
// StartPlatform activates all components.
func StartPlatform(b backend.Backend) error {

	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

	go printState(outchan, errchan, 500*time.Millisecond)

	outchan <- utils.DeisIfy("Starting Deis...")

	startDefaultServices(b, &wg, outchan, errchan)

	wg.Wait()
	close(outchan)

	fmt.Println("Done.")
	fmt.Println()
	fmt.Println("Please use `deis register` to setup an administrator account.")
	return nil
}
Beispiel #8
0
// InstallPlatform loads all components' definitions from local unit files.
// After InstallPlatform, all components will be available for StartPlatform.
func InstallPlatform(b backend.Backend) error {

	if err := checkRequiredKeys(); err != nil {
		return err
	}

	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

	go printState(outchan, errchan, 500*time.Millisecond)

	outchan <- utils.DeisIfy("Installing Deis...")

	installDefaultServices(b, &wg, outchan, errchan)

	wg.Wait()
	close(outchan)

	fmt.Println("Done.")
	fmt.Println()
	fmt.Println("Please run `deisctl start platform` to boot up Deis.")
	return nil
}
Beispiel #9
0
// Command executes the given deisctl command line.
func Command(argv []string) int {
	deisctlMotd := utils.DeisIfy("Deis Control Utility")
	usage := deisctlMotd + `
Usage: deisctl [options] <command> [<args>...]

Commands, use "deisctl help <command>" to learn more:
  install           install components, or the entire platform
  uninstall         uninstall components
  list              list installed components
  start             start components
  stop              stop components
  restart           stop, then start components
  scale             grow or shrink the number of routers, registries or store gateways
  journal           print the log output of a component
  config            set platform or component values
  refresh-units     refresh unit files from GitHub
  help              show the help screen for a command

Options:
  -h --help                   show this help screen
  --endpoint=<url>            etcd endpoint for fleet [default: http://127.0.0.1:4001]
  --etcd-cafile=<path>        etcd CA file authentication [default: ]
  --etcd-certfile=<path>      etcd cert file authentication [default: ]
  --etcd-key-prefix=<path>    keyspace for fleet data in etcd [default: /_coreos.com/fleet/]
  --etcd-keyfile=<path>       etcd key file authentication [default: ]
  --known-hosts-file=<path>   where to store remote fingerprints [default: ~/.ssh/known_hosts]
  --request-timeout=<secs>    seconds before a request is considered failed [default: 10.0]
  --ssh-timeout=<secs>        seconds before SSH connection is considered failed [default: 10.0]
  --strict-host-key-checking  verify SSH host keys [default: true]
  --tunnel=<host>             SSH tunnel for communication with fleet and etcd [default: ]
  --version                   print the version of deisctl
`
	// pre-parse command-line arguments
	argv, helpFlag := parseArgs(argv)
	// give docopt an optional final false arg so it doesn't call os.Exit()
	args, err := docopt.Parse(usage, argv, false, version.Version, true, false)
	if err != nil || len(args) == 0 {
		if helpFlag {
			fmt.Print(usage)
			return 0
		}
		return 1
	}
	command := args["<command>"]
	setTunnel := true
	// "--help" and "refresh-units" doesn't need SSH tunneling
	if helpFlag || command == "refresh-units" {
		setTunnel = false
	}
	setGlobalFlags(args, setTunnel)
	// clean up the args so subcommands don't need to reparse them
	argv = removeGlobalArgs(argv)
	// construct a client
	c, err := client.NewClient("fleet")
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return 1
	}
	// Dispatch the command, passing the argv through so subcommands can
	// re-parse it according to their usage strings.
	switch command {
	case "list":
		err = c.List(argv)
	case "scale":
		err = c.Scale(argv)
	case "start":
		err = c.Start(argv)
	case "restart":
		err = c.Restart(argv)
	case "stop":
		err = c.Stop(argv)
	case "status":
		err = c.Status(argv)
	case "journal":
		err = c.Journal(argv)
	case "install":
		err = c.Install(argv)
	case "uninstall":
		err = c.Uninstall(argv)
	case "config":
		err = c.Config(argv)
	case "refresh-units":
		err = c.RefreshUnits(argv)
	case "help":
		fmt.Print(usage)
		return 0
	default:
		fmt.Println(`Found no matching command, try "deisctl help"
Usage: deisctl <command> [<args>...] [options]`)
		return 1
	}
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return 1
	}
	return 0
}