Skip to content

Commit

Permalink
expose haspublicipv6 on rmb (#1554)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashraf Fouda <[email protected]>
  • Loading branch information
ashraffouda authored Jan 11, 2022
1 parent 2645ca7 commit eb0d6b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ func (n *NodeClient) NetworkListWGPorts(ctx context.Context) ([]uint16, error) {
return result, nil
}

func (n *NodeClient) HasPublicIPv6(ctx context.Context) (bool, error) {
const cmd = "zos.network.has_ipv6"
var result bool

if err := n.bus.Call(ctx, n.nodeTwin, cmd, nil, &result); err != nil {
return false, err
}

return result, nil
}

func (n *NodeClient) NetworkListInterfaces(ctx context.Context) (map[string][]net.IP, error) {
const cmd = "zos.network.interfaces"
var result map[string][]net.IP
Expand Down
8 changes: 8 additions & 0 deletions pkg/provision/mbus/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func (n *Network) listPortsHandler(ctx context.Context, payload []byte) (interfa
return data, nil
}

func (n *Network) hasPublicIPv6Handler(ctx context.Context, payload []byte) (interface{}, error) {
return n.hasPublicIPv6(ctx), nil
}
func (n *Network) interfacesHandler(ctx context.Context, payload []byte) (interface{}, error) {
data, err := n.listInterfaces(ctx)
if err != nil {
Expand Down Expand Up @@ -71,6 +74,7 @@ func (n *Network) setup(router rmb.Router) {
sub.WithHandler("list_public_ips", n.listPublicIPsHandler)
sub.WithHandler("public_config_get", n.getPublicConfigHandler)
sub.WithHandler("interfaces", n.interfacesHandler)
sub.WithHandler("has_ipv6", n.hasPublicIPv6Handler)
}

func (n *Network) listPorts(ctx context.Context) (interface{}, mw.Response) {
Expand All @@ -82,6 +86,10 @@ func (n *Network) listPorts(ctx context.Context) (interface{}, mw.Response) {
return ports, nil
}

func (n *Network) hasPublicIPv6(ctx context.Context) interface{} {
ipData, err := stubs.NewNetworkerStub(n.cl).GetPublicIPv6Subnet(ctx)
return ipData.IP != nil && err == nil
}
func (n *Network) listInterfaces(ctx context.Context) (interface{}, mw.Response) {
mgr := stubs.NewNetworkerStub(n.cl)
results := make(map[string][]net.IP)
Expand Down

0 comments on commit eb0d6b8

Please sign in to comment.