Skip to content

Commit fd9c091

Browse files
committed
start ipv6 support
1 parent 09d2d77 commit fd9c091

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

cmd/cloudNetworkPublicAdd.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,21 @@ operating system.
3737
If the configure-ips flag is not passed, the IP addresses will be assigned, and
3838
routing will be allowed. However the IP(s) will not be automatically configured
3939
in the guest operating system. In this scenario, it will be up to the system
40-
administrator to add the IP(s) to the network configuration.`,
40+
administrator to add the IP(s) to the network configuration.
41+
42+
IPv6 Notes:
43+
44+
Only /64s will be given out, and new-ips refers to how many /64's to assign.
45+
There is a limit of one /64 per Cloud Server. If you need more than this, you
46+
can contact support.`,
4147
Run: func(cmd *cobra.Command, args []string) {
4248
params := &instance.CloudNetworkPublicAddParams{}
4349

4450
params.UniqId, _ = cmd.Flags().GetString("uniq-id")
4551
params.ConfigureIps, _ = cmd.Flags().GetBool("configure-ips")
4652
params.NewIps, _ = cmd.Flags().GetInt64("new-ips")
4753
params.PoolIps = cloudNetworkPublicAddCmdPoolIpsFlag
54+
params.IpVersion, _ = cmd.Flags().GetInt("ip-version")
4855

4956
status, err := lwCliInst.CloudNetworkPublicAdd(params)
5057
if err != nil {
@@ -64,6 +71,8 @@ func init() {
6471
cloudNetworkPublicAddCmd.Flags().StringSliceVar(&cloudNetworkPublicAddCmdPoolIpsFlag, "pool-ips", []string{},
6572
"ips from your IP Pool separated by ',' to assign to the Cloud Server")
6673

74+
cloudNetworkPublicAddCmd.Flags().Int("ip-version", 4, "IP version 4 or 6")
75+
6776
if err := cloudNetworkPublicAddCmd.MarkFlagRequired("uniq-id"); err != nil {
6877
lwCliInst.Die(err)
6978
}

instance/cloudNetworkPublicAdd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type CloudNetworkPublicAddParams struct {
2828
ConfigureIps bool `yaml:"configure-ips"`
2929
NewIps int64 `yaml:"new-ips"`
3030
PoolIps []string `yaml:"pool-ips"`
31+
IpVersion int `yaml:"ip-version"`
3132
}
3233

3334
func (self *CloudNetworkPublicAddParams) UnmarshalYAML(unmarshal func(interface{}) error) error {
@@ -55,9 +56,15 @@ func (self *Client) CloudNetworkPublicAdd(params *CloudNetworkPublicAddParams) (
5556
return
5657
}
5758

59+
if params.IpVersion != 4 && params.IpVersion != 6 {
60+
err = fmt.Errorf("ip-version may only be 4 or 6")
61+
return
62+
}
63+
5864
apiArgs := map[string]interface{}{
5965
"configure_ips": params.ConfigureIps,
6066
"uniq_id": params.UniqId,
67+
"ip_version": params.IpVersion,
6168
}
6269
if params.NewIps != 0 {
6370
apiArgs["ip_count"] = params.NewIps

types/api/network.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ func (x NetworkAssignmentListEntry) String() string {
9696
var slice []string
9797

9898
slice = append(slice, fmt.Sprintf("\tIP: %s\n", x.Ip))
99+
slice = append(slice, fmt.Sprintf("\t\tNetwork: %s\n", x.Network))
99100
slice = append(slice, fmt.Sprintf("\t\tId: %d\n", x.Id))
100101
slice = append(slice, fmt.Sprintf("\t\tGateway: %s\n", x.Gateway))
101-
slice = append(slice, fmt.Sprintf("\t\tBroadcast: %s\n", x.Broadcast))
102+
if x.Broadcast != "" {
103+
slice = append(slice, fmt.Sprintf("\t\tBroadcast: %s\n", x.Broadcast))
104+
}
102105
slice = append(slice, fmt.Sprintf("\t\tNetmask: %s\n", x.Netmask))
103-
slice = append(slice, fmt.Sprintf("\t\tNetwork: %s\n", x.Netmask))
104106

105107
return strings.Join(slice[:], "")
106108
}

0 commit comments

Comments
 (0)