Conversation
da4a086 to
f16caec
Compare
* Handle pre-login message. * Handle post-login message. Signed-off-by: Yevhen Fastiuk <[email protected]>
f16caec to
a6a6215
Compare
|
@stepanblyschak please review |
| self.cache['pre-login'] = login_msgs.get('pre-login',{} | ||
| ).get('message', '') | ||
| self.cache['post-login'] = login_msgs.get('post-login', {} | ||
| ).get('message', '') |
There was a problem hiding this comment.
| self.cache['pre-login'] = login_msgs.get('pre-login',{} | |
| ).get('message', '') | |
| self.cache['post-login'] = login_msgs.get('post-login', {} | |
| ).get('message', '') | |
| self.cache['pre-login'] = login_msgs.get('pre-login', {}).get('message', '') | |
| self.cache['post-login'] = login_msgs.get('post-login', {}).get('message', '') |
There was a problem hiding this comment.
The total line width will exceed 80 chars. Which will break python code style
There was a problem hiding this comment.
There are lines longer then 80 chars in this file. We don't follow that guideline and a newline in the middle hurts readability.
| login_msgs = self.config_db.get_table( | ||
| swsscommon.CFG_LOGIN_MESSAGE_TABLE_NAME) | ||
| for key in login_msgs: | ||
| self.loginmsgcfg.set_login_message(key, login_msgs[key]) |
There was a problem hiding this comment.
load will save configuration into the cache, so this call to set_login_message will not set anything because it is the same as in the cache?
| msg = None if not isinstance(data, dict) else data.get('message') | ||
| if type(msg) != str: | ||
| # Nothing to handle | ||
| return |
There was a problem hiding this comment.
| msg = None if not isinstance(data, dict) else data.get('message') | |
| if type(msg) != str: | |
| # Nothing to handle | |
| return | |
| msg = data.get('message') | |
| if not msg: | |
| # Nothing to handle | |
| return |
| if key == 'pre_login': | ||
| # Write pre-login to /etc/issue file | ||
| run_cmd(self.cmds.login_message_pre.format(not_newline, msg), | ||
| True, True) |
There was a problem hiding this comment.
add log_err and raise_exception as you do on next lines for readability
|
|
||
| class LoginCfg(object): | ||
| """ | ||
| LoginCfg Config Daemon |
There was a problem hiding this comment.
The Daemon word confuses since it is not a deamon
| "modify pam_limits config file failed with exception: {}" | ||
| .format(e)) | ||
|
|
||
| class LoginCfg(object): |
There was a problem hiding this comment.
No need in python3:
| class LoginCfg(object): | |
| class LoginCfg: |
| Handles changes in LOGIN_MESSAGE table. | ||
| 1) Handle change for pre-login and post-login messages. |
There was a problem hiding this comment.
| Handles changes in LOGIN_MESSAGE table. | |
| 1) Handle change for pre-login and post-login messages. | |
| Handles changes in LOGIN_MESSAGE table for pre-login and post-login messages. |
| cache: Cache to compare/save data. | ||
| db: DB instance. | ||
| table: DB table that was changed. | ||
| key: DB table's key that was triggered change. | ||
| data: Read table data. |
There was a problem hiding this comment.
| cache: Cache to compare/save data. | |
| db: DB instance. | |
| table: DB table that was changed. | |
| key: DB table's key that was triggered change. | |
| data: Read table data. | |
| key: DB table's key that was triggered change. | |
| data: Read table data. |
|
Requires UT |
Signed-off-by: Gang Lv [email protected] Why I did it GNMI needs to use host service to invoke generic_config_updater and config reload. How I did it Add host_modules for generic_config_updater and config reload. Add unit test for host modules. How to verify it Run unit test for sonic-host-services.
This PR depends on fastiuk/sonic-buildimage#4
Why I did it
How to verify it
Build SONiC
or
When SONiC was already built:
Login into the switch.
Set messages:
Logout/login and see the results:

Clear messages:
Which release branch to backport (provide reason below if selected)
Description for the changelog
Link to config_db schema for YANG module changes
sonic-login_message.yang
Superproject PR:
A picture of a cute animal