- def ping_config(self, mano_ut, use_ns_init_conf, use_vnf_init_conf):
- suffix = ''
- if mano_ut:
- ping_cfg = r'''
-#!/bin/bash
-
-echo "!!!!!!!! Executed ping Configuration !!!!!!!!!"
- '''
- else:
- ping_cfg = r'''
-#!/bin/bash
-
-# Rest API config
-ping_mgmt_ip='<rw_mgmt_ip>'
-ping_mgmt_port=18888
-
-# VNF specific configuration
-pong_server_ip='<rw_connection_point_name pong_vnfd%s/cp0>'
-ping_rate=5
-server_port=5555
-
-# Make rest API calls to configure VNF
-curl -D /dev/stdout \
- -H "Accept: application/vnd.yang.data+xml" \
- -H "Content-Type: application/vnd.yang.data+json" \
- -X POST \
- -d "{\"ip\":\"$pong_server_ip\", \"port\":$server_port}" \
- http://${ping_mgmt_ip}:${ping_mgmt_port}/api/v1/ping/server
-rc=$?
-if [ $rc -ne 0 ]
-then
- echo "Failed to set server info for ping!"
- exit $rc
-fi
-''' % suffix
-
- if use_vnf_init_conf is False:
- ping_cfg +='''
-curl -D /dev/stdout \
- -H "Accept: application/vnd.yang.data+xml" \
- -H "Content-Type: application/vnd.yang.data+json" \
- -X POST \
- -d "{\"rate\":$ping_rate}" \
- http://${ping_mgmt_ip}:${ping_mgmt_port}/api/v1/ping/rate
-rc=$?
-if [ $rc -ne 0 ]
-then
- echo "Failed to set ping rate!"
- exit $rc
-fi
-
-'''
- if use_ns_init_conf:
- ping_cfg += "exit 0\n"
- else:
- ping_cfg +='''
-output=$(curl -D /dev/stdout \
- -H "Accept: application/vnd.yang.data+xml" \
- -H "Content-Type: application/vnd.yang.data+json" \
- -X POST \
- -d "{\"enable\":true}" \
- http://${ping_mgmt_ip}:${ping_mgmt_port}/api/v1/ping/adminstatus/state)
-if [[ $output == *"Internal Server Error"* ]]
-then
- echo $output
- exit 3
-else
- echo $output
-fi
-
-exit 0
-'''
- return ping_cfg
-
- def pong_config(self, mano_ut, use_ns_init_conf):
- suffix = ''
- if mano_ut:
- pong_cfg = r'''
-#!/bin/bash
-
-echo "!!!!!!!! Executed pong Configuration !!!!!!!!!"
- '''
- else:
- pong_cfg = r'''
-#!/bin/bash
-
-# Rest API configuration
-pong_mgmt_ip='<rw_mgmt_ip>'
-pong_mgmt_port=18889
-# username=<rw_username>
-# password=<rw_password>
-
-# VNF specific configuration
-pong_server_ip='<rw_connection_point_name pong_vnfd%s/cp0>'
-server_port=5555
-
-# Make Rest API calls to configure VNF
-curl -D /dev/stdout \
- -H "Accept: application/vnd.yang.data+xml" \
- -H "Content-Type: application/vnd.yang.data+json" \
- -X POST \
- -d "{\"ip\":\"$pong_server_ip\", \"port\":$server_port}" \
- http://${pong_mgmt_ip}:${pong_mgmt_port}/api/v1/pong/server
-rc=$?
-if [ $rc -ne 0 ]
-then
- echo "Failed to set server(own) info for pong!"
- exit $rc
-fi
-
-''' % suffix
-
- if use_ns_init_conf:
- pong_cfg += "exit 0\n"
- else:
- pong_cfg +='''
-curl -D /dev/stdout \
- -H "Accept: application/vnd.yang.data+xml" \
- -H "Content-Type: application/vnd.yang.data+json" \
- -X POST \
- -d "{\"enable\":true}" \
- http://${pong_mgmt_ip}:${pong_mgmt_port}/api/v1/pong/adminstatus/state
-rc=$?
-if [ $rc -ne 0 ]
-then
- echo "Failed to enable pong service!"
- exit $rc
-fi
-
-exit 0
-'''
- return pong_cfg
-
- def pong_fake_juju_config(self, vnf_config):
-
- if vnf_config:
- # Select "script" configuration
- vnf_config.juju.charm = 'clearwater-aio-proxy'
-
- # Set the initital-config
- vnf_config.create_initial_config_primitive()
- init_config = VnfdYang.InitialConfigPrimitive.from_dict({
- "seq": 1,
- "name": "config",
- "parameter": [
- {"name": "proxied_ip", "value": "<rw_mgmt_ip>"},
- ]
- })
- vnf_config.initial_config_primitive.append(init_config)
-
- init_config_action = VnfdYang.InitialConfigPrimitive.from_dict({
- "seq": 2,
- "name": "action1",
- "parameter": [
- {"name": "Pong Connection Point", "value": "pong_vnfd/cp0"},
- ]
- })
- vnf_config.initial_config_primitive.append(init_config_action)
- init_config_action = VnfdYang.InitialConfigPrimitive.from_dict({
- "seq": 3,
- "name": "action2",
- "parameter": [
- {"name": "Ping Connection Point", "value": "ping_vnfd/cp0"},
- ]
- })
- vnf_config.initial_config_primitive.append(init_config_action)
-
- # Config parameters can be taken from config.yaml and
- # actions from actions.yaml in the charm
- # Config to set the home domain
- vnf_config.create_service_primitive()
- config = VnfdYang.ServicePrimitive.from_dict({
- "name": "config",
- "parameter": [
- {"name": "home_domain", "data_type": "STRING"},
- {"name": "base_number", "data_type": "STRING"},
- {"name": "number_count", "data_type": "INTEGER"},
- {"name": "password", "data_type": "STRING"},
- ]
- })
- vnf_config.service_primitive.append(config)
-
- config = VnfdYang.ServicePrimitive.from_dict({
- "name": "create-update-user",
- # "user-defined-script":"/tmp/test.py",
- "parameter": [
- {"name": "number", "data_type": "STRING", "mandatory": True},
- {"name": "password", "data_type": "STRING", "mandatory": True},
- ]
- })
- vnf_config.service_primitive.append(config)
-
- config = VnfdYang.ServicePrimitive.from_dict({
- "name": "delete-user",
- "parameter": [
- {"name": "number", "data_type": "STRING", "mandatory": True},
- ]
- })
- vnf_config.service_primitive.append(config)
-
- def default_config(self, const_vnfd, vnfd, mano_ut,
- use_ns_init_conf,
- use_vnf_init_conf):