Skip to content

Commit 224e926

Browse files
committed
Update virtual disk example to use virtual_disk module
Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent 9331278 commit 224e926

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

examples/virtual_disk.yml

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,34 @@
1010
image_remove_old: false
1111

1212
tasks:
13-
# # ------------------------------------------------------
13+
# ------------------------------------------------------
1414
- name: Download Virtual Disk {{ image_filename }} from URL
1515
ansible.builtin.get_url: # TODO: what if file doesn't download completely?
1616
url: "{{ image_url }}"
1717
dest: /tmp/{{ image_filename }}
1818

19-
- name: Get the Virtual Disk size
20-
ansible.builtin.stat:
21-
path: /tmp/{{ image_filename }}
22-
register: disk_file_info
23-
24-
# TODO
25-
# - name: (Optionally) remove existing Virtual Disk {{ image_filename }} from HyperCore
26-
# scale_computing.hypercore.api:
27-
# action: get
28-
# cluster_instance:
29-
# host: "{{ sc_host }}"
30-
# username: "{{ sc_username }}"
31-
# password: "{{ sc_password }}"
32-
# endpoint: "/rest/v1/VirtualDisk"
33-
# register: virtualDiskResult
19+
- name: (Optionally) remove existing Virtual Disk {{ image_filename }} from HyperCore
20+
when: image_remove_old | bool
21+
scale_computing.hypercore.virtual_disk:
22+
name: "{{ item }}"
23+
state: absent
24+
loop:
25+
- "uploading-{{ image_filename }}"
26+
- "{{ image_filename }}"
3427

3528
# ------------------------------------------------------
3629
- name: Upload Virtual Disk {{ image_filename }} to HyperCore
37-
scale_computing.hypercore.api:
38-
action: put
39-
endpoint: /rest/v1/VirtualDisk/upload
40-
data:
41-
filename: "{{ image_filename }}"
42-
filesize: "{{ disk_file_info.stat.size }}"
30+
scale_computing.hypercore.virtual_disk:
4331
source: /tmp/{{ image_filename }}
44-
register: uploadResult
32+
name: "{{ image_filename }}"
33+
state: present
4534

4635
# ------------------------------------------------------
4736
- name: Get Information About the uploaded Virtual Disk in HyperCore
48-
scale_computing.hypercore.api:
49-
action: get
50-
endpoint: /rest/v1/VirtualDisk/{{ uploadResult.record.createdUUID }}
37+
scale_computing.hypercore.virtual_disk_info:
38+
name: "{{ image_filename }}"
5139
register: result
5240

5341
- name: Show uploaded disk info
5442
debug:
55-
var: result.record[0]
43+
var: result.records[0]

0 commit comments

Comments
 (0)