These forums are a place for learning, helping and sharing experiences with others about any of our products. Feel free to ask a question and get answers from our community and our most advanced users.
Note that these are public forums - anyone can view the discussions here.
VISIT OUR DIFFERENT FORUMS:
Announcements > | |
CloudShell > | TestShell > |
Developers > | BI (Business Inteligence) > |
This is where you can suggest your ideas to help and improve the product for everyone.
Please make sure to read the following article before posting a new idea, to get more information about the required information and ideas lifecycle.
Feel free to vote and comment on other ideas to promote them.
Thanks for everyone who suggested the ideas and voted for them.
Find, download and share integrations that can extend and enhance the CloudShell experience.
Integrations have several levels:
Certified - Officially tested and supported by Quali.
Preview - Provides a sneak peek to what the Quali team is developing. Officially supported by Quali. Feel free to experiment and comment, but please take into consideration that it is not yet tested and released.
Community - Integrations shared by community users. Feel free to look into what other users have contributed, please take into consideration that these integrations are not tested by Quali.
To learn more about creating Shells and integrating with CloudShell, use the following links:
CloudShell's Dev Guide > | Configuration Management > |
Getting started with Shells > | Extending CloudShell with Cloud Providers > |
Getting started with Orchestration > | API Guide > |
To share your integration, follow the instructions in this guide >.
Hi,
When I use ssh session manually, my device cli command 'show inventory' returns multiple pages of response with '--More--' and I have to use keyboard 'space' bar multiple times, to get to the prompt.
If I use CommandTemplateExecutor (cloudshell cli package) in my Device SHELL, how should we handle multiple pages of command output? I get a timeout error because the cli response is stuck in the first page.
Shell Commands:
from cloudshell.cli.command_template.command_template import CommandTemplate
from cloudshell.cli.command_template.command_template_executor import CommandTemplateExecutor
ERROR_MAP = {}
ACTION_MAP = {}
SHOW_ALL = CommandTemplate('show inventory', ACTION_MAP, ERROR_MAP)
CommandTemplateExecutor(self._cli_service, command_templates.SHOW_ALL).execute_command()
ERROR:
2019-03-12 15:58:40,759 [DEBUG]: QS.Ncn.MainThread session_manager_impl - remove_session SSH session was removed 2019-03-12 15:58:40,759 [INFO]: QS.Ncn.MainThread networking_utils - wrapped Command "discover" finished unsuccessfully Traceback (most recent call last): File "E:/SHELLS/NcnShell/src/run_ncn_driver.py", line 254, in out = driver.get_inventory(context) File "E:\SHELLS\NcnShell\src\ driver.py", line 267, in get_inventory response = autoload_operations.discover() File "E:\SHELLS\lib\site-packages\cloudshell\devices\ networking_utils.py", line 119, in wrapped result = func(self, *args, **kwargs) File "E:\SHELLS\lib\site-packages\cloudshell\devices\runners\ autoload_runner.py", line 61, in discover self.resource_config.name) File "E:\SHELLS\NcnShell\src\ncn\flows\ autoload_flow.py", line 17, in execute_flow card_table = autoload_actions.get_card_table() File "E:\SHELLS\NcnShell\src\ncn\command_actions\ autoload_actions.py", line 51, in get_card_table output = CommandTemplateExecutor(self._cli_service, command_templates.SHOW_ALL).execute_command() File "E:\SHELLS\lib\site-packages\cloudshell\cli\command_template\ command_template_executor.py", line 49, in execute_command **self.optional_kwargs) File "E:\SHELLS\lib\site-packages\cloudshell\cli\ cli_service_impl.py", line 93, in send_command error_map=error_map, logger=logger, *args, **kwargs) File "E:\SHELLS\lib\site-packages\cloudshell\cli\session\ expect_session.py", line 236, in hardware_expect read_buffer = self._receive_all(timeout, logger) File "E:\SHELLS\lib\site-packages\cloudshell\cli\session\ expect_session.py", line 147, in _receive_all raise ExpectedSessionException(self.__class__.__name__, 'Socket closed by timeout') cloudshell.cli.session.session_exceptions.ExpectedSessionException: ('SSHSession', 'Socket closed by timeout')
Regards
Answer by Yaroslav Nikonorov · Mar 13, 2019 at 09:29 AM
Hi Geetha,
I suggest to disable pagination.
Just for info, fixed the error:
CommandTemplate('<Command SHOW ALL>',action_map={r'--[Mm]ore--': lambda session, logger: session.send_line('', logger)})
Regards,
Yaroslav
Answer by Yaroslav Nikonorov · Mar 12, 2019 at 01:39 PM
Hi Geetha,
You can add a command, which disable pagination, to the command mode enter_actions.
'set cli screen-length 0' - the command which disable pagination for junOS.
return CommandMode(device_prompt_re, enter_command='ssh {}@{}'.format(device_user, device_host), exit_command='exit', enter_action_map={ r'password:': lambda session, logger: session.send_line( device_password, logger)}, enter_actions=lambda session: session.send_command('set cli screen-length 0'))
Or, you can solve this issue by adding action map to the command template.
CommandTemplate('<Command SHOW ALL>',action_map={[(r'--[Mm]ore--', lambda session, logger: session.send_line('', logger))]})
Let me know if that works for you?
Thanks
Regards, Yaroslav
Answer by Geetha Kuthalam · Mar 13, 2019 at 03:45 AM
Hi Yaroslav,
Thank you for your quick response. When I tried the action_map code, I got TypeError. Not sure why?
CommandTemplate('<Command SHOW ALL>',action_map={[(r'--[Mm]ore--',lambda session, logger: session.send_line('', logger))]})
File "E:\SHELLS\NcnShell\src\ncn\command_templates\autoload.py", line 11, in
CommandTemplate('<Command SHOW ALL>',action_map={[(r'--[Mm]ore--', lambda session, logger: session.send_line('', logger))]})
TypeError: unhashable type: 'list'
Note: I found a command on the device that turns off paging. So, turning off paging fixed my issue :).
Thanks & Regards
Geetha
Answer by Geetha Kuthalam · Mar 13, 2019 at 03:45 AM
Hi Yaroslav,
Thank you for your quick response. When I tried the action_map code, I got TypeError. Not sure why?
CommandTemplate('<Command SHOW ALL>',action_map={[(r'--[Mm]ore--',lambda session, logger: session.send_line('', logger))]})
File "E:\SHELLS\NcnShell\src\ncn\command_templates\autoload.py", line 11, in
CommandTemplate('<Command SHOW ALL>',action_map={[(r'--[Mm]ore--', lambda session, logger: session.send_line('', logger))]})
TypeError: unhashable type: 'list'
Note: I found a command on the device that turns off paging. So, turning off paging fixed my issue :).
Thanks & Regards
Geetha
These forums are a place for learning, helping and sharing experiences with others about any of our products. Feel free to ask a question and get answers from our community and our most advanced users.
Note that these are public forums - anyone can view the discussions here.
Announcements | |
CloudShell | TestShell |
Developers | BI (Business Inteligence) |
This is where you can suggest your ideas to help and improve the product for everyone.
Please make sure to read the following article before posting a new idea, to get more information about the required information and ideas lifecycle.
Feel free to vote and comment on other ideas to promote them.
Thanks for everyone who suggested the ideas and voted for them.
Find, download and share integrations that can extend and enhance the CloudShell experience.
Integrations have several levels:
Certified - Officially tested and supported by Quali.
Preview - Provides a sneak peek to what the Quali team is developing. Officially supported by Quali. Feel free to experiment and comment, but please take into consideration that it is not yet tested and released.
Community - Integrations shared by community users. Feel free to look into what other users have contributed, please take into consideration that these integrations are not tested by Quali.
To learn more about creating Shells and integrating with CloudShell, use the following links:
CloudShell's Dev Guide | Configuration Management |
Getting started with Shells | Extending CloudShell with Cloud Providers |
Getting started with Orchestration | API Guide |
To share your integration, follow the instructions in this guide.