From bd7eac8ddf51acb1ddb1d10a5d4c90bafb07b0c0 Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Sat, 15 Sep 2018 00:07:27 +0800 Subject: [PATCH] Updated to new hpa schema Change-Id: I2e546f4a3b56bfb331207034c285323728a3b774 Issue-ID: VNFSDK-326 Signed-off-by: Lianhao Lu --- tests/resources/hpa.csar | Bin 7984 -> 7990 bytes tests/resources/hpa_bad.csar | Bin 7984 -> 7991 bytes vnfsdk_pkgtools/validator/hpa.yaml | 304 ++++++++++----------- vnfsdk_pkgtools/validator/toscaparser_validator.py | 3 + 4 files changed, 155 insertions(+), 152 deletions(-) diff --git a/tests/resources/hpa.csar b/tests/resources/hpa.csar index a9558aea931357d2eb103011151982da0489231b..61e53bc6784d5962a1a882147dac3eda6b028645 100644 GIT binary patch delta 1218 zcmV;z1U>t(KDIuv>lY1(yDm*s%K4sO1ONaqllT`oe>Ae3WkKh+T!uD4vlw&gm!cqO zlCro+q()M5yrBPmhtwsMYC9d)B7CvTbNkL+vdU0`8Bc^1Rw!w3#kGNlIkKK)L|$YZ z??|5E8IDIew}cT(<|BkG2O6;)OOo?Bs;(Bl<7%@FDV?_QEQ-e=g_Jf`dXAJN#fWi3 zwJ5A-f9>>)z_!xXI9n&45wkpUP(~xG3YDqN4z~&&lT?g%7hVjZtHSBRdHIOpr_iGE zh`FuFfM{3n#@om#Fp*5EXvNB_qTwjCD!8_yRq0Mfc3guxWffJ~9DNo=b@rtrTV2Wr zoP)YKN=RmSM`=ZH8^!jVAYu$vQ~*APhx(oRe}EYw!kFg9e4{3$)vk#GHx~o8>=%4Y z3koDLU=tgeb7_YTwI|6Gu|jUJlcLtgnH^*nkKp99{%>u&fIOiMw^+!c1glk$J`jx2 z*G{Gq+Lk19S=}oA01}q#giww(|GN~LJKUxp?7C)+7OLvmHf7<84(CKdP?X-yT{8O~ ze@yQ0uJ6!?#YOM-`>p%fwp{lTG+^C;>V;$8Q>ru~Q^!~DOrVYi5+b_COIn3Q-Fq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FhB{I=ZVA}({ zPIVZ$UHNuTIPCw!B5o8`73A3XOT@c>o{-%Gg?yLMd-U@OxjGvze}y(OxraBz zA5f|B(2wI^oSFgO?m1jnYpwZ(Fx5;q*u}3Iq2paEv+kJd)PXbq|1OxvN5^||#*1ZRFQXq3D1WEk zyEQ?&$(eln;_Md3p4HcgV6b+GJ?k(JRODW?E`14*;Bp~2UC26fW0iQiUmauvI=r_` z{PZ4N@;PogFXDGhaL0Gw4351wO+BY+<{_P*L~;0$6z;kXyx(`rhf5DDd`ABOP)h>@ z6aWAK2mrQ*3bT+L1Og4Lh6+up;}n-!1ONaGlc63(1Ga_=lj$BC0(=~kpBx(&P)h{{ V000002LJ~E{{a918yx@u006usM+N`@ diff --git a/vnfsdk_pkgtools/validator/hpa.yaml b/vnfsdk_pkgtools/validator/hpa.yaml index 98ac42b..6b71feb 100644 --- a/vnfsdk_pkgtools/validator/hpa.yaml +++ b/vnfsdk_pkgtools/validator/hpa.yaml @@ -7,238 +7,238 @@ schemas: # hpa key name cpuModelSpecificationBinding: # json encoded key name: reg expression for the valid value - schema-version: &any '.*' - schema-location: *any - platform-id: &generic 'generic' + schemaVersion: &any '.*' + schemaSelector: *any + hardwarePlatform: &generic 'generic' mandatory: &bool 'true|false|TRUE|FALSE|True|False' - configuration-value: 'strictBinding|equalOrBetterBinding' + configurationValue: '^(strictBinding|equalOrBetterBinding)$' instructionSetRequirements: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any simultaneousMultiThreading: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'enabled|disabled' + configurationValue: '^(enabled|disabled)$' hypervisorConfiguration: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any computeRas: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'pciDetectedAndCorrectedErrors|pciDetectedAndUncorrectedErrors' + configurationValue: '^(pciDetectedAndCorrectedErrors|pciDetectedAndUncorrectedErrors)$' cpuModel: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any directIoAccessToCache: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any accelerator: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any measuredLaunchEnvironment: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any secureEnclave: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any numVirtualCpu: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+' + configurationValue: &pos_int '^\d+$' virtualCpuClock: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+\s*(Hz|kHz|MHz|GHz)' + configurationValue: '^\d+\s*(Hz|kHz|MHz|GHz)$' logicalCpuPinningPolicy: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'dedicated|shared' + configurationValue: '^(dedicated|shared)$' logicalCpuThreadPinningPolicy: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'require|isolate|prefer' + configurationValue: '^(require|isolate|prefer)$' vduMemRequirements: memoryPageSize: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+\s*(B|kB|KB|KiB|MB|MiB|GB|GiB|TB|TiB)' + configurationValue: &mem_size '^\d+\s*(B|kB|KB|KiB|MB|MiB|GB|GiB|TB|TiB)$' numberOfPages: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+' + configurationValue: *pos_int memoryAllocationPolicy: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'strictLocalAffinity|preferredLocalAffinity' + configurationValue: '^(strictLocalAffinity|preferredLocalAffinity)$' memoryType: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any memorySpeed: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any memoryRas: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any memoryBandwidth: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+' + configurationValue: *pos_int processorCacheAllocationType: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any processorCacheAllocationSize: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any vduStorageRequirements: storageIops: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+' + configurationValue: *pos_int storageResilencyMechanism: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'erasure|tripleReplication' + configurationValue: '^(erasure|tripleReplication)$' processorCacheAllocationSize: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any processorCacheAllocationSize: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any logicalNodeComputeMemoryRequirements: numberCpu: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+' + configurationValue: *pos_int localNumaMemorySize: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+\s*(B|kB|KB|KiB|MB|MiB|GB|GiB|TB|TiB)' + configurationValue: *mem_size logicalNodeIoRequirements: pciVendorId: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any pciDeviceId: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any pciNumDevices: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: '\d+' + configurationValue: *pos_int pciAddress: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any pciDeviceLocalToNumaNode: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'required|notRequired' + configurationValue: '^(required|notRequired)$' networkInterfaceRequirements: nicFeature: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any dataProcessingAccelerationLibrary: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'DPDK|dpdk' + configurationValue: '^(DPDK|dpdk)$' dataProcessingAccelerationLibraryVersion: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: *any + configurationValue: *any interfaceType: - schema-version: *any - schema-location: *any - platform-id: *generic + schemaVersion: *any + schemaSelector: *any + hardwarePlatform: *generic mandatory: *bool - configuration-value: 'virtio|PCI-Passthrough|SR-IOV|E1000|RTL8139|PCNET' + configurationValue: '^(virtio|PCI-Passthrough|SR-IOV|E1000|RTL8139|PCNET)$' mappings: # mapping between property value of a tosca node type and the valid hpa schema # type: tosca node type diff --git a/vnfsdk_pkgtools/validator/toscaparser_validator.py b/vnfsdk_pkgtools/validator/toscaparser_validator.py index dfe44b8..533cc00 100644 --- a/vnfsdk_pkgtools/validator/toscaparser_validator.py +++ b/vnfsdk_pkgtools/validator/toscaparser_validator.py @@ -138,6 +138,9 @@ class ToscaparserValidator(validator.ValidatorBase): if attr not in hpa_schema[key]: msg = "node %s, HPA key %s: %s is NOT valid HPA attribute" raise HpaValueError(msg % (refkey, key, attr)) + if not isinstance(val, basestring): + msg = ("node %s, HPA key %s, attr %s: %s is not a string attr value") + raise HpaValueError(msg % (refkey, key, attr, str(val).encode('ascii','replace'))) attr_schema = hpa_schema[key][attr] if not re.match(attr_schema, str(val)): msg = ("node %s, HPA key %s, attr %s: %s is not a valid HPA " -- 2.16.6