Example #1
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	top, err := client.GetHistory(*projectid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		for _, data := range top.Events {
			var job string
			if data.Job != nil {
				job = data.Job.ID
			} else {
				job = "<adhoc>"
			}
			table.SetHeader([]string{"Status", "Summary", "Start Time", "End Time", "S/F/T", "Job", "Execution", "User", "Project"})
			table.Append([]string{
				data.Status,
				data.Summary,
				data.StartTime,
				data.EndTime,
				fmt.Sprintf("%d/%d/%d", data.NodeSummary.Succeeded, data.NodeSummary.Failed, data.NodeSummary.Total),
				job,
				fmt.Sprintf("%d", data.Execution.ID),
				data.User,
				data.Project,
			})
		}
		table.Render()
	}
}
Example #2
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.GetJob(*jobid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		scope := data.Job
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"ID", "Name", "Description", "Group", "Steps", "Node Filters"})
		var steps []string
		var nodefilters []string
		for _, d := range scope.Sequence.Steps {
			var stepDescription string
			if d.Description == "" {
				if d.JobRef != nil {
					stepDescription = d.JobRef.Name
				} else if d.Exec != nil {
					stepDescription = *d.Exec
				}
			} else {
				stepDescription = d.Description
			}
			steps = append(steps, stepDescription)
		}
		for _, n := range scope.NodeFilters.Filter {
			nodefilters = append(nodefilters, n)
		}
		table.Append([]string{scope.ID, scope.Name, scope.Description, scope.Group, strings.Join(steps, "\n"), strings.Join(nodefilters, "\n")})
		table.Render()
	}
}
Example #3
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	err := client.DeleteExecution(*id)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		os.Exit(0)
	}
}
Example #4
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	res, err := client.ExportJob(*jobid, *format)
	if err != nil {
		fmt.Printf(err.Error())
		os.Exit(1)
	} else {
		fmt.Printf(res)
		os.Exit(0)
	}
}
Example #5
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	res, err := client.ListRunningExecutions(*project)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("%+v\n", res)
		//fmt.Printf("Job %s is %s", res.Executions[0].ID, res.Executions[0].Status)
		os.Exit(0)
	}
}
Example #6
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.ListJobs(*projectid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"ID", "Name", "Description", "Group", "Project"})
		for _, d := range data.Jobs {
			table.Append([]string{d.ID, d.Name, d.Description, d.Group, d.Project})
		}
		table.Render()
	}
}
Example #7
0
func main() {
	var jobid string
	if len(os.Args) <= 1 {
		fmt.Printf("Usage: rundeck-delete-job <job uuid>\n")
		os.Exit(1)
	}
	jobid = os.Args[1]
	client := rundeck.NewClientFromEnv()
	err := client.DeleteJob(jobid)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("Job %s deleted\n", jobid)
		os.Exit(0)
	}
}
Example #8
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	options := make(map[string]string)
	options["max"] = *max
	data, err := client.ListProjectExecutions(*projectid, options)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{
			"ID",
			"Job Name",
			"Job Description",
			"Status",
			"Node Success/Failure Count",
			"User",
			"Start",
			"End",
			"Project",
		})
		for _, d := range data.Executions {
			var description string
			var name string
			if d.Job != nil {
				name = d.Job.Name
				description = d.Job.Description
			} else {
				name = "<adhoc>"
				description = d.Description
			}
			table.Append([]string{
				d.ID,
				name,
				description,
				d.Status,
				strconv.Itoa(len(d.SuccessfulNodes.Nodes)) + "/" + strconv.Itoa(len(d.FailedNodes.Nodes)),
				d.User,
				d.DateStarted,
				d.DateEnded,
				d.Project,
			})
		}
		table.Render()
	}
}
Example #9
0
func main() {
	path := flag.String("path", "projects", "path to dump (i.e. executions/12234).")
	flag.Var(&myparams, "q", "key=value query parameter. Specify multiple times if neccessary")
	flag.Usage = func() { fmt.Printf("%s", usage) }
	flag.Parse()
	query_opts := make(map[string]string)
	paramConvert(myparams, &query_opts)
	client := rundeck.NewClientFromEnv()
	var data []byte
	err := client.Get(&data, *path, query_opts)
	if err != nil {
		fmt.Printf(err.Error())
		os.Exit(1)
	} else {
		fmt.Printf("%s\n", string(data))
	}
}
Example #10
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	jobopts := rundeck.RunOptions{
		RunAs:     *runAs,
		LogLevel:  *logLevel,
		Filter:    *nodeFilter,
		Arguments: strings.Join(*argString, " "),
	}
	res, err := client.RunJob(*jobId, jobopts)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("Job %s is %s\n", res.Executions[0].ID, res.Executions[0].Status)
		os.Exit(0)
	}
}
Example #11
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	res, err := client.DeleteAllExecutionsForProject(*project, 200)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("Successful: %d\n", res.Successful.Count)
		if res.Failed.Count != 0 {
			fmt.Printf("Failed: %d\n", res.Failed.Count)
			for _, f := range res.Failed.Failures {
				fmt.Printf("%d - %s\n", f.ID, f.Message)
			}
		}
		os.Exit(0)
	}
}
Example #12
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	importParams := rundeck.ImportParams{
		Filename: *filename,
		Format:   *format,
		Dupe:     *dupe,
		Uuid:     *uuid,
		Project:  *project,
	}
	jobid, err := client.ImportJob(importParams)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("Job %s imported\n", jobid)
		os.Exit(0)
	}
}
Example #13
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.GetExecution(*id)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		headers := []string{
			"ID",
			"User",
			"Status",
			"Start Date",
			"End Date",
		}
		table.SetHeader(headers)
		table.Append([]string{data.ID, data.User, data.Status, data.DateStarted, data.DateEnded})
		table.Render()
	}
}
Example #14
0
func main() {
	client := rundeck.NewClientFromEnv()
	data, err := client.GetTokens()
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{
			"ID",
			"User",
		})
		for _, d := range data.Tokens {
			table.Append([]string{
				d.ID,
				d.User,
			})
		}
		table.Render()
	}
}
Example #15
0
func main() {
	client := rundeck.NewClientFromEnv()
	data, err := client.ListProjects()
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{
			"Name",
			"Description",
			"URL",
		})
		for _, d := range data.Projects {
			table.Append([]string{
				d.Name,
				d.Description,
				d.Url,
			})
		}
		table.Render()
	}
}
Example #16
0
func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.GetJob(*jobid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		scope := data.Job
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"ID", "Name", "Description", "Options"})
		table.SetAutoWrapText(false)
		var options []string
		for _, d := range *scope.Context.Options {
			var option string
			option = fmt.Sprintf("%s", d.Name)
			if d.Required {
				option = fmt.Sprintf("%s (required)", option)
			}
			options = append(options, option)
		}
		table.Append([]string{scope.ID, scope.Name, scope.Description, strings.Join(options, "\n")})
		table.Render()
	}
}