<commit_before>tosca_definitions_version: alien_dsl_1_4_0

metadata:
  template_name: tomcat-war-types
  template_version: 1.4.0-SNAPSHOT
  template_author: alien4cloud

imports:
  - tosca-normative-types:1.0.0-ALIEN14
  - jdk-type:1.4.0-SNAPSHOT

description: Tomcat recipe, including war type and relationship.

node_types:
  org.alien4cloud.nodes.Tomcat:
    derived_from: tosca.nodes.WebServer
    description: >
      TOSCA node to install and run Apache Tomcat java web server.
      The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.
    metadata:
      icon: /images/tomcat.png
    properties:
      tomcat_home:
        type: string
        required: true
        description: Directory in which to install tomcat on the host.
        default: "/opt/tomcat"
      download_url:
        type: string
        required: true
        description: Url from which to download the tomcat tar.gz package
        default: "https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.39/bin/apache-tomcat-8.0.39.tar.gz"
      component_version:
        type: version
        description: Version of tomcat to install (this should match the provided download url).
        default: 8.0.39
    attributes:
      server_url: { concat: ["http://", get_attribute: [HOST, public_ip_address], ":", get_property: [SELF, data_endpoint, port]] }
    requirements:
      - host:
          capability: org.alien4cloud.capabilities.JDK
          relationship: org.alien4cloud.relationships.JavaSoftwareHostedOnJDK
          occurrences: [1, 1]
    capabilities:
      data_endpoint: # This is the application endpoint of tomcat server.
        type: tosca.capabilities.Endpoint
        occurrences: [ 0, 0 ]
        properties:
          protocol: http
          port: 80 # set a default value for the port
      admin_endpoint: # There is a tomcat admin endpoint actually but we don't provide it here.
        type: tosca.capabilities.Endpoint.Admin
        occurrences: [ 0, 0 ]
      host: # Overrides the parent container capability
        type: org.alien4cloud.capabilities.WarContainer
        occurrences: [ 0, UNBOUNDED ]
    interfaces:
      Standard:
        create:
          inputs:
            TOMCAT_HOME: { get_property: [SELF, tomcat_home] }
            TOMCAT_PORT: { get_property: [SELF, data_endpoint, port] }
            TOMCAT_URL: { get_property: [SELF, download_url] }
          implementation: scripts/tomcat_install.sh
        start:
          inputs:
            TOMCAT_HOME: { get_property: [SELF, tomcat_home] }
            TOMCAT_PORT: { get_property: [SELF, data_endpoint, port] }
          implementation: scripts/tomcat_start.sh
        stop:
          inputs:
            TOMCAT_HOME: { get_property: [SELF, tomcat_home] }
          implementation: scripts/tomcat_stop.sh

  org.alien4cloud.nodes.War:
    derived_from: tosca.nodes.WebApplication
    description: A war element
    metadata:
      icon: /images/war.jpg
    attributes:
      application_url: { concat: ["http://", get_attribute: [HOST, public_ip_address], ":", get_property: [HOST, data_endpoint, port], "/", get_property: [SELF, app_endpoint, url_path] ] }
      local_application_url: { concat: ["http://", get_attribute: [HOST, ip_address], ":", get_property: [HOST, data_endpoint, port], "/", get_property: [SELF, app_endpoint, url_path] ] }
    capabilities:
      app_endpoint:
        type: tosca.capabilities.Endpoint
        occurrences: [ 0, UNBOUNDED ]
        properties:
          protocol: { get_property: [HOST, data_endpoint, protocol] }
          port: { get_property: [HOST, data_endpoint, port] }
          url_path: hello
    requirements:
      - host:
          capability: org.alien4cloud.capabilities.WarContainer
          occurrences: [1, 1]
    artifacts:
      - war_file:
          file: warFiles/helloWorld.war
          type: org.alien4cloud.artifacts.WarFile
    interfaces:
      custom:
        update_war_file:
          inputs:
            CONTEXT_PATH: { get_property: [SELF, app_endpoint, url_path] }
            TOMCAT_HOME: { get_property: [HOST, tomcat_home] }
            TOMCAT_PORT: { get_property: [HOST, data_endpoint, port] }
            WAR_URL:
              type: string
              description: url of the war to upload to update the current one
              required: true
          implementation: scripts/tomcat_install_war.sh

relationship_types:
  org.alien4cloud.relationships.WarHostedOnTomcat:
    derived_from: tosca.relationships.HostedOn
    description: Relationship that allows to deploy a war on tomcat.
    valid_target_types: [ org.alien4cloud.capabilities.WarContainer ]
    interfaces:
      configure:
        pre_configure_source:
          inputs:
            CONTEXT_PATH: { get_property: [SOURCE, app_endpoint, url_path] }
            TOMCAT_HOME: { get_property: [TARGET, tomcat_home] }
            TOMCAT_PORT: { get_property: [TARGET, port] }
          implementation: scripts/tomcat_install_war.sh

capability_types:
  org.alien4cloud.capabilities.WarContainer:
    derived_from: tosca.capabilities.Container
<commit_msg>Fix Tomcat war (url_path was hardcoded)<commit_after>tosca_definitions_version: alien_dsl_1_4_0

metadata:
  template_name: tomcat-war-types
  template_version: 1.4.0-SNAPSHOT
  template_author: alien4cloud

imports:
  - tosca-normative-types:1.0.0-ALIEN14
  - jdk-type:1.4.0-SNAPSHOT

description: Tomcat recipe, including war type and relationship.

node_types:
  org.alien4cloud.nodes.Tomcat:
    derived_from: tosca.nodes.WebServer
    description: >
      TOSCA node to install and run Apache Tomcat java web server.
      The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.
    metadata:
      icon: /images/tomcat.png
    properties:
      tomcat_home:
        type: string
        required: true
        description: Directory in which to install tomcat on the host.
        default: "/opt/tomcat"
      download_url:
        type: string
        required: true
        description: Url from which to download the tomcat tar.gz package
        default: "https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.39/bin/apache-tomcat-8.0.39.tar.gz"
      component_version:
        type: version
        description: Version of tomcat to install (this should match the provided download url).
        default: 8.0.39
    attributes:
      server_url: { concat: ["http://", get_attribute: [HOST, public_ip_address], ":", get_property: [SELF, data_endpoint, port]] }
    requirements:
      - host:
          capability: org.alien4cloud.capabilities.JDK
          relationship: org.alien4cloud.relationships.JavaSoftwareHostedOnJDK
          occurrences: [1, 1]
    capabilities:
      data_endpoint: # This is the application endpoint of tomcat server.
        type: tosca.capabilities.Endpoint
        occurrences: [ 0, 0 ]
        properties:
          protocol: http
          port: 80 # set a default value for the port
      admin_endpoint: # There is a tomcat admin endpoint actually but we don't provide it here.
        type: tosca.capabilities.Endpoint.Admin
        occurrences: [ 0, 0 ]
      host: # Overrides the parent container capability
        type: org.alien4cloud.capabilities.WarContainer
        occurrences: [ 0, UNBOUNDED ]
    interfaces:
      Standard:
        create:
          inputs:
            TOMCAT_HOME: { get_property: [SELF, tomcat_home] }
            TOMCAT_PORT: { get_property: [SELF, data_endpoint, port] }
            TOMCAT_URL: { get_property: [SELF, download_url] }
          implementation: scripts/tomcat_install.sh
        start:
          inputs:
            TOMCAT_HOME: { get_property: [SELF, tomcat_home] }
            TOMCAT_PORT: { get_property: [SELF, data_endpoint, port] }
          implementation: scripts/tomcat_start.sh
        stop:
          inputs:
            TOMCAT_HOME: { get_property: [SELF, tomcat_home] }
          implementation: scripts/tomcat_stop.sh

  org.alien4cloud.nodes.War:
    derived_from: tosca.nodes.WebApplication
    description: A war element
    metadata:
      icon: /images/war.jpg
    attributes:
      application_url: { concat: ["http://", get_attribute: [HOST, public_ip_address], ":", get_property: [HOST, data_endpoint, port], "/", get_property: [SELF, app_endpoint, url_path] ] }
      local_application_url: { concat: ["http://", get_attribute: [HOST, ip_address], ":", get_property: [HOST, data_endpoint, port], "/", get_property: [SELF, app_endpoint, url_path] ] }
    capabilities:
      app_endpoint:
        type: tosca.capabilities.Endpoint
        occurrences: [ 0, UNBOUNDED ]
        properties:
          protocol: { get_property: [HOST, data_endpoint, protocol] }
          port: { get_property: [HOST, data_endpoint, port] }
          url_path: { get_property: [HOST, data_endpoint, url_path] }
    requirements:
      - host:
          capability: org.alien4cloud.capabilities.WarContainer
          occurrences: [1, 1]
    artifacts:
      - war_file:
          file: warFiles/helloWorld.war
          type: org.alien4cloud.artifacts.WarFile
    interfaces:
      custom:
        update_war_file:
          inputs:
            CONTEXT_PATH: { get_property: [SELF, app_endpoint, url_path] }
            TOMCAT_HOME: { get_property: [HOST, tomcat_home] }
            TOMCAT_PORT: { get_property: [HOST, data_endpoint, port] }
            WAR_URL:
              type: string
              description: url of the war to upload to update the current one
              required: true
          implementation: scripts/tomcat_install_war.sh

relationship_types:
  org.alien4cloud.relationships.WarHostedOnTomcat:
    derived_from: tosca.relationships.HostedOn
    description: Relationship that allows to deploy a war on tomcat.
    valid_target_types: [ org.alien4cloud.capabilities.WarContainer ]
    interfaces:
      configure:
        pre_configure_source:
          inputs:
            CONTEXT_PATH: { get_property: [SOURCE, app_endpoint, url_path] }
            TOMCAT_HOME: { get_property: [TARGET, tomcat_home] }
            TOMCAT_PORT: { get_property: [TARGET, port] }
          implementation: scripts/tomcat_install_war.sh

capability_types:
  org.alien4cloud.capabilities.WarContainer:
    derived_from: tosca.capabilities.Container

{'fraction_non_alphanumeric': 0.08870813397129186, 'fraction_numerical': 0.009569377990430622, 'mean_word_length': 2.6734622144112477, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1341420', 'n_tokens_mistral': 3204, 'n_tokens_neox': 3134, 'n_words': 766}