Skip to content

Commit

Permalink
move endpoint from network to system
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Sep 18, 2024
1 parent 19566ef commit 98a467a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 74 deletions.
4 changes: 2 additions & 2 deletions client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ 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"
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
Expand Down
42 changes: 16 additions & 26 deletions docs/manual/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,32 +149,6 @@ 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.
Expand Down Expand Up @@ -243,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
Expand Down
30 changes: 3 additions & 27 deletions pkg/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ 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)
// Get the types of workloads can be deployed depending on the network manager running on the node
GetNodeFeatures() ([]NodeFeature, error)

// GetPublicExitDevice either return "singe" or "dual(<nic>)"
GetPublicExitDevice() (ExitDevice, error)
Expand Down Expand Up @@ -260,31 +260,7 @@ 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"`
}
type NodeFeature string

func (p *PublicConfig) IsEmpty() bool {
return p.IPv4.Nil() && p.IPv6.Nil()
Expand Down
26 changes: 13 additions & 13 deletions pkg/network/networker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1140,19 +1140,19 @@ func (n *networker) GetPublicConfig() (pkg.PublicConfig, error) {
}

// 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,
func (n *networker) GetNodeFeatures() ([]pkg.NodeFeature, error) {
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, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/stubs/network_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ 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) {
func (s *NetworkerStub) GetNodeFeatures(ctx context.Context) (ret0 []pkg.NodeFeature, ret1 error) {
args := []interface{}{}
result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNodeFeatures", args...)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions pkg/zos_api/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ func (g *ZosAPI) networkPublicConfigGetHandler(ctx context.Context, payload []by
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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/zos_api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,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", g.systemNodeFeaturesHandler)

perf := root.SubRoute("perf")
perf.WithHandler("get", g.perfGetHandler)
Expand All @@ -26,7 +27,6 @@ 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)
Expand Down
4 changes: 4 additions & 0 deletions pkg/zos_api/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.networkerStub.GetNodeFeatures(ctx)
}

0 comments on commit 98a467a

Please sign in to comment.