Skip to content

Commit

Permalink
feat(edgeswitch): allow to differentiate between running and startup …
Browse files Browse the repository at this point in the history
…config (#105)

* feat(config): allow to differentiate between running and startup config

* fix(edgeswitch): ensuring backward compatibility - runningconfig remains config and is completed by startupconfig

* feat(changelog): adding version change info for startupconfig

Co-authored-by: Felix Fontein <[email protected]>

* fix(tests): ignore startupconfig as parameter

* fix(lint): satify linter - blank lines missmatch

* feat(changelog): adding changelog fragment

* fix(changelog): changelog fragment as required

* trigger(): retrigger

* Update changelogs/fragments/105_edgeswitch_add-startupconfig.yml

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
mrwiora and felixfontein authored Sep 3, 2020
1 parent 17760e0 commit 1aa8898
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/105_edgeswitch_add-startupconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- edgeswitch_facts - added ``startupconfig`` to facts module - to allow the comparision between startup and running config (https://github.com/ansible-collections/community.network/pull/105).
21 changes: 20 additions & 1 deletion plugins/modules/network/edgeswitch/edgeswitch_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
community.network.edgeswitch_facts:
gather_subset: all
- name: Collect only the config and default facts
- name: Collect only the running config and default facts
community.network.edgeswitch_facts:
gather_subset:
- config
"""

RETURN = """
Expand Down Expand Up @@ -69,6 +70,12 @@
type: str
# config
ansible_net_startupconfig:
description: The startup config from the device
returned: when config is configured
type: str
version_added: 1.2.0
ansible_net_config:
description: The current active config from the device
returned: when config is configured
Expand Down Expand Up @@ -148,6 +155,17 @@ def populate(self):
self.facts['config'] = data


class StartupConfig(FactsBase):

COMMANDS = ['show startup-config']

def populate(self):
super(StartupConfig, self).populate()
data = self.responses[0]
if data:
self.facts['startupconfig'] = data


class Interfaces(FactsBase):

COMMANDS = [
Expand Down Expand Up @@ -192,6 +210,7 @@ def parse_interfaces_status(self, data, interfaces):
FACT_SUBSETS = dict(
default=Default,
config=Config,
startupconfig=StartupConfig,
interfaces=Interfaces,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def load_from_file(*args, **kwargs):
self.run_commands.side_effect = load_from_file

def test_edgeswitch_facts_default(self):
set_module_args(dict(gather_subset=['all', '!interfaces', '!config']))
set_module_args(dict(gather_subset=['all', '!interfaces', '!config', '!startupconfig']))
result = self.execute_module()
facts = result.get('ansible_facts')
self.assertEqual(len(facts), 5)
Expand Down

0 comments on commit 1aa8898

Please sign in to comment.