
{#
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: Auto generated file to enable monitoring of infrastructure services (OpenStack, ONOS...etc).

imports:
   - custom_types/xos.yaml
   - custom_types/monitoring_tosca_types.yaml

topology_template:
  node_templates:
    service_ceilometer:
      type: tosca.nodes.CeilometerService
      properties:
          no-create: true
          no-update: true
          no-delete: true

    onos_monitoring_agent_head_node:
      description: Monitoring agent info
      type: tosca.nodes.InfraMonitoringAgentInfo
      properties:
          start_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/onos/start
          start_url_json_data: { get_artifact: [ SELF, onos_monitoring_service_endpoints, LOCAL_FILE] }
          stop_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/onos/stop
      artifacts:
          onos_monitoring_service_endpoints: /opt/cord_profile/onos_monitoring_service_endpoints.json

    os_monitoring_agent_head_node:
      description: Openstack Monitoring agent info
      type: tosca.nodes.InfraMonitoringAgentInfo
      properties:
          start_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/openstack/start
          stop_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/openstack/stop

# OpenStack compute nodes
{% for node in groups["compute"] %}
    os_monitoring_agent_cp_{{ loop.index }}:
      description: Openstack Monitoring agent info for {{ node }}
      type: tosca.nodes.InfraMonitoringAgentInfo
      properties:
          start_url: http://{{ node }}:5004/monitoring/agent/openstack/start
          stop_url: http://{{ node }}:5004/monitoring/agent/openstack/stop
{% endfor %}

    os_monitoring_collector_plugin:
      description: Infra Monitoring collector plugin info
      type: tosca.nodes.MonitoringCollectorPluginInfo
      properties:
          plugin_folder_path: /opt/xos/synchronizers/monitoring/ceilometer/ceilometer-plugins/network/ext_services/openstack_infra/
          plugin_rabbit_exchange: openstack_infra
 
    openstack_monitoring_publisher_tenant:
      description: OpenStack Monitoring Publisher Tenant
      type: tosca.nodes.OpenStackMonitoringPublisher
      requirements:
          - provider_service:
              node: service_ceilometer
              relationship: tosca.relationships.TenantOfService
          - monitoring_collector_plugin:
              node: os_monitoring_collector_plugin
              relationship: tosca.relationships.ProvidesMonitoringCollectorPluginInfo
          - monitoring_agent_1:
              node: os_monitoring_agent_head_node
              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
          - monitoring_agent_2:
              node: onos_monitoring_agent_head_node
              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
{% set count = 2 %}
{% for node in groups["compute"] %}
          - monitoring_agent_{{ count + loop.index }}:
              node: os_monitoring_agent_cp_{{ loop.index }}
              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
{% endfor %}

