[PDF] Preparations for vPDF support 15/50315/9
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Thu, 28 Dec 2017 22:24:41 +0000 (23:24 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Mon, 30 Apr 2018 15:48:08 +0000 (17:48 +0200)
- extend check-{jinja2,schema}.sh to scan vPDFs and construct
  proper IDF path for vPDFs;
- add support for '/' in PDF fields, by default filtered by j2
  template rendering;

SPEC changes:
- extend remote_management 'type' enum with 'libvirt';

SCHEMA changes:
- add new enum value 'libvirt' according to SPEC update;
- add separate handling of 'remote_management' for baremetal/virtual;
- remote_management 'versions' and 'mac_address' are mandatory for
  all but 'libvirt' (used to be mandatory for all);

Change-Id: Ib3f711cae807c3ab27920391402ba74844f155c3
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
config/pdf/pod1.encrypted.yaml
config/pdf/pod1.schema.yaml
config/pdf/pod1.yaml
config/utils/check-schema.sh
config/utils/generate_config.py

index b5c78b5..c251263 100644 (file)
@@ -54,7 +54,8 @@ jumphost:
   os: ubuntu-14.04
   remote_params: &remote_params
     # hardware management tool
-    type: {ipmi|amt}
+    type: {ipmi|amt|libvirt}
+    # array of supported versions, mandatory for all but 'libvirt'
     versions:
       - 1.0
       - 2.0
@@ -82,6 +83,7 @@ jumphost:
   remote_management:
     <<: *remote_params
     address: 10.4.7.3/24
+    # MAC address is mandatory for all BMC types but 'libvirt'
     mac_address: "10:23:45:67:89:AC"
   # physical interface list
   interfaces:
index 2a96d0b..33b2d8c 100644 (file)
@@ -69,25 +69,45 @@ definitions:
         additionalProperties: false
   remote_management:
     v1.0:
-      type: 'object'
       properties:
-        type:
-          type: 'string'
-          enum: ['ipmi', 'amt']
-        versions:
-          type: 'array'
-          items:
-            type: 'number'
-            enum: [1.0, 2.0]
         user:
           type: 'string'
         pass:
           type: 'string'
+        type:
+          type: 'string'
+        versions:
+          type: 'array'
         address:
-          $ref: '#/definitions/ip_address'
+          type: 'string'
         mac_address:
-          $ref: '#/definitions/mac_address'
-      required: ['type', 'versions', 'user', 'pass', 'address', 'mac_address']
+          type: 'string'
+      # These subsections are best validated separately for baremetal/virtual
+      oneOf:
+        - type: 'object'
+          properties:
+            type:
+              type: 'string'
+              enum: ['ipmi', 'amt']
+            versions:
+              type: 'array'
+              items:
+                type: 'number'
+                enum: [1.0, 2.0]
+            address:
+              $ref: '#/definitions/ip_address'
+            mac_address:
+              $ref: '#/definitions/mac_address'
+          required: ['type', 'versions', 'address', 'mac_address']
+        - type: 'object'
+          properties:
+            type:
+              type: 'string'
+              enum: ['libvirt']
+            address:
+              type: 'string'  # Loose validation of libvirt URI for now
+          required: ['type', 'address']
+      required: ['user', 'pass']
       additionalProperties: false
   interfaces:
     v1.0:
index d0cd793..4ea751e 100644 (file)
@@ -54,7 +54,8 @@ jumphost:
   os: ubuntu-14.04
   remote_params: &remote_params
     # hardware management tool
-    type: {ipmi|amt}
+    type: {ipmi|amt|libvirt}
+    # array of supported versions, mandatory for all but 'libvirt'
     versions:
       - 1.0
       - 2.0
@@ -63,6 +64,7 @@ jumphost:
   remote_management:
     <<: *remote_params
     address: 10.4.7.3/24
+    # MAC address is mandatory for all BMC types but 'libvirt'
     mac_address: "10:23:45:67:89:AC"
   # physical interface list
   interfaces:
index 0cdc6f2..041c030 100755 (executable)
@@ -16,8 +16,9 @@ RC=0
 
 SUMMARY+=";;PDF;IDF;\n"
 while IFS= read -r lab_config; do
+    idf_config="$(dirname "${lab_config}")/idf-$(basename "${lab_config}")"
     pdf_cmd="${VALIDATE_SCHEMA} -s ${PDF_SCHEMA} -y ${lab_config}"
-    idf_cmd="${VALIDATE_SCHEMA} -s ${IDF_SCHEMA} -y ${lab_config/pod/idf-pod}"
+    idf_cmd="${VALIDATE_SCHEMA} -s ${IDF_SCHEMA} -y ${idf_config}"
     echo "###################### ${lab_config} ######################"
     pdf_out=$(${pdf_cmd} 2>&1 | sed 's|ENC\[PKCS.*\][\\n]*|opnfv|g')
     if [ -z "${pdf_out}" ]; then
@@ -29,7 +30,7 @@ while IFS= read -r lab_config; do
         echo "${pdf_out}"
         echo "[PDF] [ERROR] ${pdf_cmd}"
     fi
-    if [ ! -f "${lab_config/pod/idf-pod}" ]; then
+    if [ ! -f "${idf_config}" ]; then
         SUMMARY+="-;\n"
     elif ${idf_cmd}; then
         SUMMARY+="OK;\n"
@@ -40,7 +41,7 @@ while IFS= read -r lab_config; do
         echo "[IDF] [ERROR] ${idf_cmd}"
     fi
     echo ''
-done < <(find 'labs' -name 'pod*.yaml')
+done < <(find 'labs' -name 'pod*.yaml' -or -name 'virtual*.yaml')
 
 cat <<EOF
 ###################### Schema Validation Matrix ######################
index 11d42ca..93e839b 100755 (executable)
@@ -55,7 +55,7 @@ try:
     DICT['details']
 except (NameError, TypeError) as ex:
     with open(ARGS.yaml) as _:
-        DICT = yaml.load(_, Loader=LOADER)
+        DICT = yaml.load(_.read().replace('/', '__slash__'), Loader=LOADER)
 
 # If an installer descriptor file (IDF) exists, include it (temporary)
 IDF_PATH = '/idf-'.join(split(ARGS.yaml))
@@ -69,7 +69,7 @@ if exists(IDF_PATH):
 
 for _j2 in ARGS.jinja2:
     TEMPLATE = ENV.get_template(_j2)
-    OUTPUT = TEMPLATE.render(conf=DICT)
+    OUTPUT = TEMPLATE.render(conf=DICT).replace('__slash__', '/')
     # Render template and write generated conf to file or stdout
     if ARGS.batch:
         if _j2.endswith('.j2'):