-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e93395
commit f638816
Showing
8 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import logging | ||
|
||
from .base_command import BaseCommand | ||
|
||
|
||
class CLI(BaseCommand): | ||
""" Portal CLI APIs """ | ||
|
||
def run_command(self, cli_command): | ||
""" | ||
Run a CLI command | ||
:param str cli_command: The CLI command to run on the gateway | ||
:return str: The response of the Portal | ||
""" | ||
logging.getLogger().info("Executing CLI command. %s", {'cli_command': cli_command}) | ||
response = self._portal.execute('', 'debugCmd', cli_command) | ||
logging.getLogger().info("CLI command executed. %s", {'cli_command': cli_command}) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from cterasdk.core import cli | ||
from tests.ut import base_core | ||
|
||
|
||
class TestCoreCLI(base_core.BaseCoreTest): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self._cli_command = 'show /settings' | ||
|
||
def test_run_cli_command(self): | ||
execute_response = 'Success' | ||
self._init_global_admin(execute_response=execute_response) | ||
ret = cli.CLI(self._global_admin).run_command(self._cli_command) | ||
self._global_admin.execute.assert_called_once_with('', 'debugCmd', self._cli_command) | ||
self.assertEqual(ret, execute_response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters