-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enabled VRF routes in metal-cli (#425)
## What issues it address? #414 - Enabled VRF routes in Metal-cli. - Improved metal gateways to support Vrf gateway inputs. Co-authored-by: codinja1188 <[email protected]>
- Loading branch information
1 parent
9576704
commit 36f4f5e
Showing
17 changed files
with
770 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## metal vrf create-route | ||
|
||
Create a route in a VRF. Currently only static default routes are supported. | ||
|
||
### Synopsis | ||
|
||
Create a route in a VRF. Currently only static default routes are supported. | ||
|
||
``` | ||
metal vrf create-route [-i <VrfId>] [-p <Prefix>] [-n NextHop] [-t <tags> ] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# Create a route in a VRF. Currently only static default routes are supported.. | ||
metal vrf create-route [-i <VrfID>] [-p <prefix>] [-n nextHop] [-t <tags> ] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for create-route | ||
-i, --id string Specify the VRF UUID activate route configurations | ||
-n, --nextHop string The IPv4 address within the VRF of the host that will handle this route | ||
-p, --prefix string The IPv4 prefix for the route, in CIDR-style notation. For a static default route, this will always be '0.0.0.0/0' | ||
-t, --tags strings Adds the tags for the connection --tags="tag1,tag2". | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string Path to JSON or YAML configuration file (METAL_CONFIG) | ||
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep | ||
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. | ||
--http-header strings Headers to add to requests (in format key=value) | ||
--include strings Comma separated Href references to expand in results, may be dotted three levels deep | ||
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). | ||
--search string Search keyword for use in 'get' actions. Search is not supported by all resources. | ||
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. | ||
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. | ||
--token string Metal API Token (METAL_AUTH_TOKEN) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [metal vrf](metal_vrf.md) - VRF operations : create, get, delete | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
## metal vrf delete-route | ||
|
||
Delete a VRF Route | ||
|
||
### Synopsis | ||
|
||
Delete a VRF Route | ||
|
||
``` | ||
metal vrf delete-route [-i <VrfRoute-Id>] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
#Delete a VRF Route | ||
metal vrf delete-route -i 77e6d57a-d7a4-4816-b451-cf9b043444e2 | ||
> | ||
✔ Are you sure you want to delete device 7ec86e23-8dcf-48ed-bd9b-c25c20958277 [Y/N]: y | ||
# Deletes a VRF, skipping confirmation. | ||
metal vrf delete-route -f -i 77e6d57a-d7a4-4816-b451-cf9b043444e2 | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-f, --force Skips confirmation for the removal of the VRF routes. | ||
-h, --help help for delete-route | ||
-i, --id string Specify the VRF UUID to delete the associated route configurations. | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string Path to JSON or YAML configuration file (METAL_CONFIG) | ||
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep | ||
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. | ||
--http-header strings Headers to add to requests (in format key=value) | ||
--include strings Comma separated Href references to expand in results, may be dotted three levels deep | ||
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). | ||
--search string Search keyword for use in 'get' actions. Search is not supported by all resources. | ||
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. | ||
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. | ||
--token string Metal API Token (METAL_AUTH_TOKEN) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [metal vrf](metal_vrf.md) - VRF operations : create, get, delete | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## metal vrf get-route | ||
|
||
Retrieve all routes in the VRF | ||
|
||
### Synopsis | ||
|
||
Retrieve all routes in the VRF | ||
|
||
``` | ||
metal vrf get-route [-i <VrfRoute-Id>] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
#Retrieve all routes in the VRF | ||
# Retrieve all routes in the VRF | ||
metal vrf get-route -i bb526d47-8536-483c-b436-116a5fb72235 | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for get-route | ||
-i, --id string Specify the VRF UUID to list its associated routes configurations | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string Path to JSON or YAML configuration file (METAL_CONFIG) | ||
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep | ||
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. | ||
--http-header strings Headers to add to requests (in format key=value) | ||
--include strings Comma separated Href references to expand in results, may be dotted three levels deep | ||
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). | ||
--search string Search keyword for use in 'get' actions. Search is not supported by all resources. | ||
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. | ||
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. | ||
--token string Metal API Token (METAL_AUTH_TOKEN) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [metal vrf](metal_vrf.md) - VRF operations : create, get, delete | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## metal vrf update-route | ||
|
||
Requests a VRF Route be redeployed/update across the network. | ||
|
||
### Synopsis | ||
|
||
Requests a VRF Route be redeployed/update across the network. | ||
|
||
``` | ||
metal vrf update-route [-i <VrfRoute-Id>] [-p <Prefix>] [-n NextHop] [-t <tags> ] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
#Requests a VRF Route be redeployed/update across the network. | ||
metal vrf update-route [-i <VrfID>] [-p <prefix>] [-n nextHop] [-t <tags> ] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for update-route | ||
-i, --id string Specify the VRF UUID to update the associated route configurations. | ||
-n, --nextHop string Name of the Virtual Routing and Forwarding | ||
-p, --prefix string The IPv4 prefix for the route, in CIDR-style notation. For a static default route, this will always be '0.0.0.0/0' | ||
-t, --tags strings updates the tags for the Virtual Routing and Forwarding --tags "tag1,tag2" OR --tags "tag1" --tags "tag2" (NOTE: --tags "" will remove all tags from the Virtual Routing and Forwarding | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string Path to JSON or YAML configuration file (METAL_CONFIG) | ||
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep | ||
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters. | ||
--http-header strings Headers to add to requests (in format key=value) | ||
--include strings Comma separated Href references to expand in results, may be dotted three levels deep | ||
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp). | ||
--search string Search keyword for use in 'get' actions. Search is not supported by all resources. | ||
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources. | ||
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources. | ||
--token string Metal API Token (METAL_AUTH_TOKEN) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [metal vrf](metal_vrf.md) - VRF operations : create, get, delete | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package vrf | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/equinix/equinix-sdk-go/services/metalv1" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func (c *Client) CreateRoute() *cobra.Command { | ||
var ( | ||
vrfID string | ||
prefix string | ||
nextHop string | ||
tags []string | ||
) | ||
|
||
// CreateVrfRouteCmd represents the CreateVrfRouteCmd command | ||
createRouteCmd := &cobra.Command{ | ||
Use: "create-route [-i <VrfId>] [-p <Prefix>] [-n NextHop] [-t <tags> ]", | ||
Aliases: []string{"route"}, | ||
Short: "Create a route in a VRF. Currently only static default routes are supported.", | ||
Long: "Create a route in a VRF. Currently only static default routes are supported.", | ||
Example: ` # Create a route in a VRF. Currently only static default routes are supported.. | ||
metal vrf create-route [-i <VrfID>] [-p <prefix>] [-n nextHop] [-t <tags> ]`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
cmd.SilenceUsage = true | ||
inc := []string{} | ||
exc := []string{} | ||
|
||
vrfRouteCreateInput := metalv1.VrfRouteCreateInput{ | ||
Prefix: prefix, | ||
NextHop: nextHop, | ||
Tags: tags, | ||
} | ||
|
||
vrfRoute, _, err := c.Service.CreateVrfRoute(context.Background(), vrfID).VrfRouteCreateInput(vrfRouteCreateInput).Include(c.Servicer.Includes(inc)).Exclude(c.Servicer.Excludes(exc)).Execute() | ||
if err != nil { | ||
return fmt.Errorf("could not create VrfRoute: %w", err) | ||
} | ||
|
||
data := make([][]string, 1) | ||
|
||
// This output block below is probably incorrect but leaving it for now for testing later. | ||
data[0] = []string{vrfRoute.GetId(), string(vrfRoute.GetType()), vrfRoute.GetPrefix(), vrfRoute.GetNextHop(), vrfRoute.CreatedAt.String()} | ||
header := []string{"ID", "Type", "Prefix", "NextHop", "Created"} | ||
|
||
return c.Out.Output(vrfRoute, header, &data) | ||
}, | ||
} | ||
|
||
createRouteCmd.Flags().StringVarP(&vrfID, "id", "i", "", "Specify the VRF UUID activate route configurations") | ||
createRouteCmd.Flags().StringVarP(&prefix, "prefix", "p", "", "The IPv4 prefix for the route, in CIDR-style notation. For a static default route, this will always be '0.0.0.0/0'") | ||
createRouteCmd.Flags().StringVarP(&nextHop, "nextHop", "n", "", "The IPv4 address within the VRF of the host that will handle this route") | ||
createRouteCmd.Flags().StringSliceVarP(&tags, "tags", "t", []string{}, `Adds the tags for the connection --tags="tag1,tag2".`) | ||
|
||
// making them all required here | ||
_ = createRouteCmd.MarkFlagRequired("id") | ||
_ = createRouteCmd.MarkFlagRequired("prefix") | ||
_ = createRouteCmd.MarkFlagRequired("nextHop") | ||
|
||
return createRouteCmd | ||
} |
Oops, something went wrong.