diff --git a/client/node.go b/client/node.go index 073d0154b..79ec62515 100644 --- a/client/node.go +++ b/client/node.go @@ -212,7 +212,6 @@ func (n *NodeClient) Counters(ctx context.Context) (counters Counters, err error const cmd = "zos.statistics.get" err = n.bus.Call(ctx, n.nodeTwin, cmd, nil, &counters) return - } // Pools returns statistics of separate pools @@ -267,7 +266,6 @@ func (n *NodeClient) NetworkListAllInterfaces(ctx context.Context) (result map[s err = n.bus.Call(ctx, n.nodeTwin, cmd, nil, &result) return - } // NetworkSetPublicExitDevice select which physical interface to use as an exit device @@ -322,6 +320,13 @@ func (n *NodeClient) NetworkGetPublicConfig(ctx context.Context) (cfg pkg.Public return } +func (n *NodeClient) NetworkGetNodeFeatures(ctx context.Context) (feat pkg.NodeFeatures, err error) { + const cmd = "zos.network.node_features_get" + + err = n.bus.Call(ctx, n.nodeTwin, cmd, nil, &feat) + return +} + func (n *NodeClient) SystemVersion(ctx context.Context) (ver Version, err error) { const cmd = "zos.system.version" diff --git a/docs/manual/api.md b/docs/manual/api.md index 4127a5e4f..798fdbb86 100644 --- a/docs/manual/api.md +++ b/docs/manual/api.md @@ -149,6 +149,32 @@ PublicConfig { returns the node public config or error if not set. If a node has public config it means it can act like an access node to user private networks +### Get node features + +| command |body| return| +|---|---|---| +| `zos.network.node_features_get` | - |`NodeFeatures` | + +Where + +```json +NodeFeatures { + "zmount_type": "string", + "network_type": "string", + "zdb_type": "string", + "zmachine_type": "string", + "volume_type": "string", + "public_ipv4_type": "string", + "public_ip_type": "string", + "gateway_name_proxy_type": "string", + "gateway_fqdn_proxy_type": "string", + "qantum_safe_fs_type": "string", + "zlog_type": "string", +} +``` + +returns the features of the network manager running on the node + ## Admin The next set of commands are ONLY possible to be called by the `farmer` only. diff --git a/pkg/network.go b/pkg/network.go index f373cd215..7d3bbce66 100644 --- a/pkg/network.go +++ b/pkg/network.go @@ -198,6 +198,9 @@ type Networker interface { // Get node public namespace config GetPublicConfig() (PublicConfig, error) + // Get the features of the network manager running on the node + GetNodeFeatures() (NodeFeatures, error) + // GetPublicExitDevice either return "singe" or "dual()" GetPublicExitDevice() (ExitDevice, error) @@ -257,6 +260,32 @@ type PublicConfig struct { Domain string `json:"domain"` } +type NodeFeatures struct { + // ZMountType type + ZMountType gridtypes.WorkloadType `json:"zmount_type"` + // NetworkType type + NetworkType gridtypes.WorkloadType `json:"network_type"` + // ZDBType type + ZDBType gridtypes.WorkloadType `json:"zdb_type"` + // ZMachineType type + ZMachineType gridtypes.WorkloadType `json:"zmachine_type"` + // VolumeType type + VolumeType gridtypes.WorkloadType `json:"volume_type"` + // PublicIPv4Type type [deprecated] + PublicIPv4Type gridtypes.WorkloadType `json:"public_ipv4_type"` + // PublicIPType type is the new way to assign public ips + // to a VM. this has flags (V4, and V6) that has to be set. + PublicIPType gridtypes.WorkloadType `json:"public_ip_type"` + // GatewayNameProxyType type + GatewayNameProxyType gridtypes.WorkloadType `json:"gateway_name_proxy_type"` + // GatewayFQDNProxyType type + GatewayFQDNProxyType gridtypes.WorkloadType `json:"gateway_fqdn_proxy_type"` + // QuantumSafeFSType type + QuantumSafeFSType gridtypes.WorkloadType `json:"qantum_safe_fs_type"` + // ZLogsType type + ZLogsType gridtypes.WorkloadType `json:"zlog_type"` +} + func (p *PublicConfig) IsEmpty() bool { return p.IPv4.Nil() && p.IPv6.Nil() } diff --git a/pkg/network/networker.go b/pkg/network/networker.go index ccef4a6d0..1b86f3ba7 100644 --- a/pkg/network/networker.go +++ b/pkg/network/networker.go @@ -1139,6 +1139,24 @@ func (n *networker) GetPublicConfig() (pkg.PublicConfig, error) { return cfg, nil } +// Get the features of the network manager running on the node +func (n *networker) GetNodeFeatures() (pkg.NodeFeatures, error) { + feat := pkg.NodeFeatures{ + ZMountType: zos.ZMountType, + NetworkType: zos.NetworkType, + ZDBType: zos.ZDBType, + ZMachineType: zos.ZMachineType, + VolumeType: zos.VolumeType, + PublicIPv4Type: zos.PublicIPv4Type, + PublicIPType: zos.PublicIPType, + GatewayNameProxyType: zos.GatewayNameProxyType, + GatewayFQDNProxyType: zos.GatewayFQDNProxyType, + QuantumSafeFSType: zos.QuantumSafeFSType, + ZLogsType: zos.ZLogsType, + } + return feat, nil +} + func (n *networker) networkOf(id zos.NetID) (nr pkg.Network, err error) { path := filepath.Join(n.networkDir, string(id)) file, err := os.OpenFile(path, os.O_RDWR, 0660) diff --git a/pkg/stubs/network_stub.go b/pkg/stubs/network_stub.go index 9482e6f07..d49d45dc3 100644 --- a/pkg/stubs/network_stub.go +++ b/pkg/stubs/network_stub.go @@ -188,6 +188,23 @@ func (s *NetworkerStub) GetNet(ctx context.Context, arg0 zos.NetID) (ret0 net.IP return } +func (s *NetworkerStub) GetNodeFeatures(ctx context.Context) (ret0 pkg.NodeFeatures, ret1 error) { + args := []interface{}{} + result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNodeFeatures", args...) + if err != nil { + panic(err) + } + result.PanicOnError() + ret1 = result.CallError() + loader := zbus.Loader{ + &ret0, + } + if err := result.Unmarshal(&loader); err != nil { + panic(err) + } + return +} + func (s *NetworkerStub) GetPublicConfig(ctx context.Context) (ret0 pkg.PublicConfig, ret1 error) { args := []interface{}{} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetPublicConfig", args...) diff --git a/pkg/zos_api/network.go b/pkg/zos_api/network.go index ecc524aa8..4ad9d57d8 100644 --- a/pkg/zos_api/network.go +++ b/pkg/zos_api/network.go @@ -13,9 +13,15 @@ import ( func (g *ZosAPI) networkListWGPortsHandler(ctx context.Context, payload []byte) (interface{}, error) { return g.networkerStub.WireguardPorts(ctx) } + func (g *ZosAPI) networkPublicConfigGetHandler(ctx context.Context, payload []byte) (interface{}, error) { return g.networkerStub.GetPublicConfig(ctx) } + +func (g *ZosAPI) networkNodeFeaturesGetHandler(ctx context.Context, payload []byte) (interface{}, error) { + return g.networkerStub.GetNodeFeatures(ctx) +} + func (g *ZosAPI) networkInterfacesHandler(ctx context.Context, payload []byte) (interface{}, error) { results := make(map[string][]net.IP) type q struct { @@ -42,11 +48,13 @@ func (g *ZosAPI) networkInterfacesHandler(ctx context.Context, payload []byte) ( return results, nil } + func (g *ZosAPI) networkHasIPv6Handler(ctx context.Context, payload []byte) (interface{}, error) { ipData, err := g.networkerStub.GetPublicIPv6Subnet(ctx) hasIP := ipData.IP != nil && err == nil return hasIP, err } + func (g *ZosAPI) networkListPublicIPsHandler(ctx context.Context, payload []byte) (interface{}, error) { return g.provisionStub.ListPublicIPs(ctx) } diff --git a/pkg/zos_api/routes.go b/pkg/zos_api/routes.go index 7fa70493a..f52820a21 100644 --- a/pkg/zos_api/routes.go +++ b/pkg/zos_api/routes.go @@ -5,7 +5,6 @@ import ( ) func (g *ZosAPI) SetupRoutes(router *peer.Router) { - root := router.SubRoute("zos") root.Use(g.log) system := root.SubRoute("system") @@ -27,6 +26,7 @@ func (g *ZosAPI) SetupRoutes(router *peer.Router) { network := root.SubRoute("network") network.WithHandler("list_wg_ports", g.networkListWGPortsHandler) network.WithHandler("public_config_get", g.networkPublicConfigGetHandler) + network.WithHandler("node_features_get", g.networkNodeFeaturesGetHandler) network.WithHandler("interfaces", g.networkInterfacesHandler) network.WithHandler("has_ipv6", g.networkHasIPv6Handler) network.WithHandler("list_public_ips", g.networkListPublicIPsHandler)