-
Notifications
You must be signed in to change notification settings - Fork 4
/
vm_snapshot_info.yml
73 lines (57 loc) · 2.02 KB
/
vm_snapshot_info.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
- name: Test vm_snapshot_info
hosts: all
become: false
gather_facts: false
connection: ansible.builtin.local
strategy: host_pinned
environment: # if set here - hypercore modules will automatically use this for each remote cluster - avoiding need to specify cluster_instance for each test
SC_HOST: "https://{{ inventory_hostname }}"
SC_USERNAME: "{{ scale_user | default('admin') }}"
SC_PASSWORD: "{{ scale_pass | default('admin') }}"
SC_TIMEOUT: 600
tasks:
- name: get vm info
scale_computing.hypercore.vm_info:
register: vm
- name: debug
debug:
var: vm
- name: get snapshot info
scale_computing.hypercore.vm_snapshot_info:
register: snapshot
- name: debug
debug:
var: snapshot
- name: Print table header
debug:
msg: "| VM Name | VCPUs |"
- name: Print separator
debug:
msg: "|------------------------|-------|"
- name: Display VM names and their VCPUs
debug:
msg: "name: {{ item.vm_name }} vcpus: {{ item.vcpu }}"
loop: "{{ vm.records }}"
loop_control:
label: "{{ item.vm_name }}"
- name: Print table header
debug:
msg: "{{ '%-30s | %5s' | format('VM Name', 'VCPUs') }}"
- name: Display VM names and their VCPUs in columns
debug:
msg: "{{ '%-30s | %5s' | format(item.vm_name, item.vcpu) }}"
loop: "{{ vm.records }}"
loop_control:
label: "{{ item.vm_name }}"
# - name: Convert snapshot data to CSV format
# set_fact:
# snapshot_csv: "{{ snapshot.records | map('json_query', '{label: label, vm_name: vm_name, snapshot_uuid: snapshot_uuid}') | list | map('to_json') | join('\n') }}"
# - name: Write snapshot data to a CSV file
# copy:
# content: "{{ snapshot_csv }}"
# dest: "snapshot_info.csv"
# - name: Write snapshot data to a JSON file
# copy:
# content: "{{ snapshot.records | to_nice_json }}"
# dest: "snapshot_info.json"