# Copyright 2019-present Open Networking Foundation
#
# 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.

# curl -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @edge-fabric-accelleran.yaml http://central1:30007/run

tosca_definitions_version: tosca_simple_yaml_1_0
imports:
  - custom_types/switch.yaml
  - custom_types/switchport.yaml
  - custom_types/portinterface.yaml
  - custom_types/fabricipaddress.yaml
  - custom_types/site.yaml
  - custom_types/node.yaml
  - custom_types/vrouterservice.yaml
  - custom_types/vrouterserviceinstance.yaml

description: Configures the ONF COMAC POD with Cavium

topology_template:
  node_templates:

    # Site deployment
    mySite:
      type: tosca.nodes.Site
      properties:
        name: mysite
        login_base: opencord
        abbreviated_name: ms
        site_url: http://opencord.org/
        hosts_nodes: true

    # compute nodes
    node#node1:
      type: tosca.nodes.Node
      properties:
        dataPlaneIntf: eth2
        dataPlaneIp: 192.168.251.131
        name: node1

    node#node2:
      type: tosca.nodes.Node
      properties:
        dataPlaneIntf: eth2
        dataPlaneIp: 192.168.251.132
        name: node2

    # static routes
    service#vrouter:
      type: tosca.nodes.VRouterService
      properties:
        name: vrouter
        must-exist: true

    vroutersi#calico:
      type: tosca.nodes.VRouterServiceInstance
      properties:
        name: calico
      requirements:
        - owner:
            node: service#vrouter
            relationship: tosca.relationships.BelongsToOne

    # Fabric configuration
    switch#leaf_1:
      type: tosca.nodes.Switch
      properties:
        driver: ofdpa3
        ipv4Loopback: 192.168.0.204
        ipv4NodeSid: 214
        isEdgeRouter: true
        name: Agg Switch
        ofId: of:0000000000000001
        routerMac: 54:87:de:ad:be:ef

    # staging-edge-a
    port#node_1_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 33
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#port_1_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: node_1
      requirements:
        - port:
            node: port#node_1_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_1_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: node_1_sgi_net
      requirements:
        - interface:
            node: interface#port_1_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_1_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: node_1_s1u_net
      requirements:
        - interface:
            node: interface#port_1_interface
            relationship: tosca.relationships.BelongsToOne

    # staging-edge-b
    port#node_2_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 40
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#port_2_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: node_2
      requirements:
        - port:
            node: port#node_2_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_2_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: node_2_sgi_net
      requirements:
        - interface:
            node: interface#port_2_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_2_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: node_2_s1u_net
      requirements:
        - interface:
            node: interface#port_2_interface
            relationship: tosca.relationships.BelongsToOne

    # staging-edge-c
    port#node_3_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 38
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#port_3_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: node_3
      requirements:
        - port:
            node: port#node_3_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_3_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: node_3_sgi_net
      requirements:
        - interface:
            node: interface#port_3_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_3_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: node_3_s1u_net
      requirements:
        - interface:
            node: interface#port_3_interface
            relationship: tosca.relationships.BelongsToOne

    # product-edge-1
    port#node_4_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 34
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#port_4_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: node_4
      requirements:
        - port:
            node: port#node_4_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_4_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: node_4_sgi_net
      requirements:
        - interface:
            node: interface#port_4_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_4_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: node_4_s1u_net
      requirements:
        - interface:
            node: interface#port_4_interface
            relationship: tosca.relationships.BelongsToOne

    # product-edge-2
    port#node_5_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 39
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#port_5_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: node_5
      requirements:
        - port:
            node: port#node_5_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_5_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: node_5_sgi_net
      requirements:
        - interface:
            node: interface#port_5_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_5_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: node_5_s1u_net
      requirements:
        - interface:
            node: interface#port_5_interface
            relationship: tosca.relationships.BelongsToOne

    # QA machine
    port#node_6_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 36
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#port_6_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: node_6
      requirements:
        - port:
            node: port#node_6_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_6_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: node_6_sgi_net
      requirements:
        - interface:
            node: interface#port_6_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_6_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: node_6_s1u_net
      requirements:
        - interface:
            node: interface#port_6_interface
            relationship: tosca.relationships.BelongsToOne

    # RRU Port
    port#rru_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 37
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#rru_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: rru
      requirements:
        - port:
            node: port#rru_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_rru_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: rru_sgi_net
      requirements:
        - interface:
            node: interface#rru_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_rru_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: rru_s1u_net
      requirements:
        - interface:
            node: interface#rru_interface
            relationship: tosca.relationships.BelongsToOne

    # Management node Port
    port#man_node_port:
      type: tosca.nodes.SwitchPort
      properties:
        portId: 35
      requirements:
        - switch:
            node: switch#leaf_1
            relationship: tosca.relationships.BelongsToOne

    interface#man_node_interface:
      type: tosca.nodes.PortInterface
      properties:
        vlanUntagged: 20
        name: man_node
      requirements:
        - port:
            node: port#man_node_port
            relationship: tosca.relationships.BelongsToOne

    ip#port_man_node_sgi_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.250.254/24
        description: man_node_sgi_net
      requirements:
        - interface:
            node: interface#man_node_interface
            relationship: tosca.relationships.BelongsToOne

    ip#port_man_node_s1u_net:
      type: tosca.nodes.FabricIpAddress
      properties:
        ip: 192.168.251.254/24
        description: man_node_s1u_net
      requirements:
        - interface:
            node: interface#man_node_interface
            relationship: tosca.relationships.BelongsToOne
