From 9dd40a92c51fc3c255e0fccd84670efaf00d8c85 Mon Sep 17 00:00:00 2001 From: Ilja Rotar Date: Tue, 11 Aug 2026 17:50:37 +0200 Subject: [PATCH] init vrf service --- proto/metalstack/admin/v2/switch.proto | 56 +++++++++---------- proto/metalstack/admin/v2/vrf.proto | 77 ++++++++++++++++++++++++++ proto/metalstack/api/v2/vrf.proto | 28 ++++++++++ proto/metalstack/infra/v2/switch.proto | 24 ++++---- 4 files changed, 145 insertions(+), 40 deletions(-) create mode 100644 proto/metalstack/admin/v2/vrf.proto create mode 100644 proto/metalstack/api/v2/vrf.proto diff --git a/proto/metalstack/admin/v2/switch.proto b/proto/metalstack/admin/v2/switch.proto index 4812cf80..6555caba 100644 --- a/proto/metalstack/admin/v2/switch.proto +++ b/proto/metalstack/admin/v2/switch.proto @@ -53,7 +53,7 @@ service SwitchService { // SwitchServiceGetRequest is the request payload for getting a switch. message SwitchServiceGetRequest { - // Id of the switch to get + // Id of the switch to get. string id = 1 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true @@ -62,81 +62,81 @@ message SwitchServiceGetRequest { // SwitchServiceGetResponse is the response payload for getting a switch. message SwitchServiceGetResponse { - // Switch contains the requested switch + // Switch contains the requested switch. metalstack.api.v2.Switch switch = 1; } // SwitchServiceListRequest is the request payload for listing switches. message SwitchServiceListRequest { - // Query to filter the results + // Query to filter the results. metalstack.api.v2.SwitchQuery query = 1; } // SwitchServiceListResponse is the response payload for listing switches. message SwitchServiceListResponse { - // Switches that match the request query + // Switches that match the request query. repeated metalstack.api.v2.Switch switches = 1; } // SwitchServiceUpdateRequest is the request payload for updating a switch. message SwitchServiceUpdateRequest { - // ID of the switch + // ID of the switch. string id = 1 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true }]; - // UpdateMeta contains the timestamp and strategy to be used in this update request + // UpdateMeta contains the timestamp and strategy to be used in this update request. metalstack.api.v2.UpdateMeta update_meta = 2 [(buf.validate.field).required = true]; - // UpdatedAt is the date when this entity was updated - // Must be part of the update request to ensure optimistic locking + // UpdatedAt is the date when this entity was updated. + // Must be part of the update request to ensure optimistic locking. google.protobuf.Timestamp updated_at = 3; - // Description of the switch + // Description of the switch. optional string description = 4 [(buf.validate.field).string.(metalstack.api.v2.is_description) = true]; - // ReplaceMode is used to mark a switch ready for replacement + // ReplaceMode is used to mark a switch ready for replacement. optional metalstack.api.v2.SwitchReplaceMode replace_mode = 5 [(buf.validate.field).enum.defined_only = true]; // ManagementIp is the switch's IP for management access optional string management_ip = 6 [(buf.validate.field).string.ip = true]; - // ManagementUser is the user name to use for management access + // ManagementUser is the user name to use for management access. optional string management_user = 7 [(buf.validate.field).string.(metalstack.api.v2.is_name) = true]; - // ConsoleCommand is the command for accessing the switch's console + // ConsoleCommand is the command for accessing the switch's console. optional string console_command = 8 [(buf.validate.field).string.(metalstack.api.v2.is_description) = true]; - // Nics are the front panel ports of the switch + // Nics are the front panel ports of the switch. repeated metalstack.api.v2.SwitchNic nics = 9; - // SwitchOs is the OS running on the switch + // SwitchOs is the OS running on the switch. optional metalstack.api.v2.SwitchOS os = 10; } // SwitchServiceUpdateResponse is the response payload for updating a switch. message SwitchServiceUpdateResponse { - // Switch contains the updated switch + // Switch contains the updated switch. metalstack.api.v2.Switch switch = 1; } // SwitchServiceDeleteRequest is the request payload for deleting a switch. message SwitchServiceDeleteRequest { - // Id of the switch + // Id of the switch. string id = 1 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true }]; - // Force will allow switch deletion despite existing machine connections + // Force will allow switch deletion despite existing machine connections. bool force = 2; } // SwitchServiceDeleteResponse is the response payload for deleting a switch. message SwitchServiceDeleteResponse { - // Switch contains the deleted switch + // Switch contains the deleted switch. metalstack.api.v2.Switch switch = 1; } // SwitchServiceMigrateRequest is the request payload for migrating a switch. message SwitchServiceMigrateRequest { - // OldSwitch is the switch to migrate away from + // OldSwitch is the switch to migrate away from. string old_switch = 1 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true }]; - // NewSwitch is the switch to migrate to + // NewSwitch is the switch to migrate to. string new_switch = 2 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true @@ -145,39 +145,39 @@ message SwitchServiceMigrateRequest { // SwitchServiceMigrateResponse is the response payload for migrating a switch. message SwitchServiceMigrateResponse { - // Switch contains the switch that was migrated to + // Switch contains the switch that was migrated to. metalstack.api.v2.Switch switch = 1; } // SwitchServicePortRequest is the request payload for setting the port status of a switch port. message SwitchServicePortRequest { - // Id of the switch + // Id of the switch. string id = 1 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true }]; - // NicName of the port whose status should be changed + // NicName of the port whose status should be changed. string nic_name = 2 [(buf.validate.field).string.(metalstack.api.v2.is_name) = true]; - // Status that the port should have + // Status that the port should have. metalstack.api.v2.SwitchPortStatus status = 3 [(buf.validate.field).enum.defined_only = true]; } // SwitchServicePortResponse is the response payload for setting the port status of a switch port. message SwitchServicePortResponse { - // Switch after the port status toggle + // Switch after the port status toggle. metalstack.api.v2.Switch switch = 1; } // SwitchServiceConnectedMachinesRequest is the request payload for listing switches with machine connections. message SwitchServiceConnectedMachinesRequest { - // Query to filter the switch results + // Query to filter the switch results. metalstack.api.v2.SwitchQuery query = 1; - // MachineQuery to filter the machine results + // MachineQuery to filter the machine results. metalstack.api.v2.MachineQuery machine_query = 2; } // SwitchServiceConnectedMachinesResponse is the response payload for listing switches with machine connections. message SwitchServiceConnectedMachinesResponse { - // SwitchesWithMachines contains all switches with their machine connections + // SwitchesWithMachines contains all switches with their machine connections. repeated metalstack.api.v2.SwitchWithMachines switches_with_machines = 1; } diff --git a/proto/metalstack/admin/v2/vrf.proto b/proto/metalstack/admin/v2/vrf.proto new file mode 100644 index 00000000..61e4553c --- /dev/null +++ b/proto/metalstack/admin/v2/vrf.proto @@ -0,0 +1,77 @@ +syntax = "proto3"; + +package metalstack.admin.v2; + +import "buf/validate/validate.proto"; +import "google/protobuf/timestamp.proto"; +import "metalstack/api/v2/common.proto"; +import "metalstack/api/v2/machine.proto"; +import "metalstack/api/v2/predefined_rules.proto"; +import "metalstack/api/v2/vrf.proto"; + +// VRFService provides endpoints for managing VRFs connecting to machines outside of metal-stack. +service VRFService { + // Creates a new VRF. + rpc Create(VRFServiceCreateRequest) returns (VRFServiceCreateResponse) { + option (metalstack.api.v2.admin_roles) = ADMIN_ROLE_EDITOR; + option (metalstack.api.v2.auditing) = AUDITING_INCLUDED; + } + // Returns the VRF by ID. + rpc Get(VRFServiceGetRequest) returns (VRFServiceGetResponse) { + option (metalstack.api.v2.admin_roles) = ADMIN_ROLE_EDITOR; + option (metalstack.api.v2.admin_roles) = ADMIN_ROLE_VIEWER; + option (metalstack.api.v2.auditing) = AUDITING_EXCLUDED; + } + // Returns all queried VRFs. + rpc List(VRFServiceListRequest) returns (VRFServiceListResponse) { + option (metalstack.api.v2.admin_roles) = ADMIN_ROLE_EDITOR; + option (metalstack.api.v2.admin_roles) = ADMIN_ROLE_VIEWER; + option (metalstack.api.v2.auditing) = AUDITING_EXCLUDED; + } + // Updates a VRF. + rpc Update(VRFServiceUpdateRequest) returns (VRFServiceUpdateResponse) { + option (metalstack.api.v2.admin_roles) = ADMIN_ROLE_EDITOR; + option (metalstack.api.v2.auditing) = AUDITING_INCLUDED; + } + // Deletes a VRF. + rpc Delete(VRFServiceDeleteRequest) returns (VRFServiceDeleteResponse) { + option (metalstack.api.v2.admin_roles) = ADMIN_ROLE_EDITOR; + option (metalstack.api.v2.auditing) = AUDITING_INCLUDED; + } +} + +// VRFServiceCreateRequest +message VRFServiceCreateRequest {} + +// VRFServiceCreateResponse +message VRFServiceCreateResponse {} + +// VRFServiceGetRequest +message VRFServiceGetRequest { + // Name of the VRF. + string name = 1 [(buf.validate.field).string.(metalstack.api.v2.is_name) = true]; +} + +// VRFServiceGetResponse +message VRFServiceGetResponse { + // Vrf is the requested VRF. + metalstack.api.v2.VRF vrf = 1; +} + +// VRFServiceListRequest +message VRFServiceListRequest {} + +// VRFServiceListResponse +message VRFServiceListResponse {} + +// VRFServiceUpdateRequest +message VRFServiceUpdateRequest {} + +// VRFServiceUpdateResponse +message VRFServiceUpdateResponse {} + +// VRFServiceDeleteRequest +message VRFServiceDeleteRequest {} + +// VRFServiceDeleteResponse +message VRFServiceDeleteResponse {} diff --git a/proto/metalstack/api/v2/vrf.proto b/proto/metalstack/api/v2/vrf.proto new file mode 100644 index 00000000..7fc37cbb --- /dev/null +++ b/proto/metalstack/api/v2/vrf.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package metalstack.api.v2; + +import "buf/validate/validate.proto"; +import "metalstack/api/v2/predefined_rules.proto"; +import "metalstack/api/v2/switch.proto"; + +// VRF represents a VRF that is connected to machines which are not managed by metal-stack. +message VRF { + // Name of the VRF. + string name = 1 [(buf.validate.field).string.(metalstack.api.v2.is_name) = true]; + // Vni of the VRF. + uint32 vni = 2 [(buf.validate.field).uint32 = { + gt: 0 + lte: 16777216 + }]; + // VrfPorts maps switch IDs to the respective switch's ports that are bound to this VRF. + map vrf_ports = 3; + // Cidrs that are permitted in this VRF. + repeated string cidrs = 4 [(buf.validate.field).repeated.(metalstack.api.v2.prefixes) = true]; +} + +// VRFPorts is a collection of ports bound to a VRF. +message VRFPorts { + // Nics in the VRF. + repeated metalstack.api.v2.SwitchNic nics = 1; +} diff --git a/proto/metalstack/infra/v2/switch.proto b/proto/metalstack/infra/v2/switch.proto index c9e90481..cfa30660 100644 --- a/proto/metalstack/infra/v2/switch.proto +++ b/proto/metalstack/infra/v2/switch.proto @@ -30,7 +30,7 @@ service SwitchService { // SwitchServiceGetRequest is the request payload for getting a switch. message SwitchServiceGetRequest { - // Id of the switch + // Id of the switch. string id = 1 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true @@ -39,45 +39,45 @@ message SwitchServiceGetRequest { // SwitchServiceGetResponse is the response payload for getting a switch. message SwitchServiceGetResponse { - // Switch contains the requested switch + // Switch contains the requested switch. metalstack.api.v2.Switch switch = 1; } // SwitchServiceRegisterRequest is the request payload for registering a switch. message SwitchServiceRegisterRequest { - // Switch to register + // Switch to register. metalstack.api.v2.Switch switch = 1; } // SwitchServiceRegisterResponse is the response payload for registering a switch. message SwitchServiceRegisterResponse { - // Switch contains the registered switch + // Switch contains the registered switch. metalstack.api.v2.Switch switch = 1; } // SwitchServiceHeartbeatRequest is the request payload for sending a switch heartbeat. message SwitchServiceHeartbeatRequest { - // Id of the switch + // Id of the switch. string id = 1 [(buf.validate.field).string = { hostname: true [metalstack.api.v2.is_name]: true }]; - // Duration of the sync + // Duration of the sync. google.protobuf.Duration duration = 2; - // Error if any occurred during the sync + // Error if any occurred during the sync. optional string error = 3; - // PortStates maps port identifiers to the respective port's operational state + // PortStates maps port identifiers to the respective port's operational state. map port_states = 4; - // BgpPortStates maps port identifiers to the respective port's BGP state + // BgpPortStates maps port identifiers to the respective port's BGP state. map bgp_port_states = 5; } // SwitchServiceHeartbeatResponse is the response payload for sending a switch heartbeat. message SwitchServiceHeartbeatResponse { - // Id of the switch + // Id of the switch. string id = 1; - // LastSync holds information about the last sync + // LastSync holds information about the last sync. metalstack.api.v2.SwitchSync last_sync = 2; - // LastSyncError holds information about the last erroneous sync + // LastSyncError holds information about the last erroneous sync. metalstack.api.v2.SwitchSync last_sync_error = 3; }