volume.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. # Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Get auth string
  16. shell: echo -n {{ powervault_me4_username }}_{{ powervault_me4_password }} | sha256sum
  17. register: vol_auth_string
  18. changed_when: false
  19. ignore_errors: yes
  20. tags: install
  21. - name: Get session key
  22. uri:
  23. url: https://{{ inventory_hostname }}/api/login/{{ vol_auth_string.stdout | replace(" -", "") }}
  24. method: GET
  25. headers:
  26. {'datatype': 'json'}
  27. validate_certs: no
  28. register: vol_session_key
  29. tags: install
  30. - name: Add disk group in virtual pool
  31. uri:
  32. url: https://{{ inventory_hostname }}/api/add/disk-group/type/{{ powervault_me4_pool_type }}/disks/{{ powervault_me4_disk_range }}/level/{{ powervault_me4_raid_levels }}/pool/{{ powervault_me4_pool }}/{{ powervault_me4_disk_group_name }}
  33. method: GET
  34. body_format: json
  35. validate_certs: no
  36. use_proxy: no
  37. headers:
  38. {'sessionKey': "{{ vol_session_key.json.status[0].response }}", 'datatype':'json'}
  39. register: pv_disk1
  40. when: powervault_me4_pool_type|lower == "virtual"
  41. tags: install
  42. - name: Add disk group in linear pool
  43. uri:
  44. url: https://{{ inventory_hostname }}/api/add/disk-group/type/{{ powervault_me4_pool_type }}/disks/{{ powervault_me4_disk_range }}/level/{{ powervault_me4_raid_levels }}/{{ powervault_me4_disk_group_name }}
  45. method: GET
  46. body_format: json
  47. validate_certs: no
  48. use_proxy: no
  49. headers:
  50. {'sessionKey': "{{ vol_session_key.json.status[0].response }}", 'datatype':'json'}
  51. register: pv_disk2
  52. when: powervault_me4_pool_type|lower == "linear"
  53. tags: install
  54. - name: Assert if disk group created or not
  55. fail:
  56. msg: "{{ pv_disk1.json.status[0].response }}"
  57. when:
  58. - powervault_me4_pool_type|lower == "virtual"
  59. - pv_disk1.json.status[0] ['response-type'] == "Error"
  60. - name: Assert if disk group created or not
  61. fail:
  62. msg: "{{ pv_disk2.json.status[0].response }}"
  63. when:
  64. - powervault_me4_pool_type|lower == "linear"
  65. - pv_disk2.json.status[0] ['response-type'] == "Error"
  66. - name: Create volume1
  67. uri:
  68. url: https://{{ inventory_hostname }}/api/create/volume/size/{{ powervault_me4_volume_size }}/pool/{{ powervault_me4_pool }}/{{ powervault_me4_k8s_volume_name }}
  69. method: GET
  70. body_format: json
  71. validate_certs: no
  72. use_proxy: no
  73. headers:
  74. {'sessionKey': "{{ vol_session_key.json.status[0].response }}", 'datatype':'json'}
  75. register: pv_vol1
  76. when: powervault_me4_pool_type|lower == "virtual"
  77. tags: install
  78. - name: Create volume2
  79. uri:
  80. url: https://{{ inventory_hostname }}/api/create/volume/size/{{ powervault_me4_volume_size }}/pool/{{ powervault_me4_pool }}/{{ powervault_me4_slurm_volume_name }}
  81. method: GET
  82. body_format: json
  83. validate_certs: no
  84. use_proxy: no
  85. headers:
  86. {'sessionKey': "{{ vol_session_key.json.status[0].response }}", 'datatype':'json'}
  87. register: pv_vol2
  88. when: powervault_me4_pool_type|lower == "virtual"
  89. tags: install
  90. - name: Create volume1
  91. uri:
  92. url: https://{{ inventory_hostname }}/api/create/volume/size/{{ powervault_me4_volume_size }}/pool/{{ powervault_me4_disk_group_name }}/{{ powervault_me4_k8s_volume_name }}
  93. method: GET
  94. body_format: json
  95. validate_certs: no
  96. use_proxy: no
  97. headers:
  98. {'sessionKey': "{{ vol_session_key.json.status[0].response }}", 'datatype':'json'}
  99. register: pv_vol3
  100. when: powervault_me4_pool_type|lower == "linear"
  101. tags: install
  102. - name: Create volume2
  103. uri:
  104. url: https://{{ inventory_hostname }}/api/create/volume/size/{{ powervault_me4_volume_size }}/pool/{{ powervault_me4_disk_group_name }}/{{ powervault_me4_slurm_volume_name }}
  105. method: GET
  106. body_format: json
  107. validate_certs: no
  108. use_proxy: no
  109. headers:
  110. {'sessionKey': "{{ vol_session_key.json.status[0].response }}", 'datatype':'json'}
  111. register: pv_vol4
  112. when: powervault_me4_pool_type|lower == "linear"
  113. tags: install
  114. - name: Assert if k8s_volume created correctly
  115. fail:
  116. msg: "{{ pv_vol1.json.status[0].response }}"
  117. when:
  118. - powervault_me4_pool_type| lower == "virtual"
  119. - pv_vol1.json.status[0]['response-type'] == "Error"
  120. - name: Assert if slurm_volume created correctly
  121. fail:
  122. msg: "{{ pv_vol2.json.status[0].response }}"
  123. when:
  124. - powervault_me4_pool_type| lower == "virtual"
  125. - pv_vol2.json.status[0]['response-type'] == "Error"
  126. - name: Assert if k8s_volume created correctly
  127. fail:
  128. msg: "{{ pv_vol3.json.status[0].response }}"
  129. when:
  130. - powervault_me4_pool_type| lower == "linear"
  131. - pv_vol3.json.status[0]['response-type'] == "Error"
  132. - name: Assert if slurm_volume created correctly
  133. fail:
  134. msg: "{{ pv_vol4.json.status[0].response }}"
  135. when:
  136. - powervault_me4_pool_type|lower == "linear"
  137. - pv_vol4.json.status[0]['response-type'] == "Error"