diff options
Diffstat (limited to 'tests')
8 files changed, 286 insertions, 440 deletions
| diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/delete_single.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/delete_single.yaml deleted file mode 100644 index 150242a1..00000000 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/delete_single.yaml +++ /dev/null @@ -1,57 +0,0 @@ ---- -- debug: -    msg: Start vyos_ospfv2 deleted integration tests ansible_connection={{ -      ansible_connection }} - -- include_tasks: _populate.yaml - -- block: - -    - name: Delete attributes of ospfv2. -      register: result -      vyos.vyos.vyos_ospfv2: &id001 -        config: -          log_adjacency_changes: 'detail' -          max_metric: -          default_information: -          mpls_te: -          neighbor: -          redistribute: -          parameters: -          passive_interface: -          areas: -        state: deleted - -    - name: Assert that the before dicts were correctly generated -      assert: -        that: -          - "{{ populate == result['before'] }}" - -    - name: Assert that the correct set of commands were generated -      assert: -        that: -          - "{{ deleted_single['commands'] | symmetric_difference(result['commands']) |length\ -            \ == 0 }}" - -    - name: Assert that the after dicts were correctly generated -      assert: -        that: -          - "{{ deleted_single['after'] == result['after'] }}" - -    - name: Delete attributes of given interfaces (IDEMPOTENT) -      register: result -      vyos.vyos.vyos_ospfv2: *id001 - -    - name: Assert that the previous task was idempotent -      assert: -        that: -          - result.changed == false -          - result.commands|length == 0 - -    - name: Assert that the before dicts were correctly generated -      assert: -        that: -          - "{{ deleted_single['after'] == result['before'] }}" -  always: - -    - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml index 22c378b8..bc5e1e27 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml @@ -9,9 +9,9 @@  - block: -    - name: Merge the provided configuration with the exisiting running configuration +    - name: Gather the provided configuration with the exisiting running configuration        register: result -      vyos.vyos.vyos_ospfv2: &id001 +      vyos.vyos.vyos_ospfv2:          config:          state: gathered @@ -19,15 +19,6 @@        assert:          that:            - "{{ populate  == result['gathered'] }}" - -    - name: Gather the existing running configuration (IDEMPOTENT) -      register: result -      vyos.vyos.vyos_ospfv2: *id001 - -    - name: Assert that the previous task was idempotent -      assert: -        that: -          - result['changed'] == false    always:      - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml index 453dbb09..9b6823c9 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml @@ -67,4 +67,4 @@            - "{{ merged_update['after'] == result['before'] }}"    always: -    - include_tasks: _remove_config.yaml
\ No newline at end of file +    - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml index 6fbe2f96..cfa29f99 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml @@ -3,39 +3,13 @@      msg: START vyos_ospfv2 parsed integration tests on connection={{ ansible_connection        }} -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - -    - name: Gather ospfv2 facts -      register: ospfv2_facts -      vyos.vyos.vyos_facts: -        gather_subset: -          - default -        gather_network_resources: -          - ospfv2 - -    - name: Provide the running configuration for parsing (config to be parsed) -      register: result -      vyos.vyos.vyos_ospfv2: &id001 -        running_config: "{{ lookup('file', '_parsed_config.cfg') }}" -        state: parsed - -    - name: Assert that correct parsing done -      assert: -        that: "{{ ansible_facts['network_resources']['ospfv2'] == result['parsed']\ -          \ }}" - -    - name: Gather the existing running configuration (IDEMPOTENT) -      register: result -      vyos.vyos.vyos_ospfv2: *id001 - -    - name: Assert that the previous task was idempotent -      assert: -        that: -          - result['changed'] == false -  always: - -    - include_tasks: _remove_config.yaml +- name: Parse externally provided ospfv2 config to agnostic model +  register: result +  vyos.vyos.vyos_ospfv2: +    running_config: "{{ lookup('file', '_parsed_config.cfg') }}" +    state: parsed + +- name: Assert that config was correctly parsed +  assert: +    that: +      - "{{ parsed['after'] == result['parsed'] }}" diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml index 86c07cf4..8a805a6a 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml @@ -5,13 +5,11 @@  - include_tasks: _remove_config.yaml -- include_tasks: _populate.yaml -  - block:      - name: Structure provided configuration into device specific commands        register: result -      vyos.vyos.vyos_ospfv2: &id001 +      vyos.vyos.vyos_ospfv2:          config:            log_adjacency_changes: 'detail'            max_metric: @@ -74,15 +72,5 @@          that:            - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\              \ |length == 0 }}" - -    - name: Structure provided configuration into device specific commands (IDEMPOTENT) -      register: result -      vyos.vyos.vyos_ospfv2: *id001 - -    - name: Assert that the previous task was idempotent -      assert: -        that: -          - result['changed'] == false -  always: - -    - include_tasks: _remove_config.yaml +- debug: +    msg: END vyos_ospfv2 rendered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/vyos_ospfv2/vars/main.yaml b/tests/integration/targets/vyos_ospfv2/vars/main.yaml index 76a54e32..e55da20f 100644 --- a/tests/integration/targets/vyos_ospfv2/vars/main.yaml +++ b/tests/integration/targets/vyos_ospfv2/vars/main.yaml @@ -1,6 +1,6 @@  ---  merged: -  before: [] +  before: {}    commands:      - set protocols ospf mpls-te enable      - set protocols ospf mpls-te router-address '192.0.11.11' @@ -39,63 +39,6 @@ merged:      - set protocols ospf area '4'      - set protocols ospf area 4 network 192.0.2.0/24    after: -      areas: -        - area_id: '2' -          area_type: -            normal: true -          authentication: "plaintext-password" -          shortcut: 'enable' -        - area_id: '3' -          area_type: -            nssa: -              set: true -        - area_id: '4' -          area_type: -            stub: -              default_cost: 20 -              set: true -          network: -            - address: '192.0.2.0/24' -          range: -            - address: '192.0.3.0/24' -              cost: 10 -            - address: '192.0.4.0/24' -              cost: 12 -      auto_cost: -        reference_bandwidth: 2 -      default_information: -        originate: -          always: true -          metric: 10 -          metric_type: 2 -          route_map: 'ingress' -      log_adjacency_changes: 'detail' -      max_metric: -        router_lsa: -          administrative: true -          on_shutdown: 10 -          on_startup: 10 -      mpls_te: -        enabled: true -        router_address: '192.0.11.11' -      neighbor: -        - neighbor_id: '192.0.11.12' -          poll_interval: 10 -          priority: 2 -      parameters: -        abr_type: 'cisco' -        opaque_lsa: true -        rfc1583_compatibility: true -        router_id: '192.0.1.1' -      passive_interface: -        - 'eth2' -        - 'eth1' -      redistribute: -        - metric: 10 -          metric_type: 2 -          route_type: 'bgp' -merged_update: -  before:      areas:        - area_id: '2'          area_type: @@ -145,13 +88,14 @@ merged_update:        rfc1583_compatibility: true        router_id: '192.0.1.1'      passive_interface: -      - 'eth2'        - 'eth1' +      - 'eth2'      redistribute:        - metric: 10          metric_type: 2          route_type: 'bgp' -  after: +merged_update: +  before:      areas:        - area_id: '2'          area_type: @@ -163,10 +107,12 @@ merged_update:            nssa:              set: true        - area_id: '4' +        area_type: +          stub: +            default_cost: 20 +            set: true          network:            - address: '192.0.2.0/24' -          - address: '192.0.22.0/24' -          - address: '192.0.32.0/24'          range:            - address: '192.0.3.0/24'              cost: 10 @@ -199,17 +145,13 @@ merged_update:        rfc1583_compatibility: true        router_id: '192.0.1.1'      passive_interface: -      - 'eth2'        - 'eth1' +      - 'eth2'      redistribute:        - metric: 10          metric_type: 2          route_type: 'bgp' -  commands: -    - delete protocols ospf area 4 area-type stub -    - set protocols ospf area 4 network 192.0.22.0/24 -    - set protocols ospf area 4 network 192.0.32.0/24 -populate: +  after:      areas:        - area_id: '2'          area_type: @@ -221,12 +163,10 @@ populate:            nssa:              set: true        - area_id: '4' -        area_type: -          stub: -            default_cost: 20 -            set: true          network:            - address: '192.0.2.0/24' +          - address: '192.0.22.0/24' +          - address: '192.0.32.0/24'          range:            - address: '192.0.3.0/24'              cost: 10 @@ -259,12 +199,72 @@ populate:        rfc1583_compatibility: true        router_id: '192.0.1.1'      passive_interface: -      - 'eth2'        - 'eth1' +      - 'eth2'      redistribute:        - metric: 10          metric_type: 2          route_type: 'bgp' +  commands: +    - delete protocols ospf area 4 area-type stub +    - set protocols ospf area 4 network 192.0.22.0/24 +    - set protocols ospf area 4 network 192.0.32.0/24 +populate: +  areas: +    - area_id: '2' +      area_type: +        normal: true +      authentication: "plaintext-password" +      shortcut: 'enable' +    - area_id: '3' +      area_type: +        nssa: +          set: true +    - area_id: '4' +      area_type: +        stub: +          default_cost: 20 +          set: true +      network: +        - address: '192.0.2.0/24' +      range: +        - address: '192.0.3.0/24' +          cost: 10 +        - address: '192.0.4.0/24' +          cost: 12 +  auto_cost: +    reference_bandwidth: 2 +  default_information: +    originate: +      always: true +      metric: 10 +      metric_type: 2 +      route_map: 'ingress' +  log_adjacency_changes: 'detail' +  max_metric: +    router_lsa: +      administrative: true +      on_shutdown: 10 +      on_startup: 10 +  mpls_te: +    enabled: true +    router_address: '192.0.11.11' +  neighbor: +    - neighbor_id: '192.0.11.12' +      poll_interval: 10 +      priority: 2 +  parameters: +    abr_type: 'cisco' +    opaque_lsa: true +    rfc1583_compatibility: true +    router_id: '192.0.1.1' +  passive_interface: +    - 'eth1' +    - 'eth2' +  redistribute: +    - metric: 10 +      metric_type: 2 +      route_type: 'bgp'  replaced:    commands:      - delete protocols ospf passive-interface eth2 @@ -280,57 +280,57 @@ replaced:      - set protocols ospf area 4 network 192.0.22.0/24      - set protocols ospf area 4 network 192.0.32.0/24    after: -      areas: -        - area_id: '2' -          area_type: -            normal: true -          authentication: "plaintext-password" -          shortcut: 'enable' -        - area_id: '4' -          area_type: -            stub: -              default_cost: 20 -              set: true -          network: -            - address: '192.0.12.0/24' -            - address: '192.0.2.0/24' -            - address: '192.0.22.0/24' -            - address: '192.0.32.0/24' -          range: -            - address: '1.1.2.0/24' -              cost: 10 -      auto_cost: -        reference_bandwidth: 2 -      default_information: -        originate: -          always: true -          metric: 10 -          metric_type: 2 -          route_map: 'ingress' -      log_adjacency_changes: 'detail' -      max_metric: -        router_lsa: -          administrative: true -          on_shutdown: 10 -          on_startup: 10 -      mpls_te: -        enabled: true -        router_address: '192.0.22.22' -      neighbor: -        - neighbor_id: '192.0.11.12' -          poll_interval: 10 -          priority: 2 -      parameters: -        abr_type: 'cisco' -        opaque_lsa: true -        rfc1583_compatibility: true -        router_id: '192.0.1.1' -      passive_interface: -        - 'eth1' -      redistribute: -        - metric: 10 -          metric_type: 2 -          route_type: 'bgp' +    areas: +      - area_id: '2' +        area_type: +          normal: true +        authentication: "plaintext-password" +        shortcut: 'enable' +      - area_id: '4' +        area_type: +          stub: +            default_cost: 20 +            set: true +        network: +          - address: '192.0.12.0/24' +          - address: '192.0.2.0/24' +          - address: '192.0.22.0/24' +          - address: '192.0.32.0/24' +        range: +          - address: '1.1.2.0/24' +            cost: 10 +    auto_cost: +      reference_bandwidth: 2 +    default_information: +      originate: +        always: true +        metric: 10 +        metric_type: 2 +        route_map: 'ingress' +    log_adjacency_changes: 'detail' +    max_metric: +      router_lsa: +        administrative: true +        on_shutdown: 10 +        on_startup: 10 +    mpls_te: +      enabled: true +      router_address: '192.0.22.22' +    neighbor: +      - neighbor_id: '192.0.11.12' +        poll_interval: 10 +        priority: 2 +    parameters: +      abr_type: 'cisco' +      opaque_lsa: true +      rfc1583_compatibility: true +      router_id: '192.0.1.1' +    passive_interface: +      - 'eth1' +    redistribute: +      - metric: 10 +        metric_type: 2 +        route_type: 'bgp'  rendered:    commands:      - set protocols ospf mpls-te enable @@ -369,26 +369,67 @@ rendered:      - set protocols ospf area 4 area-type stub default-cost 20      - set protocols ospf area '4'      - set protocols ospf area 4 network 192.0.2.0/24 -deleted_single: -  commands: -    - delete protocols ospf mpls-te -    - delete protocols ospf redistribute -    - delete protocols ospf auto-cost -    - delete protocols ospf passive-interface -    - delete protocols ospf parameters -    - delete protocols ospf default-information -    - delete protocols ospf max-metric -    - delete protocols ospf log-adjacency-changes -    - delete protocols ospf neighbor -    - delete protocols ospf area 2 -    - delete protocols ospf area 3 -    - delete protocols ospf area 4 -    - delete protocols ospf area -  after: [] +parsed: +  after: +    areas: +      - area_id: '2' +        area_type: +          normal: true +        authentication: "plaintext-password" +        shortcut: 'enable' +      - area_id: '3' +        area_type: +          nssa: +            set: true +      - area_id: '4' +        area_type: +          stub: +            default_cost: 20 +            set: true +        network: +          - address: '192.0.2.0/24' +        range: +          - address: '192.0.3.0/24' +            cost: 10 +          - address: '192.0.4.0/24' +            cost: 12 +    auto_cost: +      reference_bandwidth: 2 +    default_information: +      originate: +        always: true +        metric: 10 +        metric_type: 2 +        route_map: 'ingress' +    log_adjacency_changes: 'detail' +    max_metric: +      router_lsa: +        administrative: true +        on_shutdown: 10 +        on_startup: 10 +    mpls_te: +      enabled: true +      router_address: '192.0.11.11' +    neighbor: +      - neighbor_id: '192.0.11.12' +        poll_interval: 10 +        priority: 2 +    parameters: +      abr_type: 'cisco' +      opaque_lsa: true +      rfc1583_compatibility: true +      router_id: '192.0.1.1' +    passive_interface: +      - 'eth1' +      - 'eth2' +    redistribute: +      - metric: 10 +        metric_type: 2 +        route_type: 'bgp'  deleted:    commands:      - 'delete protocols ospf' -  after: [] +  after: {}  round_trip:    after:      areas: diff --git a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py index 8e6b0957..b825066d 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py +++ b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py @@ -71,7 +71,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):          self.mock_get_config.stop()          self.mock_load_config.stop()          self.mock_execute_show_command.stop() -     +      def load_fixtures(self, commands=None, transport="cli", filename=None):          if filename is None:              filename = "vyos_ospfv2_config.cfg" @@ -87,27 +87,23 @@ class TestVyosFirewallRulesModule(TestVyosModule):              dict(                  config=dict(                      log_adjacency_changes="detail", -                    mpls_te=dict(enabled=True, router_address='192.0.11.11'), +                    mpls_te=dict(enabled=True, router_address="192.0.11.11"),                      auto_cost=dict(reference_bandwidth=2),                      areas=[                          dict(                              area_id="2",                              area_type=dict(normal=True),                              authentication="plaintext-password", -                            shortcut='enable', +                            shortcut="enable",                          ),                          dict(                              area_id="4", -                            area_type=dict( -                                stub=dict(default_cost=10) -                            ), -                            network=[ -                                dict(address="192.0.2.0/24"), -                            ], +                            area_type=dict(stub=dict(default_cost=10)), +                            network=[dict(address="192.0.2.0/24"),],                              range=[                                  dict(address="192.0.3.0/24", cost=10), -                                dict(address="192.0.4.0/24", cost=12) -                            ] +                                dict(address="192.0.4.0/24", cost=12), +                            ],                          ),                      ],                  ), @@ -115,21 +111,21 @@ class TestVyosFirewallRulesModule(TestVyosModule):              )          )          commands = [ -          "set protocols ospf mpls-te enable", -          "set protocols ospf mpls-te router-address '192.0.11.11'", -          "set protocols ospf auto-cost reference-bandwidth '2'", -          "set protocols ospf log-adjacency-changes 'detail'", -          "set protocols ospf area '2'", -          "set protocols ospf area 2 authentication plaintext-password", -          "set protocols ospf area 2 shortcut enable", -          "set protocols ospf area 2 area-type normal", -          "set protocols ospf area 4 range 192.0.3.0/24 cost 10", -          "set protocols ospf area 4 range 192.0.3.0/24", -          "set protocols ospf area 4 range 192.0.4.0/24 cost 12", -          "set protocols ospf area 4 range 192.0.4.0/24", -          "set protocols ospf area 4 area-type stub default-cost 10", -          "set protocols ospf area '4'", -          "set protocols ospf area 4 network 192.0.2.0/24" +            "set protocols ospf mpls-te enable", +            "set protocols ospf mpls-te router-address '192.0.11.11'", +            "set protocols ospf auto-cost reference-bandwidth '2'", +            "set protocols ospf log-adjacency-changes 'detail'", +            "set protocols ospf area '2'", +            "set protocols ospf area 2 authentication plaintext-password", +            "set protocols ospf area 2 shortcut enable", +            "set protocols ospf area 2 area-type normal", +            "set protocols ospf area 4 range 192.0.3.0/24 cost 10", +            "set protocols ospf area 4 range 192.0.3.0/24", +            "set protocols ospf area 4 range 192.0.4.0/24 cost 12", +            "set protocols ospf area 4 range 192.0.4.0/24", +            "set protocols ospf area 4 area-type stub default-cost 10", +            "set protocols ospf area '4'", +            "set protocols ospf area 4 network 192.0.2.0/24",          ]          self.execute_module(changed=True, commands=commands) @@ -142,20 +138,16 @@ class TestVyosFirewallRulesModule(TestVyosModule):                              area_id="12",                              area_type=dict(normal=True),                              authentication="plaintext-password", -                            shortcut='enable', +                            shortcut="enable",                          ),                          dict(                              area_id="14", -                            area_type=dict( -                                stub=dict(default_cost=20) -                            ), -                            network=[ -                                dict(address="192.0.12.0/24"), -                            ], +                            area_type=dict(stub=dict(default_cost=20)), +                            network=[dict(address="192.0.12.0/24"),],                              range=[                                  dict(address="192.0.13.0/24", cost=10), -                                dict(address="192.0.14.0/24", cost=12) -                            ] +                                dict(address="192.0.14.0/24", cost=12), +                            ],                          ),                      ],                  ), @@ -173,21 +165,19 @@ class TestVyosFirewallRulesModule(TestVyosModule):                              area_id="12",                              area_type=dict(normal=True),                              authentication="plaintext-password", -                            shortcut='enable', +                            shortcut="enable",                          ),                          dict(                              area_id="14", -                            area_type=dict( -                                stub=dict(set=False) -                            ), +                            area_type=dict(stub=dict(set=False)),                              network=[                                  dict(address="192.0.12.0/24"),                                  dict(address="192.0.22.0/24"),                              ],                              range=[                                  dict(address="192.0.13.0/24", cost=10), -                                dict(address="192.0.14.0/24", cost=12) -                            ] +                                dict(address="192.0.14.0/24", cost=12), +                            ],                          ),                      ],                  ), @@ -196,7 +186,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):          )          commands = [              "delete protocols ospf area 14 area-type stub", -            "set protocols ospf area 14 network 192.0.22.0/24" +            "set protocols ospf area 14 network 192.0.22.0/24",          ]          self.execute_module(changed=True, commands=commands) @@ -205,28 +195,24 @@ class TestVyosFirewallRulesModule(TestVyosModule):              dict(                  config=dict(                      log_adjacency_changes="detail", -                    mpls_te=dict(enabled=True, router_address='192.0.11.11'), +                    mpls_te=dict(enabled=True, router_address="192.0.11.11"),                      auto_cost=dict(reference_bandwidth=2),                      areas=[                          dict(                              area_id="12",                              area_type=dict(normal=True),                              authentication="plaintext-password", -                            shortcut='enable', +                            shortcut="enable",                          ),                          dict(                              area_id="15", -                            area_type=dict( -                                stub=dict(default_cost=10) -                            ), -                            network=[ -                                dict(address="192.0.12.0/24"), -                            ], +                            area_type=dict(stub=dict(default_cost=10)), +                            network=[dict(address="192.0.12.0/24"),],                              range=[                                  dict(address="192.0.13.0/24", cost=10),                                  dict(address="192.0.14.0/24", cost=12), -                                dict(address="192.0.15.0/24", cost=14) -                            ] +                                dict(address="192.0.15.0/24", cost=14), +                            ],                          ),                      ],                  ), @@ -247,7 +233,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):              "set protocols ospf area 15 range 192.0.15.0/24",              "set protocols ospf area 15 area-type stub default-cost 10",              "set protocols ospf area '15'", -            "set protocols ospf area 15 network 192.0.12.0/24" +            "set protocols ospf area 15 network 192.0.12.0/24",          ]          self.execute_module(changed=True, commands=commands) @@ -260,20 +246,16 @@ class TestVyosFirewallRulesModule(TestVyosModule):                              area_id="12",                              area_type=dict(normal=True),                              authentication="plaintext-password", -                            shortcut='enable', +                            shortcut="enable",                          ),                          dict(                              area_id="14", -                            area_type=dict( -                                stub=dict(default_cost=20) -                            ), -                            network=[ -                                dict(address="192.0.12.0/24"), -                            ], +                            area_type=dict(stub=dict(default_cost=20)), +                            network=[dict(address="192.0.12.0/24"),],                              range=[                                  dict(address="192.0.13.0/24", cost=10), -                                dict(address="192.0.14.0/24", cost=12) -                            ] +                                dict(address="192.0.14.0/24", cost=12), +                            ],                          ),                      ],                  ), @@ -287,63 +269,30 @@ class TestVyosFirewallRulesModule(TestVyosModule):          commands = ["delete protocols ospf"]          self.execute_module(changed=True, commands=commands) -    def test_vyos_ospfv2_set_01_deleted_single_attributes(self): -        set_module_args( -            dict( -                config=dict( -                    mpls_te=dict(), -                    auto_cost=dict(), -                    areas=[] -                ), -                state="deleted", -            ) -        ) -        commands = ["delete protocols ospf area 12", -                    "delete protocols ospf area 14", -                    "delete protocols ospf area"] -        self.execute_module(changed=True, commands=commands) -      def test_vyos_ospfv2_gathered(self):          set_module_args(dict(state="gathered"))          result = self.execute_module(              changed=False, filename="vyos_ospfv2_config.cfg"          )          gather_dict = { -              "areas": [ -                  { -                      "area_id": "2", -                      "area_type": { -                          "normal": True -                      }, -                      "authentication": "plaintext-password", -                      "shortcut": "enable" -                  }, -                  { -                      "area_id": "14", -                      "area_type": { -                          "stub": { -                              "default_cost": 20, -                              "set": True -                          } -                      }, -                      "network": [ -                          { -                              "address": "192.0.12.0/24" -                          } -                      ], -                      "range": [ -                          { -                              "address": "192.0.13.0/24", -                              "cost": 10 -                          }, -                          { -                              "address": "192.0.14.0/24", -                              "cost": 12 -                          } -                      ] -                  } -              ], -          } +            "areas": [ +                { +                    "area_id": "2", +                    "area_type": {"normal": True}, +                    "authentication": "plaintext-password", +                    "shortcut": "enable", +                }, +                { +                    "area_id": "14", +                    "area_type": {"stub": {"default_cost": 20, "set": True}}, +                    "network": [{"address": "192.0.12.0/24"}], +                    "range": [ +                        {"address": "192.0.13.0/24", "cost": 10}, +                        {"address": "192.0.14.0/24", "cost": 12}, +                    ], +                }, +            ], +        }          self.assertEqual(sorted(gather_dict), sorted(result["gathered"]))      def test_vyos_ospfv2_parsed(self): @@ -382,54 +331,28 @@ set protocols ospf redistribute bgp metric-type '2'"""              "areas": [                  {                      "area_id": "2", -                    "area_type": { -                        "normal": True -                    }, +                    "area_type": {"normal": True},                      "authentication": "plaintext-password", -                    "shortcut": "enable" -                }, -                { -                    "area_id": "3", -                    "area_type": { -                        "nssa": { -                            "set": True -                        } -                    } +                    "shortcut": "enable",                  }, +                {"area_id": "3", "area_type": {"nssa": {"set": True}}},                  {                      "area_id": "4", -                    "area_type": { -                        "stub": { -                            "default_cost": 20, -                            "set": True -                        } -                    }, -                    "network": [ -                        { -                            "address": "192.0.2.0/24" -                        } -                    ], +                    "area_type": {"stub": {"default_cost": 20, "set": True}}, +                    "network": [{"address": "192.0.2.0/24"}],                      "range": [ -                        { -                            "address": "192.0.3.0/24", -                            "cost": 10 -                        }, -                        { -                            "address": "192.0.4.0/24", -                            "cost": 12 -                        } -                    ] -                } +                        {"address": "192.0.3.0/24", "cost": 10}, +                        {"address": "192.0.4.0/24", "cost": 12}, +                    ], +                },              ], -            "auto_cost": { -                "reference_bandwidth": 2 -            }, +            "auto_cost": {"reference_bandwidth": 2},              "default_information": {                  "originate": {                      "always": True,                      "metric": 10,                      "metric_type": 2, -                    "route_map": "ingress" +                    "route_map": "ingress",                  }              },              "log_adjacency_changes": "detail", @@ -437,37 +360,27 @@ set protocols ospf redistribute bgp metric-type '2'"""                  "router_lsa": {                      "administrative": True,                      "on_shutdown": 10, -                    "on_startup": 10 +                    "on_startup": 10,                  }              }, -            "mpls_te": { -                "enabled": True, -                "router_address": "192.0.11.11" -            }, +            "mpls_te": {"enabled": True, "router_address": "192.0.11.11"},              "neighbor": [                  {                      "neighbor_id": "192.0.11.12",                      "poll_interval": 10, -                    "priority": 2 +                    "priority": 2,                  }              ],              "parameters": {                  "abr_type": "cisco",                  "opaque_lsa": True,                  "rfc1583_compatibility": True, -                "router_id": "192.0.1.1" +                "router_id": "192.0.1.1",              }, -            "passive_interface": [ -                "eth2", -                "eth1" -            ], +            "passive_interface": ["eth2", "eth1"],              "redistribute": [ -                { -                    "metric": 10, -                    "metric_type": 2, -                    "route_type": "bgp" -                } -            ] +                {"metric": 10, "metric_type": 2, "route_type": "bgp"} +            ],          }          self.assertEqual(sorted(parsed_list), sorted(result["parsed"])) @@ -476,27 +389,23 @@ set protocols ospf redistribute bgp metric-type '2'"""              dict(                  config=dict(                      log_adjacency_changes="detail", -                    mpls_te=dict(enabled=True, router_address='192.0.11.11'), +                    mpls_te=dict(enabled=True, router_address="192.0.11.11"),                      auto_cost=dict(reference_bandwidth=2),                      areas=[                          dict(                              area_id="2",                              area_type=dict(normal=True),                              authentication="plaintext-password", -                            shortcut='enable', +                            shortcut="enable",                          ),                          dict(                              area_id="4", -                            area_type=dict( -                                stub=dict(default_cost=10) -                            ), -                            network=[ -                                dict(address="192.0.2.0/24"), -                            ], +                            area_type=dict(stub=dict(default_cost=10)), +                            network=[dict(address="192.0.2.0/24"),],                              range=[                                  dict(address="192.0.3.0/24", cost=10), -                                dict(address="192.0.4.0/24", cost=12) -                            ] +                                dict(address="192.0.4.0/24", cost=12), +                            ],                          ),                      ],                  ), @@ -518,7 +427,7 @@ set protocols ospf redistribute bgp metric-type '2'"""              "set protocols ospf area 4 range 192.0.4.0/24",              "set protocols ospf area 4 area-type stub default-cost 10",              "set protocols ospf area '4'", -            "set protocols ospf area 4 network 192.0.2.0/24" +            "set protocols ospf area 4 network 192.0.2.0/24",          ]          result = self.execute_module(changed=False)          self.assertEqual( diff --git a/tests/unit/modules/network/vyos/vyos_module.py b/tests/unit/modules/network/vyos/vyos_module.py index e0ab6992..49d46522 100644 --- a/tests/unit/modules/network/vyos/vyos_module.py +++ b/tests/unit/modules/network/vyos/vyos_module.py @@ -60,7 +60,7 @@ class TestVyosModule(ModuleTestCase):          commands=None,          sort=True,          defaults=False, -        filename=None +        filename=None,      ):          self.load_fixtures(commands) | 
