tosca_definitions_version: tosca_simple_yaml_1_3
description: A sample CNF descriptor
imports:
  - example_vnfd_types.yaml # VNFD definitions based on SOL001 v3.3.1 with changes to support osContainers per IFA011 v4.1.1

data_types:
  Example.datatypes.nfv.VnfAdditionalConfigurableProperties:
    derived_from: tosca.datatypes.nfv.VnfAdditionalConfigurableProperties
    properties:
      name_prefix_in_cism:
        type: string
        required: false
      dns_server:
        type: list
        entry_schema:
          type: string
        required: false
  Example.datatypes.nfv.VnfConfigurableProperties:
    derived_from: tosca.datatypes.nfv.VnfConfigurableProperties
    properties:
      additional_configurable_properties:
        type: Example.datatypes.nfv.VnfAdditionalConfigurableProperties

node_types:
  Example.nodes.nfv.VNF:
    derived_from: tosca.nodes.nfv.VNF
    properties:
      configurable_properties:
        type: Example.datatypes.nfv.VnfConfigurableProperties
        description: Describes the configurable properties of the VNF
        required: false
    requirements:
      - virtual_link:
         capability: tosca.capabilities.nfv.VirtualLinkable
           #      - virtual_link_virt:
           #capability: tosca.capabilities.nfv.VirtualLinkable

###############################################################################################################
#                                  Start of  Topology Template                                                #
###############################################################################################################


###############################################################################################################
#                                 Start of VNF Node template                                                  #
###############################################################################################################
topology_template:
  substitution_mappings:
    node_type: Example.nodes.nfv.VNF
    requirements:
      virtual_link_1: [ vdu1Cp1, virtual_link ]
      virtual_link_2: [ vdu2Cp1, virtual_link ]
      virtual_link_virt: [ VirtCp1, virtual_link ]
      virtual_link_intra_1: [ vdu1Cp2, virtual_link ]
      virtual_link_intra_2: [ vdu2Cp2, virtual_link ]

  node_templates:
    VNF:
        type: Example.nodes.nfv.VNF
        properties:
            descriptor_id: 5af09567-fc5f-4be9-b372-0cc431ad5c03
            descriptor_version: "0.2"
            provider: ExampleCorp
            product_name: vDB
            software_version: "0.1"
            product_info_name: "Firewall"
            product_info_description: "Firewall with new functionality"
            vnfm_info: [ 'ONAP_GVNFM:v0.1.01' ]
            configurable_properties: # comment: # All of the VNF  configurable properties should go here
              is_autoscale_enabled: True
              is_autoheal_enabled: True
              additional_configurable_properties:
                name_prefix_in_cism: "ExampleCNF" # Default
                dns_server: [ "8.8.8.8", "8.8.4.4" ] #Default
                
              # modifiable_attributes: {}   # comment: # All of the VNF  modifiable properties should go here
            flavour_id: simple
            flavour_description: "A specimen copy of the VNF Descriptor for containers"
            mciop_profile:
              - mciopId: nginx_helm
                deploymentOrder: 2
                associatedVdu: [ Vdu_1 ]
              - mciopId: mysql_helm
                deploymentOrder: 1
                associatedVdu: [ Vdu_2 ]

        interfaces:
            Vnflcm:
              operations: 
                # instantiate_start:
                # instantiate: # A sample illustration to run a instantiation script without any inputs.
                instantiate_end: helm_test

                # terminate:

                #terminate_start: # Invoked before terminate
                
                #terminate_end:   # Invoked after terminate
                
                #modify_information: # Invoked upon receipt of a Modify VNF Information request
                
                #modify_information_start: #Invoked before modify_information
                
                #modify_information_end: #Invoked after modify_information

                #heal: #Invoked upon receipt of a Heal VNF request
                
                #heal_start: #Invoked before heal
                
                #heal_end: #Invoked after heal
                
                scale: #Invoked upon receipt of a Scale VNF request                
                  inputs:
                    type: "scale_out"
                    aspect: "default"
                
                #scale_start: # #Invoked before scale
                
                #scale_end: # #Invoked before scale

                #change_current_package: #Invoked upon receipt of a ChangeCurrentVnfPackage request                

                #change_current_package_start: #Invoked before ChangeCurrentVnfPackage request                

                #change_current_package_end: #Invoked after a ChangeCurrentVnfPackage request                

              notifications:
                change_current_package_notification: "Package Change requested"
                # change_current_package_start_notification.
                # change_current_package_end_notification:
        artifacts:
          nginx_helm: 
            description: Helm Chart for nginx Pod
            type: tosca.artifacts.File
            file: Artifacts/Scripts/nginx.tgz
          mysql_helm: 
            description: Helm Chart for mysql Pod
            type: tosca.artifacts.File
            file: Artifacts/Scripts/mysql.tgz
          helm_test:
            description: Post instantiation test script
            type: tosca.artifacts.Implementation.Bash
            file: Artifacts/Tests/helm_test.sh
###############################################################################################################
#                                   End of VNF Node template                                                  #
###############################################################################################################


###############################################################################################################
#                 Start of VDU Definitions (Based on IFA011 v4.1.1)
###############################################################################################################

    vdu1Cp1:
      type: tosca.nodes.nfv.VduCp
      description: "Cluster vNIC"
      properties:
        layer_protocols: [ tcp ]
        vnic_type: normal
        order: 1
      requirements:
        - container_binding: Vdu_1

    vdu1Cp2:
      type: tosca.nodes.nfv.VduCp
      description: "IntraVNF External vNIC"
      properties:
        layer_protocols: [ ethernet ]
        vnic_type: macvlan
        bitrate_requirement:  10000000000 #10 GiB
        order: 2
        trunk_mode: True
      requirements:
        - container_binding: Vdu_1

    VirtCp1:
      type: tosca.nodes.nfv.VirtualCp
      properties:
        layer_protocols: [ tcp ]
        protocol:
        - address_data:
          - address_type: ip_address
            l3_address_data:
              floating_ip_activated: True
              ip_address_assignment: False
              ip_address_type: ipv6
              number_of_ip_address: 1
          associated_layer_protocol: ipv6
        additionalServiceData:
          - portData:
            - name: DBAccessService
              protocol: TCP
              port: 8001
              portConfigurable: False
            - name: DBConfigService
              protocol: TCP
              port: 443
              portConfigurable: False
      requirements:
        - target: Vdu_1

    Vdu_1:
      type: tosca.nodes.nfv.Vdu.OsContainerGroup
      properties:
        name: "nginx"
        description: "Advanced Software Load Balancer"
        vdu_profile:
          min_number_of_instances: 1
          max_number_of_instances: 4
        boot_data:
          content_or_file_data:
            data: {}
            source_path: Artifacts/Scripts/nginx_values.yaml
#        virtualStorageDesc: : {}
#        monitoringParameters: {}
      requirements:
        - container_grouping: Vdu_1_Container_1

    Vdu_1_Container_1:
      type: tosca.nodes.nfv.Vdu.OsContainer
      properties:
        name: "nginx Container"
        description: "Advanced Software Load Balancer"
        requestedCpuResources: 100 # In Milli-Cpus, ie 0.1 CPU
        cpuResourcesLimit: 1000 # In Milli-Cpus, ie 1 CPU, single threaded
        requestedMemoryResources: 10 MiB
        memoryResourceLimit: 100 MiB
      artifacts:
        sw_image:
          type: tosca.artifacts.nfv.SwImage
          file: Artifacts/Images/nginximage
          properties:
            name: nginx # AS PER VZ CNF NAMING CONVENTION GUIDE
            version: "7.3"
            checksum: 
              algorithm: sha-256
              hash: a411cafee2f0f702572369da0b765e2
            container_format: docker
            size: "1024MB"
            disk_format: raw
            min_disk: "1024MB"

    vdu2Cp1:
      type: tosca.nodes.nfv.VduCp
      properties:
        layer_protocols: [ tcp ]
        vnic_type: normal
      requirements:
        - container_binding: Vdu_2

    vdu2Cp2:
      type: tosca.nodes.nfv.VduCp
      description: "IntraVNF External vNIC"
      properties:
        layer_protocols: [ ethernet ]
        vnic_type: macvlan
        bitrate_requirement:  10000000000 #10 GiB
        order: 2
        trunk_mode: True
      requirements:
        - container_binding: Vdu_2

    Vdu_2:
      type: tosca.nodes.nfv.Vdu.OsContainerGroup
      properties:
        name: "mysql"
        description: "DB Server"
        vdu_profile:
          min_number_of_instances: 1
          max_number_of_instances: 1
        boot_data:
          content_or_file_data:
            data: {}
            source_path: Artifacts/Scripts/mysql_values.yaml
#        virtualStorageDesc: : {}
#        monitoringParameters: {}
      requirements:
        - container_grouping: Vdu_2_Container_1
        - container_grouping: Vdu_2_Container_2

    Vdu_2_Container_1:
      type: tosca.nodes.nfv.Vdu.OsContainer
      properties:
        name: "mysql FE Container"
        description: "DB Server Container"
        requestedCpuResources: 1000 # In Milli-Cpus, ie 1 CPU
        cpuResourcesLimit: 2500 # In Milli-Cpus, ie 2.5 CPU
        requestedMemoryResources: 1 GiB
        memoryResourceLimit: 10 GiB
      artifacts:
        sw_image:
          type: tosca.artifacts.nfv.SwImage
          file: Artifacts/Images/mysqlFEimage
          properties:
            name: mysql
            version: "4.3"
            checksum: 
              algorithm: sha-256
              hash: a411cafee2f0f702572369da0b765e2
            container_format: docker
            size: "1024MB"
            disk_format: raw
            min_disk: "1024MB"

    Vdu_2_Container_2:
      type: tosca.nodes.nfv.Vdu.OsContainer
      properties:
        name: "mysql Container"
        description: "DB Server Container"
        requestedCpuResources: 1000 # In Milli-Cpus, ie 1 CPU
        cpuResourcesLimit: 2500 # In Milli-Cpus, ie 2.5 CPU
        requestedMemoryResources: 1 GiB
        memoryResourceLimit: 10 GiB
      artifacts:
        sw_image:
          type: tosca.artifacts.nfv.SwImage
          file: Artifacts/Images/mysqlBEimage
          properties:
            name: mysql
            version: "4.3"
            checksum: 
              algorithm: sha-256
              hash: a411cafee2f0f702572369da0b765e2
            container_format: docker
            size: "1024MB"
            disk_format: raw
            min_disk: "1024MB"
###############################################################################################################
#                                     End of VDU Definitions                                                  #
###############################################################################################################
    
  policies:
    - change_from_version_1:
        type: tosca.policies.nfv.VnfPackageChange
        properties:
          selector:
            source_descriptor_id: oldid
            destination_descriptor_id: 5af09567-fc5f-4be9-b372-0cc431ad5c03
            source_flavour_id: simple
          modification_qualifier: up
          destination_flavour_id: default

###############################################################################################################
#                                  End of  Topology Template                                                #
###############################################################################################################

    
