Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions cloudshell/networking/huawei/autoload/snmp_entity_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def _get_entity_table(self):
# 'entPhysicalVendorType': 'str'}
entity_table_optional_port_attr = {'entPhysicalDescr': 'str', 'entPhysicalName': 'str'}

physical_desc = self._snmp.get_table('ENTITY-MIB', 'entPhysicalDescr')
physical_name = self._snmp.get_table('ENTITY-MIB', 'entPhysicalName')
physical_vendor = self._snmp.get_table('ENTITY-MIB', 'entPhysicalVendorType')
physical_class = self._snmp.get_table('ENTITY-MIB', 'entPhysicalClass')
contained_in = self._snmp.get_table('ENTITY-MIB', 'entPhysicalContainedIn')
physical_indexes = self._snmp.get_table('ENTITY-MIB', 'entPhysicalParentRelPos')
vendor_type_match_pattern = r"|".join(self.ENTITY_VENDOR_TYPE_TO_CLASS_MAP.keys())
for index in physical_indexes.keys():
Expand All @@ -129,20 +134,26 @@ def _get_entity_table(self):
continue
temp_entity_table = physical_indexes[index].copy()

temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, {"entPhysicalClass": "str"})
[index])
temp_entity_table.update(physical_class[index])
# temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, {"entPhysicalClass": "str"})
# [index])

if re.search(r"cpu|fan|sensor", temp_entity_table['entPhysicalClass'].lower()):
self._logger.debug("Loaded {}, skipping.".format(temp_entity_table['entPhysicalClass']))
continue

temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, {"entPhysicalContainedIn": "str"})
[index])
temp_entity_table.update(contained_in[index])
# temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, {"entPhysicalContainedIn": "str"})
# [index])

if temp_entity_table['entPhysicalContainedIn'] == '':
self.exclusion_list.append(index)
continue

temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, {"entPhysicalVendorType": "str"})
[index])
temp_entity_table.update(physical_vendor[index])
# temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, {"entPhysicalVendorType": "str"})
# [index])

ent_physical_class = temp_entity_table.get("entPhysicalClass")
if not ent_physical_class or ent_physical_class == "''" or "other" in ent_physical_class:
vendor_type = temp_entity_table['entPhysicalVendorType']
Expand All @@ -164,8 +175,10 @@ def _get_entity_table(self):
else:
temp_entity_table['entPhysicalClass'] = temp_entity_table['entPhysicalClass'].replace("'", "")

temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, entity_table_optional_port_attr)
[index])
temp_entity_table.update(physical_desc[index])
temp_entity_table.update(physical_name[index])
# temp_entity_table.update(self._snmp.get_properties('ENTITY-MIB', index, entity_table_optional_port_attr)
# [index])

if re.search(r'stack|chassis|module|port|powerSupply|container|backplane',
temp_entity_table['entPhysicalClass']):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def copy_file(self, src_file, dst_file):
def _device_response_verification(self, output):
""" """

match = re.search(r"\d+ bytes copied|copied.*[\[\(].*[0-9]* bytes.*[\)\]]|[Cc]opy complete",
match = re.search(r"\d+ bytes copied|copied.*[\[\(].*[0-9]* bytes.*[\)\]]|[Cc]opy complete|[Cc]omplete.",
output,
re.IGNORECASE)

Expand Down Expand Up @@ -79,7 +79,7 @@ def setup_startup_config(self, dst_file):
""" Specifies the system configuration file for next startup """

output = CommandTemplateExecutor(self._cli_service,
configuration.SAVE_RUNNING).execute_command(dst_file=dst_file)
configuration.SAVE_STARTUP).execute_command(dst_file=dst_file)

match = re.search(r"Succeeded in setting the configuration for booting system",
output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

import re

from collections import OrderedDict
from cloudshell.cli.command_template.command_template_executor import CommandTemplateExecutor
from cloudshell.networking.huawei.command_templates import system

Expand Down Expand Up @@ -71,7 +71,9 @@ def reboot(self, action_map=None, error_map=None):
try:
CommandTemplateExecutor(cli_service=self._cli_service,
command_template=system.REBOOT,
action_map=action_map,
action_map=OrderedDict({
r"\[Y/N\]": lambda session, logger: session.send_line("Y", logger),
"\(Y/N\)": lambda session, logger: session.send_line("Y", logger)}),
error_map=error_map,
expected_string="System is rebooting, please wait").execute_command()
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
r"[Oo]verwrit+e": lambda session, logger: session.send_line("y", logger),
"\(Y/N\)": lambda session, logger: session.send_line("Y", logger)}))

SAVE_STARTUP = CommandTemplate("startup saved-configuration {dst}",
SAVE_STARTUP = CommandTemplate("startup saved-configuration {dst_file}",
action_map=OrderedDict({
r"\[confirm\]": lambda session, logger: session.send_line("", logger),
r"\[Y/N\]": lambda session, logger: session.send_line("y", logger),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def execute_flow(self):

src_file = save_action.get_startup_config_filename(startup_config=startup_config)

return src_file.split(":")[0]
return src_file.split(":")[0].lstrip(' ')
5 changes: 5 additions & 0 deletions cloudshell/networking/huawei/flows/huawei_restore_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from cloudshell.devices.networking_utils import UrlParser
from cloudshell.networking.huawei.command_actions.system_actions import SystemActions
from cloudshell.networking.huawei.command_actions.save_restore_actions import SaveRestoreActions
import re


class HuaweiRestoreFlow(RestoreConfigurationFlow):
Expand All @@ -23,6 +24,10 @@ def execute_flow(self, path, configuration_type, restore_method, vrf_management_
:param vrf_management_name: Virtual Routing and Forwarding Name
"""

path = re.sub('{}:'.format(self.file_system), '', path)
if 'cfg' not in path:
path = path + '.cfg'

if not configuration_type:
configuration_type = "running-config"
elif "-config" not in configuration_type:
Expand Down
9 changes: 8 additions & 1 deletion cloudshell/networking/huawei/flows/huawei_save_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from cloudshell.devices.flows.action_flows import SaveConfigurationFlow
from cloudshell.networking.huawei.command_actions.system_actions import SystemActions
from cloudshell.networking.huawei.command_actions.save_restore_actions import SaveRestoreActions
import re


class HuaweiSaveFlow(SaveConfigurationFlow):
Expand All @@ -22,6 +23,10 @@ def execute_flow(self, folder_path, configuration_type, vrf_management_name=None
:return: saved configuration file name
"""

folder_path = re.sub('{}:'.format(self.file_system), '', folder_path)
if 'cfg' not in folder_path:
folder_path = folder_path + '.cfg'

if not configuration_type:
configuration_type = "running-config"
elif "-config" not in configuration_type:
Expand All @@ -39,7 +44,7 @@ def execute_flow(self, folder_path, configuration_type, vrf_management_name=None

if configuration_type == "running-config":
# src_file = "{file_system}:/qualirunconfig.cfg".format(file_system=self.file_system)
src_file = "quali_run_config.cfg"
src_file = folder_path
save_action.save_runninig_config(dst_file=src_file)
else:
startup_config = system_action.display_startup_config()
Expand All @@ -53,6 +58,8 @@ def execute_flow(self, folder_path, configuration_type, vrf_management_name=None
save_action.put_file(server_address=url.get(UrlParser.HOSTNAME),
src_file=src_file,
dst_file=url.get(UrlParser.FILENAME))
elif src_file == folder_path:
pass
else:
raise Exception("Unsupported backup protocol {scheme}. "
"Supported types are ftp, tftp of local({file_system})".format(scheme=scheme,
Expand Down