# Modeling of Trunk service in WFO

This is a dummy implementation of a trunk service in workflow orchestrator. The "pieces" of the trunk service are mapped to Products. The parameters of the trunk service are modelled as Resource Types.

## Quickstart

- Follow Steps 1 and 2 from here: https://workfloworchestrator.org/orchestrator-core/workshops/beginner/debian/
- To install the orchestrator GUI, you can follow the steps 5 and 6 from the above link.
- Clone this repo:
- ``pip install -r requirements.txt``
- from the top-level directory:
- ``pip install -e .``
- Create ``oss-params.json``
- Export the oss-params file: ``export OSS_PARAMS_FILENAME="/path/to/file.json"``
- The core of workflow orchestrator can be started with ``uvicorn --host 0.0.0.0 --port 8080 main:app`` from inside the ``geant_service_orchestrator`` directory of this repo.
- The GUI can be started with ``yarn start``.

## Structure description

### Products & fixed inputs
- Trunk
    - Reference to PB Trunk
- TrunkConfig
    - Reference to PB TrunkConfig
- TrunkConfigCommon
    - Reference to PB TrunkConfigCommon
- TrunkConfigSide
    - Reference to PB TrunkConfigSide
### Product blocks & resource types
- Trunk
	- Id
	- GeantSSid
	- Name
- TrunkConfig
	- Id
	- Reference to PB Trunk
- TrunkConfigCommon
	- Id
	- Speed
	- IsLeasedLine
	- IsIsMetric
	- MinimumLinks
	- Reference to PB TrunkConfig
- TrunkConfigSide
	- Id
	- Name
	- AEName
	- GeantASid
	- IPv4Address
	- IPv6Address
	- Members
	- Reference to PB TrunkConfig

### Workflows
- Workflows included are CREATE and TERMINATE for:
    - Trunk
    - TrunkConfig
    - TrunkConfigCommon
    - TrunkConfigSide


## Useful WFO Resources
- WFO API (Swagger): https://workfloworchestrator.org/orchestrator-core/architecture/application/api/
- WFO API (repo): https://github.com/workfloworchestrator/orchestrator-core/tree/main/orchestrator/api/api_v1/endpoints
- Carolina notes:
https://wiki.geant.org/pages/viewpage.action?pageId=562921625

### API examples

*Note: update IP address in the request to your own where you're running WFO.*

**Creating subscriptions** (look at initial_input_form_generator method of the workflow to find what properties need to be passed in the data of the POST request)

Create process that produces a new subscription (CREATE workflow)

``curl -X POST -H "Content-Type: application/json" http://10.98.1.62:8080/api/processes/create_trunk --data '[{"product": "321045fc-21ec-476b-b67b-5f211e47c3d7"},{"trunk_name": "mytrunkfromapi", "geant_s_sid": "a1b2c3"}]'``

Create process that manipulates the state of a subscription (TERMINATE workflow)

``curl -X POST -H "Content-Type: application/json" http://10.98.1.62:8080/api/processes/terminate_trunk --data '[{"subscription_id": "910e7044-c427-46d1-afc3-7817e221d45d"}, {"are_you_sure": "yes"}]'``

**Deleting subscriptions** (not the same as running a TERMINATE workflow for a subscription, but to actually erase it from the WFO database)

Delete a subscription:

``curl -X 'DELETE' 'http://10.98.1.62:8080/api/subscriptions/3f16532b-0a48-4fe3-802a-36b3f54eed0e'``

To do the above, you first have to delete the processes first:

``curl -X 'DELETE' 'http://10.98.1.62:8080/api/processes/7447a3e9-7c58-4ae7-8804-c0a75c39c924'``