create_egress.go 848 B

1234567891011121314151617181920212223242526272829303132
  1. package node
  2. import (
  3. "strings"
  4. "github.com/gravitl/netmaker/cli/functions"
  5. "github.com/gravitl/netmaker/models"
  6. "github.com/spf13/cobra"
  7. )
  8. var nodeCreateEgressCmd = &cobra.Command{
  9. Use: "create_egress [NETWORK NAME] [NODE ID] [EGRESS GATEWAY ADDRESSES (comma separated)]",
  10. Args: cobra.ExactArgs(3),
  11. Short: "Turn a Node into a Egress",
  12. Long: `Turn a Node into a Egress`,
  13. Run: func(cmd *cobra.Command, args []string) {
  14. egress := &models.EgressGatewayRequest{
  15. NetID: args[0],
  16. NodeID: args[1],
  17. Ranges: strings.Split(args[2], ","),
  18. }
  19. if natEnabled {
  20. egress.NatEnabled = "yes"
  21. }
  22. functions.PrettyPrint(functions.CreateEgress(args[0], args[1], egress))
  23. },
  24. }
  25. func init() {
  26. nodeCreateEgressCmd.Flags().BoolVar(&natEnabled, "nat", false, "Enable NAT for Egress Traffic ?")
  27. rootCmd.AddCommand(nodeCreateEgressCmd)
  28. }