Updated to new hpa schema

Change-Id: I2e546f4a3b56bfb331207034c285323728a3b774
Issue-ID: VNFSDK-326
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
diff --git a/tests/resources/hpa.csar b/tests/resources/hpa.csar
index a9558ae..61e53bc 100644
--- a/tests/resources/hpa.csar
+++ b/tests/resources/hpa.csar
Binary files differ
diff --git a/tests/resources/hpa_bad.csar b/tests/resources/hpa_bad.csar
index 4431d61..45bdef2 100644
--- a/tests/resources/hpa_bad.csar
+++ b/tests/resources/hpa_bad.csar
Binary files differ
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 @@
       # 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 @@
                 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 "