fetch mesos leader
This commit is contained in:
parent
890b2efe1f
commit
15455eff0d
1 changed files with 46 additions and 0 deletions
46
cmd/fetch.go
46
cmd/fetch.go
|
@ -62,6 +62,23 @@ func init() {
|
||||||
help(cmd, s)
|
help(cmd, s)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* Fetch mesos leader */
|
||||||
|
mesosCmd.Flags().String("zkPath", "/mesos", "Zookeeper node path where mesos leader election happens")
|
||||||
|
|
||||||
|
fetchCmd.AddCommand(mesosCmd)
|
||||||
|
|
||||||
|
// Hijack help function to hide unnecessary global flags
|
||||||
|
mesosCmd.SetHelpFunc(func(cmd *cobra.Command, s []string) {
|
||||||
|
if cmd.HasInheritedFlags() {
|
||||||
|
cmd.InheritedFlags().VisitAll(func(f *pflag.Flag) {
|
||||||
|
if f.Name != "logLevel" {
|
||||||
|
f.Hidden = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
help(cmd, s)
|
||||||
|
})
|
||||||
|
|
||||||
// Fetch jobs
|
// Fetch jobs
|
||||||
fetchJobsCmd.Flags().StringVarP(role, "role", "r", "", "Aurora Role")
|
fetchJobsCmd.Flags().StringVarP(role, "role", "r", "", "Aurora Role")
|
||||||
fetchCmd.AddCommand(fetchJobsCmd)
|
fetchCmd.AddCommand(fetchJobsCmd)
|
||||||
|
@ -106,6 +123,18 @@ Pass Zookeeper nodes separated by a space as an argument to this command.`,
|
||||||
Run: fetchLeader,
|
Run: fetchLeader,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mesosCmd = &cobra.Command{
|
||||||
|
Use: "mesos [zkNode0, zkNode1, ...zkNodeN]",
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {}, // We don't need a realis client for this cmd
|
||||||
|
PersistentPostRun: func(cmd *cobra.Command, args []string) {}, // We don't need a realis client for this cmd
|
||||||
|
PreRun: setConfig,
|
||||||
|
Args: cobra.MinimumNArgs(1),
|
||||||
|
Short: "Fetch current Mesos-master leader given Zookeeper nodes. ",
|
||||||
|
Long: `Gets the current leading Mesos-master instance using information from Zookeeper path.
|
||||||
|
Pass Zookeeper nodes separated by a space as an argument to this command.`,
|
||||||
|
Run: fetchMesos,
|
||||||
|
}
|
||||||
|
|
||||||
var fetchJobsCmd = &cobra.Command{
|
var fetchJobsCmd = &cobra.Command{
|
||||||
Use: "jobs",
|
Use: "jobs",
|
||||||
Short: "Fetch a list of task Aurora running under a role.",
|
Short: "Fetch a list of task Aurora running under a role.",
|
||||||
|
@ -218,6 +247,23 @@ func fetchLeader(cmd *cobra.Command, args []string) {
|
||||||
fmt.Println(url)
|
fmt.Println(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fetchMesos(cmd *cobra.Command, args []string) {
|
||||||
|
log.Infof("Fetching Mesos-master leader from %v \n", args)
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
log.Info("Zookeepers were not indicated. Fetch mesos via localhost.")
|
||||||
|
args = append(args, "localhost")
|
||||||
|
}
|
||||||
|
|
||||||
|
url, err := realis.MesosFromZKOpts(realis.ZKEndpoints(args...), realis.ZKPath(cmd.Flag("zkPath").Value.String()))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error: %+v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(url)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Expand this to be able to filter by job name and environment.
|
// TODO: Expand this to be able to filter by job name and environment.
|
||||||
func fetchJobs(cmd *cobra.Command, args []string) {
|
func fetchJobs(cmd *cobra.Command, args []string) {
|
||||||
log.Infof("Fetching tasks under role: %s \n", *role)
|
log.Infof("Fetching tasks under role: %s \n", *role)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue