예제 #1
0
파일: fortios.py 프로젝트: ogarraux/napalm
    def load_replace_candidate(self, filename=None, config=None):
        self.config_replace = True

        self.device.candidate_config = FortiConfig('candidate')
        self.device.running_config = FortiConfig('running')

        self._load_config(filename, config)

        self.device.load_config(empty_candidate=True)
예제 #2
0
파일: fortios.py 프로젝트: ogarraux/napalm
    def load_merge_candidate(self, filename=None, config=None):
        self.config_replace = False

        self.device.candidate_config = FortiConfig('candidate')
        self.device.running_config = FortiConfig('running')

        self._load_config(filename, config)

        for block in self.device.candidate_config.get_block_names():
            try:
                self.device.load_config(path=block, empty_candidate=True)
            except CommandExecutionException as e:
                raise MergeConfigException(e.message)
예제 #3
0
class FakeFortiOSDevice:
    @staticmethod
    def read_txt_file(filename):
        with open(filename) as data_file:
            return data_file.read().splitlines()

    def execute_command(self, command):
        return self.read_txt_file('fortios/mock_data/{}.txt'.format(command.replace(' ', '_')))

    def load_config(self, config_block):
        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file('fortios/mock_data/{}.txt'.format(
                                                                                    config_block.replace(' ', '_'))))
예제 #4
0
class FakeFortiOSDevice:
    @staticmethod
    def read_txt_file(filename):
        with open(filename) as data_file:
            return data_file.read().splitlines()

    def execute_command(self, command):
        return self.read_txt_file('fortios/mock_data/{}.txt'.format(
            command.replace(' ', '_').replace('|', '').replace(':', '')))

    def load_config(self, config_block):
        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(
            self.read_txt_file('fortios/mock_data/{}.txt'.format(
                config_block.replace(' ', '_'))))
예제 #5
0
class FakeDevice(BaseTestDouble):
    """Device test double."""
    def open(self):
        pass

    def close(self):
        pass

    def execute_command(self, command):
        filename = '{}.txt'.format(self.sanitize_text(command))
        full_path = self.find_file(filename)
        return self.read_txt_file(full_path).splitlines()

    def load_config(self, config_block):
        filename = '{}.txt'.format(self.sanitize_text(config_block))
        full_path = self.find_file(filename)

        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file(full_path))
예제 #6
0
class FakeDevice(BaseTestDouble):
    """Device test double."""

    def open(self):
        pass

    def close(self):
        pass

    def execute_command(self, command):
        filename = '{}.txt'.format(self.sanitize_text(command))
        full_path = self.find_file(filename)
        return self.read_txt_file(full_path).splitlines()

    def load_config(self, config_block):
        filename = '{}.txt'.format(self.sanitize_text(config_block))
        full_path = self.find_file(filename)

        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file(full_path))
예제 #7
0
파일: fortios.py 프로젝트: ogarraux/napalm
 def discard_config(self):
     self.device.candidate_config = FortiConfig('candidate')
     self.device.load_config(in_candidate=True)
예제 #8
0
 def load_config(self, config_block):
     self.running_config = FortiConfig('running')
     self.running_config.parse_config_output(
         self.read_txt_file('fortios/mock_data/{}.txt'.format(
             config_block.replace(' ', '_'))))
예제 #9
0
 def load_config(self, config_block):
     self.running_config = FortiConfig('running')
     self.running_config.parse_config_output(self.read_txt_file('fortios/mock_data/{}.txt'.format(
         config_block.replace(' ', '_'))))
예제 #10
0
    def load_config(self, config_block):
        filename = '{}.txt'.format(self.sanitize_text(config_block))
        full_path = self.find_file(filename)

        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file(full_path))
예제 #11
0
    def load_config(self, config_block):
        filename = '{}.txt'.format(self.sanitize_text(config_block))
        full_path = self.find_file(filename)

        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file(full_path))