Пример #1
0
func HandleDelete(cmd *cobra.Command, args []string) {
	var (
		node      string
		target    []string
		tag       []string
		group     []string
		container string
		err       tree_lib.TreeError
	)
	err.From = tree_lib.FROM_HANDLE_DELETE
	node, err.Err = cmd.Flags().GetString("node")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	target, err.Err = cmd.Flags().GetStringSlice("target")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	container, err.Err = cmd.Flags().GetString("container")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	var (
		docker_cmd = tree_docker.DockerCmd{}
	)
	docker_cmd.Content = make(map[string]string)
	docker_cmd.Command = tree_docker.COMMAND_DOCKER_CONTAINER_DELETE
	docker_cmd.Content["container"] = container
	SendDockerCommand(docker_cmd, node, target, tag, group)
}
Пример #2
0
func HandleImageDelete(cmd *cobra.Command, args []string) {
	var (
		node   string
		target []string
		tag    []string
		group  []string
		force  bool
		image  string
		err    tree_lib.TreeError
	)
	err.From = tree_lib.FROM_HANDLE_IMAGE_DELETE
	node, err.Err = cmd.Flags().GetString("node")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	target, err.Err = cmd.Flags().GetStringSlice("target")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	tag, err.Err = cmd.Flags().GetStringSlice("tag")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	group, err.Err = cmd.Flags().GetStringSlice("group")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	image, err.Err = cmd.Flags().GetString("image")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	force, err.Err = cmd.Flags().GetBool("force")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	var (
		docker_cmd = tree_docker.DockerCmd{}
	)
	docker_cmd.Content = make(map[string]string)
	docker_cmd.Command = tree_docker.COMMAND_DOCKER_IMAGE_DELETE
	docker_cmd.Content["image"] = image
	if force {
		docker_cmd.Content["force"] = "yes"
	} else {
		docker_cmd.Content["force"] = "no"
	}
	SendDockerCommand(docker_cmd, node, target, tag, group)
}
Пример #3
0
func HandleList(cmd *cobra.Command, args []string) {
	var (
		node   string
		target []string
		tag    []string
		group  []string
		err    tree_lib.TreeError
	)
	err.From = tree_lib.FROM_HANDLE_LIST
	node, err.Err = cmd.Flags().GetString("node")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	target, err.Err = cmd.Flags().GetStringSlice("target")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	tag, err.Err = cmd.Flags().GetStringSlice("tag")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	group, err.Err = cmd.Flags().GetStringSlice("group")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	var (
		docker_cmd = tree_docker.DockerCmd{}
	)
	docker_cmd.Content = make(map[string]string)
	if cmd.Parent().Name() == "container" {
		docker_cmd.Command = tree_docker.COMMAND_DOCKER_CONTAINER_LIST
	} else {
		docker_cmd.Command = tree_docker.COMMAND_DOCKER_IMAGE_LIST
	}
	docker_cmd.Content["all"] = "yes"
	SendDockerCommand(docker_cmd, node, target, tag, group)
}
Пример #4
0
func HandleImagePull(cmd *cobra.Command, args []string) {
	var (
		node     string
		target   []string
		tag      []string
		group    []string
		image    string
		registry string
		username string
		address  string
		password string
		email    string
		err      tree_lib.TreeError
	)
	err.From = tree_lib.FROM_HANDLE_IMAGE_PULL
	node, err.Err = cmd.Flags().GetString("node")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	target, err.Err = cmd.Flags().GetStringSlice("target")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	tag, err.Err = cmd.Flags().GetStringSlice("tag")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	group, err.Err = cmd.Flags().GetStringSlice("group")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	registry, err.Err = cmd.Flags().GetString("registry")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	image, err.Err = cmd.Flags().GetString("image")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	address, err.Err = cmd.Flags().GetString("address")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	password, err.Err = cmd.Flags().GetString("password")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	username, err.Err = cmd.Flags().GetString("username")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	email, err.Err = cmd.Flags().GetString("email")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	var (
		docker_cmd = tree_docker.DockerCmd{}
	)
	docker_cmd.Content = make(map[string]string)
	docker_cmd.Command = tree_docker.COMMAND_DOCKER_IMAGE_PULL
	docker_cmd.Content["image"] = image
	docker_cmd.Content["registry"] = registry
	docker_cmd.Content["registry_username"] = username
	docker_cmd.Content["registry_password"] = password
	docker_cmd.Content["registry_address"] = address
	docker_cmd.Content["registry_email"] = email
	SendDockerCommand(docker_cmd, node, target, tag, group)
}
Пример #5
0
func HandleCreate(cmd *cobra.Command, args []string) {
	var (
		node      string
		target    []string
		tag       []string
		group     []string
		image     string
		command   string
		ram       string
		cpu       string
		container string
		count     string
		start     bool
		err       tree_lib.TreeError
	)
	err.From = tree_lib.FROM_HANDLE_CREATE
	node, err.Err = cmd.Flags().GetString("node")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	target, err.Err = cmd.Flags().GetStringSlice("target")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	tag, err.Err = cmd.Flags().GetStringSlice("tag")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	group, err.Err = cmd.Flags().GetStringSlice("group")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	image, err.Err = cmd.Flags().GetString("image")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	command, err.Err = cmd.Flags().GetString("command")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	container, err.Err = cmd.Flags().GetString("container")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	ram, err.Err = cmd.Flags().GetString("ram")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	cpu, err.Err = cmd.Flags().GetString("cpu")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	count, err.Err = cmd.Flags().GetString("count")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	start, err.Err = cmd.Flags().GetBool("start")
	if !err.IsNull() {
		tree_log.Error(err.From, err.Error())
		return
	}
	var (
		docker_cmd = tree_docker.DockerCmd{}
	)
	docker_cmd.Content = make(map[string]string)
	docker_cmd.Command = tree_docker.COMMAND_DOCKER_CONTAINER_CREATE
	docker_cmd.Content["cmd"] = command
	docker_cmd.Content["ram"] = ram
	docker_cmd.Content["cpu"] = cpu
	docker_cmd.Content["image"] = image
	docker_cmd.Content["container"] = container
	docker_cmd.Content["count"] = count
	if start {
		docker_cmd.Content["start"] = "yes"
	} else {
		docker_cmd.Content["start"] = "no"
	}

	SendDockerCommand(docker_cmd, node, target, tag, group)
}