예제 #1
0
 def test_iosxr_config_lines_w_parents(self):
     lines = ['shutdown']
     parents = ['interface GigabitEthernet0/0']
     set_module_args(dict(lines=lines, parents=parents))
     module = MagicMock()
     module.params = {'lines': lines, 'parents': parents, 'src': None}
     candidate_config = iosxr_config.get_candidate(module)
     self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(
         candidate_config, self.running_config))
     commands = ['interface GigabitEthernet0/0', 'shutdown']
     self.execute_module(changed=True, commands=commands)
예제 #2
0
 def test_iosxr_config_lines_w_parents(self):
     lines = ["shutdown"]
     parents = ["interface GigabitEthernet0/0"]
     set_module_args(dict(lines=lines, parents=parents))
     module = MagicMock()
     module.params = {"lines": lines, "parents": parents, "src": None}
     candidate_config = iosxr_config.get_candidate(module)
     self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(
         candidate_config,
         self.running_config,
     ), )
     commands = ["interface GigabitEthernet0/0", "shutdown"]
     self.execute_module(changed=True, commands=commands)
예제 #3
0
    def test_iosxr_config_match_none(self):
        lines = ['ip address 1.2.3.4 255.255.255.0', 'description test string']
        parents = ['interface GigabitEthernet0/0']
        set_module_args(dict(lines=lines, parents=parents, match='none'))
        commands = parents + lines
        module = MagicMock()
        module.params = {'lines': lines, 'parents': parents, 'src': None}
        candidate_config = iosxr_config.get_candidate(module)
        self.conn.get_diff = MagicMock(
            return_value=self.cliconf_obj.get_diff(candidate_config,
                                                   self.running_config,
                                                   diff_match='none',
                                                   path=parents))

        self.execute_module(changed=True, commands=commands, sort=False)
예제 #4
0
    def test_iosxr_config_replace_block(self):
        lines = ['description test string', 'test string']
        parents = ['interface GigabitEthernet0/0']
        set_module_args(dict(lines=lines, replace='block', parents=parents))
        commands = parents + lines

        module = MagicMock()
        module.params = {'lines': lines, 'parents': parents, 'src': None}
        candidate_config = iosxr_config.get_candidate(module)
        self.conn.get_diff = MagicMock(
            return_value=self.cliconf_obj.get_diff(candidate_config,
                                                   self.running_config,
                                                   diff_replace='block',
                                                   path=parents))
        self.execute_module(changed=True, commands=commands)
예제 #5
0
    def test_iosxr_config_match_none(self):
        lines = ["ip address 1.2.3.4 255.255.255.0", "description test string"]
        parents = ["interface GigabitEthernet0/0"]
        set_module_args(dict(lines=lines, parents=parents, match="none"))
        commands = parents + lines
        module = MagicMock()
        module.params = {"lines": lines, "parents": parents, "src": None}
        candidate_config = iosxr_config.get_candidate(module)
        self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(
            candidate_config,
            self.running_config,
            diff_match="none",
            path=parents,
        ))

        self.execute_module(changed=True, commands=commands, sort=False)
예제 #6
0
    def test_iosxr_config_replace_block(self):
        lines = ["description test string", "test string"]
        parents = ["interface GigabitEthernet0/0"]
        set_module_args(dict(lines=lines, replace="block", parents=parents))
        commands = parents + lines

        module = MagicMock()
        module.params = {"lines": lines, "parents": parents, "src": None}
        candidate_config = iosxr_config.get_candidate(module)
        self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(
            candidate_config,
            self.running_config,
            diff_replace="block",
            path=parents,
        ))
        self.execute_module(changed=True, commands=commands)