Esempio n. 1
0
    def __init__(self, cli, resource_config, logger, api):
        """

        :param cloudshell.cli.cli.CLI cli: CLI object
        :param traffic.teravm.controller.configuration_attributes_structure.TrafficGeneratorControllerResource resource_config:
        :param logging.Logger logger:
        :param cloudshell.api.cloudshell_api.CloudShellAPISession api: cloudshell API object
        """
        super(VyOSCliHandler, self).__init__(cli, resource_config, logger, api)
        self._modes = CommandModeHelper.create_command_mode()
    def __init__(self, logger):
        self._logger = logger
        self._cli = CLI(session_pool=SessionPoolManager(max_pool_size=1))
        self.modes = CommandModeHelper.create_command_mode()
        self._defined_session_types = {
            'SSH': VWSSHSession,
            'TELNET': TelnetSession
        }

        self._session_types = RuntimeConfiguration().read_key(
            'CLI.TYPE', ['SSH']) or self._defined_session_types.keys()
        self._ports = RuntimeConfiguration().read_key('CLI.PORTS', '22')

        self._host = None
        self._username = None
        self._password = None
Esempio n. 3
0
    def __init__(self, logger, runtime_config):
        """
        :param logger:
        :param cloudshell.layer_one.core.helper.runtime_configuration.RuntimeConfiguration runtime_config:
        """
        self._logger = logger
        self._runtime_config = runtime_config
        self._cli = CLI(session_pool=SessionPoolManager(max_pool_size=1))
        self.modes = CommandModeHelper.create_command_mode()
        self._defined_session_types = {
            VWSSHSession.SESSION_TYPE: VWSSHSession,
            TelnetSession.SESSION_TYPE: TelnetSession
        }

        self._session_types = self._runtime_config.read_key(
            'CLI.TYPE',
            [VWSSHSession.SESSION_TYPE]) or self._defined_session_types.keys()
        self._ports = RuntimeConfiguration().read_key('CLI.PORTS', {})

        self._host = None
        self._username = None
        self._password = None
Esempio n. 4
0
 def __init__(self, cli, resource_config, logger, api):
     super(FTOSCliHandler, self).__init__(cli, resource_config, logger, api)
     self.modes = CommandModeHelper.create_command_mode(
         resource_config, api)
 def __init__(self, logger):
     super(MrvCliHandler, self).__init__(logger)
     self.modes = CommandModeHelper.create_command_mode()
 def __init__(self, cli, context, logger):
     super(SwitchCliHandler, self).__init__(cli, context, logger, None)
     modes = CommandModeHelper.create_command_mode(context)
     self.default_mode = modes[DefaultCommandMode]
     self.enable_mode = modes[EnableCommandMode]
     self.config_mode = modes[ConfigCommandMode]
Esempio n. 7
0
 def __init__(self, cli, resource_config, logger, api):
     super(AlcatelCliHandler, self).__init__(cli, resource_config, logger, api)
     self.modes = CommandModeHelper.create_command_mode(resource_config, api)
     self._enable_password = None

LOGGER = get_qs_logger()

CommandMode.RELATIONS_DICT = {CliCommandMode: {}}
if __name__ == "__main__":
    pool = SessionPoolManager(max_pool_size=1)
    cli = CLI(session_pool=pool)

    context = type(
        "context",
        (object, ),
        {"resource": type("resource", (object, ), {"name": "test name"})},
    )

    host = "<IP>"
    username = "******"
    password = "******"

    session = SSHSession(host, username, password)
    modes = CommandModeHelper.create_command_mode(context)
    default_mode = modes[CliCommandMode]

    with cli.get_session(session, default_mode) as default_session:
        out = default_session.send_command(
            "echo Cli Demo connected to Ubuntu Machine")
        print(out)  # noqa: T001
        fd = open("<src_file_path>")
        default_session.session.upload_scp(fd, "<dst_file_path>",
                                           "<file_size>", "0666")
 def __init__(self, cli, resource_config, logger, api):
     super(HuaweiCliHandler, self).__init__(cli, resource_config, logger, api)
     self.modes = CommandModeHelper.create_command_mode(resource_config, api)
Esempio n. 10
0
 def __init__(self, cli, resource_address, username, password):
     self._cli = cli
     self.resource_address = resource_address
     self.username = username
     self.password = password
     self.modes = CommandModeHelper.create_command_mode()