Merge "Fix the type of checksum about v2 objects"
This commit is contained in:
commit
d619851fe3
@ -28,6 +28,7 @@ def register_all():
|
||||
# function in order for it to be registered by services that may
|
||||
# need to receive it via RPC.
|
||||
objects_root = 'tacker.sol_refactored.objects'
|
||||
__import__(objects_root + '.common.checksum')
|
||||
__import__(objects_root + '.common.cp_protocol_data')
|
||||
__import__(objects_root + '.common.crypt_key')
|
||||
__import__(objects_root + '.common.ext_link_port_data')
|
||||
|
31
tacker/sol_refactored/objects/common/checksum.py
Normal file
31
tacker/sol_refactored/objects/common/checksum.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (C) 2024 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.objects import base
|
||||
from tacker.sol_refactored.objects import fields
|
||||
|
||||
|
||||
# NFV-SOL 013
|
||||
# - v3.3.1 7.1.7
|
||||
@base.TackerObjectRegistry.register
|
||||
class Checksum(base.TackerObject, base.TackerObjectDictCompat):
|
||||
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
|
||||
fields = {
|
||||
'algorithm': fields.StringField(nullable=False),
|
||||
'hash': fields.StringField(nullable=False)
|
||||
}
|
@ -103,11 +103,3 @@ class Uri(ovoo_fields.String):
|
||||
|
||||
class UriField(AutoTypedField):
|
||||
AUTO_TYPE = Uri()
|
||||
|
||||
|
||||
class Checksum(ovoo_fields.String):
|
||||
pass
|
||||
|
||||
|
||||
class ChecksumField(AutoTypedField):
|
||||
AUTO_TYPE = Checksum()
|
||||
|
@ -28,7 +28,7 @@ class VnfPackageArtifactInfoV2(base.TackerObject, base.TackerObjectDictCompat):
|
||||
fields = {
|
||||
'artifactPath': fields.StringField(nullable=True),
|
||||
'artifactURI': fields.UriField(nullable=True),
|
||||
'checksum': fields.ChecksumField(nullable=False),
|
||||
'checksum': fields.ObjectField('Checksum', nullable=False),
|
||||
'isEncrypted': fields.BooleanField(nullable=False),
|
||||
'nonManoArtifactSetId': fields.StringField(nullable=True),
|
||||
'artifactClassification': fields.EnumField(
|
||||
|
@ -31,7 +31,7 @@ class VnfPackageSoftwareImageInfoV2(base.TackerObject,
|
||||
'name': fields.StringField(nullable=False),
|
||||
'provider': fields.StringField(nullable=False),
|
||||
'version': fields.VersionField(nullable=False),
|
||||
'checksum': fields.ChecksumField(nullable=False),
|
||||
'checksum': fields.ObjectField('Checksum', nullable=False),
|
||||
'isEncrypted': fields.BooleanField(nullable=False),
|
||||
'containerFormat': fields.EnumField(
|
||||
valid_values=[
|
||||
|
@ -35,7 +35,7 @@ class VnfPkgInfoV2(base.TackerObject, base.TackerObjectDictCompat):
|
||||
'vnfdVersion': fields.VersionField(nullable=True),
|
||||
'compatibleSpecificationVersions': fields.ListOfVersionsField(
|
||||
nullable=True),
|
||||
'checksum': fields.ChecksumField(nullable=True),
|
||||
'checksum': fields.ObjectField('Checksum', nullable=True),
|
||||
'packageSecurityOption': fields.EnumField(
|
||||
valid_values=[
|
||||
'OPTION_1',
|
||||
|
@ -26,7 +26,7 @@ class VnfStateSnapshotInfoV2(base.TackerObject, base.TackerObjectDictCompat):
|
||||
VERSION = '1.0'
|
||||
|
||||
fields = {
|
||||
'checksum': fields.ChecksumField(nullable=False),
|
||||
'checksum': fields.ObjectField('Checksum', nullable=False),
|
||||
'isEncrypted': fields.BooleanField(nullable=False),
|
||||
'metadata': fields.KeyValuePairsField(nullable=True),
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
# 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 hashlib
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
@ -32,3 +33,25 @@ class VnfPackage:
|
||||
"usageState": "NOT_IN_USE"
|
||||
}
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
def make_get_vnf_pkg_info_resp_with_checksum(vnfdid):
|
||||
data = {
|
||||
"id": uuidutils.generate_uuid(),
|
||||
"vnfdId": vnfdid,
|
||||
"vnfProvider": "Company",
|
||||
"vnfProductName": "Sample VNF",
|
||||
"vnfSoftwareVersion": "1.0",
|
||||
"vnfdVersion": "1.0",
|
||||
"onboardingState": "ONBOARDED",
|
||||
"operationalState": "ENABLED",
|
||||
"usageState": "NOT_IN_USE",
|
||||
"checksum":
|
||||
{"algorithm": "SHA-512", "hash": hashlib.sha512().hexdigest()},
|
||||
"softwareImages": [{"id": "test", "name": "cirros-0.6.2",
|
||||
"checksum": {"algorithm": "sha-512",
|
||||
"hash": hashlib.sha512().hexdigest()}}],
|
||||
"additionalArtifacts": [{"checksum": {"algorithm": "sha-512",
|
||||
"hash": hashlib.sha512().hexdigest()}, "isEncrypted": True}]
|
||||
}
|
||||
return data
|
||||
|
@ -1809,6 +1809,17 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
if is_nfvo:
|
||||
self._register_vnf_package_mock_response(
|
||||
new_image_vnfd_id, new_image_zip_path)
|
||||
# Overwrite "Individual VNF package" response with checksum
|
||||
self.set_server_callback(
|
||||
'GET',
|
||||
os.path.join('/vnfpkgm/v2/onboarded_vnf_packages',
|
||||
new_image_vnfd_id),
|
||||
status_code=200,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
response_body=(fake_vnfpkgm_v2.VnfPackage.
|
||||
make_get_vnf_pkg_info_resp_with_checksum(
|
||||
new_image_vnfd_id))
|
||||
)
|
||||
g_image_id_1, g_image_id_2 = self.glance_create_image(
|
||||
instantiate_req.get("vimConnectionInfo").get("vim1"),
|
||||
image_path, sw_data, inst_id, num_vdu=2)
|
||||
|
@ -45,8 +45,14 @@ _vnfpkg_body_example = {
|
||||
"vnfdVersion": "1.0",
|
||||
"onboardingState": "ONBOARDED",
|
||||
"operationalState": "ENABLED",
|
||||
"usageState": "NOT_IN_USE"
|
||||
"usageState": "NOT_IN_USE",
|
||||
"checksum": {"algorithm": "SHA-512", "hash": "test"},
|
||||
"softwareImages": [{"id": "test", "name": "cirros-0.6.2",
|
||||
"checksum": {"algorithm": "sha-512", "hash": "test"}}],
|
||||
"additionalArtifacts": [{"checksum": {"algorithm": "sha-512",
|
||||
"hash": "test"}, "isEncrypted": True}]
|
||||
}
|
||||
|
||||
_grant_res = {
|
||||
'id': 'b94d05c9-eb45-4855-9132-20e1d3e7cecf',
|
||||
'vnfInstanceId': '2d004394-d0f0-406d-845a-2b148f91039a',
|
||||
|
Loading…
x
Reference in New Issue
Block a user