コード例 #1
0
    def initialize(self, context):
        """

        :param cloudshell.shell.core.driver_context.InitCommandContext context: the context the command runs on
        """
        self._cli = get_cli(SSH_SESSION_POOL)
        return "Finished initializing"
コード例 #2
0
    def get_inventory(self, context):
        """ Return device structure with all standard attributes

        :type context: cloudshell.shell.core.driver_context.AutoLoadCommandContext
        :rtype: cloudshell.shell.core.driver_context.AutoLoadDetails
        """

        logger = get_logger_with_thread_id(context)
        logger.info("Autoload started")

        with ErrorHandlingContext(logger):
            resource_config = TrafficGeneratorChassisResource.from_context(context=context,
                                                                           shell_name=self.SHELL_NAME)

            session_pool_size = int(resource_config.sessions_concurrency_limit)
            self._cli = get_cli(session_pool_size)
            api = get_api(context)

            autoload_runner = TRexAutoloadRunner(api=api,
                                                 cli=self._cli,
                                                 resource_config=resource_config,
                                                 logger=logger)

            response = autoload_runner.discover()
            logger.info("Autoload completed")

            return response
コード例 #3
0
 def initialize(self, context):
     """
     Initialize the driver session, this function is called everytime a new instance of the driver is created
     This is a good place to load and cache the driver configuration, initiate sessions etc.
     :param InitCommandContext context: the context the command runs on
     """
     self._cli = get_cli(SSH_SESSION_POOL)
     return "Finished initializing"
コード例 #4
0
    def initialize(self, context):
        """ Initialize the driver session """

        resource_config = create_networking_resource_from_context(
            shell_name=self.SHELL_NAME,
            supported_os=self.SUPPORTED_OS,
            context=context)

        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)
        return 'Finished initializing'
コード例 #5
0
    def initialize(self, context):
        """Initialize the driver session, this function is called everytime a new instance of the driver is created.

        This is a good place to load and cache the driver configuration, initiate sessions etc.
        :param InitCommandContext context: the context the command runs on
        """
        resource_config = TrafficGeneratorVChassisResource.from_context(context,
                                                                        shell_type=SHELL_TYPE,
                                                                        shell_name=SHELL_NAME)
        self._cli = get_cli(resource_config.sessions_concurrency_limit)
        return "Finished initializing"
コード例 #6
0
    def initialize(self, context):
        """Initialize the driver session.

        :param InitCommandContext context: the context the command runs on
        :rtype: str
        """
        resource_config = create_firewall_resource_from_context(
            self.SHELL_NAME, self.SUPPORTED_OS, context
        )
        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)
        return "Finished initializing"
コード例 #7
0
    def _setUp(self, attrs=None):
        self.resource_config = create_networking_resource_from_context(
            self.SHELL_NAME, ['TiMOS'], self.create_context(attrs))
        self._cli = get_cli(
            int(self.resource_config.sessions_concurrency_limit))

        self.logger = MagicMock()
        self.api = MagicMock(
            DecryptPassword=lambda password: MagicMock(Value=password))

        self.cli_handler = AlcatelCliHandler(self._cli, self.resource_config,
                                             self.logger, self.api)
コード例 #8
0
    def initialize(self, context):
        """Initialize method

        :param InitCommandContext context: the context the command runs on
        """

        resource_config = create_networking_resource_from_context(
            self.SHELL_NAME, self.SUPPORTED_OS, context)

        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)
        return 'Finished initializing'
コード例 #9
0
    def initialize(self, context):
        """
        :param context: ResourceCommandContext,ReservationContextDetailsobject with all Resource Attributes inside
        :type context:  context: cloudshell.shell.core.driver_context.ResourceRemoteCommandContext
        """

        resource_config = TrafficGeneratorControllerResource.from_context(
            context)
        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)

        return 'Finished initializing'
コード例 #10
0
    def initialize(self, context):
        """Initialize method

        :type context: cloudshell.shell.core.context.driver_context.InitCommandContext
        """

        resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
                                                                  supported_os=self.SUPPORTED_OS,
                                                                  context=context)

        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)
        return 'Finished initializing'
コード例 #11
0
    def initialize(self, context):
        """Initialize method

        :type context: cloudshell.shell.core.context.driver_context.InitCommandContext
        """

        resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
                                                                  supported_os=self.SUPPORTED_OS,
                                                                  context=context)

        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)
        return 'Finished initializing'
コード例 #12
0
    def initialize(self, context):
        """
        Initialize the driver session, this function is called everytime a new instance of the driver is created
        This is a good place to load and cache the driver configuration, initiate sessions etc.
        :param InitCommandContext context: the context the command runs on
        """
        #resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
        #                                                          supported_os=self.SUPPORTED_OS,
        #                                                          context=context)

        #session_pool_size = int(resource_config.sessions_concurrency_limit)
        #self._cli = get_cli(session_pool_size)
        self._cli = get_cli(1)
コード例 #13
0
    def initialize(self, context):
        """
        Initialize the driver session, this function is called everytime a new instance of the driver is created
        This is a good place to load and cache the driver configuration, initiate sessions etc.
        """

        resource_config = create_firewall_resource_from_context(
            shell_name=self.SHELL_NAME,
            supported_os=self.SUPPORTED_OS,
            context=context)

        # session_pool_size = int(resource_config.sessions_concurrency_limit or 1)
        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)
        return 'Finished initializing'
コード例 #14
0
 def test_get_cli(self, cli_class, session_pool_manager_class):
     """Check that method will return CLI instance"""
     cli = mock.MagicMock()
     cli_class.return_value = cli
     session_pool = mock.MagicMock()
     session_pool_manager_class.return_value = session_pool
     session_pool_size = 10
     pool_timeout = 50
     # act
     result = driver_helper.get_cli(session_pool_size=session_pool_size, pool_timeout=pool_timeout)
     # verify
     self.assertEqual(result, cli)
     cli_class.assert_called_once_with(session_pool=session_pool)
     session_pool_manager_class.assert_called_once_with(max_pool_size=session_pool_size,
                                                        pool_timeout=pool_timeout)
コード例 #15
0
    def _setUp(self, attrs=None):
        if attrs is None:
            attrs = {}

        self.resource_config = create_firewall_resource_from_context(
            self.SHELL_NAME, ['ACOS'], self.create_context(attrs))
        self._set_snmp_v3_protocols(self.resource_config, attrs)
        self._cli = get_cli(
            int(self.resource_config.sessions_concurrency_limit))

        self.logger = MagicMock()
        self.api = MagicMock(
            DecryptPassword=lambda password: MagicMock(Value=password))

        self.cli_handler = CliHandler(self._cli, self.resource_config,
                                      self.logger, self.api)
コード例 #16
0
    def initialize(self, context):
        """Initialize method

        :type context: cloudshell.shell.core.context.driver_context.InitCommandContext
        """

        resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
                                                                  supported_os=self.SUPPORTED_OS,
                                                                  context=context)

        session_pool_size = int(resource_config.sessions_concurrency_limit)
        self._cli = get_cli(session_pool_size)
        ConfigCommandMode.ENTER_COMMAND = "conf sync"
        ConfigCommandMode.ENTER_ACTION_COMMANDS = ["switch-profile configure-fex"]
        ConfigCommandMode.EXIT_COMMAND = "end"
        return 'Finished initializing'