Skip to content

Commit

Permalink
Update code to display client_auth for rest and telemetry (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
KR, HaemanthiSree authored and GitHub Enterprise committed Oct 10, 2022
1 parent 469e798 commit 0e1786f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
22 changes: 7 additions & 15 deletions CLI/actioner/sonic_cli_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,7 @@ def invoke_api(func, args):
body = None
path = None
# Set/Get the rules of all IFA table entries.
if func == "get_sonic_client_auth_rest":
path = cc.Path(
"/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/client_auth"
)
return api.get(path)
elif func == "get_sonic_client_auth_telemetry":
path = cc.Path(
"/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/client_auth"
)
return api.get(path)

elif func == "get_sonic_client_rest":
if func == "get_sonic_client_rest":
if len(args) < 1 :
path = cc.Path(
"/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default")
Expand All @@ -62,12 +51,12 @@ def invoke_api(func, args):
elif args[0] == 'read-timeout':
path = cc.Path(
"/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/read_timeout")
elif args[0] == 'security-profile':
elif args[0] == 'authentication':
path = cc.Path(
"/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/security_profile")
"/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/client_auth")
else:
path = cc.Path(
"/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default")
"/restconf/data/sonic-mgmt-rest:sonic-mgmt-rest/REST_SERVER/REST_SERVER_LIST=default/security_profile")
return api.get(path)

elif func == "get_sonic_client_telemetry":
Expand All @@ -87,6 +76,9 @@ def invoke_api(func, args):
elif args[0] == 'port':
path = cc.Path(
"/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/port")
elif args[0] == 'authentication':
path = cc.Path(
"/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/client_auth")
else:
path = cc.Path(
"/restconf/data/sonic-mgmt-telemetry:sonic-mgmt-telemetry/TELEMETRY/TELEMETRY_LIST=gnmi/security_profile")
Expand Down
17 changes: 16 additions & 1 deletion CLI/renderer/templates/show_mgmt_rest_telemetry.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{% set vars = {'req_limit': ""} %}
{% set vars = {'read_timeout': ""} %}
{% set vars = {'security_profile': ""} %}
{% set vars = {'client_auth': ""} %}

{% if json_output -%}
{{ ' ' }}
Expand All @@ -17,6 +18,7 @@
{% if vars.update({'jwt_refresh':900}) %}{% endif %}
{% if vars.update({'req_limit':0}) %}{% endif %}
{% if vars.update({'read_timeout':30}) %}{% endif %}
{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %}
{% if vars.update({'security_profile':"not-set"}) %}{% endif %}
{% else %}
{% for vals in rest_keys %}
Expand Down Expand Up @@ -55,6 +57,11 @@
{% else %}
{% if vars.update({'security_profile':"not-set"}) %}{% endif %}
{% endif %}
{% if "client_auth" in vals %}
{% if vars.update({'client_auth':vals["client_auth"]}) %}{% endif %}
{% else %}
{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %}
{% endif %}
{% endfor %}
{% endif %}
Log level is {{vars.log_level}}
Expand All @@ -63,6 +70,7 @@ JWT refresh is {{vars.jwt_refresh}} seconds
Port is {{vars.port}}
Request limit is {{vars.req_limit}}
Read timeout is {{vars.read_timeout}} seconds
Client authentication mode is {{vars.client_auth}}
Security profile is {{vars.security_profile}}
{% endif %}

Expand Down Expand Up @@ -90,12 +98,13 @@ Security profile is {{json_output["sonic-mgmt-rest:security_profile"]}}

{% if "sonic-mgmt-telemetry:TELEMETRY_LIST" in json_output %}
{% set telem_keys = json_output["sonic-mgmt-telemetry:TELEMETRY_LIST"] %}
{% if rest_keys|length == 0 %}
{% if telem_keys|length == 0 %}
{% if vars.update({'log_level':"not-set"}) %}{% endif %}
{% if vars.update({'port':8080}) %}{% endif %}
{% if vars.update({'jwt_valid':3600}) %}{% endif %}
{% if vars.update({'jwt_refresh':900}) %}{% endif %}
{% if vars.update({'security_profile':"not-set"}) %}{% endif %}
{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %}
{% else %}
{% for vals in telem_keys %}
{% if "log_level" in vals %}
Expand Down Expand Up @@ -123,13 +132,19 @@ Security profile is {{json_output["sonic-mgmt-rest:security_profile"]}}
{% else %}
{% if vars.update({'security_profile':"not-set"}) %}{% endif %}
{% endif %}
{% if "client_auth" in vals %}
{% if vars.update({'client_auth':vals["client_auth"]}) %}{% endif %}
{% else %}
{% if vars.update({'client_auth':"password,jwt"}) %}{% endif %}
{% endif %}
{% endfor %}
{% endif %}

Log level is {{vars.log_level}}
JWT valid is {{vars.jwt_valid}} seconds
JWT refresh is {{vars.jwt_refresh}} seconds
Port is {{vars.port}}
Client authentication mode is {{vars.client_auth}}
Security profile is {{vars.security_profile}}
{% endif %}

Expand Down

0 comments on commit 0e1786f

Please sign in to comment.