Fix for package error during vnflcm creation
Execution "openstack vnflcm create" raises some package errors. In order to avoid them, the exception process in vnflcm creation is fixed. Closes-bug: #1898963 Closes-bug: #1899112 Closes-bug: #1899134 Additional Information: --------------------------------------- - vnf_lcm_subscription.id was decoded. The code we developed in advance was created on the premise of varbinary and there was an unmatch, therefore, at first, the DB type was matched. To modify the code correctly, id decode was removed. - Spec (Support LCM notifications for VNF based on ETSI NFV-SOL specification) There was a discrepancy with the content and I fixed the registered migration, but the procedure was incorrect, so it was restored. - Spec (Support LCM notifications for VNF based on ETSI NFV-SOL specification) I found that some columns were not added to the DB due to a mismatch with the contents, so I am adding a new migration file. Also, since the type definition was different for the already registered columns, it was also corrected. Change-Id: I0ee9d7e1e0c4ea26dd5894ad4fca302fe9bfd4d1
This commit is contained in:
parent
25f93312c1
commit
0b4b67129e
@ -154,7 +154,7 @@ class ViewBuilder(base.BaseViewBuilder):
|
||||
if isinstance(vnf_lcm_subscription.id, str):
|
||||
decode_id = vnf_lcm_subscription.id
|
||||
else:
|
||||
decode_id = vnf_lcm_subscription.id.decode()
|
||||
decode_id = vnf_lcm_subscription.id
|
||||
return {
|
||||
"_links": {
|
||||
"self": {
|
||||
@ -168,12 +168,12 @@ class ViewBuilder(base.BaseViewBuilder):
|
||||
if 'filter' in vnf_lcm_subscription:
|
||||
filter_dict = json.loads(vnf_lcm_subscription.filter)
|
||||
return {
|
||||
'id': vnf_lcm_subscription.id.decode(),
|
||||
'id': vnf_lcm_subscription.id,
|
||||
'filter': filter_dict,
|
||||
'callbackUri': vnf_lcm_subscription.callback_uri.decode(),
|
||||
}
|
||||
return {
|
||||
'id': vnf_lcm_subscription.id.decode(),
|
||||
'id': vnf_lcm_subscription.id,
|
||||
'callbackUri': vnf_lcm_subscription.callback_uri.decode(),
|
||||
}
|
||||
else:
|
||||
|
@ -335,7 +335,7 @@ class VnfLcmController(wsgi.Controller):
|
||||
placement_attr=placement_attr,
|
||||
status=constants.INACTIVE,
|
||||
error_reason=None,
|
||||
deleted_at=datetime.min)
|
||||
deleted_at=datetime.datetime.min)
|
||||
context.session.add(vnf_db)
|
||||
for key, value in attributes.items():
|
||||
arg = vnfm_db.VNFAttribute(
|
||||
@ -421,6 +421,7 @@ class VnfLcmController(wsgi.Controller):
|
||||
vnf_product_name=vnfd.vnf_product_name,
|
||||
vnf_software_version=vnfd.vnf_software_version,
|
||||
vnfd_version=vnfd.vnfd_version,
|
||||
vnf_pkg_id=vnfd.package_uuid,
|
||||
tenant_id=request.context.project_id,
|
||||
vnf_metadata=req_body.get('metadata'))
|
||||
|
||||
@ -442,6 +443,9 @@ class VnfLcmController(wsgi.Controller):
|
||||
# roll back db changes
|
||||
self._destroy_vnf(context, vnf_instance)
|
||||
vnf_instance.destroy(context)
|
||||
if 'vnf_package' not in locals():
|
||||
LOG.error("vnf_package is not assigned")
|
||||
else:
|
||||
self._update_package_usage_state(context, vnf_package)
|
||||
|
||||
# create notification data
|
||||
|
@ -1483,20 +1483,20 @@ class Conductor(manager.Manager):
|
||||
|
||||
# Notification shipping
|
||||
for line in vnf_lcm_subscriptions:
|
||||
notification['subscriptionId'] = line.id.decode()
|
||||
notification['subscriptionId'] = line.id
|
||||
if (notification.get('notificationType') ==
|
||||
'VnfLcmOperationOccurrenceNotification'):
|
||||
notification['_links'] = {}
|
||||
notification['_links']['subscription'] = {}
|
||||
notification['_links']['subscription']['href'] = \
|
||||
CONF.vnf_lcm.endpoint_url + \
|
||||
"/vnflcm/v1/subscriptions/" + line.id.decode()
|
||||
"/vnflcm/v1/subscriptions/" + line.id
|
||||
else:
|
||||
notification['links'] = {}
|
||||
notification['links']['subscription'] = {}
|
||||
notification['links']['subscription']['href'] = \
|
||||
CONF.vnf_lcm.endpoint_url + \
|
||||
"/vnflcm/v1/subscriptions/" + line.id.decode()
|
||||
"/vnflcm/v1/subscriptions/" + line.id
|
||||
notification['timeStamp'] = datetime.datetime.utcnow(
|
||||
).isoformat()
|
||||
try:
|
||||
|
@ -1 +1 @@
|
||||
2c5211036579
|
||||
d25c7c865ce8
|
||||
|
@ -0,0 +1,85 @@
|
||||
# Copyright 2020 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.
|
||||
#
|
||||
|
||||
# flake8: noqa: E402
|
||||
|
||||
"""mod_vnflcm_subscription
|
||||
|
||||
Revision ID: d25c7c865ce8
|
||||
Revises: 2c5211036579
|
||||
Create Date: 2020-10-15 14:27:04.946002
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd25c7c865ce8'
|
||||
down_revision = '2c5211036579'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from tacker.db import types
|
||||
|
||||
from tacker.db import migration
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
|
||||
op.alter_column('vnf_lcm_filters', 'subscription_uuid',
|
||||
type_=types.Uuid(length=36), existing_type=sa.String(length=255),
|
||||
nullable=False)
|
||||
|
||||
sta_str = "json_unquote(json_extract('filter','$.operationTypes'))"
|
||||
op.add_column(
|
||||
'vnf_lcm_filters',
|
||||
sa.Column('operation_types',
|
||||
sa.LargeBinary(length=65536),
|
||||
sa.Computed(sta_str)))
|
||||
|
||||
op.add_column(
|
||||
'vnf_lcm_filters',
|
||||
sa.Column('operation_types_len',
|
||||
sa.Integer,
|
||||
sa.Computed("ifnull(json_length('operation_types'),0)")))
|
||||
|
||||
op.drop_column('vnf_lcm_filters', 'operation_states')
|
||||
op.drop_column('vnf_lcm_filters', 'operation_states_len')
|
||||
|
||||
op.alter_column('vnf_lcm_op_occs', 'operation_state',
|
||||
type_=sa.String(length=16), existing_type=sa.String(length=255))
|
||||
|
||||
op.alter_column('vnf_lcm_op_occs', 'operation',
|
||||
type_=sa.String(length=16),existing_type=sa.String(length=255))
|
||||
|
||||
op.add_column('vnf_lcm_op_occs',
|
||||
sa.Column('is_cancel_pending', sa.Boolean, nullable=False)),
|
||||
|
||||
op.add_column('vnf_lcm_op_occs',
|
||||
sa.Column('resource_changes', sa.JSON(), nullable=True))
|
||||
|
||||
op.add_column('vnf_lcm_op_occs',
|
||||
sa.Column('error_point', sa.Integer, nullable=True))
|
||||
|
||||
op.add_column('vnf_lcm_op_occs',
|
||||
sa.Column('changed_info', sa.JSON(), nullable=True))
|
||||
|
||||
op.add_column('vnf_lcm_op_occs',
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False))
|
||||
|
||||
op.add_column('vnf_lcm_op_occs',
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True))
|
||||
|
||||
op.add_column('vnf_lcm_op_occs',
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True))
|
||||
|
||||
pass
|
@ -244,7 +244,7 @@ def _vnf_lcm_subscriptions_create(context, values, filter):
|
||||
operation_type=operation_type)
|
||||
|
||||
if vnf_lcm_subscriptions_id:
|
||||
raise Exception("303" + vnf_lcm_subscriptions_id.id.decode())
|
||||
raise Exception("303" + vnf_lcm_subscriptions_id)
|
||||
|
||||
_add_filter_data(context, values.id, filter)
|
||||
|
||||
@ -253,7 +253,7 @@ def _vnf_lcm_subscriptions_create(context, values, filter):
|
||||
callbackUri)
|
||||
|
||||
if vnf_lcm_subscriptions_id:
|
||||
raise Exception("303" + vnf_lcm_subscriptions_id.id.decode())
|
||||
raise Exception("303" + vnf_lcm_subscriptions_id.id)
|
||||
_add_filter_data(context, values.id, {})
|
||||
|
||||
return values
|
||||
|
@ -554,8 +554,6 @@ class VnfPackage(base.TackerObject, base.TackerPersistentObject,
|
||||
# check if vnf package is used by any vnf instances.
|
||||
query = context.session.query(
|
||||
func.count(models.VnfInstance.id)).\
|
||||
filter_by(
|
||||
instantiation_state=fields.VnfInstanceState.INSTANTIATED).\
|
||||
filter_by(tenant_id=self.tenant_id).\
|
||||
filter_by(vnfd_id=self.vnfd.vnfd_id).\
|
||||
filter_by(deleted=False)
|
||||
|
@ -130,7 +130,7 @@ class TestConductor(SqlTestCase, unit_base.FixturedTestCase):
|
||||
self.subscription_authentication = json.dumps(
|
||||
auth_params).encode()
|
||||
|
||||
self.id = uuidsentinel.lcm_subscription_id.encode()
|
||||
self.id = uuidsentinel.lcm_subscription_id
|
||||
self.callback_uri = 'https://localhost/callback'.encode()
|
||||
|
||||
def __getattr__(self, name):
|
||||
|
@ -302,8 +302,9 @@ class VnfLcmDriver(abstract_driver.VnfInstanceAbstractDriver):
|
||||
vim_connection_info, instantiate_vnf_req):
|
||||
vnfd_dict = vnflcm_utils._get_vnfd_dict(context, vnf_instance.vnfd_id,
|
||||
instantiate_vnf_req.flavour_id)
|
||||
base_hot_dict, nested_hot_dict = vnflcm_utils. \
|
||||
get_base_nest_hot_dict(context,
|
||||
base_hot_dict, nested_hot_dict = \
|
||||
vnflcm_utils.get_base_nest_hot_dict(
|
||||
context,
|
||||
instantiate_vnf_req.flavour_id,
|
||||
vnf_instance.vnfd_id)
|
||||
vnf_package_path = None
|
||||
|
@ -163,8 +163,9 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
|
||||
|
||||
if user_data_path is not None and user_data_class is not None:
|
||||
LOG.info('Execute user data and create heat-stack.')
|
||||
base_hot_dict, nested_hot_dict = vnflcm_utils. \
|
||||
get_base_nest_hot_dict(context,
|
||||
base_hot_dict, nested_hot_dict = \
|
||||
vnflcm_utils.get_base_nest_hot_dict(
|
||||
context,
|
||||
inst_req_info.flavour_id,
|
||||
vnf_instance.vnfd_id)
|
||||
if base_hot_dict is None:
|
||||
|
Loading…
Reference in New Issue
Block a user