Add support cnf auto heal and scale

Support container based VNF AutoHeal and AutoScale operation with
External Monitoring Tools.

Add the Fault Management interfaces and CLI to support AutoHeal.
Add the Performance Management interfaces and CLI to support
AutoScale. The Fault Management and Performance Management
interfaces are based on ETSI NFV-SOL 002 v3.3.1 and ETSI NFV-SOL
003 v3.3.1, which are Version "2.0.0" API of Tacker. Add the
Prometheus Plugin that has a interface between tacker and Prometheus
as a sample of External Monitoring Tool.

Implements: blueprint support-auto-lcm
Change-Id: Ib74305f0b1da4eb8d996ebae400e75902aaa1321
changes/48/854348/27
Koji Shimizu 6 months ago
parent 46da7f8f59
commit d1a23a3c28

@ -561,7 +561,13 @@
$TACKER_CONF:
v2_vnfm:
kubernetes_vim_rsc_wait_timeout: 800
prometheus_plugin:
fault_management: True
performance_management: True
auto_scaling: True
tox_envlist: dsvm-functional-sol-kubernetes-v2
vars:
prometheus_setup: true
- job:
name: tacker-functional-devstack-kubernetes-oidc-auth

@ -6,6 +6,11 @@ use = egg:Paste#urlmap
/vnflcm: vnflcm_versions
/vnflcm/v1: vnflcm_v1
/vnflcm/v2: vnflcm_v2
/vnffm/v1: vnffm_v1
/vnfpm/v2: vnfpm_v2
/alert/vnf_instances: prometheus_auto_scaling
/alert: prometheus_fm
/pm_event: prometheus_pm
[composite:tackerapi_v1_0]
use = call:tacker.auth:pipeline_factory
@ -27,11 +32,21 @@ use = call:tacker.auth:pipeline_factory
noauth = request_id catch_errors vnflcmaapp_v2
keystone = request_id catch_errors authtoken keystonecontext vnflcmaapp_v2
[composite:vnfpm_v2]
use = call:tacker.auth:pipeline_factory
noauth = request_id catch_errors vnfpmaapp_v2
keystone = request_id catch_errors authtoken keystonecontext vnfpmaapp_v2
[composite:vnflcm_versions]
use = call:tacker.auth:pipeline_factory
noauth = request_id catch_errors vnflcm_api_versions
keystone = request_id catch_errors authtoken keystonecontext vnflcm_api_versions
[composite:vnffm_v1]
use = call:tacker.auth:pipeline_factory
noauth = request_id catch_errors vnffmaapp_v1
keystone = request_id catch_errors authtoken keystonecontext vnffmaapp_v1
[filter:request_id]
paste.filter_factory = oslo_middleware:RequestId.factory
@ -65,5 +80,20 @@ paste.app_factory = tacker.api.vnflcm.v1.router:VnflcmAPIRouter.factory
[app:vnflcmaapp_v2]
paste.app_factory = tacker.sol_refactored.api.router:VnflcmAPIRouterV2.factory
[app:vnfpmaapp_v2]
paste.app_factory = tacker.sol_refactored.api.router:VnfPmAPIRouterV2.factory
[app:vnflcm_api_versions]
paste.app_factory = tacker.sol_refactored.api.router:VnflcmVersions.factory
[app:vnffmaapp_v1]
paste.app_factory = tacker.sol_refactored.api.router:VnffmAPIRouterV1.factory
[app:prometheus_auto_scaling]
paste.app_factory = tacker.sol_refactored.api.prometheus_plugin_router:AutoScalingRouter.factory
[app:prometheus_fm]
paste.app_factory = tacker.sol_refactored.api.prometheus_plugin_router:FmAlertRouter.factory
[app:prometheus_pm]
paste.app_factory = tacker.sol_refactored.api.prometheus_plugin_router:PmEventRouter.factory

@ -6,6 +6,8 @@
- setup-k8s-oidc
- setup-default-vim
- setup-helm
- role: setup-fake-prometheus-server
when: prometheus_setup is defined and prometheus_setup | bool
- role: setup-multi-tenant-vim
when: setup_multi_tenant is defined and setup_multi_tenant | bool
- role: bindep

@ -0,0 +1,17 @@
---
features:
- |
Support container based VNF AutoHeal and AutoScale operation with External
Monitoring Tools.
Add the Fault Management interfaces and CLI to support AutoHeal. AutoHeal
supports two modes, Polling Mode and Notification Mode.
Add the Performance Management interfaces and CLI to support AutoScale.
The Fault Management and Performance Management interfaces are based on
ETSI NFV-SOL 002 v3.3.1 and ETSI NFV-SOL 003 v3.3.1, which are Version
"2.0.0" API of Tacker.
Add the Prometheus Plugin that has a interface between tacker and
the External Monitoring Tool. Prometheus Plugin supports data model
conversion from Prometheus format data to SOL based FM/PM schema,
and vice versa.
At the same time, a user guide is also made to help users understand the
function.

@ -0,0 +1,39 @@
- block:
- name: Copy tools/test-setup-fake-prometheus-server.sh
copy:
remote_src=True
src={{ devstack_base_dir }}/tacker/tools/test-setup-fake-prometheus-server.sh
dest={{ zuul_work_dir }}/tools/test-setup-fake-prometheus-server.sh
mode=0755
- name: Get stackenv from devstack environment
slurp:
src: "{{ devstack_base_dir }}/devstack/.stackenv"
register: stackenv
- name: Install docker
package:
name: docker.io
state: present
become: yes
- name: Replace prometheus host ip
replace:
path: "{{ item }}"
regexp: "0.0.0.0"
replace: "{{ hostvars['controller-tacker']['nodepool']['private_ipv4'] }}"
with_items:
- "{{ zuul_work_dir }}/tools/test-setup-fake-prometheus-server.sh"
when:
- p.stat.exists
- name: Run tools/test-setup-fake-prometheus-server.sh
command: tools/test-setup-fake-prometheus-server.sh
args:
chdir: "{{ zuul_work_dir }}"
when:
- p.stat.exists
- p.stat.executable
when:
- inventory_hostname == 'controller-tacker'

@ -0,0 +1,92 @@
# Copyright 2022 OpenStack 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.
#
"""add_pm_and_fm_table
Revision ID: de8d835ae776
Revises: 85c06a0714b7
Create Date: 2022-07-21 17:34:45.675428
"""
# flake8: noqa: E402
# revision identifiers, used by Alembic.
revision = 'de8d835ae776'
down_revision = '85c06a0714b7'
from alembic import op
import sqlalchemy as sa
def upgrade(active_plugins=None, options=None):
op.create_table('AlarmV1',
sa.Column('id', sa.String(length=255), nullable=False),
sa.Column('managedObjectId', sa.String(length=255), nullable=False),
sa.Column('vnfcInstanceIds', sa.JSON(), nullable=True),
sa.Column('rootCauseFaultyResource', sa.JSON(), nullable=True),
sa.Column('alarmRaisedTime', sa.DateTime(), nullable=False),
sa.Column('alarmChangedTime', sa.DateTime(), nullable=True),
sa.Column('alarmClearedTime', sa.DateTime(), nullable=True),
sa.Column('alarmAcknowledgedTime', sa.DateTime(), nullable=True),
sa.Column('ackState', sa.Enum(
'UNACKNOWLEDGED', 'ACKNOWLEDGED'), nullable=False),
sa.Column('perceivedSeverity', sa.Enum(
'CRITICAL', 'MAJOR', 'MINOR', 'WARNING',
'INDETERMINATE', 'CLEARED'), nullable=False),
sa.Column('eventTime', sa.DateTime(), nullable=False),
sa.Column('eventType', sa.Enum(
'COMMUNICATIONS_ALARM', 'PROCESSING_ERROR_ALARM',
'ENVIRONMENTAL_ALARM', 'QOS_ALARM',
'EQUIPMENT_ALARM'), nullable=False),
sa.Column('faultType', sa.String(length=255), nullable=True),
sa.Column('probableCause', sa.String(length=255), nullable=False),
sa.Column('isRootCause', sa.Boolean(), nullable=False),
sa.Column('correlatedAlarmIds', sa.JSON(), nullable=True),
sa.Column('faultDetails', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_engine='InnoDB'
)
op.create_table('FmSubscriptionV1',
sa.Column('id', sa.String(length=255), nullable=False),
sa.Column('filter', sa.JSON(), nullable=True),
sa.Column('callbackUri', sa.String(length=255), nullable=False),
sa.Column('authentication', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_engine='InnoDB'
)
op.create_table('PmJobV2',
sa.Column('id', sa.String(length=255), nullable=False),
sa.Column('objectType', sa.String(length=32), nullable=False),
sa.Column('objectInstanceIds', sa.JSON(), nullable=False),
sa.Column('subObjectInstanceIds', sa.JSON(), nullable=True),
sa.Column('criteria', sa.JSON(), nullable=False),
sa.Column('callbackUri', sa.String(length=255), nullable=False),
sa.Column('reports', sa.JSON(), nullable=True),
sa.Column('authentication', sa.JSON(), nullable=True),
sa.Column('metadata', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_engine='InnoDB'
)
op.create_table('PerformanceReportV2',
sa.Column('id', sa.String(length=255), nullable=False),
sa.Column('jobId', sa.String(length=255), nullable=False),
sa.Column('entries', sa.JSON(), nullable=False),
sa.PrimaryKeyConstraint('id'),
mysql_engine='InnoDB'
)

@ -19,7 +19,9 @@ import itertools
from tacker.policies import base
from tacker.policies import vnf_lcm
from tacker.policies import vnf_package
from tacker.sol_refactored.api.policies import vnffm_v1
from tacker.sol_refactored.api.policies import vnflcm_v2
from tacker.sol_refactored.api.policies import vnfpm_v2
def list_rules():
@ -28,4 +30,6 @@ def list_rules():
vnf_package.list_rules(),
vnf_lcm.list_rules(),
vnflcm_v2.list_rules(),
vnffm_v1.list_rules(),
vnfpm_v2.list_rules(),
)

@ -33,7 +33,23 @@ supported_versions_v2 = {
]
}
supported_fm_versions_v1 = {
'uriPrefix': '/vnffm/v1',
'apiVersions': [
{'version': '1.3.0', 'isDeprecated': False}
]
}
supported_pm_versions_v2 = {
'uriPrefix': '/vnfpm/v2',
'apiVersions': [
{'version': '2.1.0', 'isDeprecated': False}
]
}
CURRENT_VERSION = '2.0.0'
CURRENT_FM_VERSION = '1.3.0'
CURRENT_PM_VERSION = '2.1.0'
v1_versions = [
item['version'] for item in supported_versions_v1['apiVersions']
@ -43,6 +59,14 @@ v2_versions = [
item['version'] for item in supported_versions_v2['apiVersions']
]
v1_fm_versions = [
item['version'] for item in supported_fm_versions_v1['apiVersions']
]
v2_pm_versions = [
item['version'] for item in supported_pm_versions_v2['apiVersions']
]
class APIVersion(object):

@ -0,0 +1,110 @@
# Copyright (C) 2022 Fujitsu
# 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.
from oslo_policy import policy
POLICY_NAME = 'os_nfv_orchestration_api_v2:vnf_fault_monitor:{}'
RULE_ANY = '@'
V1_PATH = '/vnffm/v1'
ALARMS_PATH = V1_PATH + '/alarms'
ALARMS_ID_PATH = ALARMS_PATH + '/{alarmId}'
SUBSCRIPTIONS_PATH = V1_PATH + '/subscriptions'
SUBSCRIPTIONS_ID_PATH = SUBSCRIPTIONS_PATH + '/{subscriptionId}'
POLICY_NAME_PROM_PLUGIN = 'tacker_PROM_PLUGIN_api:PROM_PLUGIN:{}'
PROM_PLUGIN_FM_PATH = '/alert'
rules = [
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('index'),
check_str=RULE_ANY,
description="Query FM alarms.",
operations=[
{'method': 'GET',
'path': ALARMS_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('show'),
check_str=RULE_ANY,
description="Query an Individual FM alarm.",
operations=[
{'method': 'GET',
'path': ALARMS_ID_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('update'),
check_str=RULE_ANY,
description="Modify FM alarm information.",
operations=[
{'method': 'PATCH',
'path': ALARMS_ID_PATH}
]
),
# NOTE: add when the operation supported
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('subscription_create'),
check_str=RULE_ANY,
description="Create subscription.",
operations=[
{'method': 'POST',
'path': SUBSCRIPTIONS_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('subscription_list'),
check_str=RULE_ANY,
description="List subscription.",
operations=[
{'method': 'GET',
'path': SUBSCRIPTIONS_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('subscription_show'),
check_str=RULE_ANY,
description="Show subscription.",
operations=[
{'method': 'GET',
'path': SUBSCRIPTIONS_ID_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('subscription_delete'),
check_str=RULE_ANY,
description="Delete subscription.",
operations=[
{'method': 'DELETE',
'path': SUBSCRIPTIONS_ID_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME_PROM_PLUGIN.format('alert'),
check_str=RULE_ANY,
description="Receive the alert sent from External Monitoring Tool",
operations=[
{'method': 'POST',
'path': PROM_PLUGIN_FM_PATH}
]
)
]
def list_rules():
return rules

@ -0,0 +1,132 @@
# Copyright (C) 2022 Fujitsu
# 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.
from oslo_policy import policy
POLICY_NAME = 'os_nfv_orchestration_api_v2:vnf_performance_management:{}'
RULE_ANY = '@'
V2_PATH = '/vnfpm/v2'
PM_JOB_PATH = V2_PATH + '/pm_jobs'
PM_JOB_ID_PATH = PM_JOB_PATH + '/{pmJobId}'
REPORT_GET = '/vnfpm/v2/pm_jobs/{id}/reports/{report_id}'
POLICY_NAME_PROM_PLUGIN = 'tacker_PROM_PLUGIN_api:PROM_PLUGIN:{}'
PROM_PLUGIN_PM_PATH = '/pm_event'
PROM_PLUGIN_AUTO_SCALING_PATH = '/alert/vnf_instances'
rules = [
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('create'),
check_str=RULE_ANY,
description="Create a PM job.",
operations=[
{
'method': 'POST',
'path': PM_JOB_PATH
}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('index'),
check_str=RULE_ANY,
description="Query PM jobs.",
operations=[
{
'method': 'GET',
'path': PM_JOB_PATH
}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('update'),
check_str=RULE_ANY,
description="Update a PM job.",
operations=[
{
'method': 'PATCH',
'path': PM_JOB_ID_PATH
}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('show'),
check_str=RULE_ANY,
description="Get an individual PM job.",
operations=[
{
'method': 'GET',
'path': PM_JOB_ID_PATH
}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('delete'),
check_str=RULE_ANY,
description="Delete a PM job.",
operations=[
{
'method': 'DELETE',
'path': PM_JOB_ID_PATH
}
]
),
# Add new Rest API GET /vnfpm/v2/pm_jobs/{id}/reports/{report_id} to
# get the specified PM report.
policy.DocumentedRuleDefault(
name=POLICY_NAME.format('report_get'),
check_str=RULE_ANY,
description="Get an individual performance report.",
operations=[
{
'method': 'GET',
'path': REPORT_GET
}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME_PROM_PLUGIN.format('pm_event'),
check_str=RULE_ANY,
description="Receive the PM event sent from External Monitoring Tool",
operations=[
{'method': 'POST',
'path': PROM_PLUGIN_PM_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME_PROM_PLUGIN.format('auto_scaling'),
check_str=RULE_ANY,
description="auto_scaling",
operations=[
{'method': 'POST',
'path': PROM_PLUGIN_AUTO_SCALING_PATH}
]
),
policy.DocumentedRuleDefault(
name=POLICY_NAME_PROM_PLUGIN.format('auto_scaling_id'),
check_str=RULE_ANY,
description="auto_scaling_id",
operations=[
{'method': 'POST',
'path': PROM_PLUGIN_AUTO_SCALING_PATH + '/{vnfInstanceId}'}
]
)
]
def list_rules():
return rules

@ -0,0 +1,43 @@
# Copyright (C) 2022 Fujitsu
# 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.
from tacker.sol_refactored.api.policies import vnffm_v1 as vnffm_policy_v1
from tacker.sol_refactored.api.policies import vnfpm_v2 as vnfpm_policy_v2
from tacker.sol_refactored.api import prometheus_plugin_wsgi as prom_wsgi
from tacker.sol_refactored.controller import prometheus_plugin_controller
class PmEventRouter(prom_wsgi.PrometheusPluginAPIRouter):
controller = prom_wsgi.PrometheusPluginResource(
prometheus_plugin_controller.PmEventController(),
policy_name=vnfpm_policy_v2.POLICY_NAME_PROM_PLUGIN)
route_list = [("", {"POST": "pm_event"})]
class FmAlertRouter(prom_wsgi.PrometheusPluginAPIRouter):
controller = prom_wsgi.PrometheusPluginResource(
prometheus_plugin_controller.FmAlertController(),
policy_name=vnffm_policy_v1.POLICY_NAME_PROM_PLUGIN)
route_list = [("", {"POST": "alert"})]
class AutoScalingRouter(prom_wsgi.PrometheusPluginAPIRouter):
controller = prom_wsgi.PrometheusPluginResource(
prometheus_plugin_controller.AutoScalingController(),
policy_name=vnfpm_policy_v2.POLICY_NAME_PROM_PLUGIN)
route_list = [
("", {"POST": "auto_scaling"}),
("/{id}", {"POST": "auto_scaling"})
]

@ -0,0 +1,46 @@
# Copyright (C) 2022 Fujitsu
# 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 functools
from tacker.api.validation import validators
from tacker.common import exceptions as tacker_ex
from tacker.sol_refactored.common import exceptions as sol_ex
class PrometheusPluginSchemaValidator(validators._SchemaValidator):
def validate(self, *args, **kwargs):
try:
super(PrometheusPluginSchemaValidator, self).validate(
*args, **kwargs)
except tacker_ex.ValidationError as ex:
raise sol_ex.PrometheusPluginValidationError(detail=str(ex))
def schema(request_body_schema):
def add_validator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if 'body' not in kwargs:
raise sol_ex.PrometheusPluginValidationError(
detail="body is missing.")
schema_validator = PrometheusPluginSchemaValidator(
request_body_schema)
schema_validator.validate(kwargs['body'])
return func(*args, **kwargs)
return wrapper
return add_validator

@ -0,0 +1,68 @@
# Copyright (C) 2022 Fujitsu
# 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.
from oslo_log import log as logging
from tacker.sol_refactored.api import wsgi as sol_wsgi
import webob
LOG = logging.getLogger(__name__)
class PrometheusPluginResponse(sol_wsgi.SolResponse):
allowed_headers = ['content_type']
def __init__(self, status, body, **kwargs):
self.status = status
self.body = body
self.headers = {}
for hdr in self.allowed_headers:
if hdr in kwargs:
self.headers[hdr] = kwargs[hdr]
class PrometheusPluginErrorResponse(sol_wsgi.SolErrorResponse):
pass
class PrometheusPluginResource(sol_wsgi.SolResource):
@webob.dec.wsgify(RequestClass=sol_wsgi.SolRequest)
def __call__(self, request):
LOG.info("%(method)s %(url)s", {"method": request.method,
"url": request.url})
try:
action, args, accept = self._deserialize_request(request)
self._check_policy(request, action)
result = self._dispatch(request, action, args)
response = result.serialize(accept)
except Exception as ex:
result = PrometheusPluginErrorResponse(ex, request)
try:
response = result.serialize('application/problem+json')
except Exception:
LOG.exception("Unknown error")
return webob.exc.HTTPBadRequest(explanation="Unknown error")
LOG.info("%(url)s returned with HTTP %(status)d",
{"url": request.url, "status": response.status_int})
return response
class PrometheusPluginAPIRouter(sol_wsgi.SolAPIRouter):
pass
class PrometheusPluginAPIController(sol_wsgi.SolAPIController):
pass

@ -14,10 +14,14 @@
# under the License.
from tacker.sol_refactored.api.policies import vnffm_v1 as vnffm_policy_v1
from tacker.sol_refactored.api.policies import vnflcm_v2 as vnflcm_policy_v2
from tacker.sol_refactored.api.policies import vnfpm_v2 as vnfpm_policy_v2
from tacker.sol_refactored.api import wsgi as sol_wsgi
from tacker.sol_refactored.controller import vnffm_v1
from tacker.sol_refactored.controller import vnflcm_v2
from tacker.sol_refactored.controller import vnflcm_versions
from tacker.sol_refactored.controller import vnfpm_v2
class VnflcmVersions(sol_wsgi.SolAPIRouter):
@ -57,3 +61,27 @@ class VnflcmAPIRouterV2(sol_wsgi.SolAPIRouter):
("/vnf_lcm_op_occs/{id}", {"GET": "lcm_op_occ_show",
"DELETE": "lcm_op_occ_delete"})
]
class VnffmAPIRouterV1(sol_wsgi.SolAPIRouter):
controller = sol_wsgi.SolResource(vnffm_v1.VnfFmControllerV1(),
policy_name=vnffm_policy_v1.POLICY_NAME)
route_list = [
("/alarms", {"GET": "index"}),
("/alarms/{id}", {"GET": "show", "PATCH": "update"}),
("/subscriptions", {"GET": "subscription_list",
"POST": "subscription_create"}),
("/subscriptions/{id}", {"GET": "subscription_show",
"DELETE": "subscription_delete"})
]
class VnfPmAPIRouterV2(sol_wsgi.SolAPIRouter):
controller = sol_wsgi.SolResource(vnfpm_v2.VnfPmControllerV2(),
policy_name=vnfpm_policy_v2.POLICY_NAME)
route_list = [
("/pm_jobs", {"POST": "create", "GET": "index"}),
("/pm_jobs/{id}", {
"PATCH": "update", "GET": "show", "DELETE": "delete"}),
("/pm_jobs/{id}/reports/{report_id}", {"GET": "report_get"}),
]

@ -16,7 +16,6 @@
from tacker.api.validation import parameter_types
# SOL013 7.2.2
Identifier = {
'type': 'string', 'minLength': 1, 'maxLength': 255
@ -123,6 +122,40 @@ _IpAddresses = {
'additionalProperties': True
}
# SOL013 8.3.4
SubscriptionAuthentication = {
'type': 'object',
'properties': {
'authType': {
'type': 'array',
'items': {
'type': 'string',
'enum': [
'BASIC',
'OAUTH2_CLIENT_CREDENTIALS',
'TLS_CERT']
}
},
'paramsBasic': {
'type': 'object',
'properties': {
'userName': {'type': 'string'},
'password': {'type': 'string'}
}
},
'paramsOauth2ClientCredentials': {
'type': 'object',
'properties': {
'clientId': {'type': 'string'},
'clientPassword': {'type': 'string'},
'tokenEndpoint': {'type': 'string'}
}
}
},
'required': ['authType'],
'additionalProperties': True,
}
# SOL003 4.4.1.10c
IpOverEthernetAddressData = {
'type': 'object',

@ -0,0 +1,87 @@
# Copyright (C) 2022 Fujitsu
# 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.
Alert = {
'type': 'object',
'status': {
'type': 'string',
'enum': ['firing', 'resolved']
},
'properties': {
'status': {
'type': 'string',
'enum': ['firing', 'resolved']
},
'labels': {
'type': 'object',
'properties': {
'receiver_type': {
'type': 'string',
'enum': ['tacker']
},
'function_type': {
'type': 'string',
'enum': ['vnffm', 'vnfpm', 'auto_scale']
},
'job_id': {'type': 'string'},
'object_instance_id': {'type': 'string'},
'vnf_instance_id': {'type': 'string'},
'node': {'type': 'string'},
'perceived_severity': {
'type': 'string',
'enum': ['CRITICAL', 'MAJOR', 'MINOR', 'WARNING',
'INDETERMINATE', 'CLEARED']
},
'event_type': {'type': 'string'},
'auto_scale_type': {
'type': 'string',
'enum': ['SCALE_OUT', 'SCALE_IN']
},
'aspect_id': {'type': 'string'}
},
'required': ['receiver_type', 'function_type'],
'additionalProperties': True
},
'annotations': {
'type': 'object',
'properties': {
'value': {'type': 'number'},
'probable_cause': {'type': 'string'},
'fault_type': {'type': 'string'},
'fault_details': {'type': 'string'}
},
'required': [],
'additionalProperties': True
},
'startsAt': {'type': 'string'},
'endsAt': {'type': 'string'},
'fingerprint': {'type': 'string'}
},
'required': ['status', 'labels', 'annotations', 'startsAt',
'fingerprint'],
'additionalProperties': True
}
AlertMessage = {
'type': 'object',
'properties': {
'alerts': {
'type': 'array',
'items': Alert
}
},
'required': ['alerts']
}

@ -0,0 +1,173 @@
# Copyright (C) 2022 Fujitsu
# 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.
from tacker.sol_refactored.api.schemas import common_types
# SOL003 7.5.2.8
AlarmModifications_V130 = {
'type': 'object',
'properties': {
'ackState': {
'type': 'string',
'enum': ['ACKNOWLEDGED', 'UNACKNOWLEDGED']
}
},
'required': ['ackState'],
'additionalProperties': True,
}
# SOL003 4.4.1.5 inner
_VnfProductVersions = {
'type': 'array',
'items': {
'type': 'objects',
'properties': {
'vnfSoftwareVersion': {'type': 'string'},
'vnfdVersions': {
'type': 'array',
'items': {'type': 'string'}
}
},
'required': ['vnfSoftwareVersion'],
'additionalProperties': True,
}
}
# SOL003 4.4.1.5 inner
_VnfProducts = {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'vnfProductName': {'type': 'string'},
'versions': _VnfProductVersions
},
'required': ['vnfProductName'],
'additionalProperties': True,
}
}
# SOL003 4.4.1.5 inner
_VnfProductsFromProviders = {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'type': 'object',
'properties': {
'vnfProvider': {'type': 'string'},
'vnfProducts': _VnfProducts
}
},
'required': ['vnfProvider'],
'additionalProperties': True,
}
}
# SOL003 4.4.1.5
_VnfInstanceSubscriptionFilter = {
'type': 'object',
'properties': {
'vnfdIds': {
'type': 'array',
'items': common_types.Identifier
},
'vnfProductsFromProviders': _VnfProductsFromProviders,
'vnfInstanceIds': {
'type': 'array',
'items': common_types.Identifier
},
'vnfInstanceNames': {
'type': 'array',
'items': {'type': 'string'}
}
},
'additionalProperties': True,
}
# SOL003 7.5.3.2
_FmNotificationsFilter = {
'type': 'object',
'properties': {
'vnfInstanceSubscriptionFilter': _VnfInstanceSubscriptionFilter,
'notificationTypes': {
'type': 'array',
'items': {
'type': 'string',
'enum': [
'AlarmNotification',
'AlarmClearedNotification',
'AlarmListRebuiltNotification']
}
},
'faultyResourceTypes': {
'type': 'array',
'items': {
'type': 'string',
'enum': [
'COMPUTE',
'STORAGE',
'NETWORK']
}
},
'perceivedSeverities': {
'type': 'array',
'items': {
'type': 'string',
'enum': [
'CRITICAL',
'MAJOR',
'MINOR',
'WARNING',
'INDETERMINATE',
'CLEARED']
}
},
'eventTypes': {
'type': 'array',
'items': {
'type': 'string',
'enum': [
'COMMUNICATIONS_ALARM',
'PROCESSING_ERROR_ALARM',
'ENVIRONMENTAL_ALARM',
'QOS_ALARM',
'EQUIPMENT_ALARM']
}
},
'probableCauses': {
'type': 'array',
'items': {'type': 'string'}
}
},
'additionalProperties': True,
}
# SOL003 7.5.2.2
FmSubscriptionRequest_V130 = {
'type': 'object',
'properties': {
'filter': _FmNotificationsFilter,
'callbackUri': {'type': 'string', 'maxLength': 255},
'authentication': common_types.SubscriptionAuthentication,
'verbosity': {
'type': 'string',
'enum': ['FULL', 'SHORT']
}
},
'required': ['callbackUri'],
'additionalProperties': True,
}

@ -0,0 +1,86 @@
# Copyright (C) 2022 Fujitsu
# 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.
from tacker.sol_refactored.api.schemas import common_types
# SOL003 6.5.3.3
_PmJobCriteria_V210 = {
'type': 'object',
'properties': {
'performanceMetric': {
'type': 'array',
'items': {'type:': 'string'}
},
'performanceMetricGroup': {
'type': 'array',
'items': {'type:': 'string'}
},
'collectionPeriod': {'type': 'integer'},
'reportingPeriod': {'type': 'integer'},
'reportingBoundary': {'type': 'string'}
},
'anyOf': [
{'required': ['performanceMetric']},
{'required': ['performanceMetricGroup']}
],
'required': ['collectionPeriod', 'reportingPeriod'],
'additionalProperties': True,
}
# SOL003 6.5.2.6
CreatePmJobRequest_V210 = {
'type': 'object',
'properties': {
'objectType': {
'type': 'string',
'enum': [
# TODO(YiFeng): Currently, this API only supports CNF, and
# supports the following types. When VNF is supported,
# the types can be extended.
'Vnf',
'Vnfc',
'VnfIntCP',
'VnfExtCP']
},
'objectInstanceIds': {
'type': 'array',
'items': common_types.Identifier
},
'subObjectInstanceIds': {
'type': 'array',
'items': common_types.IdentifierInVnf
},
'criteria': _PmJobCriteria_V210,
'callbackUri': {'type': 'string'},
'authentication': common_types.SubscriptionAuthentication,
},
'required': ['objectType', 'objectInstanceIds', 'criteria', 'callbackUri'],
'additionalProperties': True,
}
# SOL003 6.5.2.12
PmJobModificationsRequest_V210 = {
'type': 'object',
'properties': {
'callbackUri': {'type': 'string'},
'authentication': common_types.SubscriptionAuthentication
},
'anyOf': [
{'required': ['callbackUri']},
{'required': ['authentication']}
],
'required': [],
'additionalProperties': True,
}

@ -133,6 +133,10 @@ class SolResource(object):
response = result.serialize(accept)
except Exception as ex:
result = SolErrorResponse(ex, request.best_match_language())
if type(self.controller).__name__ == 'VnfFmControllerV1':
result.headers['version'] = api_version.CURRENT_FM_VERSION
if type(self.controller).__name__ == 'VnfPmControllerV2':
result.headers['version'] = api_version.CURRENT_PM_VERSION
try:
response = result.serialize('application/problem+json')
except Exception:

@ -56,6 +56,14 @@ VNFM_OPTS = [
'connection error when sending a notification. '
'Period between retries is exponential starting '
'0.5 seconds up to a maximum of 60 seconds.')),
cfg.IntOpt('vnffm_alarm_page_size',
default=0, # 0 means no paging
help=_('Paged response size of the query result '
'for VNF Fault Management alarm.')),
cfg.IntOpt('vnfpm_pmjob_page_size',
default=0, # 0 means no paging
help=_('Paged response size of the query result for '
'VNF PM job.')),
# NOTE: This is for test use since it is convenient to be able to delete
# under development.
cfg.BoolOpt('test_enable_lcm_op_occ_delete',
@ -104,7 +112,28 @@ NFVO_OPTS = [
CONF.register_opts(NFVO_OPTS, 'v2_nfvo')
PROMETHEUS_PLUGIN_OPTS = [
cfg.BoolOpt('performance_management',
default=False,
help=_('Enable prometheus plugin performance management')),
cfg.IntOpt('reporting_period_margin',
default=1,
help=_('Some margin time for PM jos\'s reportingPeriod')),
cfg.BoolOpt('fault_management',
default=False,
help=_('Enable prometheus plugin fault management')),
cfg.BoolOpt('auto_scaling',
default=False,
help=_('Enable prometheus plugin autoscaling')),
]
CONF.register_opts(PROMETHEUS_PLUGIN_OPTS, 'prometheus_plugin')
def config_opts():
return [('v2_nfvo', NFVO_OPTS),
('v2_vnfm', VNFM_OPTS)]
('v2_vnfm', VNFM_OPTS),
('prometheus_plugin', PROMETHEUS_PLUGIN_OPTS)]

@ -67,3 +67,36 @@ def lock_vnf_instance(inst_arg, delay=False):
return wrapper
return operation_lock
def lock_resources(res_arg, delay=False):
def operation_lock(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
coord = coordination.COORDINATOR
# ensure coordination start
# NOTE: it is noop if already started.
coord.start()
sig = inspect.signature(func)
call_args = sig.bind(*args, **kwargs).arguments
res_id = res_arg.format(**call_args)
lock = coord.get_lock(res_id)
blocking = False if not delay else 10
# NOTE: 'with lock' is not used since it can't handle
# lock failed exception well.
if not lock.acquire(blocking=blocking):
LOG.debug("Locking resources %s failed.", res_id)
raise sol_ex.ResourcesOtherOperationInProgress(inst_id=res_id)
try:
LOG.debug("resources %s locked.", res_id)
return func(*args, **kwargs)
finally:
lock.release()
return wrapper
return operation_lock

@ -92,6 +92,11 @@ class SolHttpError422(SolException):
title = 'Unprocessable Entity'
class SolHttpError503(SolException):
status = 503
title = 'Service Unavailable'
class MethodNotAllowed(SolHttpError405):
message = _("Method %(method)s is not supported.")
@ -372,3 +377,53 @@ class HelmOperationFailed(SolHttpError422):
class HelmParameterNotFound(SolHttpError400):
message = _("Helm parameter for scale vdu %(vdu_name)s is not found.")
class AlarmNotFound(SolHttpError404):
message = _("Alarm %(alarm_id)s not found.")
class AckStateInvalid(SolHttpError409):
message = _("The ackState of alarm cannot specify the same value.")
class FmSubscriptionNotFound(SolHttpError404):
message = _("FmSubscription %(subsc_id)s not found.")
class PMJobNotExist(SolHttpError404):
message = _("The specified PM job does not exist.")
class PMReportNotExist(SolHttpError404):
message = _("The specified Performance Report does not exist.")
class PMJobInvalidRequest(SolHttpError400):
message = _("Invalid request")
class ResourcesOtherOperationInProgress(SolHttpError409):
message = _("Other LCM operation of resources %(inst_id)s "
"is in progress.")
# prometheus plugin
class PrometheusPluginNotEnabled(SolHttpError404):
message = _("%(name)s API is not enabled.")
class PrometheusPluginError(Exception):
pass
class PrometheusPluginSkipped(Exception):
pass
class PrometheusPluginValidationError(SolValidationError):
pass
class PrometheusSettingFailed(SolHttpError503):
message = _("Setting PM job on External Monitoring Tool failed.")

@ -0,0 +1,86 @@
# Copyright (C) 2022 Fujitsu
# 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.
from datetime import datetime
from oslo_log import log as logging
from oslo_utils import uuidutils
from tacker.sol_refactored.common import exceptions as sol_ex
from tacker.sol_refactored.common import fm_subscription_utils as subsc_utils
from tacker.sol_refactored.common import vnf_instance_utils as inst_utils
from tacker.sol_refactored import objects
LOG = logging.getLogger(__name__) # not used at the moment
def get_alarm(context, alarm_id):
alarm = objects.AlarmV1.get_by_id(context, alarm_id)
if alarm is None:
raise sol_ex.AlarmNotFound(alarm_id=alarm_id)
return alarm
def get_alarms_all(context, marker=None):
return objects.AlarmV1.get_all(context, marker)
def get_not_cleared_alarms(context, inst_id):
return objects.AlarmV1.get_by_filter(context, managedObjectId=inst_id)
def alarm_href(alarm_id, endpoint):
return f"{endpoint}/vnffm/v1/alarms/{alarm_id}"
def make_alarm_links(alarm, endpoint):
links = objects.AlarmV1_Links()
links.self = objects.Link(href=alarm_href(alarm.id, endpoint))
links.objectInstance = objects.Link(
href=inst_utils.inst_href(alarm.managedObjectId, endpoint))
return links
def make_alarm_notif_data(subsc, alarm, endpoint):
if alarm.obj_attr_is_set('alarmClearedTime'):
notif_data = objects.AlarmClearedNotificationV1(
id=uuidutils.generate_uuid(),
notificationType="AlarmClearedNotification",
subscriptionId=subsc.id,
timeStamp=datetime.utcnow(),
alarmId=alarm.id,
alarmClearedTime=alarm.alarmClearedTime,
_links=objects.AlarmClearedNotificationV1_Links(
alarm=objects.NotificationLink(
href=alarm_href(alarm.id, endpoint)),
subscription=objects.NotificationLink(
href=subsc_utils.subsc_href(subsc.id, endpoint))
)
)
else:
notif_data = objects.AlarmNotificationV1(
id=uuidutils.generate_uuid(),
notificationType="AlarmNotification",
subscriptionId=subsc.id,
timeStamp=datetime.utcnow(),
alarm=alarm,
_links=objects.AlarmNotificationV1_Links(
subscription=objects.NotificationLink(
href=subsc_utils.subsc_hr