Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from njayachandran/master
Browse files Browse the repository at this point in the history
Included fetch status command to get the maintenance status of a node…
  • Loading branch information
rdelval committed Sep 22, 2018
2 parents 7f64de6 + e1c403f commit 91d962f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]`

Expand Down
24 changes: 23 additions & 1 deletion cmd/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 91d962f

Please sign in to comment.