diff --git a/sample_ee_ns/sample_ee_nsd.yaml b/sample_ee_ns/sample_ee_nsd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0f6d44b52ab2d4d1157468ab31e059ca14f8dfce --- /dev/null +++ b/sample_ee_ns/sample_ee_nsd.yaml @@ -0,0 +1,26 @@ +nsd: + nsd: + - description: Single sample_ee VNF + df: + - id: default-df + vnf-profile: + - id: sample_ee + virtual-link-connectivity: + - constituent-cpd-id: + - constituent-base-element-id: sample_ee + constituent-cpd-id: vnf-mgmt-ext + virtual-link-profile-id: mgmtnet + - constituent-cpd-id: + - constituent-base-element-id: sample_ee + constituent-cpd-id: vnf-internal-ext + virtual-link-profile-id: internal + vnfd-id: sample_ee-vnf + id: sample_ee-ns + name: sample_ee-ns + version: '1.0' + virtual-link-desc: + - id: mgmtnet + mgmt-network: true + - id: internal + vnfd-id: + - sample_ee-vnf diff --git a/sample_ee_vnf/helm-charts/eechart/.helmignore b/sample_ee_vnf/helm-charts/eechart/.helmignore new file mode 100644 index 0000000000000000000000000000000000000000..50af0317254197a5a019f4ac2f8ecc223f93f5a7 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/sample_ee_vnf/helm-charts/eechart/Chart.yaml b/sample_ee_vnf/helm-charts/eechart/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..414c5f1aa1becbd34d69342874b63db8bb1cb77c --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: OSM EE helm chart +name: eechart +version: 0.1.0 diff --git a/sample_ee_vnf/helm-charts/eechart/source/install.sh b/sample_ee_vnf/helm-charts/eechart/source/install.sh new file mode 100755 index 0000000000000000000000000000000000000000..ffec14d6a3dc0f95158c797bd4dfbb88a041f425 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/source/install.sh @@ -0,0 +1,33 @@ +#!/bin/bash +## +# 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. +## + +echo "Updating operating system" +apt-get update + +# Install ansible libraries +echo "Installing ansible" +apt-get install -y software-properties-common +apt-add-repository --yes --update ppa:ansible/ansible +apt install -y ansible + +# Install library to execute command remotely by ssh +echo "Installing asynssh" +python3 -m pip install asyncssh + +# Install ping system command +apt install -y iputils-ping + +# Install HTTP python library +python3 -m pip install requests diff --git a/sample_ee_vnf/helm-charts/eechart/source/install_nginx.sh b/sample_ee_vnf/helm-charts/eechart/source/install_nginx.sh new file mode 100755 index 0000000000000000000000000000000000000000..48f8cf767ec0727652fd0ae8c97c932a8dd4146b --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/source/install_nginx.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -eux +sudo -s < (int, str): + """ + Execute a remote command via SSH. + """ + + try: + async with asyncssh.connect(host, + username=user, + known_hosts=None) as conn: + logger.debug("Executing command '{}'".format(command)) + result = await conn.run(command) + logger.debug("Result: {}".format(result)) + return result.exit_status, result.stderr + except Exception as e: + logger.error("Error: {}".format(repr(e))) + return -1, str(e) diff --git a/sample_ee_vnf/helm-charts/eechart/source/playbook.yaml b/sample_ee_vnf/helm-charts/eechart/source/playbook.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bc6013d7e5a0557d5a41cd2211d50e85c0d71222 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/source/playbook.yaml @@ -0,0 +1,14 @@ +--- +- hosts: all + become: yes + tasks: + - name: Wait 120 seconds, but only start checking after 10 seconds + wait_for_connection: + delay: 20 + timeout: 120 + - name: Install packages + apt: + name: + - "{{ app }}" + state: latest + cache_valid_time: 3600 diff --git a/sample_ee_vnf/helm-charts/eechart/source/run_ssh.sh b/sample_ee_vnf/helm-charts/eechart/source/run_ssh.sh new file mode 100755 index 0000000000000000000000000000000000000000..8b58b3cce67868565722c481427d683a14a84fe4 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/source/run_ssh.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +date "+%H:%M:%S Starting $0..." +IP=$1 +USERNAME=$2 +SCRIPT=$3 +PARAMS=$4 + +DIR=$(dirname $0) + +date "+%H:%M:%S Waiting for $IP to be ready..." +i=5 +while ! ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 -o LogLevel=ERROR "$USERNAME"@"$IP" 'exit' ; do + date "+%H:%M:%S Error accessing $IP, retrying..." + sleep 5 + i=$(( $i - 1 )) + [ $i -ge 0 ] || exit 1 +done + +date "+%H:%M:%S SSH server is up, sending script '${DIR}/${SCRIPT}'..." +scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${DIR}/${SCRIPT} "$USERNAME"@"$IP": +if [ $? -ne 0 ]; then + date "+%H:%M:%S scp error" + exit 1 +fi +date "+%H:%M:%S OK. Setting file permissions" +ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 -o LogLevel=ERROR "$USERNAME"@"$IP" "chmod a+x $SCRIPT" +if [ $? -ne 0 ]; then + date "+%H:%M:%S ssh error" + exit 1 +fi + +COMMAND="./$SCRIPT" +[ ${#PARAMS} -ge 0 ] || COMMAND="${COMMAND=} $PARAMS" +date "+%H:%M:%S Running '$COMMAND' on $IP..." +ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 -o LogLevel=ERROR "$USERNAME"@"$IP" "$COMMAND" +if [ $? -ne 0 ]; then + date "+%H:%M:%S ssh error" + exit 1 +fi + +date "+%H:%M:%S End" +exit 0 diff --git a/sample_ee_vnf/helm-charts/eechart/source/vnf_ee.py b/sample_ee_vnf/helm-charts/eechart/source/vnf_ee.py new file mode 100644 index 0000000000000000000000000000000000000000..4c0f1cb7065ec0ebe5976431b2937084252f5d25 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/source/vnf_ee.py @@ -0,0 +1,133 @@ +## +# 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. +## + +import asyncio +import asyncssh +import requests +import logging +import os + +from osm_ee.exceptions import VnfException + +import osm_ee.util.util_ee as util_ee +import osm_ee.util.util_ansible as util_ansible +import osm_ee.vnf.mylib as mylib + +class VnfEE: + + PLAYBOOK_PATH = "/app/EE/osm_ee/vnf" + SSH_SCRIPT = "/app/EE/osm_ee/vnf/run_ssh.sh" + + def __init__(self, config_params): + self.logger = logging.getLogger('osm_ee.vnf') + self.config_params = config_params + + # config method saves SSH access parameters (host and username) for future use by other methods. + # It is mandatory in any case. + async def config(self, id, params): + self.logger.debug("Execute action config, params: {}".format(params)) + # Config action is special, params are merged with previous config calls + self.config_params.update(params) + required_params = ["ssh-hostname"] + self._check_required_params(self.config_params, required_params) + yield "OK", "Configured" + + # This method implements the "run_script" primitive. Uncomment and modify it if a primitive requires executing a user + # script in the VDU. It needs "file" parameter (script's file to run, must be in "source" directory) + # and optionally "parameters" (command-line arguments for script). + # async def run_script(self, id, params): + # self.logger.debug("Execute action run_script, params: '{}'".format(params)) + # self._check_required_params(params, ["file"]) + + # command = "bash " + self.SSH_SCRIPT + " " + self.config_params["ssh-hostname"] + " " + self.config_params["ssh-username"] + " " + params["file"] + # if "parameters" in params: + # command += " \"" + params.get("parameters", "") + "\"" + # self.logger.debug("Command: '{}'".format(command)) + # return_code, stdout, stderr = await util_ee.local_async_exec(command) + # if return_code != 0: + # yield "ERROR", "return code {}: {}".format(return_code, stderr.decode()) + # else: + # yield "OK", stdout.decode() + + # This method implements the "ansible_playbook" primitive. Uncomment and modify it if a primitive requires + # executing an Ansible Playbook. It needs "playbook-name" parameter (playbook file, must be in "source" directory). + # async def ansible_playbook(self, id, params): + # self.logger.debug("Execute action ansible_playbook, params: '{}'".format(params)) + + # try: + # self._check_required_params(params, ["playbook-name"]) + # params["ansible_user"] = self.config_params["ssh-username"] + # inventory = self.config_params["ssh-hostname"] + "," + # playbook = self.PLAYBOOK_PATH + "/" + params["playbook-name"] + # os.environ["ANSIBLE_HOST_KEY_CHECKING"] = "False" + # return_code, stdout, stderr = await util_ansible.execute_playbook(playbook, inventory, params) + # status = "OK" if return_code == 0 else "ERROR" + # yield status, stdout + stderr + # except Exception as e: + # self.logger.debug("Error executing ansible playbook: {}".format(repr(e))) + # yield "ERROR", str(e) + + # This method implements the "ping" primitive. Uncomment and modify it if a primitive requires + # executing a local command (such as ping) on EE. It uses "ssh-hostname" as ping destination. + # async def ping(self, id, params): + # self.logger.debug("Execute action ping, params: '{}'".format(params)) + + # command = "ping -c 3 " + self.config_params["ssh-hostname"] + # return_code, stdout, stderr = await util_ee.local_async_exec(command) + # if return_code != 0: + # yield "ERROR", "return code {}: {}".format(return_code, stderr.decode()) + # else: + # yield "OK", stdout.decode() + + # This method implements the "http_check" primitive. Uncomment and modify it if a primitive requires + # executing embedded python code on VfnEE class. It requests "http:///" using a HTTP library. + # async def http_check(self, id, params): + # self.logger.debug("Execute action http_check, params: '{}'".format(params)) + + # try: + # session = requests.Session() + # url = 'http://' + self.config_params["ssh-hostname"] + # self.logger.debug("HTTP GET {}...".format(url)) + # req = session.get(url) + # self.logger.debug("{}".format(req.text)) + # if req.status_code == 200: + # yield "OK", req.text + # else: + # yield "ERROR", req.text + # except Exception as e: + # self.logger.error("HTTP error: {}".format(repr(e))) + # yield "ERROR", str(e) + + # This method implements the "touch" primitive. Uncomment and modify it if you need a primitive that + # imports a user-defined python library. It only needs "file" parameter for creating it in VDU via SSH. + # async def touch(self, id, params): + # self.logger.debug("Execute action touch, params: '{}'".format(params)) + + # self._check_required_params(params, ["file"]) + # command = "touch" + " " + params["file"] + # return_code, description = await mylib.ssh_exec(self.config_params["ssh-hostname"], self.config_params["ssh-username"], command) + # if return_code != 0: + # yield "ERROR", description + # else: + # yield "OK", description + + # Static method that verifies whether a parameter exists in the map + @staticmethod + def _check_required_params(params, required_params): + for required_param in required_params: + if required_param not in params: + raise VnfException("Missing required param: {}".format(required_param)) diff --git a/sample_ee_vnf/helm-charts/eechart/templates/NOTES.txt b/sample_ee_vnf/helm-charts/eechart/templates/NOTES.txt new file mode 100755 index 0000000000000000000000000000000000000000..c52fc2c419ef6f4cccfb63fd93ca7379bfc04cf7 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "eechart.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "eechart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "eechart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "eechart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/sample_ee_vnf/helm-charts/eechart/templates/_helpers.tpl b/sample_ee_vnf/helm-charts/eechart/templates/_helpers.tpl new file mode 100755 index 0000000000000000000000000000000000000000..d3e28e0260b8bff2fdef09046df0abaea885739c --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/_helpers.tpl @@ -0,0 +1,56 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "eechart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "eechart.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "eechart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "eechart.labels" -}} +app.kubernetes.io/name: {{ include "eechart.name" . }} +helm.sh/chart: {{ include "eechart.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "eechart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "eechart.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/sample_ee_vnf/helm-charts/eechart/templates/configmap.yaml b/sample_ee_vnf/helm-charts/eechart/templates/configmap.yaml new file mode 100755 index 0000000000000000000000000000000000000000..5b9634c7e1abe64c6f720f708dd5c9664e72e8cf --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/configmap.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "eechart.fullname" . }} +data: +{{ (.Files.Glob "source/*").AsConfig | indent 2 }} diff --git a/sample_ee_vnf/helm-charts/eechart/templates/generator.yaml b/sample_ee_vnf/helm-charts/eechart/templates/generator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..96f7e237d85cecfba6f7047c169ba09fdcb8865e --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/generator.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "vnf-snmp-generator-{{ .Values.global.osm.vnf_id | lower }}" +data: + generator.yml: |- + {{ .Files.Get "snmp/generator.yml" | nindent 4}} \ No newline at end of file diff --git a/sample_ee_vnf/helm-charts/eechart/templates/ingress.yaml b/sample_ee_vnf/helm-charts/eechart/templates/ingress.yaml new file mode 100755 index 0000000000000000000000000000000000000000..264f89091bee2ba8746edc2841c275d28fef1168 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "eechart.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: +{{ include "eechart.labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/sample_ee_vnf/helm-charts/eechart/templates/mibs.yaml b/sample_ee_vnf/helm-charts/eechart/templates/mibs.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e7b5eab55038ea9e0d17d7c8d0b9fc7dc15ddfe6 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/mibs.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "vnf-snmp-mibs-{{ .Values.global.osm.vnf_id | lower}}" +data: +{{ (.Files.Glob "snmp/mibs/**").AsConfig | indent 2 }} \ No newline at end of file diff --git a/sample_ee_vnf/helm-charts/eechart/templates/service.yaml b/sample_ee_vnf/helm-charts/eechart/templates/service.yaml new file mode 100755 index 0000000000000000000000000000000000000000..88d38d66a3997c6e2a96754582736cfb065da6c2 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "eechart.fullname" . }} + labels: +{{ include "eechart.labels" . | indent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: grpc + protocol: TCP + name: grpc + selector: + app.kubernetes.io/name: {{ include "eechart.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/sample_ee_vnf/helm-charts/eechart/templates/serviceaccount.yaml b/sample_ee_vnf/helm-charts/eechart/templates/serviceaccount.yaml new file mode 100755 index 0000000000000000000000000000000000000000..be615a5f08c7b557446fa74e5e3619e47d2ee804 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "eechart.serviceAccountName" . }} + labels: +{{ include "eechart.labels" . | indent 4 }} +{{- end -}} diff --git a/sample_ee_vnf/helm-charts/eechart/templates/statefulset.yaml b/sample_ee_vnf/helm-charts/eechart/templates/statefulset.yaml new file mode 100755 index 0000000000000000000000000000000000000000..8b124995057b996bbf43b867ffb908da1c254f31 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/statefulset.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "eechart.fullname" . }} + labels: +{{ include "eechart.labels" . | indent 4 }} +spec: + serviceName: {{ include "eechart.fullname" . }} + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "eechart.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "eechart.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + vnf: {{ .Values.global.osm.vnf_id | lower}} + spec: + imagePullSecrets: + - name: regcred + serviceAccountName: {{ template "eechart.serviceAccountName" . }} + securityContext: + runAsUser: 0 + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: grpc + containerPort: 50051 + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: osm-ee + mountPath: /app/storage + - name: osm-ee-source + mountPath: /app/EE/osm_ee/vnf + - name: snmp-config-volume + mountPath: /etc/snmp_exporter + - name: vnf-mibs + mountPath: /root/.snmp/mibs + - name: vnf-generator + mountPath: /app/vnf/generator + volumes: + - name: osm-ee-source + configMap: + name: {{ include "eechart.fullname" . }} + - name: snmp-config-volume + hostPath: + path: "/var/lib/osm/snmp_exporter/{{ .Values.global.osm.vnf_id | lower }}/" + - name: vnf-mibs + configMap: + name: "vnf-snmp-mibs-{{ .Values.global.osm.vnf_id | lower}}" + - name: vnf-generator + configMap: + name: "vnf-snmp-generator-{{ .Values.global.osm.vnf_id | lower}}" + - name: osm-ee + hostPath: + path: /var/lib/osm/osm/osm_osm_packages/_data diff --git a/sample_ee_vnf/helm-charts/eechart/templates/tests/test-connection.yaml b/sample_ee_vnf/helm-charts/eechart/templates/tests/test-connection.yaml new file mode 100755 index 0000000000000000000000000000000000000000..e52b7b8b2515729e582b5efbc22dc5a0bdb0f3b2 --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "eechart.fullname" . }}-test-connection" + labels: +{{ include "eechart.labels" . | indent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "eechart.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/sample_ee_vnf/helm-charts/eechart/values.yaml b/sample_ee_vnf/helm-charts/eechart/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7006b5df1ac6ad4972e7f9a535f26ebff21176ae --- /dev/null +++ b/sample_ee_vnf/helm-charts/eechart/values.yaml @@ -0,0 +1,72 @@ +global: + osm: + vnf_id: AVNFId + +# Default values for eechart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: illoret/grpcee + tag: latest + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 50050 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/sample_ee_vnf/sample_ee_vnfd.yaml b/sample_ee_vnf/sample_ee_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..87d6a41562ca48f744388b8ee6a2a91cd3e017d0 --- /dev/null +++ b/sample_ee_vnf/sample_ee_vnfd.yaml @@ -0,0 +1,153 @@ +vnfd: + description: Basic execution environment example + df: + - id: default-df + instantiation-level: + - id: default-instantiation-level + vdu-level: + - number-of-instances: 1 + vdu-id: sample_ee-VM + vdu-profile: + - id: sample_ee-VM + min-number-of-instances: 1 + lcm-operations-configuration: + operate-vnf-op-config: + day1-2: + - config-primitive: + # - execution-environment-primitive: run_script + # execution-environment-ref: sample_ee + # name: run_script + # parameter: + # - data-type: STRING + # name: file + # - data-type: STRING + # name: parameters + # - execution-environment-primitive: ansible_playbook + # execution-environment-ref: sample_ee + # name: ansible_playbook + # parameter: + # - data-type: STRING + # name: playbook-name + # - data-type: STRING + # name: app + # - execution-environment-primitive: ping + # execution-environment-ref: sample_ee + # name: ping + # - execution-environment-primitive: http_check + # execution-environment-ref: sample_ee + # name: http_check + # - execution-environment-primitive: touch + # execution-environment-ref: sample_ee + # name: touch + # parameter: + # - data-type: STRING + # name: file + config-access: + ssh-access: + default-user: ubuntu + required: true + execution-environment-list: + - external-connection-point-ref: vnf-mgmt-ext + helm-chart: eechart + id: sample_ee + id: sample_ee-vnf + initial-config-primitive: + - execution-environment-ref: sample_ee + name: config + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + seq: 1 + # - execution-environment-ref: sample_ee + # name: run_script + # parameter: + # - name: file + # value: install_nginx.sh + # seq: 2 + # - execution-environment-ref: sample_ee + # name: ansible_playbook + # parameter: + # - name: playbook-name + # value: playbook.yaml + # - name: app + # value: ntp + # seq: 3 + # - execution-environment-ref: sample_ee + # name: ping + # seq: 4 + # - execution-environment-ref: sample_ee + # name: http_check + # seq: 5 + # - execution-environment-ref: sample_ee + # name: touch + # parameter: + # - name: file + # value: myfile.txt + # seq: 6 + ext-cpd: + - id: vnf-mgmt-ext + int-cpd: + cpd: vdu-eth0-int + vdu-id: sample_ee-VM + - id: vnf-internal-ext + int-cpd: + cpd: vdu-eth1-int + vdu-id: sample_ee-VM + id: sample_ee-vnf + mgmt-cp: vnf-mgmt-ext + product-name: sample_ee-vnf + sw-image-desc: + - id: ubuntu20.04 + image: ubuntu20.04 + name: ubuntu20.04 + - id: ubuntu20.04-azure + name: ubuntu20.04-azure + image: Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest + vim-type: azure + - id: ubuntu20.04-gcp + name: ubuntu20.04-gcp + image: ubuntu-os-cloud:image-family:ubuntu-2004-lts + vim-type: gcp + vdu: + - id: sample_ee-VM + int-cpd: + - id: vdu-eth0-int + virtual-network-interface-requirement: + - name: vdu-eth0 + position: 0 + virtual-interface: + type: PARAVIRT + - id: vdu-eth1-int + virtual-network-interface-requirement: + - name: vdu-eth1 + position: 1 + virtual-interface: + type: PARAVIRT + - id: vdu-eth2-int + virtual-network-interface-requirement: + - name: vdu-eth2 + position: 2 + virtual-interface: + type: PARAVIRT + name: sample_ee-VM + supplemental-boot-data: + boot-data-drive: true + sw-image-desc: ubuntu20.04 + alternative-sw-image-desc: + - ubuntu20.04-azure + - ubuntu20.04-gcp + virtual-compute-desc: sample_ee-VM-compute + virtual-storage-desc: + - sample_ee-VM-storage + version: '1.0' + virtual-compute-desc: + - id: sample_ee-VM-compute + virtual-cpu: + num-virtual-cpu: 1 + virtual-memory: + size: 4.0 + virtual-storage-desc: + - id: sample_ee-VM-storage + size-of-storage: 20