def get_startup_config(self, response, *args, **kwargs): response['get_startup_config'] = False try: filename = self.expand(kwargs['resource'], STARTUP_CONFIG_FN) self.repository.get_file(filename) response['get_startup_config'] = True actions = [replace_config_action(kwargs['resource'], STARTUP_CONFIG_FN)] response['definition'] = dict(name='Autogenerated definition', actions=actions) except FileObjectNotFound: log.debug('%s: no startup-config %s' % (kwargs['resource'], filename)) return (response, 'get_definition')
def get_startup_config(self, response, *args, **kwargs): response['get_startup_config'] = False try: filename = self.expand(kwargs['resource'], STARTUP_CONFIG_FN) self.repository.get_file(filename) response['get_startup_config'] = True actions = [ replace_config_action(kwargs['resource'], STARTUP_CONFIG_FN) ] response['definition'] = dict(name='Autogenerated definition', actions=actions) except FileObjectNotFound: log.debug('%s: no startup-config %s' % (kwargs['resource'], filename)) return (response, 'get_definition')
def test_replace_config_action(self): resource = random_string() result = replace_config_action(resource) self.assertEqual('install static startup-config file', result['name']) self.assertEqual('replace_config', result['action']) self.assertTrue(result['always_execute'])