# Copyright 2017-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.


tosca_definitions_version: tosca_simple_yaml_1_0

description: Persist M-CORD Subscriber

imports:
   - custom_types/mcordsubscriberservice.yaml
   - custom_types/venbservice.yaml
   - custom_types/slice.yaml
   - custom_types/site.yaml
   - custom_types/image.yaml
   - custom_types/servicedependency.yaml

topology_template:
  node_templates:

    # Site
    {{ site_humanname | lower }}:
      type: tosca.nodes.Site
      properties:
        must-exist: true
        name: {{ site_humanname | lower }}

    # Images
    image#vsg-1.1:
      type: tosca.nodes.Image
      properties:
        must-exist: true
        name: vsg-1.1

    # M-CORD Subscriber Service
    mcord:
      type: tosca.nodes.MCordSubscriberService
      properties:
        name: mcord

    # M-CORD vENB Service
    service#vENB:
      type: tosca.nodes.VENBService
      properties:
        name: vENB

    slice#vENB_slice:
      type: tosca.nodes.Slice
      properties:
        name: {{ site_name }}_vENB_slice
      requirements:
        - service:
            node: service#vENB
            relationship: tosca.relationships.BelongsToOne
        - site:
            node: {{ site_humanname | lower }}
            relationship: tosca.relationships.BelongsToOne
        - default_image:
            node: image#vsg-1.1
            relationship: tosca.relationships.BelongsToOne

    # ServiceDependency M-CORD to vENB
    mcord_venb:
      type: tosca.nodes.ServiceDependency
      properties:
        connect_method: None
      requirements:
        - subscriber_service:
            node: mcord
            relationship: tosca.relationships.BelongsToOne
        - provider_service:
            node: service#vENB
            relationship: tosca.relationships.BelongsToOne
