Commit 508c78f5 authored by Mohamad Rahhal's avatar Mohamad Rahhal
Browse files

-Device Component:

Added new tests
parent 3bb2289a
Loading
Loading
Loading
Loading
+50 −6
Original line number Diff line number Diff line
@@ -215,6 +215,50 @@ class MikrotikRouterOSDriver(_Driver):
                                payload["instance"] = str(resource_value["instance"])
                            if "vni" in resource_value:
                                payload["vni"] = int(resource_value["vni"])
                        # --- OSPF Instance ---
                        elif resource_key.startswith("/network_instances/ospf_instance"):
                            endpoint = "/routing/ospf/instance"
                            payload = {
                                "name": str(resource_value["name"]),
                                "router-id": str(resource_value["router-id"]),
                                "version": int(resource_value.get("version", 2))
                            }
        
                        # --- OSPF Area ---
                        elif resource_key.startswith("/network_instances/ospf_area"):
                            endpoint = "/routing/ospf/area"
                            payload = {
                                "name": str(resource_value["name"]),
                                "instance": str(resource_value["instance"]),
                                "area-id": str(resource_value.get("area-id", "0.0.0.0"))
                            }
        
                        # --- OSPF Interface Template ---
                        elif resource_key.startswith("/network_instances/ospf_interface"):
                            endpoint = "/routing/ospf/interface-template"
                            payload = {
                                "interfaces": [str(resource_value["interface"])],
                                "area": str(resource_value.get("area", "backbone"))
                            }
        
                        # --- IS-IS Instance ---
                        elif resource_key.startswith("/network_instances/isis_instance"):
                            endpoint = "/routing/isis/instance"
                            payload = {
                                "name": str(resource_value["name"]),
                                "areas": str(resource_value["areas"]),
                                "system-id": str(resource_value["system-id"])
                            }
        
                        # --- IS-IS Interface Template ---
                        elif resource_key.startswith("/network_instances/isis_interface"):
                            endpoint = "/routing/isis/interface-template"
                            level_val = resource_value.get("levels", "l2")
                            payload = {
                                "instance": str(resource_value["instance"]),
                                "interfaces": [str(resource_value["interface"])],
                                "levels": [str(level_val)]
                            }
                        else:
                            raise NotImplementedError(f"Resource not implemented: {resource_key}")
        
+35 −0
Original line number Diff line number Diff line
{
  "device_id": { "device_uuid": { "uuid": "1f3a8cbe-5826-585b-a207-4826d4ae9a61" } },
  "device_config": {
    "config_rules": [
      {
        "action": 1,
        "custom": {
          "resource_key": "/interfaces/ip",
          "resource_value": "{\"address\": \"10.255.0.2/32\", \"interface\": \"lo\", \"comment\": \"Spine 2 Loopback\"}"
        }
      },
            {
        "action": 1,
        "custom": {
          "resource_key": "/network_instances/isis_instance",
          "resource_value": "{\"name\": \"default-isis\", \"areas\": \"49.0001\", \"system-id\": \"0102.5500.0002\"}"
        }
      },
            {
        "action": 1,
        "custom": {
          "resource_key": "/network_instances/isis_interface",
          "resource_value": "{\"instance\": \"default-isis\", \"interface\": \"lo\"}"
        }
      },
      {
        "action": 1,
        "custom": {
          "resource_key": "/network_instances/isis_interface",
          "resource_value": "{\"instance\": \"default-isis\", \"interface\": \"sfp-sfpplus1\", \"levels\": [\"l2\"]}"
        }
      }
    ]
  }
}
 No newline at end of file