Support vimConnectionInfo.extra when CNF deploy
If 'vimConnectionInfo.extra' is included in the Input parameter file specified during CNF instantiation via helm, this information is taken in and used as a parameter for deployment via helm. If the extra parameter is set in the config-file specified when the 'openstack vim register' command is executed, the information is saved in the VIM DB. Implements: blueprint remove-cnf-restriction Change-Id: I11f83857f784eea1f8c4caefdc6161a86fefe4e4
This commit is contained in:
parent
dbca617b98
commit
03956dad31
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
When executing the 'openstack vim register' or 'openstack vim set' command,
|
||||
if the `extra` parameter is specified in the config-file, data is stored
|
||||
in the `extra` field of the VIM DB.
|
||||
Develop to accept the vimConnectionInfo.extra field, if present, in the
|
||||
input parameter file when performing a CNF deployment via helm.
|
@ -372,6 +372,14 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'allow_put': False,
|
||||
'is_visible': True,
|
||||
},
|
||||
'extra': {
|
||||
'allow_post': True,
|
||||
'allow_put': True,
|
||||
'convert_to': attr.convert_none_to_empty_dict,
|
||||
'validate': {'type:dict_or_nodata': None},
|
||||
'is_visible': True,
|
||||
'default': None
|
||||
},
|
||||
},
|
||||
|
||||
'vnffgds': {
|
||||
|
@ -30,8 +30,7 @@ class VimConnectionInfo(base.TackerObject, base.TackerPersistentObject):
|
||||
default={}),
|
||||
'access_info': fields.DictOfNullableStringsField(nullable=True,
|
||||
default={}),
|
||||
'extra': fields.DictOfNullableStringsField(nullable=True,
|
||||
default={}),
|
||||
'extra': fields.DictOfNullableField(nullable=True, default={}),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
@ -82,6 +82,7 @@ class BaseVnfLcmKubernetesTest(base.BaseTackerTest):
|
||||
if not vim:
|
||||
self.skipTest(f"Kubernetes VIM '{vim_name}' is missing")
|
||||
self.vim_id = vim['id']
|
||||
self.extra = vim['extra']
|
||||
|
||||
def _create_and_upload_vnf_package_add_mgmt(
|
||||
self, tacker_client, csar_package_name,
|
||||
@ -201,7 +202,8 @@ class BaseVnfLcmKubernetesTest(base.BaseTackerTest):
|
||||
|
||||
@classmethod
|
||||
def _instantiate_vnf_instance_request(
|
||||
cls, flavour_id, vim_id=None, additional_param=None):
|
||||
cls, flavour_id, vim_id=None, additional_param=None,
|
||||
extra_param=None):
|
||||
request_body = {"flavourId": flavour_id}
|
||||
|
||||
if vim_id:
|
||||
@ -210,6 +212,9 @@ class BaseVnfLcmKubernetesTest(base.BaseTackerTest):
|
||||
"vimId": vim_id,
|
||||
"vimType": "kubernetes"}]
|
||||
|
||||
if vim_id and extra_param:
|
||||
request_body["vimConnectionInfo"][0]["extra"] = extra_param
|
||||
|
||||
if additional_param:
|
||||
request_body["additionalParams"] = additional_param
|
||||
|
||||
|
@ -149,3 +149,78 @@ class VnfLcmKubernetesHelmTest(vnflcm_base.BaseVnfLcmKubernetesTest):
|
||||
|
||||
self._terminate_vnf_instance(vnf_instance['id'])
|
||||
self._delete_vnf_instance(vnf_instance['id'])
|
||||
|
||||
def test_cnf_insta_with_extra_field_v1(self):
|
||||
"""Test instantiate using Helm chart.
|
||||
|
||||
Input parameter includes VimConnectionInfo.extra fields
|
||||
"""
|
||||
vnf_instance_name = "cnf_with_helmchart"
|
||||
vnf_instance_description = "cnf with helmchart"
|
||||
helmchartfile_path = "Files/kubernetes/localhelm-0.1.0.tgz"
|
||||
flavour_id = "helmchart"
|
||||
inst_additional_param = {
|
||||
"namespace": "default",
|
||||
"use_helm": "true",
|
||||
"using_helm_install_param": [
|
||||
{
|
||||
"exthelmchart": "false",
|
||||
"helmchartfile_path": helmchartfile_path,
|
||||
"helmreleasename": "vdu1",
|
||||
"helmparameter": [
|
||||
"service.port=8081"
|
||||
]
|
||||
},
|
||||
{
|
||||
"exthelmchart": "true",
|
||||
"helmreleasename": "vdu2",
|
||||
"helmrepositoryname": "bitnami",
|
||||
"helmchartname": "apache",
|
||||
"exthelmrepo_url": "https://charts.bitnami.com/bitnami"
|
||||
}
|
||||
],
|
||||
"helm_replica_values": {
|
||||
"vdu1_aspect": "replicaCount",
|
||||
"vdu2_aspect": "replicaCount"
|
||||
},
|
||||
"vdu_mapping": {
|
||||
"VDU1": {
|
||||
"name": "vdu1-localhelm",
|
||||
"kind": "Deployment",
|
||||
"helmreleasename": "vdu1"
|
||||
},
|
||||
"VDU2": {
|
||||
"name": "vdu2-apache",
|
||||
"kind": "Deployment",
|
||||
"helmreleasename": "vdu2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inst_extra_param = self.extra
|
||||
|
||||
# create vnf instance
|
||||
_, vnf_instance = self._create_vnf_instance(
|
||||
self.vnfd_id, vnf_instance_name=vnf_instance_name,
|
||||
vnf_instance_description=vnf_instance_description)
|
||||
self.assertEqual(
|
||||
'NOT_INSTANTIATED', vnf_instance['instantiationState'])
|
||||
|
||||
# instantiate vnf instance
|
||||
additional_param = inst_additional_param
|
||||
request_body = self._instantiate_vnf_instance_request(
|
||||
flavour_id, vim_id=self.vim_id, additional_param=additional_param,
|
||||
extra_param=inst_extra_param)
|
||||
|
||||
self._instantiate_vnf_instance(vnf_instance['id'], request_body)
|
||||
vnf_instance = self._show_vnf_instance(vnf_instance['id'])
|
||||
|
||||
self.assertEqual(
|
||||
'INSTANTIATED', vnf_instance['instantiationState'])
|
||||
vnflcm_op_occ = self._get_vnflcm_op_occs_by_id(
|
||||
self.context, vnf_instance['id'])
|
||||
self.assertEqual('COMPLETED', vnflcm_op_occ.operation_state)
|
||||
self.assertEqual('INSTANTIATE', vnflcm_op_occ.operation)
|
||||
|
||||
self._terminate_vnf_instance(vnf_instance['id'])
|
||||
self._delete_vnf_instance(vnf_instance['id'])
|
||||
|
@ -18,6 +18,9 @@ import os
|
||||
import ddt
|
||||
from oslo_config import cfg
|
||||
|
||||
from tacker.objects import fields
|
||||
from tacker.objects.instantiate_vnf_req import InstantiateVnfRequest
|
||||
from tacker.objects.vim_connection import VimConnectionInfo
|
||||
from tacker.tests.unit import base
|
||||
from tacker.tests.unit.vnflcm import fakes
|
||||
from tacker.tests import uuidsentinel
|
||||
@ -64,3 +67,29 @@ class VnfLcmUtilsTestCase(base.TestCase):
|
||||
self.assertIn('node_templates', vnf_keys)
|
||||
self.assertIn('policies', vnf_keys)
|
||||
self.assertIn('groups', vnf_keys)
|
||||
|
||||
def test_vim_connection_info_extra_param(self):
|
||||
id = "817954e4-c321-4a31-ae06-cedcc4ddb85c"
|
||||
vim_id = "690edc6b-7581-48d8-9ac9-910c2c3d7c02"
|
||||
vim_type = "kubernetes"
|
||||
extra = {
|
||||
"helm_info": {
|
||||
"masternode_ip": [
|
||||
"192.168.1.1"
|
||||
],
|
||||
"masternode_username": "dummy_user",
|
||||
"masternode_password": "dummy_pass"
|
||||
}
|
||||
}
|
||||
|
||||
vim_conn = VimConnectionInfo(id=id,
|
||||
vim_id=vim_id, vim_type=vim_type,
|
||||
extra=extra)
|
||||
|
||||
instantiate_vnf_req = InstantiateVnfRequest()
|
||||
instantiate_vnf_req.vim_connection_info = [vim_conn]
|
||||
vnf_instance = fakes.return_vnf_instance(
|
||||
fields.VnfInstanceState.NOT_INSTANTIATED)
|
||||
result = vnflcm_utils._get_vim_connection_info_from_vnf_req(
|
||||
vnf_instance, instantiate_vnf_req)
|
||||
self.assertEqual(result[0].extra, vim_conn.extra)
|
||||
|
@ -530,7 +530,8 @@ def _get_vim_connection_info_from_vnf_req(vnf_instance, instantiate_vnf_req):
|
||||
vim_conn = objects.VimConnectionInfo(id=vim_connection.id,
|
||||
vim_id=vim_connection.vim_id, vim_type=vim_connection.vim_type,
|
||||
access_info=vim_connection.access_info,
|
||||
interface_info=vim_connection.interface_info)
|
||||
interface_info=vim_connection.interface_info,
|
||||
extra=vim_connection.extra)
|
||||
|
||||
vim_connection_obj_list.append(vim_conn)
|
||||
|
||||
|
@ -808,9 +808,9 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
|
||||
|
||||
def _get_helm_info(self, vim_connection_info):
|
||||
# replace single quote to double quote
|
||||
helm_info = jsonutils.loads(
|
||||
vim_connection_info.extra.get('helm_info')
|
||||
.replace("'", '"'))
|
||||
helm_info = vim_connection_info.extra.get('helm_info')
|
||||
if isinstance(helm_info, str):
|
||||
helm_info = jsonutils.loads(helm_info.replace("'", '"'))
|
||||
ips = helm_info.get('masternode_ip', [])
|
||||
username = helm_info.get('masternode_username', '')
|
||||
password = helm_info.get('masternode_password', '')
|
||||
|
Loading…
Reference in New Issue
Block a user