コード例 #1
0
ファイル: stop.go プロジェクト: bgxavier/capstan
func Stop(name string) error {
	instanceName, instancePlatform := util.SearchInstance(name)
	if instanceName == "" {
		fmt.Printf("Instance: %s not found\n", name)
		return nil
	}

	var err error
	switch instancePlatform {
	case "qemu":
		err = qemu.StopVM(name)
	case "vbox":
		err = vbox.StopVM(name)
	case "vmw":
		err = vmw.StopVM(name)
	case "gce":
		err = gce.StopVM(name)
	}

	if err != nil {
		fmt.Printf("Failed to stop instance: %s\n", name)
	}

	fmt.Printf("Stopped instance: %s\n", name)
	return nil
}
コード例 #2
0
ファイル: delete.go プロジェクト: bgxavier/capstan
func Delete(name string) error {
	var err error
	instanceName, instancePlatform := util.SearchInstance(name)
	if instanceName == "" {
		fmt.Printf("Instance: %s not found\n", name)
		return nil
	}

	switch instancePlatform {
	case "qemu":
		qemu.StopVM(name)
		err = qemu.DeleteVM(name)
	case "vbox":
		vbox.StopVM(name)
		err = vbox.DeleteVM(name)
	case "vmw":
		vmw.StopVM(name)
		err = vmw.DeleteVM(name)
	case "gce":
		gce.StopVM(name)
		err = gce.DeleteVM(name)
	}
	if err != nil {
		fmt.Printf("Failed to delete instance: %s\n", name)
		return err
	}

	fmt.Printf("Deleted instance: %s\n", name)
	return nil
}