Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial ipv6 support #72

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cmd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ func init() {
networkAllocateCmd.Flags().StringP("partition", "", "", "partition where this network should exist. [required]")
networkAllocateCmd.Flags().StringP("project", "", "", "partition where this network should exist. [required]")
networkAllocateCmd.Flags().StringP("description", "d", "", "description of the network to create. [optional]")
networkAllocateCmd.Flags().Uint8P("length", "", 0, "the bitlength of the prefix to allocate, defaults to the configured child prefix length in the super network [optional]")
networkAllocateCmd.Flags().BoolP("ipv6", "", false, "if set a ipv6 subnet is allocated, default is ipv4 [optional]")
networkAllocateCmd.Flags().StringSlice("labels", []string{}, "labels for this network. [optional]")
networkAllocateCmd.Flags().BoolP("shared", "", false, "shared allows usage of this private network from other networks")
err := networkAllocateCmd.MarkFlagRequired("name")
Expand Down Expand Up @@ -320,6 +322,21 @@ func networkAllocate(driver *metalgo.Driver) error {
Labels: labelsFromTags(viper.GetStringSlice("labels")),
}
}
length := viper.GetUint("length")
if length > 0 {
l := uint8(length)
ncr.Length = &l
}

ipv6 := viper.GetBool("ipv6")
if ipv6 {
ipv6Str := "IPv6"
ncr.AddressFamily = &ipv6Str
} else {
ipv4Str := "IPv4"
ncr.AddressFamily = &ipv4Str
}

resp, err := driver.NetworkAllocate(&ncr)
if err != nil {
return fmt.Errorf("network allocate error:%v", err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.10.0
github.com/metal-stack/masterdata-api v0.8.4
github.com/metal-stack/metal-go v0.11.5
github.com/metal-stack/metal-go v0.11.6-0.20210128133943-12eaf9015284
github.com/metal-stack/metal-lib v0.6.9
github.com/metal-stack/updater v1.1.1
github.com/metal-stack/v v1.0.2
Expand Down
Loading