Commit 77a7f78d authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Clean-up for merge

- remove unrelated or outdated files
parent b42005fb
Loading
Loading
Loading
Loading
+0 −223
Changes for src/tests/ecoc26_pluggables/Fixtures.py: 0 added lines, 223 removed lines.
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Pytest fixtures for the ecoc26 E2E pluggables test.

"""

import logging
import os
import time

import pytest

from common.Constants import ServiceNameEnum
from common.Settings  import (
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC,
    get_env_var_name, get_service_port_grpc,
)
from common.proto.context_pb2       import Context, DeviceId, Topology
from common.proto.context_pb2_grpc  import add_ContextServiceServicer_to_server
from common.tests.MockServicerImpl_Context import MockServicerImpl_Context
from common.tools.service.GenericGrpcService import GenericGrpcService

from context.client.ContextClient   import ContextClient
from device.client.DeviceClient     import DeviceClient
from device.service.DeviceService   import DeviceService
from device.service.driver_api.DriverFactory      import DriverFactory
from device.service.driver_api.DriverInstanceCache import DriverInstanceCache
from device.service.drivers import DRIVERS

from pluggables.client.PluggablesClient  import PluggablesClient
from pluggables.service.PluggablesService import PluggablesService

from nbi_test_data.MockWebServer    import MockWebServer
from pluggable_test_data.CommonObjects import (
    CONTEXT,
    TOPOLOGY,
    DEVICE_HUB_ID,
    DEVICE_HUB_UUID,
    DEVICE_LEAF_ID,
    DEVICE_LEAF_UUID,
    get_device_hub_with_connect_rules,
    get_device_leaf_with_connect_rules,
)


LOGGER = logging.getLogger(__name__)

LOCAL_HOST       = '127.0.0.1'
MOCKSERVICE_PORT = 10000

# Port assignments (same pattern as PreparePluggablesTestScenario.py)
CONTEXT_SERVICE_PORT   = MOCKSERVICE_PORT + get_service_port_grpc(ServiceNameEnum.CONTEXT)
DEVICE_SERVICE_PORT    = MOCKSERVICE_PORT + get_service_port_grpc(ServiceNameEnum.DEVICE)
PLUGGABLE_SERVICE_PORT = get_service_port_grpc(ServiceNameEnum.PLUGGABLES)

# Set env vars before any service or client is instantiated
os.environ[get_env_var_name(ServiceNameEnum.CONTEXT,   ENVVAR_SUFIX_SERVICE_HOST     )] = LOCAL_HOST
os.environ[get_env_var_name(ServiceNameEnum.CONTEXT,   ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(CONTEXT_SERVICE_PORT)
os.environ[get_env_var_name(ServiceNameEnum.DEVICE,    ENVVAR_SUFIX_SERVICE_HOST     )] = LOCAL_HOST
os.environ[get_env_var_name(ServiceNameEnum.DEVICE,    ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(DEVICE_SERVICE_PORT)
os.environ[get_env_var_name(ServiceNameEnum.PLUGGABLES,ENVVAR_SUFIX_SERVICE_HOST     )] = LOCAL_HOST
os.environ[get_env_var_name(ServiceNameEnum.PLUGGABLES,ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(PLUGGABLE_SERVICE_PORT)


# ---------------------------------------------------------------------------
# Mock Context Service
# ---------------------------------------------------------------------------

class MockContextService(GenericGrpcService):
    def __init__(self, bind_port):
        super().__init__(bind_port, LOCAL_HOST, enable_health_servicer=False,
                         cls_name='MockContextService')

    def install_servicers(self):
        self.context_servicer = MockServicerImpl_Context()
        add_ContextServiceServicer_to_server(self.context_servicer, self.server)


@pytest.fixture(scope='session')
def mock_context_service():
    LOGGER.info('Starting MockContextService...')
    svc = MockContextService(CONTEXT_SERVICE_PORT)
    svc.start()
    yield svc
    LOGGER.info('Stopping MockContextService...')
    svc.stop()


# ---------------------------------------------------------------------------
# Context client
# ---------------------------------------------------------------------------

@pytest.fixture(scope='session')
def context_client(mock_context_service):  # pylint: disable=redefined-outer-name
    LOGGER.info('Creating ContextClient...')
    client = ContextClient()
    yield client
    LOGGER.info('Closing ContextClient...')
    client.close()


# ---------------------------------------------------------------------------
# Device service + client
# ---------------------------------------------------------------------------

@pytest.fixture(scope='session')
def device_service(context_client: ContextClient):  # pylint: disable=redefined-outer-name
    LOGGER.info('Starting DeviceService...')
    factory  = DriverFactory(DRIVERS)
    cache    = DriverInstanceCache(factory)
    svc      = DeviceService(cache)
    svc.start()
    yield svc
    LOGGER.info('Stopping DeviceService...')
    svc.stop()


@pytest.fixture(scope='session')
def device_client(device_service: DeviceService):  # pylint: disable=redefined-outer-name
    LOGGER.info('Creating DeviceClient...')
    client = DeviceClient()
    yield client
    LOGGER.info('Closing DeviceClient...')
    client.close()


# ---------------------------------------------------------------------------
# Pluggables service + client
# ---------------------------------------------------------------------------

@pytest.fixture(scope='session')
def pluggables_service(context_client: ContextClient):  # pylint: disable=redefined-outer-name
    LOGGER.info('Starting PluggablesService...')
    svc = PluggablesService()
    svc.start()
    yield svc
    LOGGER.info('Stopping PluggablesService...')
    svc.stop()


@pytest.fixture(scope='session')
def pluggables_client(pluggables_service: PluggablesService,
                      context_client: ContextClient,
                      device_client: DeviceClient):
    LOGGER.info('Creating PluggablesClient...')
    client = PluggablesClient()
    yield client
    LOGGER.info('Closing PluggablesClient...')
    client.close()


# ---------------------------------------------------------------------------
# NBI REST server
# ---------------------------------------------------------------------------

@pytest.fixture(scope='session')
def nbi_web_server(pluggables_service: PluggablesService):  # pylint: disable=redefined-outer-name
    LOGGER.info('Starting NBI MockWebServer...')
    server = MockWebServer()
    server.start()
    time.sleep(1)   # give the Flask server a moment to bind
    yield server
    # daemon thread — terminates with the process


# ---------------------------------------------------------------------------
# Environment preparation (autouse)
# ---------------------------------------------------------------------------

@pytest.fixture(scope='session', autouse=True)
def prepare_environment(context_client: ContextClient,
                        device_client: DeviceClient,
                        pluggables_service: PluggablesService,
                        nbi_web_server):
    """Register context, topology, and both test devices before any test runs."""
    LOGGER.info('Preparing test environment...')

    context_client.SetContext(Context(**CONTEXT))
    context_client.SetTopology(Topology(**TOPOLOGY))
    LOGGER.info('Created admin Context and Topology')

    hub_device = get_device_hub_with_connect_rules()
    context_client.SetDevice(hub_device)
    LOGGER.info(f'Registered Hub device: {DEVICE_HUB_UUID}')

    leaf_device = get_device_leaf_with_connect_rules()
    context_client.SetDevice(leaf_device)
    LOGGER.info(f'Registered Leaf device: {DEVICE_LEAF_UUID}')

    # Sanity-check that Context accepted both devices
    hub_retrieved  = context_client.GetDevice(DeviceId(**DEVICE_HUB_ID))
    assert hub_retrieved.device_id.device_uuid.uuid == DEVICE_HUB_UUID

    leaf_retrieved = context_client.GetDevice(DeviceId(**DEVICE_LEAF_ID))
    assert leaf_retrieved.device_id.device_uuid.uuid == DEVICE_LEAF_UUID

    LOGGER.info('Test environment is ready.')
    yield
    LOGGER.info('Test environment teardown (nothing to clean up for embedded services).')


# ---------------------------------------------------------------------------
# Per-test logging helper
# ---------------------------------------------------------------------------

@pytest.fixture(autouse=True)
def log_each(request):
    LOGGER.info(f'>>>>>> START {request.node.name} >>>>>>')
    yield
    LOGGER.info(f'<<<<<< END   {request.node.name} <<<<<<')
+189 −0
Changes for src/tests/ecoc26_pluggables/README.md: 189 added lines, 0 removed lines.
Original line number Diff line number Diff line
# ECOC26 Pluggables: NBI → Pluggables → SBI test (v2)

End-to-end test that sends pluggable (DSCM) configurations through the TFS NBI
RESTCONF API and checks that they reach the real HUB and LEAF devices over
NETCONF:

```
pytest (K8s Job) ──HTTP──▶ nbiservice ──gRPC──▶ pluggablesservice ──gRPC──▶ deviceservice ──NETCONF──▶ HUB / LEAF
```

| Item | Path |
|---|---|
| K8s Job manifest | [run_in_K8s/nbi_pluggable_sbi_test_job_v2.yaml](run_in_K8s/nbi_pluggable_sbi_test_job_v2.yaml) |
| Runner script | [run_in_K8s/run_nbi_pluggable_sbi_test_v2.sh](run_in_K8s/run_nbi_pluggable_sbi_test_v2.sh) |
| Test file | [tests/test_nbi_pluggable_sbi_v2.py](tests/test_nbi_pluggable_sbi_v2.py) |
| RESTCONF payloads | [descriptors/ecoc26_nbi_pluggable_sbi_messages.py](descriptors/ecoc26_nbi_pluggable_sbi_messages.py) |
| Topology loader | [helper_methods/add_topology.py](helper_methods/add_topology.py) |

## What the test does

The Job loads two topologies into one TFS instance, in this order:

1. [ecoc26_topo_devices_links_L3VPN_v2.json](descriptors/ecoc26_topo_devices_links_L3VPN_v2.json)
   loads context/topology `admin/admin` with containerlab routers `r1`/`r2` (gNMI) and their links. These are used by the L3VPN tests.
2. [ecoc26_no_links_actual_data_plane_v2.json](descriptors/ecoc26_no_links_actual_data_plane_v2.json)
   loads context/topology `ecoc/ecoc` with the real pluggable devices `R1` (HUB) and `R2` (LEAF) (NETCONF).

Tests that are currently enabled in `test_nbi_pluggable_sbi_v2.py`:

| Test | What it checks |
|---|---|
| `test_ensure_topology` | Loads both descriptors if any object is missing or stale. Skips loading if everything is already there. |
| `test_nbi_reset_all_false` | For HUB and then LEAF: `DELETE`, `POST` an all-false DSC config (expects `201`), checks the returned state, `DELETE` again (expects `204`), then `GET` (expects `404`). This leaves both devices with no active subcarriers. |

The selective activation tests (`test_nbi_hub_group1_leaf_channel5` and
`test_nbi_hub_group2_leaf_channel7`) and the basic POST/GET/DELETE tests are
commented out in the file. To run them, uncomment them. Their cleanup and link
creation in `_run_selective_hub_leaf_flow()` are also commented out, so they
will leave the devices configured.

A `netconf_reachable` fixture opens a TCP connection to both devices before the
tests run. If neither device answers, the session stops with
`Both NETCONF devices unreachable — aborting session.` If only one answers, the
tests still run and the ones that use the unreachable device fail.

## Prerequisites

### 1. Kubernetes and TFS

- A **single-node MicroK8s** cluster with the built-in registry at
  `localhost:32000`, and `kubectl` working from your shell.
- TFS deployed in namespace **`tfs`** with at least `context`, `device`, `nbi`
  and **`pluggables`**, built with tag `dev`. The ECOC26 deploy profile sets this
  up:

  ```bash
  cd /home/cttc/tfs-ctrl
  source src/tests/ecoc26_pluggables/ecoc26_deploy.sh   # check LOAD_BALANCER_IP first
  ./deploy/all.sh
  kubectl get pods -n tfs        # all pods Running, including pluggablesservice
  ```

- The image **`localhost:32000/tfs/pluggables:dev`** must exist. The Job uses it
  only for its Python environment (pytest, grpc, requests, TFS protos). The test
  code itself comes from the mounted source tree.

### 2. Source tree on the node

The Job mounts the repository from the node with a `hostPath` volume:

```yaml
hostPath: { path: /home/cttc/tfs-ctrl, type: Directory }
```

- The repository must be at **`/home/cttc/tfs-ctrl`** on the node where the pod
  runs. If it is somewhere else, change `hostPath.path`, `mountPath`,
  `workingDir` and `PYTHONPATH` in the manifest.
- The mount is **read-write** (`readOnly: false`) because the test saves every
  payload it sends to `tmp/` (see [Outputs](#outputs)).
- The generated protobuf files must exist in `src/common/proto/`. If they don't,
  run `./proto/generate_code_python.sh`.
- Because the source is mounted, changes to the test files take effect on the
  next run without rebuilding the image. Changes to the **services**
  (`nbi`, `pluggables`, `device`) need a redeploy.

### 3. Real pluggable devices (NETCONF)

Pods must be able to reach these devices (this usually needs the lab VPN):

| Role | Device ID | Address | Credentials |
|---|---|---|---|
| HUB  | `R1` | `10.30.7.8:830` | `admin` / `admin` |
| LEAF | `R2` | `10.30.7.7:830` | `admin` / `admin` |

Quick check from a pod:

```bash
kubectl exec -n tfs deploy/deviceservice -c server -- \
  python3 -c "import socket; [socket.create_connection((h,830),5) for h in ('10.30.7.8','10.30.7.7')]; print('OK')"
```

### 4. Containerlab routers for the `admin/admin` topology

The L3VPN descriptor adds the gNMI routers `r1` (`172.20.20.101:6030`) and `r2`
(`172.20.20.102:6030`). On the CTTC lab machine they come from the `hf5`
containerlab topology in `/home/cttc/l3vpn/ecoc26/clab/`:

```bash
cd /home/cttc/l3vpn/ecoc26/clab && ./clab_deploy.sh
```

`test_ensure_topology` requires every device to report an operational status,
so if these routers are down, the topology check fails. If you don't need the
`admin/admin` topology, remove `ecoc26_topo_devices_links_L3VPN_v2.json` from
`TFS_TOPOLOGY_DESCRIPTORS` in the manifest.

## How to run

### Option A: runner script (recommended)

```bash
cd /home/cttc/tfs-ctrl
./src/tests/ecoc26_pluggables/run_in_K8s/run_nbi_pluggable_sbi_test_v2.sh
```

The script:

1. Deletes any old `nbi-pluggable-sbi-test-v2` Job.
2. Applies the manifest and waits for the pod to start.
3. Streams the pod logs to
   `src/tests/ecoc26_pluggables/logs/nbi_pluggable_sbi_v2_<YYYYmmdd_HHMM>.log`.
4. Waits for the Job to finish, then deletes it.
5. Prints `[OK] Tests PASSED` or `[FAIL] Tests FAILED` with the log path and
   exits with code `0` or `1`.

Nothing is printed to the terminal while the tests run. To watch progress, run
`tail -f` on the log file from another terminal.

> The script waits at most about **3 minutes** (60 × 3 s) for the Job to finish.
> If you enable more tests and a run takes longer, the script deletes the Job
> early and reports `FAIL`. Increase the `seq 1 60` loop if that happens.

### Option B: by hand with kubectl

```bash
cd /home/cttc/tfs-ctrl
kubectl delete job nbi-pluggable-sbi-test-v2 -n tfs --ignore-not-found
kubectl apply  -f src/tests/ecoc26_pluggables/run_in_K8s/nbi_pluggable_sbi_test_job_v2.yaml
kubectl logs   -f -n tfs -l job-name=nbi-pluggable-sbi-test-v2
kubectl get job nbi-pluggable-sbi-test-v2 -n tfs     # COMPLETIONS 1/1 = passed
```

`ttlSecondsAfterFinished: 600` removes the Job automatically 10 minutes after
it finishes.

## Configuration (Job environment variables)

| Variable | Value in manifest | Meaning |
|---|---|---|
| `TFS_TOPOLOGY_DESCRIPTORS` | `ecoc26_topo_devices_links_L3VPN_v2.json,ecoc26_no_links_actual_data_plane_v2.json` | Descriptors loaded from left to right, from `descriptors/`. The **last** one is the one removed and reloaded when it is stale. |
| `TFS_TOPOLOGY_DESCRIPTOR` | `ecoc26_no_links_actual_data_plane_v2.json` | Single-descriptor fallback, used only when `TFS_TOPOLOGY_DESCRIPTORS` is empty. |
| `TFS_TOPOLOGY_ALLOW_EXISTING` | `true` | Load on top of whatever is already in Context, instead of requiring an empty scenario. With `false`, the test expects an empty Context. |
| `ECOC26_CONTEXT_ID` / `ECOC26_TOPOLOGY_ID` | `ecoc` / `ecoc` | Context and topology of the pluggable devices. |
| `ECOC26_HUB_DEVICE_ID` / `ECOC26_LEAF_DEVICE_ID` | `R1` / `R2` | Device IDs used in the NBI URL `.../device=<id>/openconfig-platform:components/component=1/optical-channel/config`. |
| `ECOC26_CONFIG_LOG_DIR` | *(not set)* | Where payload copies are saved. The default is `src/tests/ecoc26_pluggables/tmp/`. |

The service addresses (`NBISERVICE_SERVICE_HOST`, `CONTEXTSERVICE_...`, and so on) are
set automatically by Kubernetes because the Job runs in the `tfs` namespace.

## Outputs

- **Test log:** `logs/nbi_pluggable_sbi_v2_<timestamp>.log`, written by the
  runner script. `*.log` files are git-ignored.
- **Sent payloads:** every config the test POSTs is saved as
  `tmp/hub_<timestamp>_config.json` or `tmp/leaf_<timestamp>_config.json`.
  `tmp/` is git-ignored.
- **TFS UI:** after a successful run, the WebUI shows the `ecoc/ecoc` and
  `admin/admin` context/topologies with their devices.

## Troubleshooting

| Symptom | Likely cause |
|---|---|
| Pod stuck in `ContainerCreating` or `ErrImagePull` | `localhost:32000/tfs/pluggables:dev` is missing. Deploy TFS with `pluggables` in `TFS_COMPONENTS`. |
| `ModuleNotFoundError: common.proto...` | Protos not generated in the mounted tree. Run `./proto/generate_code_python.sh`. |
| `Both NETCONF devices unreachable — aborting session.` | VPN down, or `10.30.7.7`/`10.30.7.8` can't be reached from the cluster. |
| `test_ensure_topology` fails on assertion | A device in a descriptor never came up (for example, the containerlab routers aren't running), or a stale object is left over from an older run. Check `kubectl logs -n tfs deploy/deviceservice -c server`. |
| POST returns non-`201` | Check `kubectl logs -n tfs deploy/nbiservice -c server` and `deploy/pluggablesservice -c server`. |
| `PermissionError` writing `tmp/...` | The volume is mounted read-only. Make sure `readOnly: false` is set in the manifest. |
+0 −42
Changes for src/tests/ecoc26_pluggables/descriptors/ecoc26_devices_only.json: 0 added lines, 42 removed lines.
Original line number Diff line number Diff line
{
    "devices": [
        {
            "device_id": {"device_uuid": {"uuid": "r1"}}, "device_type": "packet-router",
            "device_drivers": ["DEVICEDRIVER_GNMI_OPENCONFIG"],
            "device_config": {"config_rules": [
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "172.20.20.101"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port", "resource_value": "6030"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
                    "username": "admin", "password": "admin", "use_tls": false
                }}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "r2"}}, "device_type": "packet-router",
            "device_drivers": ["DEVICEDRIVER_GNMI_OPENCONFIG"],
            "device_config": {"config_rules": [
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "172.20.20.102"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port", "resource_value": "6030"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
                    "username": "admin", "password": "admin", "use_tls": false
                }}}
            ]}
        }
    ],
    "links": [
        {
            "link_id": {"link_uuid": {"uuid": "r1/Ethernet2==r2/Ethernet1"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "r1"}}, "endpoint_uuid": {"uuid": "Ethernet2"}},
                {"device_id": {"device_uuid": {"uuid": "r2"}}, "endpoint_uuid": {"uuid": "Ethernet1"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "r2/Ethernet1==r1/Ethernet2"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "r2"}}, "endpoint_uuid": {"uuid": "Ethernet1"}},
                {"device_id": {"device_uuid": {"uuid": "r1"}}, "endpoint_uuid": {"uuid": "Ethernet2"}}
            ]
        }
    ]
}
+0 −42
Changes for src/tests/ecoc26_pluggables/descriptors/ecoc26_devices_only_L3VPN.json: 0 added lines, 42 removed lines.
Original line number Diff line number Diff line
{
    "devices": [
        {
            "device_id": {"device_uuid": {"uuid": "r1"}}, "device_type": "packet-router",
            "device_drivers": ["DEVICEDRIVER_GNMI_OPENCONFIG"],
            "device_config": {"config_rules": [
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "172.20.20.101"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port", "resource_value": "6030"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
                    "username": "admin", "password": "admin", "use_tls": false
                }}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "r2"}}, "device_type": "packet-router",
            "device_drivers": ["DEVICEDRIVER_GNMI_OPENCONFIG"],
            "device_config": {"config_rules": [
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "172.20.20.102"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port", "resource_value": "6030"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
                    "username": "admin", "password": "admin", "use_tls": false
                }}}
            ]}
        }
    ],
    "links": [
        {
            "link_id": {"link_uuid": {"uuid": "r1/Ethernet2==r2/Ethernet1"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "r1"}}, "endpoint_uuid": {"uuid": "Ethernet2"}},
                {"device_id": {"device_uuid": {"uuid": "r2"}}, "endpoint_uuid": {"uuid": "Ethernet1"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "r2/Ethernet1==r1/Ethernet2"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "r2"}}, "endpoint_uuid": {"uuid": "Ethernet1"}},
                {"device_id": {"device_uuid": {"uuid": "r1"}}, "endpoint_uuid": {"uuid": "Ethernet2"}}
            ]
        }
    ]
}
+0 −30
Changes for src/tests/ecoc26_pluggables/descriptors/ecoc26_no_links_actual_data_plane.json: 0 added lines, 30 removed lines.
Original line number Diff line number Diff line
{
    "devices": [
        {
            "device_id": {"device_uuid": {"uuid": "R1"}}, "device_type": "packet-router",
            "device_drivers": ["DEVICEDRIVER_OPENCONFIG"],
            "device_config": {"config_rules": [
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "10.30.7.8"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port", "resource_value": "830"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
                    "username": "admin", "password": "admin", "use_tls": false,
                    "hostkey_verify": false, "look_for_keys": false, "allow_agent": false
                }}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/populate_resource_keys", "resource_value": "__inventory__, __interfaces__, __network_instances__"}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "R2"}}, "device_type": "packet-router",
            "device_drivers": ["DEVICEDRIVER_OPENCONFIG"],
            "device_config": {"config_rules": [
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "10.30.7.7"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port", "resource_value": "830"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
                    "username": "admin", "password": "admin", "use_tls": false,
                    "hostkey_verify": false, "look_for_keys": false, "allow_agent": false
                }}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/populate_resource_keys", "resource_value": "__inventory__, __interfaces__, __network_instances__"}}
            ]}
        }
    ]
}
Loading