def test_awplus_config_lines_wo_parents(self):
     lines = ["hostname foo"]
     set_module_args(dict(lines=lines))
     self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(
         "\n".join(lines), self.running_config))
     commands = ["hostname foo"]
     self.execute_module(changed=True, commands=commands)
 def test_awplus_config_config(self):
     config = "hostname localhost"
     lines = ["hostname R-changed"]
     set_module_args(dict(lines=lines, config=config))
     self.conn.get_diff = MagicMock(
         return_value=self.cliconf_obj.get_diff("\n".join(lines), config))
     commands = ["hostname R-changed"]
     self.execute_module(changed=True, commands=commands)
 def test_awplus_lacp_interfaces_merged_idempotent(self):
     set_module_args(
         dict(
             config=[dict(name="port1.0.2", port_priority=3, timeout="long")],
             state="merged",
         )
     )
     self.execute_module(changed=False, commands=[])
Example #4
0
 def test_awplus_banner_merged(self):
     for banner_type in ("motd", "exec"):
         set_module_args(
             dict(config=[
                 dict(banner=banner_type, text="test banner string")
             ]))
         commands = ["banner {0} test banner string".format(banner_type)]
         self.execute_module(changed=True, commands=commands)
 def test_awplus_lldp_interfaces_deleted(self):
     set_module_args(dict(config=[dict(name="port1.0.3")], state="deleted"))
     commands = [
         "interface port1.0.3",
         "lldp receive",
         "no lldp tlv-select link-aggregation",
     ]
     self.execute_module(changed=True, commands=commands)
Example #6
0
 def test_awplus_lldp_deleted(self):
     set_module_args(dict(config=dict(), state="deleted"))
     commands = [
         "no lldp run", "no lldp faststart-count",
         "no lldp holdtime-multiplier",
         "no lldp non-strict-med-tlv-order-check"
     ]
     self.execute_module(changed=True, commands=commands)
 def test_awplus_static_lag_interfaces_default_idempotent(self):
     set_module_args(
         dict(config=[{
             'name': "2",
             'members': ["port1.0.2"],
             'member-filters': True
         }]))
     self.execute_module(changed=False, commands=[])
 def test_awplus_lldp_interfaces_replaced_idempotent(self):
     set_module_args(
         dict(
             config=[dict(name="port1.0.2", receive=True, transmit=True)],
             state="replaced",
         )
     )
     self.execute_module(changed=False, commands=[])
 def test_awplus_user_overridden_idempotent(self):
     set_module_args(
         dict(config=[
             dict(name="ansible", privilege=8),
             dict(name="jin", privilege=3)
         ],
              state="overridden"))
     result = self.execute_module(changed=False)
Example #10
0
 def test_awplus_system_domain_list(self):
     set_module_args(dict(domain_list=["ansible.com", "redhat.com"]))
     commands = [
         "no ip domain-list example.net",
         "ip domain-list ansible.com",
         "ip domain-list redhat.com",
     ]
     self.execute_module(changed=True, commands=commands, sort=False)
 def test_awplus_ntp_replace_server(self):
     set_module_args(
         dict(
             config=dict(server=["10.75.33.7"], ),
             state="replaced",
         ))
     commands = ["no ntp server 10.75.33.5", "ntp server 10.75.33.7"]
     self.execute_module(changed=True, commands=commands)
Example #12
0
 def test_awplus_command_match_any(self):
     wait_for = [
         'result[0] contains "AlliedWare Plus"',
         'result[0] contains "Open vSwitch"',
     ]
     set_module_args(
         dict(commands=["show version"], wait_for=wait_for, match="all"))
     self.execute_module()
 def test_awplus_openflow_add_new_controller(self):
     set_module_args(
         dict(controllers=[
             dict(protocol="tcp", address="184.5.3.2", ssl_port=10)
         ]))
     commands = ["openflow controller tcp 184.5.3.2 10"]
     result = self.execute_module(changed=True)
     self.assertEqual(commands, result["commands"])
 def test_awplus_ospf_passive_interface_interface(self):
     set_module_args(
         {"router": {"process_id": 100}, "passive_interface": {"name": "vlan1"}}
     )
     result = self.execute_module(changed=True)
     self.assertEqual(
         result["commands"], ["router ospf 100", "passive-interface vlan1"]
     )
Example #15
0
 def test_awplus_vlan_replaced(self):
     set_module_args(
         dict(
             config=[dict(vlan_id=30, name="thirty", state="suspend")],
             state="replaced",
         ))
     commands = ["vlan database", "vlan 30 name thirty state disable"]
     self.execute_module(changed=True, commands=commands)
 def test_awplus_ospf_router_id(self):
     set_module_args(
         {"router": {"process_id": 100}, "ospf_router_id": {"ip_addr": "2.3.4.5"}}
     )
     result = self.execute_module(changed=True)
     self.assertEqual(
         result["commands"], ["router ospf 100", "ospf router-id 2.3.4.5"]
     )
 def test_awplus_ospf_area_authentication_change_nothing(self):
     set_module_args(
         {
             "router": {"process_id": 100},
             "area": {"area_id": 1, "authentication": {"state": "present"}},
         }
     )
     self.execute_module(changed=False)
Example #18
0
 def test_awplus_system_name_servers(self):
     name_servers = ["8.8.8.8", "8.8.4.4"]
     set_module_args(dict(name_servers=name_servers))
     commands = [
         "no ip name-server vrf management 8.8.8.8 ",
         "ip name-server 8.8.4.4",
     ]
     self.execute_module(changed=True, commands=commands, sort=False)
Example #19
0
 def test_awplus_lag_interfaces_default(self):
     set_module_args(
         dict(config=[
             dict(name="2",
                  members=[dict(member="port1.0.4", mode="passive")])
         ]))
     commands = ["interface port1.0.4", "channel-group 2 mode passive"]
     self.execute_module(changed=True, commands=commands)
Example #20
0
 def test_awplus_rip_no_passive_interface(self):
     set_module_args(dict(passive_int="yellow vlan10", state="absent"))
     commands = [
         "router rip",
         "address-family ipv4 vrf yellow",
         "no passive-interface vlan10",
     ]
     self.execute_module(changed=True, commands=commands)
Example #21
0
 def test_awplus_interfaces_merged_idempotent(self):
     set_module_args(
         dict(
             config=[
                 dict(name="vlan1", description="Merged by Ansible Network")
             ],
             state="merged",
         ))
     self.execute_module(changed=False, commands=[])
 def test_awplus_ospf_area_stub_no(self):
     set_module_args(
         {
             "router": {"process_id": 100},
             "area": {"area_id": 1, "stub": {"state": "absent"}},
         }
     )
     result = self.execute_module(changed=True)
     self.assertEqual(result["commands"], ["router ospf 100", "no area 1 stub"])
Example #23
0
 def test_awplus_lag_interfaces_deleted(self):
     set_module_args(
         dict(config=[
             dict(name="1",
                  members=[dict(member="port1.0.2", mode="active")])
         ],
              state="deleted"))
     commands = ["interface port1.0.2", "no channel-group"]
     self.execute_module(changed=True, commands=commands)
Example #24
0
 def test_awplus_command_match_all_failure(self):
     wait_for = [
         'result[0] contains "AlliedWare Plus"',
         'result[0] contains "test string"',
     ]
     commands = ["show version", "show version"]
     set_module_args(dict(commands=commands, wait_for=wait_for,
                          match="all"))
     self.execute_module(failed=True)
Example #25
0
 def test_awplus_bgp_replaced_idempotent(self):
     set_module_args(dict(
         config=dict(bgp_as=100, router_id='1.2.3.4',
                     neighbors=[dict(neighbor='1.1.1.1', remote_as=3)],
                     address_family=[dict(vrf='red',
                                          networks=[dict(prefix='2.2.2.2', masklen=32, route_map='f')],
                                          neighbors=[dict(neighbor='6.6.6.6', remote_as=3)])]),
         state='merged'))
     self.execute_module(changed=False)
 def test_awplus_bgp_default_value(self):
     set_module_args(
         dict(asn=100, graceful_restart_timers_restart="default"))
     self.execute_module(
         changed=True,
         commands=[
             "router bgp 100", "bgp graceful-restart restart-time 120"
         ],
     )
Example #27
0
 def test_awplus_interfaces_replaced_idempotent(self):
     set_module_args(
         dict(config=[
             dict(name="port1.0.3",
                  speed=1000,
                  description="Overridden by Ansible Network")
         ],
              state="replaced"))
     self.execute_module(changed=False, commands=[])
 def test_awplus_user_overridden(self):
     set_module_args(
         dict(config=[dict(name="test", configured_password="******")],
              state="overridden"))
     commands = [
         "username test privilege 1 password test", "no username ansible",
         "no username jin"
     ]
     result = self.execute_module(changed=True, commands=commands)
Example #29
0
 def rest_awplus_system_name_servers_complex(self):
     name_servers = dict(server="8.8.8.8", vrf="test")
     set_module_args(dict(name_servers=name_servers))
     commands = [
         "no name-server 8.8.8.8",
         "no name-server vrf management 8.8.8.8",
         "ip name-server vrf test 8.8.8.8",
     ]
     self.execute_module(changed=True, commands=commands, sort=False)
Example #30
0
 def test_awplus_static_route_present_vrf(self):
     set_module_args(
         dict(prefix="192.168.20.64", mask=24, next_hop="192.0.2.3", vrf="test")
     )
     self.execute_module(
         changed=True,
         sort=False,
         commands=["ip route vrf test 192.168.20.64/24 192.0.2.3"],
     )