Commit 94e65624 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Tools:

- added tool to load scenarios from descriptor files
- added README.md file
- added helper script
- added example descriptors
parent 1829036f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
# Tool: Load Scenario:

Simple tool to populate ETSI TeraFlowSDN controller with same descriptors that can be loaded through the WebUI.

## Example:

Deploy TeraFlowSDN controller with your specific settings:
```(bash)
cd ~/tfs-ctrl
source my_deploy.sh 
./deploy.sh 
```

Populate TeraFlowSDN controller with your descriptor file:
```(bash)
./src/tests/tools/load_scenario/run.sh src/tests/tools/load_scenario/example_descriptors.json
```
+14 −0
Original line number Diff line number Diff line
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.
+37 −0
Original line number Diff line number Diff line
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.

import logging, sys
from common.tests.LoadScenario import load_scenario_from_descriptor
from context.client.ContextClient import ContextClient
from device.client.DeviceClient import DeviceClient
from service.client.ServiceClient import ServiceClient
from slice.client.SliceClient import SliceClient

logging.basicConfig(level=logging.INFO)
LOGGER = logging.getLogger(__name__)

def main():
    context_client = ContextClient()
    device_client = DeviceClient()
    service_client = ServiceClient()
    slice_client = SliceClient()

    LOGGER.info('Loading scenario...')
    load_scenario_from_descriptor(sys.argv[1], context_client, device_client, service_client, slice_client)
    LOGGER.info('Done!')
    return 0

if __name__ == '__main__':
    sys.exit(main())
+229 −0
Original line number Diff line number Diff line
{
    "contexts": [
        {
            "context_id": {"context_uuid": {"uuid": "admin"}},
            "topology_ids": [], "service_ids": []
        }
    ],
    "topologies": [
        {
            "topology_id": {
                "context_id": {"context_uuid": {"uuid": "admin"}},
                "topology_uuid": {"uuid": "admin"}
            },
            "device_ids": [
                {"device_uuid": {"uuid": "R1"}},
                {"device_uuid": {"uuid": "R2"}},
                {"device_uuid": {"uuid": "R3"}},
                {"device_uuid": {"uuid": "R4"}},
                {"device_uuid": {"uuid": "R5"}},
                {"device_uuid": {"uuid": "R6"}},
                {"device_uuid": {"uuid": "R7"}}
            ],
            "link_ids": [
                {"link_uuid": {"uuid": "R1==R2"}},
                {"link_uuid": {"uuid": "R2==R3"}},
                {"link_uuid": {"uuid": "R3==R4"}},
                {"link_uuid": {"uuid": "R4==R5"}},
                {"link_uuid": {"uuid": "R5==R6"}},
                {"link_uuid": {"uuid": "R6==R1"}},
                {"link_uuid": {"uuid": "R1==R7"}},
                {"link_uuid": {"uuid": "R3==R7"}},
                {"link_uuid": {"uuid": "R5==R7"}}
            ]
        }
    ],
    "devices": [
        {
            "device_id": {"device_uuid": {"uuid": "R1"}}, "device_type": "emu-packet-router", "device_drivers": [0],
            "device_endpoints": [], "device_operational_status": 1, "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                    {"sample_types": [], "type": "copper", "uuid": "1/1"},
                    {"sample_types": [], "type": "copper", "uuid": "1/2"},
                    {"sample_types": [], "type": "copper", "uuid": "1/3"},
                    {"sample_types": [], "type": "copper", "uuid": "1/4"},
                    {"sample_types": [], "type": "copper", "uuid": "1/5"},
                    {"sample_types": [], "type": "copper", "uuid": "1/6"},
                    {"sample_types": [], "type": "copper", "uuid": "2/1"},
                    {"sample_types": [], "type": "copper", "uuid": "2/2"},
                    {"sample_types": [], "type": "copper", "uuid": "2/3"}
                ]}}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "R2"}}, "device_type": "emu-packet-router", "device_drivers": [0],
            "device_endpoints": [], "device_operational_status": 1, "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                    {"sample_types": [], "type": "copper", "uuid": "1/1"},
                    {"sample_types": [], "type": "copper", "uuid": "1/2"},
                    {"sample_types": [], "type": "copper", "uuid": "1/3"},
                    {"sample_types": [], "type": "copper", "uuid": "1/4"},
                    {"sample_types": [], "type": "copper", "uuid": "1/5"},
                    {"sample_types": [], "type": "copper", "uuid": "1/6"},
                    {"sample_types": [], "type": "copper", "uuid": "2/1"},
                    {"sample_types": [], "type": "copper", "uuid": "2/2"},
                    {"sample_types": [], "type": "copper", "uuid": "2/3"}
                ]}}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "R3"}}, "device_type": "emu-packet-router", "device_drivers": [0],
            "device_endpoints": [], "device_operational_status": 1, "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                    {"sample_types": [], "type": "copper", "uuid": "1/1"},
                    {"sample_types": [], "type": "copper", "uuid": "1/2"},
                    {"sample_types": [], "type": "copper", "uuid": "1/3"},
                    {"sample_types": [], "type": "copper", "uuid": "1/4"},
                    {"sample_types": [], "type": "copper", "uuid": "1/5"},
                    {"sample_types": [], "type": "copper", "uuid": "1/6"},
                    {"sample_types": [], "type": "copper", "uuid": "2/1"},
                    {"sample_types": [], "type": "copper", "uuid": "2/2"},
                    {"sample_types": [], "type": "copper", "uuid": "2/3"}
                ]}}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "R4"}}, "device_type": "emu-packet-router", "device_drivers": [0],
            "device_endpoints": [], "device_operational_status": 1, "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                    {"sample_types": [], "type": "copper", "uuid": "1/1"},
                    {"sample_types": [], "type": "copper", "uuid": "1/2"},
                    {"sample_types": [], "type": "copper", "uuid": "1/3"},
                    {"sample_types": [], "type": "copper", "uuid": "1/4"},
                    {"sample_types": [], "type": "copper", "uuid": "1/5"},
                    {"sample_types": [], "type": "copper", "uuid": "1/6"},
                    {"sample_types": [], "type": "copper", "uuid": "2/1"},
                    {"sample_types": [], "type": "copper", "uuid": "2/2"},
                    {"sample_types": [], "type": "copper", "uuid": "2/3"}
                ]}}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "R5"}}, "device_type": "emu-packet-router", "device_drivers": [0],
            "device_endpoints": [], "device_operational_status": 1, "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                    {"sample_types": [], "type": "copper", "uuid": "1/1"},
                    {"sample_types": [], "type": "copper", "uuid": "1/2"},
                    {"sample_types": [], "type": "copper", "uuid": "1/3"},
                    {"sample_types": [], "type": "copper", "uuid": "1/4"},
                    {"sample_types": [], "type": "copper", "uuid": "1/5"},
                    {"sample_types": [], "type": "copper", "uuid": "1/6"},
                    {"sample_types": [], "type": "copper", "uuid": "2/1"},
                    {"sample_types": [], "type": "copper", "uuid": "2/2"},
                    {"sample_types": [], "type": "copper", "uuid": "2/3"}
                ]}}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "R6"}}, "device_type": "emu-packet-router", "device_drivers": [0],
            "device_endpoints": [], "device_operational_status": 1, "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                    {"sample_types": [], "type": "copper", "uuid": "1/1"},
                    {"sample_types": [], "type": "copper", "uuid": "1/2"},
                    {"sample_types": [], "type": "copper", "uuid": "1/3"},
                    {"sample_types": [], "type": "copper", "uuid": "1/4"},
                    {"sample_types": [], "type": "copper", "uuid": "1/5"},
                    {"sample_types": [], "type": "copper", "uuid": "1/6"},
                    {"sample_types": [], "type": "copper", "uuid": "2/1"},
                    {"sample_types": [], "type": "copper", "uuid": "2/2"},
                    {"sample_types": [], "type": "copper", "uuid": "2/3"}
                ]}}}
            ]}
        },
        {
            "device_id": {"device_uuid": {"uuid": "R7"}}, "device_type": "emu-packet-router", "device_drivers": [0],
            "device_endpoints": [], "device_operational_status": 1, "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                    {"sample_types": [], "type": "copper", "uuid": "1/1"},
                    {"sample_types": [], "type": "copper", "uuid": "1/2"},
                    {"sample_types": [], "type": "copper", "uuid": "1/3"},
                    {"sample_types": [], "type": "copper", "uuid": "2/1"},
                    {"sample_types": [], "type": "copper", "uuid": "2/2"},
                    {"sample_types": [], "type": "copper", "uuid": "2/3"},
                    {"sample_types": [], "type": "copper", "uuid": "2/4"},
                    {"sample_types": [], "type": "copper", "uuid": "2/5"},
                    {"sample_types": [], "type": "copper", "uuid": "2/6"}
                ]}}}
            ]}
        }
    ],
    "links": [
        {
            "link_id": {"link_uuid": {"uuid": "R1==R2"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "2/1"}},
                {"device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "2/2"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R2==R3"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "2/1"}},
                {"device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "2/2"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R3==R4"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "2/1"}},
                {"device_id": {"device_uuid": {"uuid": "R4"}}, "endpoint_uuid": {"uuid": "2/2"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R4==R5"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R4"}}, "endpoint_uuid": {"uuid": "2/1"}},
                {"device_id": {"device_uuid": {"uuid": "R5"}}, "endpoint_uuid": {"uuid": "2/2"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R5==R6"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R5"}}, "endpoint_uuid": {"uuid": "2/1"}},
                {"device_id": {"device_uuid": {"uuid": "R6"}}, "endpoint_uuid": {"uuid": "2/2"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R6==R1"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R6"}}, "endpoint_uuid": {"uuid": "2/1"}},
                {"device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "2/2"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R1==R7"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "2/3"}},
                {"device_id": {"device_uuid": {"uuid": "R7"}}, "endpoint_uuid": {"uuid": "2/1"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R3==R7"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "2/3"}},
                {"device_id": {"device_uuid": {"uuid": "R7"}}, "endpoint_uuid": {"uuid": "2/3"}}
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "R5==R7"}},
            "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "R5"}}, "endpoint_uuid": {"uuid": "2/3"}},
                {"device_id": {"device_uuid": {"uuid": "R7"}}, "endpoint_uuid": {"uuid": "2/5"}}
            ]
        }
    ]
}
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
#!/bin/bash

source tfs_runtime_env_vars.sh
python -m tests.tools.load_scenario $1