Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify that the VM is created after it is created #657

Merged
merged 10 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions plugins/modules/azure_rm_virtualmachine_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@
returned: always
type: str
sample: running
display_status:
description:
- The short localizable label for the status.
returned: always
type: str
sample: "VM running"
provisioning_state:
description:
- The provisioning state, which only appears in the response.
returned: always
type: str
sample: running
'''

try:
Expand Down Expand Up @@ -380,12 +392,16 @@ def serialize_vm(self, vm):
code = instance['statuses'][index]['code'].split('/')
if code[0] == 'PowerState':
power_state = code[1]
display_status = instance['statuses'][index]['displayStatus']
elif code[0] == 'OSState' and code[1] == 'generalized':
display_status = instance['statuses'][index]['displayStatus']
power_state = 'generalized'
break

new_result = {}
new_result['power_state'] = power_state
new_result['display_status'] = display_status
new_result['provisioning_state'] = vm.provisioning_state
new_result['id'] = vm.id
new_result['resource_group'] = resource_group
new_result['name'] = vm.name
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/targets/azure_rm_gallery/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@
- name: Get VM facts
azure_rm_virtualmachine_info:
resource_group: "{{ resource_group }}"
name: "vmforimage{{ rpfx }}"
name: "vmforimage{{ rpfx }}"
register: output

- name: Pause for 10 mimutes to VM updating
shell: sleep 600

- name: Create a snapshot by importing an unmanaged blob from the same subscription.
azure_rm_snapshot:
resource_group: "{{ resource_group }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
version: latest
register: vm_output

- name: Get VM facts
azure_rm_virtualmachine_info:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
register: vm_state

- name: Pause for 10 mimutes to VM updating
shell: sleep 600

- name: Restart the virtual machine
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@
assert:
that: dual_nics_result is not changed

- name: Get VM facts
azure_rm_virtualmachine_info:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
register: vm_state

- name: Pause for 10 mimutes to VM updating
shell: sleep 600

- name: Generalize VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}" # Should this be resource_group_secondary?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
version: latest
register: vm_output

- name: Get VM facts
azure_rm_virtualmachine_info:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
register: vm_state

- name: Pause for 10 mimutes to VM updating
shell: sleep 600

- name: Generalize VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@
- not vm_facts_no_boot_diag_result.vms[0].boot_diagnostics.enabled
- not vm_facts_no_boot_diag_result.vms[0].boot_diagnostics.storage_uri

- name: Get VM facts
azure_rm_virtualmachine_info:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
register: vm_state

- name: Pause for 10 mimutes to VM updating
shell: sleep 600

- name: Enable boot diagnostics on an existing VM for the first time without specifying a storage account
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
publisher: Canonical
sku: 18.04-LTS
version: latest
- name: Get VM facts
azure_rm_virtualmachine_info:
resource_group: "{{ resource_group }}"
name: "vmforimage{{ rpfx }}"
register: vm_state
- name: Pause for 10 mimutes to VM updating
shell: sleep 600
- name: Generalize VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
publisher: Canonical
sku: 16.04-LTS
version: latest
register: vm_output
register: vm_output
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
tasks:
- include_vars: vars.yml

- name: Pause for 10 mimutes for updating
shell: sleep 600

- meta: refresh_inventory

- name: Test Inventory
Expand Down