aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests
diff options
context:
space:
mode:
authorKrzysztof Kuzmicki <krzysztof.kuzmicki@nokia.com>2020-11-06 20:44:28 +0000
committerGerrit Code Review <gerrit@onap.org>2020-11-06 20:44:28 +0000
commit882e2b34db0ea53de3195303267c17d8809fca15 (patch)
treee75baa7f93f042fa43e4ee684adbf336b227b80c /src/onaptests
parenteeeb7190de7185c9994e460cc0472e8817ab68aa (diff)
parent18642f67fcd7268a914fb6632f0f755336e8ba24 (diff)
Merge "Add CLAMP E2E tests"
Diffstat (limited to 'src/onaptests')
-rw-r--r--src/onaptests/configuration/basic_clamp_settings.py52
-rw-r--r--src/onaptests/configuration/clampnode.yaml172
-rw-r--r--src/onaptests/scenario/__init__.py0
-rw-r--r--src/onaptests/steps/loop/clamp.py125
-rw-r--r--src/onaptests/steps/loop/instantiate_loop.py87
-rw-r--r--src/onaptests/steps/onboard/clamp.py91
-rw-r--r--src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.env19
-rw-r--r--src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.yaml153
-rw-r--r--src/onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zipbin0 -> 2496 bytes
-rw-r--r--src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml39
10 files changed, 738 insertions, 0 deletions
diff --git a/src/onaptests/configuration/basic_clamp_settings.py b/src/onaptests/configuration/basic_clamp_settings.py
new file mode 100644
index 0000000..1781c54
--- /dev/null
+++ b/src/onaptests/configuration/basic_clamp_settings.py
@@ -0,0 +1,52 @@
+import sys
+from yaml import load
+
+from pathlib import Path
+
+from .settings import * # pylint: disable=W0614
+
+""" Specific Basic clamp settings."""
+CLEANUP_FLAG = False
+CLAMP_DISTRIBUTION_TIMER = 10
+VENDOR_NAME = "basiclamp_vendor"
+
+VSP_NAME = "basiclamp_vsp"
+
+OPERATIONAL_POLICIES = [
+ {
+ "name": "MinMax",
+ "policy_type": "onap.policies.controlloop.guard.common.MinMax",
+ "policy_version": "1.0.0",
+ "config_function": "add_minmax_config", #func
+ "configuration": {
+ "min": 1,
+ "max": 10
+ }
+ },
+ {
+ "name": "FrequencyLimiter",
+ "policy_type": "onap.policies.controlloop.guard.common.FrequencyLimiter",
+ "policy_version": "1.0.0",
+ "config_function": "add_frequency_limiter", #func
+ "configuration": {}
+ }
+]
+
+CERT = (Path.cwd() / 'cert.pem', Path.cwd() / 'cert.key')
+# SERVICE_NAME = "ubuntu18agent"
+
+# if a yaml file is define, retrieve info from this yaml files
+# if not declare the parameters in the settings
+SERVICE_YAML_TEMPLATE = (sys.path[-1] + "/onaptests/templates/vnf-services/" +
+ "ubuntu18agent-service.yaml")
+CONFIGURATION_PATH = sys.path[-1] + "/onaptests/configuration/"
+
+try:
+ # Try to retrieve the SERVICE NAME from the yaml file
+ with open(SERVICE_YAML_TEMPLATE, "r") as yaml_template:
+ yaml_config_file = load(yaml_template)
+ SERVICE_NAME = next(iter(yaml_config_file.keys()))
+ VF_NAME = SERVICE_NAME
+except ValueError:
+ SERVICE_NAME = "" # Fill me
+ VF_NAME = "" # Fill me
diff --git a/src/onaptests/configuration/clampnode.yaml b/src/onaptests/configuration/clampnode.yaml
new file mode 100644
index 0000000..61e5017
--- /dev/null
+++ b/src/onaptests/configuration/clampnode.yaml
@@ -0,0 +1,172 @@
+#
+# ============LICENSE_START====================================================
+# =============================================================================
+# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+# =============================================================================
+# 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.
+# ============LICENSE_END======================================================
+tosca_definitions_version: cloudify_dsl_1_3
+
+description: >
+ This blueprint deploys/manages the TCA module as a Docker container
+
+imports:
+ - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml
+ # yamllint disable rule:line-length
+ - "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml"
+ # yamllint disable rule:line-length
+ - "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/clamppolicyplugin/1.1.0/clamppolicyplugin_types.yaml"
+inputs:
+ aaiEnrichmentHost:
+ type: string
+ default: aai.onap.svc.cluster.local
+ aaiEnrichmentPort:
+ type: string
+ default: '8443'
+ enableAAIEnrichment:
+ type: string
+ default: 'true'
+ dmaap_host:
+ type: string
+ default: message-router.onap.svc.cluster.local
+ dmaap_port:
+ type: string
+ default: '3904'
+ enableRedisCaching:
+ type: string
+ default: 'false'
+ redisHosts:
+ type: string
+ default: 'dcae-redis.onap.svc.cluster.local:6379'
+ tag_version:
+ type: string
+ default: >-
+ nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.2.2
+ consul_host:
+ type: string
+ default: consul-server.onap
+ consul_port:
+ type: string
+ default: '8500'
+ cbs_host:
+ type: string
+ default: config-binding-service
+ cbs_port:
+ type: string
+ default: '10000'
+ policy_id:
+ type: string
+ default: onap.restart.tca
+ external_port:
+ type: string
+ description: Kubernetes node port on which CDAPgui is exposed
+ default: '32012'
+ policy_model_id:
+ type: string
+ default: onap.policies.monitoring.cdap.tca.hi.lo.app
+node_templates:
+ tca_k8s:
+ type: dcae.nodes.ContainerizedServiceComponent
+ relationships:
+ - target: tca_policy
+ type: cloudify.relationships.depends_on
+ properties:
+ docker_config: {}
+ image:
+ get_input: tag_version
+ log_info:
+ log_directory: /opt/app/TCAnalytics/logs
+ application_config:
+ app_config:
+ appDescription: DCAE Analytics Threshold Crossing Alert Application
+ appName: dcae-tca
+ tcaAlertsAbatementTableName: TCAAlertsAbatementTable
+ tcaAlertsAbatementTableTTLSeconds: '1728000'
+ tcaSubscriberOutputStreamName: TCASubscriberOutputStream
+ tcaVESAlertsTableName: TCAVESAlertsTable
+ tcaVESAlertsTableTTLSeconds: '1728000'
+ tcaVESMessageStatusTableName: TCAVESMessageStatusTable
+ tcaVESMessageStatusTableTTLSeconds: '86400'
+ thresholdCalculatorFlowletInstances: '2'
+ app_preferences:
+ aaiEnrichmentHost:
+ get_input: aaiEnrichmentHost
+ aaiEnrichmentIgnoreSSLCertificateErrors: 'true'
+ aaiEnrichmentPortNumber: '8443'
+ aaiEnrichmentProtocol: https
+ aaiEnrichmentUserName: dcae@dcae.onap.org
+ aaiEnrichmentUserPassword: demo123456!
+ aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query
+ aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf
+ enableAAIEnrichment:
+ get_input: enableAAIEnrichment
+ enableRedisCaching:
+ get_input: enableRedisCaching
+ redisHosts:
+ get_input: redisHosts
+ enableAlertCEFFormat: 'false'
+ publisherContentType: application/json
+ publisherHostName:
+ get_input: dmaap_host
+ publisherHostPort:
+ get_input: dmaap_port
+ publisherMaxBatchSize: '1'
+ publisherMaxRecoveryQueueSize: '100000'
+ publisherPollingInterval: '20000'
+ publisherProtocol: http
+ publisherTopicName: unauthenticated.DCAE_CL_OUTPUT
+ subscriberConsumerGroup: OpenDCAE-clamp
+ subscriberConsumerId: c12
+ subscriberContentType: application/json
+ subscriberHostName:
+ get_input: dmaap_host
+ subscriberHostPort:
+ get_input: dmaap_port
+ subscriberMessageLimit: '-1'
+ subscriberPollingInterval: '30000'
+ subscriberProtocol: http
+ subscriberTimeoutMS: '-1'
+ subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT
+ tca_policy: ''
+ service_component_type: dcaegen2-analytics_tca
+ interfaces:
+ cloudify.interfaces.lifecycle:
+ start:
+ inputs:
+ envs:
+ DMAAPHOST:
+ get_input: dmaap_host
+ DMAAPPORT: '3904'
+ DMAAPPUBTOPIC: unauthenticated.DCAE_CL_OUTPUT
+ DMAAPSUBTOPIC: unauthenticated.VES_MEASUREMENT_OUTPUT
+ AAIHOST:
+ get_input: aaiEnrichmentHost
+ AAIPORT: '8443'
+ CONSUL_HOST:
+ get_input: consul_host
+ CONSUL_PORT: '8500'
+ CBS_HOST:
+ get_input: cbs_host
+ CBS_PORT: '10000'
+ CONFIG_BINDING_SERVICE: config_binding_service
+ ports:
+ - concat:
+ - '11011:'
+ - get_input: external_port
+ tca_policy:
+ type: clamp.nodes.policy
+ properties:
+ policy_id:
+ get_input: policy_id
+ policy_model_id:
+ get_input: policy_model_id
diff --git a/src/onaptests/scenario/__init__.py b/src/onaptests/scenario/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/src/onaptests/scenario/__init__.py
+++ /dev/null
diff --git a/src/onaptests/steps/loop/clamp.py b/src/onaptests/steps/loop/clamp.py
new file mode 100644
index 0000000..e601772
--- /dev/null
+++ b/src/onaptests/steps/loop/clamp.py
@@ -0,0 +1,125 @@
+#!/usr/bin/python
+#
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+"""Clamp Scenario class."""
+from yaml import load
+import time
+
+from onapsdk.clamp.clamp_element import Clamp
+from onapsdk.sdc.service import Service
+
+from onapsdk.configuration import settings
+from onaptests.steps.onboard.clamp import OnboardClampStep
+from onaptests.steps.loop.instantiate_loop import InstantiateLoop
+
+from ..base import YamlTemplateBaseStep
+
+
+class ClampStep(YamlTemplateBaseStep):
+ """class defining the different CLAMP scenarios."""
+
+ count: int = 0
+
+ def __init__(self, cleanup=False):
+ super().__init__(cleanup=cleanup)
+ self._yaml_template: dict = None
+ self.add_step(OnboardClampStep(cleanup=cleanup))
+ Clamp(cert=settings.CERT)
+ self.loop_instance = None
+
+ @property
+ def yaml_template(self) -> dict:
+ """Step YAML template.
+
+ Load from file if it's a root step, get from parent otherwise.
+
+ Returns:
+ dict: Step YAML template
+
+ """
+ if self.is_root:
+ if not self._yaml_template:
+ with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
+ self._yaml_template: dict = load(yaml_template)
+ return self._yaml_template
+ return self.parent.yaml_template
+
+ @property
+ def service_name(self) -> str:
+ """Service name.
+
+ Get from YAML template if it's a root step, get from parent otherwise.
+
+ Returns:
+ str: Service name
+
+ """
+ if self.is_root:
+ return next(iter(self.yaml_template.keys()))
+ else:
+ return self.parent.service_name
+
+
+ def check(self, operational_policies: list, is_template: bool = False) -> str:
+ """Check CLAMP requirements to create a loop."""
+ self._logger.info("Check operational policy")
+ for policy in operational_policies:
+ exist = Clamp.check_policies(policy_name=policy["name"],
+ req_policies=30)# 30 required policy
+ self._logger.info("Operational policy found.")
+ if not exist:
+ raise ValueError("Couldn't load the policy %s", policy)
+ # retrieve the service..based on service name
+ service: Service = Service(self.service_name)
+ if is_template:
+ loop_template = Clamp.check_loop_template(service=service)
+ self._logger.info("Loop template checked.")
+ return loop_template
+
+ def instantiate_clamp(self, loop_template: str, loop_name: str, operational_policies: list):
+ """Instantite a closed loopin CLAMP."""
+ loop = InstantiateLoop(template=loop_template,
+ loop_name=loop_name,
+ operational_policies=operational_policies,
+ cert=settings.CERT)
+ return loop.instantiate_loop()
+
+ def loop_counter(self, action: str) -> None:
+ """ Count number of loop instances."""
+ if action == "plus":
+ self.count += 1
+ if action == "minus":
+ self.count -= 1
+
+ @YamlTemplateBaseStep.store_state
+ def execute(self):
+ super().execute() # TODO work only the 1st time, not if already onboarded
+ # time to wait for template load in CLAMP
+ self._logger.info("Wait a little bit to give a chance to the distribution")
+ time.sleep(settings.CLAMP_DISTRIBUTION_TIMER)
+ # Test 1
+ operational_policies = settings.OPERATIONAL_POLICIES
+ loop_template = self.check(operational_policies, True)
+ # Test 2
+ loop_name = "instance_" + self.service_name + str(self.count)
+ self.loop_counter(action="plus")
+ self.loop_instance = self.instantiate_clamp(
+ loop_template=loop_template,
+ loop_name=loop_name,
+ operational_policies=operational_policies)
+
+ def cleanup(self) -> None:
+ """Cleanup Service.
+
+ Raises:
+ Exception: Clamp cleaning failed
+
+ """
+ self.loop_counter(action="minus")
+ self.loop_instance.undeploy_microservice_from_dcae()
+ self.loop_instance.delete()
+ super().cleanup()
diff --git a/src/onaptests/steps/loop/instantiate_loop.py b/src/onaptests/steps/loop/instantiate_loop.py
new file mode 100644
index 0000000..bd34a04
--- /dev/null
+++ b/src/onaptests/steps/loop/instantiate_loop.py
@@ -0,0 +1,87 @@
+#!/usr/bin/python
+# http://www.apache.org/licenses/LICENSE-2.0
+"""Instantiation class."""
+import logging
+import logging.config
+
+from onapsdk.clamp.loop_instance import LoopInstance
+from onapsdk.configuration import settings
+
+
+class InstantiateLoop():
+ """class instantiating a closed loop in clamp."""
+
+ def __init__(self, template: str, loop_name: str, operational_policies: list, cert: tuple):
+ self.template=template
+ self.loop_name=loop_name
+ self.operational_policies=operational_policies
+ self.cert=cert
+
+ self._logger: logging.Logger = logging.getLogger("")
+ logging.config.dictConfig(settings.LOG_CONFIG)
+
+ def add_policies(self, loop: LoopInstance) -> None:
+ """add necessary wanted operational policies."""
+ for policy in self.operational_policies:
+ self._logger.info("******** ADD OPERATIONAL POLICY %s *******", policy["name"])
+ added = loop.add_operational_policy(policy_type=policy["policy_type"],
+ policy_version=policy["policy_version"])
+ if not added:
+ self._logger.error("an error occured while adding an operational policy")
+ self._logger.info("ADD OPERATION SUCCESSFULY DONE")
+
+
+ def configure_policies(self, loop: LoopInstance) -> None:
+ """Configure all policies."""
+ self._logger.info("******** UPDATE MICROSERVICE POLICY *******")
+ loop._update_loop_details()
+ loop.update_microservice_policy()
+ self._logger.info("******** UPDATE OPERATIONAL POLICIES CONFIG *******")
+ for policy in self.operational_policies:
+ #loop.add_op_policy_config(loop.LoopInstance.__dict__[policy["config_function"]])
+ #possible configurations for the moment
+ if policy["name"] == "MinMax":
+ loop.add_op_policy_config(loop.add_minmax_config)
+ if policy["name"] == "Drools":
+ loop.add_op_policy_config(loop.add_drools_conf)
+ if policy["name"] == "FrequencyLimiter":
+ loop.add_op_policy_config(loop.add_frequency_limiter)
+ self._logger.info("Policies are well configured")
+
+ def deploy(self, loop: LoopInstance) -> None:
+ """Deploy closed loop."""
+ self._logger.info("******** SUBMIT POLICIES TO PE *******")
+ submit = loop.act_on_loop_policy(loop.submit)
+ self._logger.info("******** CHECK POLICIES SUBMITION *******")
+ if submit :
+ self._logger.info("Policies successfully submited to PE")
+
+ else:
+ self._logger.error("An error occured while submitting the loop instance")
+ exit(1)
+ self._logger.info("******** DEPLOY LOOP INSTANCE *******")
+ deploy = loop.deploy_microservice_to_dcae()
+ if deploy:
+ self._logger.info("Loop instance %s successfully deployed on DCAE !!", self.loop_name)
+ else:
+ self._logger.error("An error occured while deploying the loop instance")
+ exit(1)
+
+ def instantiate_loop(self):
+ """Instantiate the control loop."""
+ loop = LoopInstance(template=self.template,
+ name=self.loop_name,
+ details={},
+ cert=self.cert)
+ details = loop.create()
+ if details:
+ self._logger.info("Loop instance %s successfully created !!", self.loop_name)
+ else:
+ self._logger.error("An error occured while creating the loop instance")
+
+ self.add_policies(loop=loop)
+ self.configure_policies(loop=loop)
+ self.deploy(loop=loop)
+
+ loop.details = loop._update_loop_details()
+ return loop
diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py
new file mode 100644
index 0000000..8f6b6bf
--- /dev/null
+++ b/src/onaptests/steps/onboard/clamp.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+# http://www.apache.org/licenses/LICENSE-2.0
+"""Clamp Onboard service class."""
+from yaml import load
+from onapsdk.sdc.service import Service
+from onapsdk.sdc.vf import Vf
+
+from onapsdk.configuration import settings
+
+from ..base import YamlTemplateBaseStep
+from .service import YamlTemplateVfOnboardStep
+
+class OnboardClampStep(YamlTemplateBaseStep):
+ """Onboard class to create CLAMP templates."""
+
+ def __init__(self, cleanup=False):
+ """Initialize Clamp Onboard object."""
+ super().__init__(cleanup=cleanup)
+ self._yaml_template: dict = None
+ self.add_step(YamlTemplateVfOnboardStep(cleanup=cleanup))
+ # if "service_name" in kwargs:
+ # self.service_name = kwargs['service_name']
+ # else:
+ # raise ValueError("Service Name to define")
+ # self.vf_list = []
+ # self.vsp_list = []
+ # self.set_logger()
+
+ @property
+ def yaml_template(self) -> dict:
+ """Step YAML template.
+
+ Load from file if it's a root step, get from parent otherwise.
+
+ Returns:
+ dict: Step YAML template
+
+ """
+ if self.is_root:
+ if not self._yaml_template:
+ with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
+ self._yaml_template: dict = load(yaml_template)
+ return self._yaml_template
+ return self.parent.yaml_template
+
+ @property
+ def service_name(self) -> str:
+ """Service name.
+
+ Get from YAML template if it's a root step, get from parent otherwise.
+
+ Returns:
+ str: Service name
+
+ """
+ if self.is_root:
+ return next(iter(self.yaml_template.keys()))
+ else:
+ return self.parent.service_name
+
+ @YamlTemplateBaseStep.store_state
+ def execute(self):
+ """Onboard service."""
+ super().execute()
+ # retrieve the Vf
+ vf = None
+ for sdc_vf in Vf.get_all():
+ if sdc_vf.name == settings.VF_NAME:
+ vf = sdc_vf
+ self._logger.debug("Vf retrieved %s", vf)
+
+ service: Service = Service(name=self.service_name,
+ resources=[vf])
+ service.create()
+ self._logger.info(" Service %s created", service)
+
+ service.add_resource(vf)
+
+ # we add the artifact to the first VNF
+ self._logger.info("Try to add blueprint to %s", vf.name)
+ payload_file = open(settings.CONFIGURATION_PATH + 'clampnode.yaml', 'rb')
+ data = payload_file.read()
+ self._logger.info("DCAE INVENTORY BLUEPRINT file retrieved")
+ service.add_artifact_to_vf(vnf_name=vf.name,
+ artifact_type="DCAE_INVENTORY_BLUEPRINT",
+ artifact_name="clampnode.yaml",
+ artifact=data)
+ payload_file.close()
+ service.checkin()
+ service.onboard()
+ self._logger.info("DCAE INVENTORY BLUEPRINT ADDED")
diff --git a/src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.env b/src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.env
new file mode 100644
index 0000000..062468a
--- /dev/null
+++ b/src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.env
@@ -0,0 +1,19 @@
+parameters:
+# Metadata required by ONAP
+ vnf_id: Ubuntu18-VNF
+ vf_module_id: Ubuntu18-VF-module
+ vnf_name: Ubuntu18-VNF-name
+
+# Server parameters, naming required by ONAP
+ ubuntu18_image_name: ubuntu-18.04-daily
+ ubuntu18_flavor_name: onap.small
+ ubuntu18_pub_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC3dbqgymZVpu2cIWqzlKNxnOy2Qjt07NZxaXtQyu9dr0kbmursTE5N0IW0qg/rsCXgw2vjjdPOxU6jtrTbyzbAmo9F6LtS9oqvct9LmLjDNyiQFuCPETIBGy43daDVgw3hrg3f9ihN88V/JwnI9n3ZFn8Wy15KV6XCHn3MASV31YnbkjruUtj7rZm5V8NUwAteZ91k5T7WBpywt483rrkeQjEzyKiVSmmOhHWNSmbnko9XzO7QDUHfVIk5qCf/aBES7hcE0YiqX5lfLamSyCqOGANnv+AN2opDEakUeCyJHZrsk3Nkk7A9p+CNlq42sUEKtrO0xiH63viMA6eBYSiaQPzckdq/T52naozx/Oj9ITCgX/6XjldMUF99afIydpC6+kymflTYA8P/9u1Ih93+Vjg1Bf2e4lJaf9z9frXcB9F+ZRDq6feN+XQ93Q8xQ9blu9Gq8BZUbPvAQxW0UaryeuzhCKx4QA33qqYA+tmWVXTsaG0uow6f0hm7z+pkYCM= master@Utilisateur-PC
+ ubuntu18_name_0: ubuntu18
+
+# Network parameters, naming required by ONAP
+ admin_plane_net_name: admin
+
+# APP/USER_DATA
+ dcae_collector_ip: 10.4.2.166
+ # 30417 is https node port to VES
+ dcae_collector_port: 30417
diff --git a/src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.yaml b/src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.yaml
new file mode 100644
index 0000000..73612a0
--- /dev/null
+++ b/src/onaptests/templates/heat-files/ubuntu18/base_ubuntu18.yaml
@@ -0,0 +1,153 @@
+heat_template_version: 2013-05-23
+
+description: Heat template to deploy ubuntu VM Closed Loop for ONAP
+
+parameters:
+ # Metadata required by ONAP
+ vnf_name:
+ type: string
+ label: VM name
+ description: The VM name
+ vnf_id:
+ type: string
+ label: VNF ID
+ description: The VNF ID is provided by ONAP
+ vf_module_id:
+ type: string
+ label: VF module ID
+ description: The VF Module ID is provided by ONAP
+
+# Server parameters, naming required by ONAP
+ ubuntu18_image_name:
+ type: string
+ label: Image name or ID
+ description: Image to be used for compute instance
+ ubuntu18_flavor_name:
+ type: string
+ label: Flavor
+ description: Type of instance (flavor) to be used
+ ubuntu18_pub_key:
+ type: string
+ label: Public key
+ description: Public key to be installed on the compute instance
+ ubuntu18_name_0:
+ type: string
+ label: VM name
+ description: The VM name
+
+# Network parameters, naming required by ONAP
+ admin_plane_net_name:
+ type: string
+ label: management network
+ description: The external management network
+
+# DCAE parameters
+ dcae_collector_ip:
+ type: string
+ label: DCAE collector IP address
+ description: IP address of the DCAE collector
+ dcae_collector_port:
+ type: string
+ label: DCAE collector port
+ description: Port of the DCAE collector
+
+resources:
+ random-str:
+ type: OS::Heat::RandomString
+ properties:
+ length: 4
+
+ ubuntu18_instantiated_key_name:
+ type: OS::Nova::KeyPair
+ properties:
+ name:
+ str_replace:
+ template: pre_base_rand
+ params:
+ pre: key_
+ base: { get_param: vnf_name }
+ rand: { get_resource: random-str }
+ public_key: { get_param: ubuntu18_pub_key }
+ save_private_key: false
+
+ ubuntu18_admin_security_group:
+ type: OS::Neutron::SecurityGroup
+ properties:
+ description: security group
+ name:
+ str_replace:
+ template: pre_base_rand
+ params:
+ pre: sg_
+ base: { get_param: vnf_name }
+ rand: { get_resource: random-str }
+ rules: [
+ {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 22, port_range_max: 22},
+ {remote_ip_prefix: 0.0.0.0/0, protocol: icmp}]
+
+ ubuntu18_0_admin_plane_port_0:
+ type: OS::Neutron::Port
+ properties:
+ name:
+ str_replace:
+ template: pre_base_rand
+ params:
+ pre: port_
+ base: { get_param: vnf_name }
+ rand: { get_resource: random-str }
+ network: { get_param: admin_plane_net_name }
+ security_groups: [{ get_resource: ubuntu18_admin_security_group }]
+
+ ubuntu18_VM_settings:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config: |
+ #!/bin/bash
+ sudo apt-get update
+
+ ubuntu18_server_0:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: ubuntu18_image_name }
+ flavor: { get_param: ubuntu18_flavor_name }
+ name: { get_param: ubuntu18_name_0 }
+ metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }, vnf_name: { get_param: vnf_name }}
+ key_name: { get_resource: ubuntu18_instantiated_key_name }
+ networks:
+ - port: { get_resource: ubuntu18_0_admin_plane_port_0 }
+ user_data_format: RAW
+ user_data:
+ str_replace:
+ params:
+ __dcae_collector_ip__: { get_param: dcae_collector_ip }
+ __dcae_collector_port__: { get_param: dcae_collector_port }
+ template: |
+ #!/bin/bash
+
+ # Create configuration files
+ sudo mkdir /opt/config
+ echo __dcae_collector_ip__ > /opt/config/dcae_collector_ip.txt
+ echo __dcae_collector_port__ > /opt/config/dcae_collector_port.txt
+ cd /opt
+ sudo apt-get update
+ sudo apt-get install --allow-unauthenticated -y make gcc rpl
+ sudo apt-get update && sudo apt-get -y upgrade
+ sudo apt-get install -y libcurl4-openssl-dev
+ sudo git clone https://github.com/onap/vnfsdk-ves-agent.git
+ sudo cp -r vnfsdk-ves-agent/veslibrary/ves_clibrary/ /opt
+ sudo rm -rf /opt/vnfsdk-ves-agent/
+ sudo chmod +x /opt/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client.sh
+ cd /opt/ves_clibrary/evel/evel-library/bldjobs/
+ sudo mv ../code/VESreporting_vFW ../code/VESreporting
+ # choose HTTPS
+ sudo rpl "0, /* HTTPS?" "1, /* HTTPS?" ../code/VESreporting/vpp_measurement_reporter.c
+ sudo make clean
+ sudo make all
+ sudo sleep 1
+ cd /opt/ves_clibrary/evel/evel-library/libs/x86_64
+ sudo cp libevel.so /usr/lib
+ sudo ldconfig
+ # Start VES client
+ cd /opt/ves_clibrary/evel/evel-library/code/VESreporting/
+ ./go-client.sh &>/dev/null &disown
+ #get_resource: ubuntu18_VM_settings
diff --git a/src/onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zip b/src/onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zip
new file mode 100644
index 0000000..90b07e7
--- /dev/null
+++ b/src/onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zip
Binary files differ
diff --git a/src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml b/src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml
new file mode 100644
index 0000000..baf804e
--- /dev/null
+++ b/src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml
@@ -0,0 +1,39 @@
+---
+basicclamp-1:
+ vnfs:
+ - vnf_name: basicclamp-1
+ heat_files_to_upload: onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zip
+ vnf_parameters: [
+ {"name": "ubuntu18_image_name",
+ "value": "ubuntu-agent"
+ },
+ {"name": "ubuntu18_key_name",
+ "value": "cleouverte"
+ },
+ {"name": "ubuntu18_pub_key",
+ "value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAA\
+BAQDY15cdBmIs2XOpe4EiFCsaY6bmUmK/GysMoLl4UG51JCfJwvwoWCoA+6mDIbymZxhxq9IGx\
+ilp/yTA6WQ9s/5pBag1cUMJmFuda9PjOkXl04jgqh5tR6I+GZ97AvCg93KAECis5ubSqw1xOCj4\
+utfEUtPoF1OuzqM/lE5mY4N6VKXn+fT7pCD6cifBEs6JHhVNvs5OLLp/tO8Pa3kKYQOdyS0xc3r\
+h+t2lrzvKUSWGZbX+dLiFiEpjsUL3tDqzkEMNUn4pdv69OJuzWHCxRWPfdrY9Wg0j3mJesP29EBh\
+t+w+EC9/kBKq+1VKdmsXUXAcjEvjovVL8l1BrX3BY0R8D imported-openssh-key"
+ },
+ {"name": "ubuntu18_flavor_name",
+ "value": "onap.small"
+ },
+ {"name": "VM_name",
+ "value": "ubuntu18agent-VM-01"
+ },
+ {"name": "vnf_id",
+ "value": "ubuntu18agent-VNF-instance"
+ },
+ {"name": "vf_module_id",
+ "value": "ubuntu18agent-vfmodule-instance"
+ },
+ {"name": "vnf_name",
+ "value": "ubuntu18agent-VNF"
+ },
+ {"name": "admin_plane_net_name",
+ "value": "admin"
+ }
+ ]