From 501fb3b44f14e9c0d40a63bd8b47200b01e50be9 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Thu, 14 Apr 2016 17:23:04 +0300 Subject: regression: python3 support --- .../automation/regression/interactive_platform.py | 110 ++++++++++----------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'scripts/automation/regression/interactive_platform.py') diff --git a/scripts/automation/regression/interactive_platform.py b/scripts/automation/regression/interactive_platform.py index bfedd37d..10e89910 100755 --- a/scripts/automation/regression/interactive_platform.py +++ b/scripts/automation/regression/interactive_platform.py @@ -33,30 +33,30 @@ class InteractivePlatform(cmd.Cmd): self.platform.launch_connection(self.device_cfg) except Exception as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) exit(-1) def do_show_cfg (self, line): """Outputs the loaded interface configuration""" self.platform.get_if_manager().dump_if_config() - print termstyle.green("*** End of interface configuration ***") + print(termstyle.green("*** End of interface configuration ***")) def do_show_nat_cfg (self, line): """Outputs the loaded nat provided configuration""" try: self.platform.dump_obj_config('nat') - print termstyle.green("*** End of nat configuration ***") + print(termstyle.green("*** End of nat configuration ***")) except UserWarning as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) def do_show_static_route_cfg (self, line): """Outputs the loaded static route configuration""" try: self.platform.dump_obj_config('static_route') - print termstyle.green("*** End of static route configuration ***") + print(termstyle.green("*** End of static route configuration ***")) except UserWarning as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) def do_switch_cfg (self, cfg_file_path): """Switch the current platform interface configuration with another one""" @@ -66,9 +66,9 @@ class InteractivePlatform(cmd.Cmd): self.platform.load_platform_data_from_file(self.device_cfg) if not self.virtual_mode: self.platform.reload_connection(self.device_cfg) - print termstyle.green("Configuration switching completed successfully.") + print(termstyle.green("Configuration switching completed successfully.")) else: - print termstyle.magenta("Configuration file is missing. Please try again.") + print(termstyle.magenta("Configuration file is missing. Please try again.")) def do_load_clean (self, arg): """Loads a clean configuration file onto the platform @@ -80,7 +80,7 @@ class InteractivePlatform(cmd.Cmd): if len(in_val)==2: self.platform.load_clean_config(in_val[0], in_val[1]) else: - print termstyle.magenta("One of the config inputs is missing.") + print(termstyle.magenta("One of the config inputs is missing.")) else: self.platform.load_clean_config() # print termstyle.magenta("Configuration file definition is missing. use 'help load_clean' for further info.") @@ -88,27 +88,27 @@ class InteractivePlatform(cmd.Cmd): def do_basic_if_config(self, line): """Apply basic interfaces configuartion to all platform interfaces""" self.platform.configure_basic_interfaces() - print termstyle.green("Basic interfaces configuration applied successfully.") + print(termstyle.green("Basic interfaces configuration applied successfully.")) def do_pbr(self, line): """Apply IPv4 PBR configuration on all interfaces""" self.platform.config_pbr() - print termstyle.green("IPv4 PBR configuration applied successfully.") + print(termstyle.green("IPv4 PBR configuration applied successfully.")) def do_no_pbr(self, line): """Removes IPv4 PBR configuration from all interfaces""" self.platform.config_no_pbr() - print termstyle.green("IPv4 PBR configuration removed successfully.") + print(termstyle.green("IPv4 PBR configuration removed successfully.")) def do_nbar(self, line): """Apply NBAR PD configuration on all interfaces""" self.platform.config_nbar_pd() - print termstyle.green("NBAR configuration applied successfully.") + print(termstyle.green("NBAR configuration applied successfully.")) def do_no_nbar(self, line): """Removes NBAR PD configuration from all interfaces""" self.platform.config_no_nbar_pd() - print termstyle.green("NBAR configuration removed successfully.") + print(termstyle.green("NBAR configuration removed successfully.")) def do_static_route(self, arg): """Apply IPv4 static routing configuration on all interfaces @@ -131,16 +131,16 @@ class InteractivePlatform(cmd.Cmd): 'server_destination_mask' : '255.0.0.0' } stat_route_obj = CStaticRouteConfig(stat_route_dict) self.platform.config_static_routing(stat_route_obj) - print termstyle.green("IPv4 static routing configuration applied successfully.") + print(termstyle.green("IPv4 static routing configuration applied successfully.")) # print termstyle.magenta("Specific configutaion is missing. use 'help static_route' for further info.") def do_no_static_route(self, line): """Removes IPv4 static route configuration from all non-duplicated interfaces""" try: self.platform.config_no_static_routing() - print termstyle.green("IPv4 static routing configuration removed successfully.") + print(termstyle.green("IPv4 static routing configuration removed successfully.")) except UserWarning as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) def do_nat(self, arg): """Apply NAT configuration on all non-duplicated interfaces @@ -164,122 +164,122 @@ class InteractivePlatform(cmd.Cmd): 'pool_netmask' : '255.255.255.0' } nat_obj = CNatConfig(nat_dict) self.platform.config_nat(nat_obj) - print termstyle.green("NAT configuration applied successfully.") + print(termstyle.green("NAT configuration applied successfully.")) def do_no_nat(self, arg): """Removes NAT configuration from all non-duplicated interfaces""" try: self.platform.config_no_nat() - print termstyle.green("NAT configuration removed successfully.") + print(termstyle.green("NAT configuration removed successfully.")) except UserWarning as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) def do_ipv6_pbr(self, line): """Apply IPv6 PBR configuration on all interfaces""" self.platform.config_ipv6_pbr() - print termstyle.green("IPv6 PBR configuration applied successfully.") + print(termstyle.green("IPv6 PBR configuration applied successfully.")) def do_no_ipv6_pbr(self, line): """Removes IPv6 PBR configuration from all interfaces""" self.platform.config_no_ipv6_pbr() - print termstyle.green("IPv6 PBR configuration removed successfully.") + print(termstyle.green("IPv6 PBR configuration removed successfully.")) def do_zbf(self, line): """Apply Zone-Based policy Firewall configuration on all interfaces""" self.platform.config_zbf() - print termstyle.green("Zone-Based policy Firewall configuration applied successfully.") + print(termstyle.green("Zone-Based policy Firewall configuration applied successfully.")) def do_no_zbf(self, line): """Removes Zone-Based policy Firewall configuration from all interfaces""" self.platform.config_no_zbf() - print termstyle.green("Zone-Based policy Firewall configuration removed successfully.") + print(termstyle.green("Zone-Based policy Firewall configuration removed successfully.")) def do_show_cpu_util(self, line): """Fetches CPU utilization stats from the platform""" try: - print self.platform.get_cpu_util() - print termstyle.green("*** End of show_cpu_util output ***") + print(self.platform.get_cpu_util()) + print(termstyle.green("*** End of show_cpu_util output ***")) except PlatformResponseMissmatch as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) def do_show_drop_stats(self, line): """Fetches packet drop stats from the platform.\nDrop are summed and presented for both input and output traffic of each interface""" - print self.platform.get_drop_stats() - print termstyle.green("*** End of show_drop_stats output ***") + print(self.platform.get_drop_stats()) + print(termstyle.green("*** End of show_drop_stats output ***")) def do_show_nbar_stats(self, line): """Fetches NBAR classification stats from the platform.\nStats are available both as raw data and as percentage data.""" try: - print self.platform.get_nbar_stats() - print termstyle.green("*** End of show_nbar_stats output ***") + print(self.platform.get_nbar_stats()) + print(termstyle.green("*** End of show_nbar_stats output ***")) except PlatformResponseMissmatch as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) def do_show_nat_stats(self, line): """Fetches NAT translations stats from the platform""" - print self.platform.get_nat_stats() - print termstyle.green("*** End of show_nat_stats output ***") + print(self.platform.get_nat_stats()) + print(termstyle.green("*** End of show_nat_stats output ***")) def do_show_cft_stats(self, line): """Fetches CFT stats from the platform""" - print self.platform.get_cft_stats() - print termstyle.green("*** End of show_sft_stats output ***") + print(self.platform.get_cft_stats()) + print(termstyle.green("*** End of show_sft_stats output ***")) def do_show_cvla_memory_usage(self, line): """Fetches CVLA memory usage stats from the platform""" (res, res2) = self.platform.get_cvla_memory_usage() - print res - print res2 - print termstyle.green("*** End of show_cvla_memory_usage output ***") + print(res) + print(res2) + print(termstyle.green("*** End of show_cvla_memory_usage output ***")) def do_clear_counters(self, line): """Clears interfaces counters""" self.platform.clear_counters() - print termstyle.green("*** clear counters completed ***") + print(termstyle.green("*** clear counters completed ***")) def do_clear_nbar_stats(self, line): """Clears interfaces counters""" self.platform.clear_nbar_stats() - print termstyle.green("*** clear nbar stats completed ***") + print(termstyle.green("*** clear nbar stats completed ***")) def do_clear_cft_counters(self, line): """Clears interfaces counters""" self.platform.clear_cft_counters() - print termstyle.green("*** clear cft counters completed ***") + print(termstyle.green("*** clear cft counters completed ***")) def do_clear_drop_stats(self, line): """Clears interfaces counters""" self.platform.clear_packet_drop_stats() - print termstyle.green("*** clear packet drop stats completed ***") + print(termstyle.green("*** clear packet drop stats completed ***")) def do_clear_nat_translations(self, line): """Clears nat translations""" self.platform.clear_nat_translations() - print termstyle.green("*** clear nat translations completed ***") + print(termstyle.green("*** clear nat translations completed ***")) def do_set_tftp_server (self, line): """Configures TFTP access on platform""" self.platform.config_tftp_server(self.device_cfg) - print termstyle.green("*** TFTP config deployment completed ***") + print(termstyle.green("*** TFTP config deployment completed ***")) def do_show_running_image (self, line): """Fetches currently loaded image of the platform""" res = self.platform.get_running_image_details() - print res - print termstyle.green("*** Show running image completed ***") + print(res) + print(termstyle.green("*** Show running image completed ***")) def do_check_image_existence(self, arg): """Check if specific image file (usually *.bin) is already stored in platform drive""" if arg: try: res = self.platform.check_image_existence(arg.split(' ')[0]) - print res - print termstyle.green("*** Check image existence completed ***") + print(res) + print(termstyle.green("*** Check image existence completed ***")) except PlatformResponseAmbiguity as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) else: - print termstyle.magenta("Please provide an image name in order to check for existance.") + print(termstyle.magenta("Please provide an image name in order to check for existance.")) def do_load_image (self, arg): """Loads a given image filename from tftp server (if not available on disk) and sets it as the boot image on the platform""" @@ -287,9 +287,9 @@ class InteractivePlatform(cmd.Cmd): try: self.platform.load_platform_image('asr1001-universalk9.BLD_V155_2_S_XE315_THROTTLE_LATEST_20150324_100047-std.bin')#arg.split(' ')[0]) except UserWarning as inst: - print termstyle.magenta(inst) + print(termstyle.magenta(inst)) else: - print termstyle.magenta("Image filename is missing.") + print(termstyle.magenta("Image filename is missing.")) def do_reload (self, line): """Reloads the platform""" @@ -298,9 +298,9 @@ class InteractivePlatform(cmd.Cmd): if ans: # user confirmed he wishes to reload the platform self.platform.reload_platform(self.device_cfg) - print termstyle.green("*** Platform reload completed ***") + print(termstyle.green("*** Platform reload completed ***")) else: - print termstyle.green("*** Platform reload aborted ***") + print(termstyle.green("*** Platform reload aborted ***")) def do_quit(self, arg): """Quits the application""" -- cgit 1.2.3-korg