You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hard_disks_set.json.j2 1.1KB

6 年之前
123456789101112131415161718192021222324252627282930313233343536373839
  1. [
  2. {% for hd in hard_disks %}
  3. {
  4. "name": "{{hd.name}}",
  5. "device": "{{hd.device}}",
  6. "label_type": "{{ hd.label_type }}",
  7. "partitions": [
  8. {% for part in hd.partitions %}
  9. {% if hd.label_type == 'gpt' %}
  10. {% if not part.name is defined and ( part.prefix is defined or part.suffix is defined ) %}
  11. {% set part = part | combine({ 'name': hd.name }) %}
  12. {% if part.prefix is defined %}
  13. {% set part = part | combine({ 'name': part.prefix+part.name }) %}
  14. {% endif %}
  15. {% if part.suffix is defined %}
  16. {% set part = part | combine({ 'name': part.name+part.suffix }) %}
  17. {% endif %}
  18. {% endif %}
  19. {% if part.name is defined and not part.device is defined %}
  20. {% set part = part | combine({ 'device': '/dev/disk/by-partlabel/'+part.name }) %}
  21. {% endif %}
  22. {% elif hd.label_type == 'msdos' and not part.device is defined %}
  23. {% set part = part | combine({ 'device': hd.device+(loop.index|string) }) %}
  24. {% endif %}
  25. {{part|to_json}},
  26. {% endfor %}
  27. ]
  28. },
  29. {% endfor %}
  30. ]