示例#1
0
文件: cmd.go 项目: uniite/deis
// Install loads the definitions of components from local unit files.
// After Install, the components will be available to Start.
func Install(targets []string, b backend.Backend, cb config.Backend, checkKeys func(config.Backend) error) error {

	// if target is platform, install all services
	if len(targets) == 1 {
		switch targets[0] {
		case PlatformCommand:
			return InstallPlatform(b, cb, checkKeys, false)
		case StatelessPlatformCommand:
			return InstallPlatform(b, cb, checkKeys, true)
		case mesos:
			return InstallMesos(b)
		case swarm:
			return InstallSwarm(b)
		case k8s:
			return InstallK8s(b)
		}
	}
	var wg sync.WaitGroup

	// otherwise create the specific targets
	b.Create(targets, &wg, Stdout, Stderr)
	wg.Wait()

	return nil
}
示例#2
0
文件: cmd.go 项目: pombredanne/deo
// Start activates the specified components.
func Start(argv []string, b backend.Backend) error {
	usage := `Activates the specified components.

Usage:
  deisctl start [<target>...] [options]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	// if target is platform, install all services
	targets := args["<target>"].([]string)

	if len(targets) == 1 && targets[0] == PlatformCommand {
		return StartPlatform(b)
	}

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

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

	b.Start(targets, &wg, outchan, errchan)
	wg.Wait()
	close(outchan)

	return nil
}
示例#3
0
文件: cmd.go 项目: bladealslayer/deis
// SSH opens an interactive shell on a machine in the cluster
func SSH(target string, b backend.Backend) error {
	if err := b.SSH(target); err != nil {
		return err
	}

	return nil
}
示例#4
0
文件: cmd.go 项目: uniite/deis
// Stop deactivates the specified components.
func Stop(targets []string, b backend.Backend) error {

	// if target is platform, stop all services
	if len(targets) == 1 {
		switch targets[0] {
		case PlatformCommand:
			return StopPlatform(b, false)
		case StatelessPlatformCommand:
			return StopPlatform(b, true)
		case mesos:
			return StopMesos(b)
		case swarm:
			return StopSwarm(b)
		case k8s:
			return StopK8s(b)
		}
	}

	var wg sync.WaitGroup

	b.Stop(targets, &wg, Stdout, Stderr)
	wg.Wait()

	return nil
}
示例#5
0
文件: cmd.go 项目: pombredanne/deo
// Uninstall unloads the definitions of the specified components.
// After Uninstall, the components will be unavailable until Install is called.
func Uninstall(argv []string, b backend.Backend) error {
	usage := `Unloads the definitions of the specified components.

After uninstall, the components will be unavailable until install is called.

Usage:
  deisctl uninstall [<target>...] [options]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	// if target is platform, uninstall all services
	targets := args["<target>"].([]string)
	if len(targets) == 1 && targets[0] == PlatformCommand {
		return UninstallPlatform(b)
	}

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

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

	// uninstall the specific target
	b.Destroy(targets, &wg, outchan, errchan)
	wg.Wait()
	close(outchan)

	return nil
}
示例#6
0
文件: cmd.go 项目: bladealslayer/deis
// Start activates the specified components.
func Start(targets []string, b backend.Backend) error {

	// if target is platform, install all services
	if len(targets) == 1 {
		if targets[0] == PlatformCommand {
			return StartPlatform(b, false)
		} else if targets[0] == StatelessPlatformCommand {
			return StartPlatform(b, true)
		} else if targets[0] == swarm {
			return StartSwarm(b)
		}
	}
	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

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

	b.Start(targets, &wg, outchan, errchan)
	wg.Wait()
	close(outchan)
	close(errchan)

	return nil
}
示例#7
0
文件: cmd.go 项目: bladealslayer/deis
// Uninstall unloads the definitions of the specified components.
// After Uninstall, the components will be unavailable until Install is called.
func Uninstall(targets []string, b backend.Backend) error {
	if len(targets) == 1 {
		if targets[0] == PlatformCommand {
			return UninstallPlatform(b, false)
		} else if targets[0] == StatelessPlatformCommand {
			return UninstallPlatform(b, true)
		} else if targets[0] == swarm {
			return UnInstallSwarm(b)
		}
	}

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

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

	// uninstall the specific target
	b.Destroy(targets, &wg, outchan, errchan)
	wg.Wait()
	close(outchan)
	close(errchan)

	return nil
}
示例#8
0
文件: cmd.go 项目: bladealslayer/deis
// Install loads the definitions of components from local unit files.
// After Install, the components will be available to Start.
func Install(targets []string, b backend.Backend, checkKeys func() error) error {

	// if target is platform, install all services
	if len(targets) == 1 {
		if targets[0] == PlatformCommand {
			return InstallPlatform(b, checkKeys, false)
		} else if targets[0] == StatelessPlatformCommand {
			return InstallPlatform(b, checkKeys, true)
		} else if targets[0] == swarm {
			return InstallSwarm(b)
		}
	}
	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

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

	// otherwise create the specific targets
	b.Create(targets, &wg, outchan, errchan)
	wg.Wait()

	close(outchan)
	close(errchan)
	return nil
}
示例#9
0
文件: upgrade.go 项目: CodeJuan/deis
func doUpgradeTakeOver(stateless bool, b backend.Backend, cb config.Backend) error {
	var wg sync.WaitGroup

	nodes, err := listPublishedServices(cb)
	if err != nil {
		return err
	}

	b.Stop([]string{"publisher"}, &wg, Stdout, Stderr)
	wg.Wait()
	b.Destroy([]string{"publisher"}, &wg, Stdout, Stderr)
	wg.Wait()

	if err := republishServices(1800, nodes, cb); err != nil {
		return err
	}

	b.RollingRestart("router", &wg, Stdout, Stderr)
	wg.Wait()
	b.Create([]string{"publisher"}, &wg, Stdout, Stderr)
	wg.Wait()
	b.Start([]string{"publisher"}, &wg, Stdout, Stderr)
	wg.Wait()

	installUpgradeServices(b, stateless, &wg, Stdout, Stderr)
	wg.Wait()

	startUpgradeServices(b, stateless, &wg, Stdout, Stderr)
	wg.Wait()
	return nil
}
示例#10
0
文件: cmd.go 项目: uniite/deis
// SSH opens an interactive shell on a machine in the cluster
func SSH(target string, cmd []string, b backend.Backend) error {

	if len(cmd) > 0 {
		return b.SSHExec(target, strings.Join(cmd, " "))
	}

	return b.SSH(target)
}
示例#11
0
文件: cmd.go 项目: uniite/deis
// RollingRestart restart instance unit in a rolling manner
func RollingRestart(target string, b backend.Backend) error {
	var wg sync.WaitGroup

	b.RollingRestart(target, &wg, Stdout, Stderr)
	wg.Wait()

	return nil
}
示例#12
0
文件: swarm.go 项目: Kazanz/deis
//UnInstallSwarm uninstall Swarm
func UnInstallSwarm(b backend.Backend) error {
	var wg sync.WaitGroup
	io.WriteString(Stdout, prettyprint.DeisIfy("Destroying Swarm..."))
	fmt.Fprintln(Stdout, "swarm nodes and swarm manager...")
	b.Destroy([]string{"swarm-node", "swarm-manager"}, &wg, Stdout, Stderr)
	wg.Wait()
	fmt.Fprintln(Stdout, "Done.\n ")
	return nil
}
示例#13
0
文件: cmd.go 项目: uniite/deis
// Journal prints log output for the specified components.
func Journal(targets []string, b backend.Backend) error {

	for _, target := range targets {
		if err := b.Journal(target); err != nil {
			return err
		}
	}
	return nil
}
示例#14
0
文件: swarm.go 项目: Kazanz/deis
//InstallSwarm Installs swarm
func InstallSwarm(b backend.Backend) error {
	var wg sync.WaitGroup
	io.WriteString(Stdout, prettyprint.DeisIfy("Installing Swarm..."))
	fmt.Fprintln(Stdout, "Swarm node and Swarm Manager...")
	b.Create([]string{"swarm-node", "swarm-manager"}, &wg, Stdout, Stderr)
	wg.Wait()
	fmt.Fprintln(Stdout, "Done.\n ")
	fmt.Fprintln(Stdout, "Please run `deisctl start swarm` to start swarm.")
	return nil
}
示例#15
0
文件: cmd.go 项目: uniite/deis
// Dock connects to the appropriate host and runs 'docker exec -it'.
func Dock(target string, cmd []string, b backend.Backend) error {

	c := "sh"
	if len(cmd) > 0 {
		c = strings.Join(cmd, " ")
	}

	execit := fmt.Sprintf("docker exec -it %s %s", target, c)

	return b.SSHExec(target, execit)
}
示例#16
0
文件: cmd.go 项目: pombredanne/deo
// ListUnits prints a list of installed units.
func ListUnits(argv []string, b backend.Backend) error {
	usage := `Prints a list of installed units.

Usage:
  deisctl list [options]
`
	// parse command-line arguments
	if _, err := docopt.Parse(usage, argv, true, "", false); err != nil {
		return err
	}
	return b.ListUnits()
}
示例#17
0
文件: mesos.go 项目: ngpestelos/deis
func uninstallMesosServices(b backend.Backend, wg *sync.WaitGroup, out, err io.Writer) error {

	fmt.Fprintln(out, "Mesos/Marathon data plane...")
	b.Destroy([]string{"mesos-slave"}, wg, out, err)
	wg.Wait()

	fmt.Fprintln(out, "Mesos/Marathon control plane...")
	b.Destroy([]string{"mesos-marathon", "mesos-master", "zookeeper"}, wg, out, err)
	wg.Wait()

	return nil
}
示例#18
0
文件: swarm.go 项目: ngpestelos/deis
//UnInstallSwarm uninstall Swarm
func UnInstallSwarm(b backend.Backend) error {
	var wg sync.WaitGroup
	io.WriteString(Stdout, prettyprint.DeisIfy("Uninstalling Swarm..."))
	fmt.Fprintln(Stdout, "Swarm data plane...")
	b.Destroy([]string{"swarm-node"}, &wg, Stdout, Stderr)
	wg.Wait()
	fmt.Fprintln(Stdout, "Swarm control plane...")
	b.Destroy([]string{"swarm-manager"}, &wg, Stdout, Stderr)
	wg.Wait()
	fmt.Fprintln(Stdout, "Done.\n ")
	return nil
}
示例#19
0
文件: swarm.go 项目: ngpestelos/deis
//StartSwarm starts Swarm Schduler
func StartSwarm(b backend.Backend) error {
	var wg sync.WaitGroup
	io.WriteString(Stdout, prettyprint.DeisIfy("Starting Swarm..."))
	fmt.Fprintln(Stdout, "Swarm control plane...")
	b.Start([]string{"swarm-manager"}, &wg, Stdout, Stderr)
	wg.Wait()
	fmt.Fprintln(Stdout, "Swarm data plane...")
	b.Start([]string{"swarm-node"}, &wg, Stdout, Stderr)
	wg.Wait()
	fmt.Fprintln(Stdout, "Done.\n ")
	fmt.Fprintln(Stdout, "Please run `deisctl config controller set schedulerModule=swarm` to use the swarm scheduler.")
	return nil
}
示例#20
0
文件: swarm.go 项目: gpxl/deis
//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
}
示例#21
0
文件: swarm.go 项目: gpxl/deis
//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
}
示例#22
0
文件: cmd.go 项目: uniite/deis
// Scale grows or shrinks the number of running components.
// Currently "router", "registry" and "store-gateway" are the only types that can be scaled.
func Scale(targets []string, b backend.Backend) error {
	var wg sync.WaitGroup

	for _, target := range targets {
		component, num, err := splitScaleTarget(target)
		if err != nil {
			return err
		}
		// the router, registry, and store-gateway are the only component that can scale at the moment
		if !strings.Contains(component, "router") && !strings.Contains(component, "registry") && !strings.Contains(component, "store-gateway") {
			return fmt.Errorf("cannot scale %s component", component)
		}
		b.Scale(component, num, &wg, Stdout, Stderr)
		wg.Wait()
	}
	return nil
}
示例#23
0
文件: cmd.go 项目: CloudSide/deis
// Start activates the specified components.
func Start(targets []string, b backend.Backend) error {

	// if target is platform, install all services
	if len(targets) == 1 {
		switch targets[0] {
		case PlatformCommand:
			return StartPlatform(b, false)
		case StatelessPlatformCommand:
			return StartPlatform(b, true)
		}
	}
	var wg sync.WaitGroup

	b.Start(targets, &wg, Stdout, Stderr)
	wg.Wait()

	return nil
}
示例#24
0
文件: cmd.go 项目: CloudSide/deis
// Uninstall unloads the definitions of the specified components.
// After Uninstall, the components will be unavailable until Install is called.
func Uninstall(targets []string, b backend.Backend) error {
	if len(targets) == 1 {
		switch targets[0] {
		case PlatformCommand:
			return UninstallPlatform(b, false)
		case StatelessPlatformCommand:
			return UninstallPlatform(b, true)
		}
	}

	var wg sync.WaitGroup

	// uninstall the specific target
	b.Destroy(targets, &wg, Stdout, Stderr)
	wg.Wait()

	return nil
}
示例#25
0
文件: swarm.go 项目: gpxl/deis
//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
}
示例#26
0
文件: cmd.go 项目: pombredanne/deo
// Status prints the current status of components.
func Status(argv []string, b backend.Backend) error {
	usage := `Prints the current status of components.

Usage:
  deisctl status [<target>...] [options]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	targets := args["<target>"].([]string)
	for _, target := range targets {
		if err := b.Status(target); err != nil {
			return err
		}
	}
	return nil
}
示例#27
0
文件: cmd.go 项目: pombredanne/deo
// Journal prints log output for the specified components.
func Journal(argv []string, b backend.Backend) error {
	usage := `Prints log output for the specified components.

Usage:
  deisctl journal [<target>...] [options]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	targets := args["<target>"].([]string)
	for _, target := range targets {
		if err := b.Journal(target); err != nil {
			return err
		}
	}
	return nil
}
示例#28
0
文件: mesos.go 项目: ngpestelos/deis
func stopMesosServices(b backend.Backend, wg *sync.WaitGroup, out, err io.Writer) {

	fmt.Fprintln(out, "Mesos/Marathon data plane...")
	b.Stop([]string{"mesos-slave"}, wg, out, err)
	wg.Wait()

	fmt.Fprintln(out, "Mesos/Marathon control plane...")
	b.Stop([]string{"mesos-marathon"}, wg, out, err)
	wg.Wait()
	b.Stop([]string{"mesos-master"}, wg, out, err)
	wg.Wait()
	b.Stop([]string{"zookeeper"}, wg, out, err)
	wg.Wait()
}
示例#29
0
文件: cmd.go 项目: pombredanne/deo
func installDefaultServices(b backend.Backend, wg *sync.WaitGroup, outchan chan string, errchan chan error) {

	outchan <- fmt.Sprintf("Storage subsystem...")
	b.Create([]string{"store-daemon", "store-monitor", "store-metadata", "store-volume", "store-gateway"}, wg, outchan, errchan)
	wg.Wait()

	outchan <- fmt.Sprintf("Logging subsystem...")
	b.Create([]string{"logger", "logspout"}, wg, outchan, errchan)
	wg.Wait()

	outchan <- fmt.Sprintf("Control plane...")
	b.Create([]string{"cache", "database", "registry", "controller", "builder"}, wg, outchan, errchan)
	wg.Wait()

	outchan <- fmt.Sprintf("Data plane...")
	b.Create([]string{"publisher"}, wg, outchan, errchan)
	wg.Wait()

	outchan <- fmt.Sprintf("Routing mesh...")
	b.Create([]string{"router@1", "router@2", "router@3"}, wg, outchan, errchan)
	wg.Wait()
}
示例#30
0
文件: cmd.go 项目: pombredanne/deo
// Install loads the definitions of components from local unit files.
// After Install, the components will be available to Start.
func Install(argv []string, b backend.Backend) error {
	usage := `Loads the definitions of components from local unit files.

After install, the components will be available to start.

"deisctl install" looks for unit files in these directories, in this order:
- the $DEISCTL_UNITS environment variable, if set
- $HOME/.deis/units
- /var/lib/deis/units

Usage:
  deisctl install [<target>...] [options]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	// if target is platform, install all services
	targets := args["<target>"].([]string)
	if len(targets) == 1 && targets[0] == PlatformCommand {
		return InstallPlatform(b)
	}

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

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

	// otherwise create the specific targets
	b.Create(targets, &wg, outchan, errchan)
	wg.Wait()

	close(outchan)
	return nil
}