Included fetch status command to get the maintenance status of a node in Aurora

This commit is contained in:
Natarajan, Jayachandran 2018-09-21 14:25:12 +05:30
parent 7f64de61de
commit e1c403f585
2 changed files with 26 additions and 1 deletions

View file

@ -37,6 +37,9 @@ Use "australis [command] --help" for more information about a command.
### Fetching current leader
`australis fetch leader [ZK NODE 1] [ZK NODE 2]...[ZK NODE N]`
### Fetching status/mode of a agent
`australis fetch status [HOST 1] [HOST 2]...[HOST N]`
### Setting host to DRAIN:
`australis start drain [HOST 1] [HOST 2]...[HOST N]`

View file

@ -3,7 +3,6 @@ package cmd
import (
"fmt"
"os"
"github.com/paypal/gorealis"
"github.com/paypal/gorealis/gen-go/apache/aurora"
"github.com/spf13/cobra"
@ -26,6 +25,9 @@ func init() {
// Fetch jobs
fetchCmd.AddCommand(fetchJobsCmd)
fetchJobsCmd.Flags().StringVarP(role, "role", "r", "", "Aurora Role")
// Fetch Status
fetchCmd.AddCommand(fetchStatusCmd)
}
var fetchCmd = &cobra.Command{
@ -56,6 +58,13 @@ var fetchJobsCmd = &cobra.Command{
Run: fetchJobs,
}
var fetchStatusCmd = &cobra.Command{
Use: "status",
Short: "Fetch the maintenance status of a node from Aurora",
Long: `This command will print the actual status of the mesos agent nodes in Aurora server`,
Run: fetchStatus,
}
func fetchTasks(cmd *cobra.Command, args []string) {
fmt.Printf("Fetching job configuration for [%s/%s/%s] \n", env, role, name)
@ -84,6 +93,19 @@ func fetchTasks(cmd *cobra.Command, args []string) {
}
}
func fetchStatus(cmd *cobra.Command, args []string) {
fmt.Printf("Fetching maintenance status for %v \n", args)
_, result, err := client.MaintenanceStatus(args...)
if err != nil {
fmt.Printf("error: %+v\n", err.Error())
os.Exit(1)
}
for k := range result.Statuses {
fmt.Printf("Result: %s:%s\n", k.Host, k.Mode)
}
}
func fetchLeader(cmd *cobra.Command, args []string) {
fmt.Printf("Fetching leader from %v \n", args)