Sobes.tech
Intern

What programming languages do you use and how would you approach writing a configuration converter between vendors (Cisco, Juniper, Ubiquiti → ELTEX)?

sobes.tech AI

Answer from AI

For the task of writing a configuration converter between vendors (Cisco, Juniper, Ubiquiti → ELTEX), I would choose a language with good support for text processing and the ability to easily parse and generate configuration files. For example, Python — thanks to its rich libraries for parsing (pyparsing, textfsm) and ease of working with strings.

Approach:

  1. Analyze the configuration formats of each vendor, highlighting key parameters and structures.
  2. Create an intermediate representation (e.g., as an object or dictionary) that abstracts common elements of the configuration.
  3. Implement parsers for each source format that convert the configuration into the intermediate representation.
  4. Generate ELTEX configuration based on the intermediate representation.

Example of simplified Python code:

# Example of parsing a simplified Cisco configuration
def parse_cisco(config_str):
    config = {}
    for line in config_str.splitlines():
        if line.startswith('interface'):
            iface = line.split()[1]
            config[iface] = {}
        elif 'ip address' in line:
            parts = line.strip().split()
            config[iface]['ip'] = parts[2]
    return config

# Generating ELTEX configuration
def generate_eltex(config):
    lines = []
    for iface, params in config.items():
        lines.append(f'interface {iface}')
        if 'ip' in params:
            lines.append(f' ip address {params["ip"]}')
    return '\n'.join(lines)

# Usage
cisco_conf = '''interface GigabitEthernet0/1
 ip address 192.168.1.1 255.255.255.0
'''
parsed = parse_cisco(cisco_conf)
eltex_conf = generate_eltex(parsed)
print(eltex_conf)

This approach will allow scaling the converter by adding new parsers and generators for other vendors.