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: Ib74305f0b1da4eb8d996ebae400e75902aaa1321changes/48/854348/27
parent
46da7f8f59
commit
d1a23a3c28
@ -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'
|
@ -1 +1 @@
|
||||
85c06a0714b7
|
||||
de8d835ae776
|
||||
|
@ -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'
|
||||
)
|
@ -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
|
@ -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,
|
||||
}
|
@ -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 |