コード例 #1
0
    def get_drop_stats (self):

        response    = self.cmd_link.run_single_command('show platform hardware qfp active interface all statistics', flush_first = True)
        # print response
        # response    = self.cmd_link.run_single_command('show platform hardware qfp active interface all statistics')
        # print response
        if_list_by_name = [x.get_name() for x in self.if_mngr.get_if_list()]
        return CShowParser.parse_drop_stats(response, if_list_by_name )
コード例 #2
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
    def get_drop_stats (self):

        response    = self.cmd_link.run_single_command('show platform hardware qfp active interface all statistics', flush_first = True)
        # print response
        # response    = self.cmd_link.run_single_command('show platform hardware qfp active interface all statistics')
        # print response
        if_list_by_name = [x.get_name() for x in self.if_mngr.get_if_list()]
        return CShowParser.parse_drop_stats(response, if_list_by_name )
コード例 #3
0
ファイル: CPlatform.py プロジェクト: wshen0123/trex-core
 def get_nbar_stats(self):
     per_intf_stats = {}
     for intf in self.if_mngr.get_if_list(if_type=IFType.Client):
         response = self.cmd_link.run_single_command(
             "show ip nbar protocol-discovery interface {interface} stats packet-count protocol"
             .format(interface=intf.get_name()),
             flush_first=True)
         per_intf_stats[intf.get_name()] = CShowParser.parse_nbar_stats(
             response)
     return per_intf_stats
コード例 #4
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
    def get_running_image_details (self):
        """ get_running_image_details() -> dict

        Check for the currently running image file on the platform.
        Returns a dictionary, where 'drive' key is the drive in which the image is installed,
        and 'image' key is the actual image file used.
        """
        response = self.cmd_link.run_single_command('show version | include System image')
        parsed_info = CShowParser.parse_show_image_version(response)
        self.running_image = parsed_info
        return parsed_info
コード例 #5
0
ファイル: CPlatform.py プロジェクト: chetangaonker/trex-core
 def get_nbar_stats(self):
     per_intf_stats = {}
     for intf in self.if_mngr.get_if_list(if_type=IFType.Client):
         response = self.cmd_link.run_single_command(
             "show ip nbar protocol-discovery interface {interface} stats packet-count protocol".format(
                 interface=intf.get_name()
             ),
             flush_first=True,
         )
         per_intf_stats[intf.get_name()] = CShowParser.parse_nbar_stats(response)
     return per_intf_stats
コード例 #6
0
    def get_running_image_details (self):
        """ get_running_image_details() -> dict

        Check for the currently running image file on the platform.
        Returns a dictionary, where 'drive' key is the drive in which the image is installed,
        and 'image' key is the actual image file used.
        """
        response = self.cmd_link.run_single_command('show version | include System image')
        parsed_info = CShowParser.parse_show_image_version(response)
        self.running_image = parsed_info
        return parsed_info
コード例 #7
0
ファイル: CPlatform.py プロジェクト: wshen0123/trex-core
    def load_platform_image(self, img_filename, external_tftp_config=None):
        """ load_platform_image(self, img_filename, external_tftp_config) -> None

        Parameters
        ----------
        external_tftp_config : dict
            A path to external tftp config file other than using the one defined in the instance.
        img_filename : str
            image name to be saved into the platforms drive.

        This method loads the configured image into the platform's harddisk (unless it is already loaded),
        and sets that image to be the boot_image of the platform.
        """
        if not self.check_image_existence(
                img_filename
        ):  # check if this image isn't already saved in platform
            #tmp_tftp_config = external_tftp_config if external_tftp_config is not None else self.tftp_cfg

            if self.config_history[
                    'tftp_server_config']:  # make sure a TFTP configuration has been loaded
                cache = CCommandCache()
                if self.running_image is None:
                    self.get_running_image_details()

                command = "copy tftp://{tftp_ip}/{img_path}/{image} bootflash:".format(
                    tftp_ip=self.tftp_cfg['ip_address'],
                    img_path=self.tftp_cfg['images_path'],
                    image=img_filename)
                cache.add('EXEC', [command, '\r', '\r'])

                progress_thread = CProgressDisp.ProgressThread(
                    notifyMessage=
                    "Copying image via tftp, this may take a while...\n")
                progress_thread.start()

                response = self.cmd_link.run_single_command(
                    cache, timeout=900, read_until=['\?', '#'])
                print("RESPONSE:")
                print(response)
                progress_thread.join()
                copy_ok = CShowParser.parse_file_copy(response)

                if not copy_ok:
                    raise UserWarning(
                        'Image file loading failed. Please make sure the accessed image exists and has read privileges'
                    )
            else:
                raise UserWarning(
                    'TFTP configuration is not available. Please make sure a valid TFTP configuration has been provided'
                )
コード例 #8
0
ファイル: CPlatform.py プロジェクト: chetangaonker/trex-core
    def load_platform_image(self, img_filename, external_tftp_config=None):
        """ load_platform_image(self, img_filename, external_tftp_config) -> None

        Parameters
        ----------
        external_tftp_config : dict
            A path to external tftp config file other than using the one defined in the instance.
        img_filename : str
            image name to be saved into the platforms drive.

        This method loads the configured image into the platform's harddisk (unless it is already loaded),
        and sets that image to be the boot_image of the platform.
        """
        if not self.check_image_existence(img_filename):  # check if this image isn't already saved in platform
            # tmp_tftp_config = external_tftp_config if external_tftp_config is not None else self.tftp_cfg

            if self.config_history["tftp_server_config"]:  # make sure a TFTP configuration has been loaded
                cache = CCommandCache()
                if self.running_image is None:
                    self.get_running_image_details()

                command = "copy tftp://{tftp_ip}/{img_path}/{image} harddisk:".format(
                    tftp_ip=self.tftp_cfg["ip_address"], img_path=self.tftp_cfg["images_path"], image=img_filename
                )
                cache.add("EXEC", [command, "\r", "\r"])

                progress_thread = CProgressDisp.ProgressThread(
                    notifyMessage="Copying image via tftp, this may take a while...\n"
                )
                progress_thread.start()

                response = self.cmd_link.run_single_command(cache, timeout=900, read_until=["\?", "\#"])
                print("RESPONSE:")
                print(response)
                progress_thread.join()
                copy_ok = CShowParser.parse_file_copy(response)

                if not copy_ok:
                    raise UserWarning(
                        "Image file loading failed. Please make sure the accessed image exists and has read privileges"
                    )
            else:
                raise UserWarning(
                    "TFTP configuration is not available. Please make sure a valid TFTP configuration has been provided"
                )
コード例 #9
0
    def check_image_existence (self, img_name):
        """ check_image_existence(self, img_name) -> boolean

        Parameters
        ----------
        img_name : str
            a string represents the image name.

        Check if the image file defined in the platform_config already loaded into the platform.
        """
        search_drives = ['bootflash', 'harddisk', self.running_image['drive']]
        for search_drive in search_drives:
            command = "dir {drive}: | include {image}".format(drive = search_drive, image = img_name)
            response = self.cmd_link.run_single_command(command, timeout = 10)
            if CShowParser.parse_image_existence(response, img_name):
                self.needed_image_path = '%s:/%s' % (search_drive, img_name)
                print('Found image in platform:', self.needed_image_path)
                return True
        return False
コード例 #10
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
    def check_image_existence (self, img_name):
        """ check_image_existence(self, img_name) -> boolean

        Parameters
        ----------
        img_name : str
            a string represents the image name.

        Check if the image file defined in the platform_config already loaded into the platform.
        """
        search_drives = ['bootflash', 'harddisk', self.running_image['drive']]
        for search_drive in search_drives:
            command = "dir {drive}: | include {image}".format(drive = search_drive, image = img_name)
            response = self.cmd_link.run_single_command(command, timeout = 10)
            if CShowParser.parse_image_existence(response, img_name):
                self.needed_image_path = '%s:/%s' % (search_drive, img_name)
                print('Found image in platform:', self.needed_image_path)
                return True
        return False
コード例 #11
0
 def get_cvla_memory_usage(self):
     response    = self.cmd_link.run_single_command('show platform hardware qfp active infrastructure cvla client handles')
     # (res, res2) = CShowParser.parse_cvla_memory_usage(response)
     return CShowParser.parse_cvla_memory_usage(response)
コード例 #12
0
 def get_nat_stats (self):
     response    = self.cmd_link.run_single_command('show ip nat statistics')
     return CShowParser.parse_nat_stats(response)
コード例 #13
0
 def get_nbar_profiling_stats (self):
     response = self.cmd_link.run_single_command("show platform hardware qfp active feature nbar profiling")
     return CShowParser.parse_nbar_profiling_stats(response)
コード例 #14
0
 def get_cft_stats (self):
     response    = self.cmd_link.run_single_command('test platform hardware qfp active infrastructure cft datapath function cft-cpp-show-all-instances')
     return CShowParser.parse_cft_stats(response)
コード例 #15
0
 def get_cpu_util (self):
     response    = self.cmd_link.run_single_command('show platform hardware qfp active datapath utilization | inc Load')
     return CShowParser.parse_cpu_util_stats(response)
コード例 #16
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
 def get_cvla_memory_usage(self):
     response    = self.cmd_link.run_single_command('show platform hardware qfp active infrastructure cvla client handles')
     # (res, res2) = CShowParser.parse_cvla_memory_usage(response)
     return CShowParser.parse_cvla_memory_usage(response)
コード例 #17
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
 def get_nat_stats (self):
     response    = self.cmd_link.run_single_command('show ip nat statistics')
     return CShowParser.parse_nat_stats(response)
コード例 #18
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
 def get_cpu_util (self):
     response    = self.cmd_link.run_single_command('show platform hardware qfp active datapath utilization | inc Load')
     return CShowParser.parse_cpu_util_stats(response)
コード例 #19
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
 def get_nbar_profiling_stats (self):
     response = self.cmd_link.run_single_command("show platform hardware qfp active feature nbar profiling")
     return CShowParser.parse_nbar_profiling_stats(response)
コード例 #20
0
ファイル: CPlatform.py プロジェクト: wlm328cs/trex
 def get_cft_stats (self):
     response    = self.cmd_link.run_single_command('test platform hardware qfp active infrastructure cft datapath function cft-cpp-show-all-instances')
     return CShowParser.parse_cft_stats(response)