diff --git a/client/node.go b/client/node.go index 073d0154b..455f448fb 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) SystemGetNodeFeatures(ctx context.Context) (feat []pkg.NodeFeature, err error) { + const cmd = "zos.system.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..250eb00f2 100644 --- a/docs/manual/api.md +++ b/docs/manual/api.md @@ -217,6 +217,22 @@ name must be one of (free) names returned by `zos.network.admin.interfaces` |---|---|---| | `zos.system.hypervisor` | - | `string` | +### Get Node Features + +| command |body| return| +|---|---|---| +| `zos.system.node_features_get` | - |`[]NodeFeature` | + + +Where + +```json +NodeFeature: "string" + +``` + +returns the types of workloads can be deployed depending on the network manager running on the node + ## GPUs ### List Gpus diff --git a/pkg/monitor.go b/pkg/monitor.go index 6e3f30199..39a6de7da 100644 --- a/pkg/monitor.go +++ b/pkg/monitor.go @@ -78,6 +78,9 @@ type PoolStats struct { // PoolsStats alias for map[string]PoolStats type PoolsStats map[string]PoolStats +// Types of workloads can be deployed depending on the network manager running on the node +type NodeFeature string + // SystemMonitor interface (provided by noded) type SystemMonitor interface { NodeID() uint32 @@ -85,6 +88,7 @@ type SystemMonitor interface { CPU(ctx context.Context) <-chan TimesStat Disks(ctx context.Context) <-chan DisksIOCountersStat Nics(ctx context.Context) <-chan NicsIOCounterStat + GetNodeFeatures() []NodeFeature } // HostMonitor interface (provided by noded) diff --git a/pkg/monitord/system.go b/pkg/monitord/system.go index 0f3853a75..05ac7f35c 100644 --- a/pkg/monitord/system.go +++ b/pkg/monitord/system.go @@ -10,11 +10,10 @@ import ( "github.com/shirou/gopsutil/mem" "github.com/shirou/gopsutil/net" "github.com/threefoldtech/zos/pkg" + "github.com/threefoldtech/zos/pkg/gridtypes/zos" ) -var ( - _ pkg.SystemMonitor = (*systemMonitor)(nil) -) +var _ pkg.SystemMonitor = (*systemMonitor)(nil) // systemMonitor stream type systemMonitor struct { @@ -199,3 +198,21 @@ func (m *systemMonitor) Nics(ctx context.Context) <-chan pkg.NicsIOCounterStat { return ch } + +// Get the types of workloads can be deployed depending on the network manager running on the node +func (n *systemMonitor) GetNodeFeatures() []pkg.NodeFeature { + feat := []pkg.NodeFeature{ + pkg.NodeFeature(zos.ZMountType), + pkg.NodeFeature(zos.NetworkType), + pkg.NodeFeature(zos.ZDBType), + pkg.NodeFeature(zos.ZMachineType), + pkg.NodeFeature(zos.VolumeType), + pkg.NodeFeature(zos.PublicIPv4Type), + pkg.NodeFeature(zos.PublicIPType), + pkg.NodeFeature(zos.GatewayNameProxyType), + pkg.NodeFeature(zos.GatewayFQDNProxyType), + pkg.NodeFeature(zos.QuantumSafeFSType), + pkg.NodeFeature(zos.ZLogsType), + } + return feat +} diff --git a/pkg/stubs/system_monitor_stub.go b/pkg/stubs/system_monitor_stub.go index b98bd9ae3..2ffc04907 100644 --- a/pkg/stubs/system_monitor_stub.go +++ b/pkg/stubs/system_monitor_stub.go @@ -75,6 +75,22 @@ func (s *SystemMonitorStub) Disks(ctx context.Context) (<-chan pkg.DisksIOCounte return ch, nil } +func (s *SystemMonitorStub) GetNodeFeatures(ctx context.Context) (ret0 []pkg.NodeFeature) { + args := []interface{}{} + result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNodeFeatures", args...) + if err != nil { + panic(err) + } + result.PanicOnError() + loader := zbus.Loader{ + &ret0, + } + if err := result.Unmarshal(&loader); err != nil { + panic(err) + } + return +} + func (s *SystemMonitorStub) Memory(ctx context.Context) (<-chan pkg.VirtualMemoryStat, error) { ch := make(chan pkg.VirtualMemoryStat, 1) recv, err := s.client.Stream(ctx, s.module, s.object, "Memory") diff --git a/pkg/zos_api/routes.go b/pkg/zos_api/routes.go index 7fa70493a..8006f23b7 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") @@ -13,6 +12,7 @@ func (g *ZosAPI) SetupRoutes(router *peer.Router) { system.WithHandler("dmi", g.systemDMIHandler) system.WithHandler("hypervisor", g.systemHypervisorHandler) system.WithHandler("diagnostics", g.systemDiagnosticsHandler) + system.WithHandler("node_features_get", g.systemNodeFeaturesHandler) perf := root.SubRoute("perf") perf.WithHandler("get", g.perfGetHandler) diff --git a/pkg/zos_api/system.go b/pkg/zos_api/system.go index 7bae7beb6..88b775177 100644 --- a/pkg/zos_api/system.go +++ b/pkg/zos_api/system.go @@ -37,3 +37,7 @@ func (g *ZosAPI) systemHypervisorHandler(ctx context.Context, payload []byte) (i func (g *ZosAPI) systemDiagnosticsHandler(ctx context.Context, payload []byte) (interface{}, error) { return g.diagnosticsManager.GetSystemDiagnostics(ctx) } + +func (g *ZosAPI) systemNodeFeaturesHandler(ctx context.Context, payload []byte) (interface{}, error) { + return g.systemMonitorStub.GetNodeFeatures(ctx), nil +} diff --git a/pkg/zos_api/zos_api.go b/pkg/zos_api/zos_api.go index 3e21ef61b..e3661f706 100644 --- a/pkg/zos_api/zos_api.go +++ b/pkg/zos_api/zos_api.go @@ -14,6 +14,7 @@ import ( type ZosAPI struct { oracle *capacity.ResourceOracle versionMonitorStub *stubs.VersionMonitorStub + systemMonitorStub *stubs.SystemMonitorStub provisionStub *stubs.ProvisionStub networkerStub *stubs.NetworkerStub statisticsStub *stubs.StatisticsStub @@ -37,6 +38,7 @@ func NewZosAPI(manager substrate.Manager, client zbus.Client, msgBrokerCon strin api := ZosAPI{ oracle: capacity.NewResourceOracle(storageModuleStub), versionMonitorStub: stubs.NewVersionMonitorStub(client), + systemMonitorStub: stubs.NewSystemMonitorStub(client), provisionStub: stubs.NewProvisionStub(client), networkerStub: stubs.NewNetworkerStub(client), statisticsStub: stubs.NewStatisticsStub(client),