|
|
|
@ -7,8 +7,9 @@ import (
|
|
|
|
|
"strconv" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
"git.jpi.io/amery/jpictl/pkg/zones" |
|
|
|
|
"github.com/spf13/cobra" |
|
|
|
|
|
|
|
|
|
"git.jpi.io/amery/jpictl/pkg/cluster" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// Command
|
|
|
|
@ -38,9 +39,9 @@ var gatewaySetCmd = &cobra.Command{
|
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func gatewaySet(zi zones.ZoneIterator, gw string) error { |
|
|
|
|
func gatewaySet(zi cluster.ZoneIterator, gw string) error { |
|
|
|
|
var err error |
|
|
|
|
zi.ForEachZone(func(z *zones.Zone) bool { |
|
|
|
|
zi.ForEachZone(func(z *cluster.Zone) bool { |
|
|
|
|
for _, m := range z.Machines { |
|
|
|
|
if m.Name == gw { |
|
|
|
|
z.SetGateway(m.ID, true) |
|
|
|
@ -74,9 +75,9 @@ var gatewayUnsetCmd = &cobra.Command{
|
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func gatewayUnset(zi zones.ZoneIterator, ngw string) error { |
|
|
|
|
func gatewayUnset(zi cluster.ZoneIterator, ngw string) error { |
|
|
|
|
var err error |
|
|
|
|
zi.ForEachZone(func(z *zones.Zone) bool { |
|
|
|
|
zi.ForEachZone(func(z *cluster.Zone) bool { |
|
|
|
|
for _, m := range z.Machines { |
|
|
|
|
if m.Name == ngw && m.IsGateway() { |
|
|
|
|
z.SetGateway(m.ID, false) |
|
|
|
@ -115,10 +116,10 @@ var gatewayListCmd = &cobra.Command{
|
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func gatewayListAll(zi zones.ZoneIterator) error { |
|
|
|
|
func gatewayListAll(zi cluster.ZoneIterator) error { |
|
|
|
|
var b bytes.Buffer |
|
|
|
|
var err error |
|
|
|
|
zi.ForEachZone(func(z *zones.Zone) bool { |
|
|
|
|
zi.ForEachZone(func(z *cluster.Zone) bool { |
|
|
|
|
b.WriteString(z.Name + ":") |
|
|
|
|
var sIDs []string |
|
|
|
|
ids, num := z.GatewayIDs() |
|
|
|
@ -137,10 +138,10 @@ func gatewayListAll(zi zones.ZoneIterator) error {
|
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func gatewayList(zi zones.ZoneIterator, m string) error { |
|
|
|
|
func gatewayList(zi cluster.ZoneIterator, m string) error { |
|
|
|
|
var b bytes.Buffer |
|
|
|
|
var err error |
|
|
|
|
zi.ForEachZone(func(z *zones.Zone) bool { |
|
|
|
|
zi.ForEachZone(func(z *cluster.Zone) bool { |
|
|
|
|
if z.Name == m { |
|
|
|
|
b.WriteString(z.Name + ":") |
|
|
|
|
ids, num := z.GatewayIDs() |
|
|
|
|