fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/41105?usp=email )
Change subject: [REST] Implement ErabDelete ......................................................................
[REST] Implement ErabDelete
Change-Id: I3576814f44d87551fdac6236ddbec6215ba07455 Related: SYS#7066 --- M contrib/openapi.yaml M contrib/osmo-s1gw-cli.py M priv/openapi.json M src/rest_server.erl 4 files changed, 57 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/05/41105/1
diff --git a/contrib/openapi.yaml b/contrib/openapi.yaml index adf3e58..75174d2 100644 --- a/contrib/openapi.yaml +++ b/contrib/openapi.yaml @@ -135,6 +135,16 @@ $ref: '#/components/schemas/ErabItem' '404': description: Unsuccessful outcome (E-RAB not found) + delete: + summary: Terminate an E-RAB FSM process + operationId: ErabDelete + parameters: + - $ref: '#/components/parameters/ErabId' + responses: + '200': + description: Successful outcome (E-RAB FSM terminated) + '404': + description: Unsuccessful outcome (E-RAB not found)
components: responses: diff --git a/contrib/osmo-s1gw-cli.py b/contrib/osmo-s1gw-cli.py index 8a65295..c008dad 100755 --- a/contrib/osmo-s1gw-cli.py +++ b/contrib/osmo-s1gw-cli.py @@ -126,6 +126,11 @@ with self.send_get_req(f'erab/pid:{pid}') as f: return json.load(f)
+ def erab_delete(self, pid: str) -> int: + ''' ErabDelete :: Terminate an E-RAB FSM process ''' + with self.send_delete_req(f'erab/pid:{pid}') as f: + return f.status +
class OsmoS1GWCli(cmd2.Cmd): DESC = 'Interactive CLI for OsmoS1GW' @@ -326,6 +331,12 @@ data = self.iface.erab_info(opts.pid) self.erab_list_print([data])
+ @cmd2.with_argparser(erab_info_parser) + @cmd2.with_category(CAT_ERAB) + def do_erab_delete(self, opts) -> None: + ''' Terminate an E-RAB FSM process ''' + self.iface.erab_delete(opts.pid) +
ap = argparse.ArgumentParser(prog='osmo-s1gw-cli', description=OsmoS1GWCli.DESC)
diff --git a/priv/openapi.json b/priv/openapi.json index bfe82a3..3b77c8a 100644 --- a/priv/openapi.json +++ b/priv/openapi.json @@ -209,6 +209,23 @@ "description": "Unsuccessful outcome (E-RAB not found)" } } + }, + "delete": { + "summary": "Terminate an E-RAB FSM process", + "operationId": "ErabDelete", + "parameters": [ + { + "$ref": "#/components/parameters/ErabId" + } + ], + "responses": { + "200": { + "description": "Successful outcome (E-RAB FSM terminated)" + }, + "404": { + "description": "Unsuccessful outcome (E-RAB not found)" + } + } } } }, diff --git a/src/rest_server.erl b/src/rest_server.erl index e1333c0..6de53a0 100644 --- a/src/rest_server.erl +++ b/src/rest_server.erl @@ -41,7 +41,8 @@ enb_info/1, enb_erab_list/1, erab_list/1, - erab_info/1 + erab_info/1, + erab_delete/1 ]).
-include_lib("kernel/include/logger.hrl"). @@ -140,6 +141,23 @@ end.
+%% ErabDelete :: Terminate an E-RAB FSM process +erab_delete(#{path_parameters := PP}) -> + [{<< "ErabId" >>, << ID/bytes >>}] = PP, + case ID of + << "pid:", Val/bytes >> -> + Pid = parse_pid(Val), + try erab_fsm:shutdown(Pid) of + ok -> {200, [], undefined} + catch + exit:{noproc, _} -> {404, [], undefined} + end; + _ -> + ?LOG_ERROR("Unhandled E-RAB ID ~p", [ID]), + {400, [], undefined} + end. + + %% ------------------------------------------------------------------ %% private API %% ------------------------------------------------------------------