def load_firmware(self, context, path, vrf_management_name): """Upload and updates firmware on the resource :param ResourceCommandContext context: ResourceCommandContext object with all Resource Attributes inside :param path: full path to firmware file, i.e. tftp://10.10.10.1/firmware.tar :param vrf_management_name: VRF management Name """ logger = get_logger_with_thread_id(context) api = get_api(context) resource_config = create_networking_resource_from_context( shell_name=self.SHELL_NAME, supported_os=self.SUPPORTED_OS, context=context) if not vrf_management_name: vrf_management_name = resource_config.vrf_management_name cli_handler = CliHandler(self._cli, resource_config, logger, api) logger.info('Start Load Firmware') firmware_operations = FirmwareRunner(cli_handler=cli_handler, logger=logger) response = firmware_operations.load_firmware( path=path, vrf_management_name=vrf_management_name) logger.info('Finish Load Firmware: {}'.format(response))
class TestCiscoConfigurationRunner(TestCase): def setUp(self): self._logger = MagicMock() self._cli_handler = MagicMock() self._handler = CiscoFirmwareRunner(logger=self._logger, cli_handler=self._cli_handler) def test_runs_firmware_flow(self): with patch( "cloudshell.networking.cisco.runners.cisco_firmware_runner.CiscoLoadFirmwareFlow" ) as flow_mock: self._handler.load_firmware("tftp://10.10.10.10/qs_fw.bin") flow_mock.assert_called_once_with(self._cli_handler, self._logger)
def update_firmware(self, context, remote_host, file_path): """Upload and updates firmware on the resource :param ResourceCommandContext context: ResourceCommandContext object with all Resource Attributes inside :param remote_host: full path to firmware file, i.e. tftp://10.10.10.1/firmware.tar :param file_path: file name """ logger = get_logger_with_thread_id(context) api = get_api(context) resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME, supported_os=self.SUPPORTED_OS, context=context) cli_handler = CliHandler(self._cli, resource_config, logger, api) logger.info('Start Load Firmware') firmware_operations = FirmwareRunner(cli_handler=cli_handler, logger=logger) response = firmware_operations.load_firmware(path=remote_host, vrf_management_name=resource_config.vrf_management_name) logger.info('Finish Load Firmware: {}'.format(response))
def update_firmware(self, context, remote_host, file_path): """Upload and updates firmware on the resource :param remote_host: path to firmware file location on ftp or tftp server :param file_path: firmware file name :return: result :rtype: str """ logger = get_logger_with_thread_id(context) api = get_api(context) vrf_management_name = get_attribute_by_name( context=context, attribute_name='VRF Management Name') logger.info('Start Update Firmware') firmware_operations = FirmwareRunner(cli=self._cli, logger=logger, context=context, api=api) response = firmware_operations.load_firmware( path=remote_host, vrf_management_name=vrf_management_name) logger.info('Finish Update Firmware: {}'.format(response))
def load_firmware(self, context, path, vrf_management_name): """Upload and updates firmware on the resource :param ResourceCommandContext context: ResourceCommandContext object with all Resource Attributes inside :param path: full path to firmware file, i.e. tftp://10.10.10.1/firmware.tar :param vrf_management_name: VRF management Name """ logger = get_logger_with_thread_id(context) api = get_api(context) if not vrf_management_name: vrf_management_name = get_attribute_by_name( context=context, attribute_name='VRF Management Name') logger.info('Start Load Firmware') firmware_operations = FirmwareRunner(cli=self._cli, logger=logger, context=context, api=api) response = firmware_operations.load_firmware( path=path, vrf_management_name=vrf_management_name) logger.info('Finish Load Firmware: {}'.format(response))
def setUp(self): self._logger = MagicMock() self._cli_handler = MagicMock() self._handler = CiscoFirmwareRunner(logger=self._logger, cli_handler=self._cli_handler)