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

azure_rm_virtualmachine_info serialization fails with empty storageUri #137

Closed
timmyreilly opened this issue May 27, 2020 · 9 comments
Closed
Labels
has_pr PR fixes have been made

Comments

@timmyreilly
Copy link

SUMMARY

The azure_rm_virtualmachine_info isn't properly deserializing a diagnosticsProfile with an empty storage uri.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure_rm_virtualmachine_info

ANSIBLE VERSION
ansible 2.9.9
  config file = None
  configured module search path = ['/home/conductor/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /mnt/c/Users/tireilly/GitHub/Spikes/EITC/ansible/venv/lib/python3.6/site-packages/ansible
  executable location = /mnt/c/Users/tireilly/GitHub/Spikes/ansible/venv/bin/ansible
  python version = 3.6.8 (default, Oct  7 2019, 12:59:55) [GCC 8.3.0]
CONFIGURATION
'' 
OS / ENVIRONMENT

Windows 10 -> bash

STEPS TO REPRODUCE

Create a vm, get info on vm.

ansible localhost -m azure_rm_virtualmachine_info -a "tags=environment:dev" -vvv
EXPECTED RESULTS

Expected to get information about vm's in the target subscription
With az vm list I get this:

$ az vm list
[
  {
    "additionalCapabilities": null,
    "availabilitySet": {
      "id": "/subscriptions/5c514147-secret-4f7e-8329-625443da4254/resourceGroups/NETWORK-TEST-KA6U7-RG/providers/Microsoft.Compute/availabilitySets/MACHINES-SET",
      "resourceGroup": "NETWORK-TEST-KA6U7-RG"
    },
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": false,
        "storageUri": null
      }
    },
ACTUAL RESULTS
The full traceback is:
  File "/tmp/ansible_azure_rm_virtualmachine_info_payload_o2js5d3j/ansible_azure_rm_virtualmachine_info_payload.zip/ansible/modules/cloud/azure/azure_rm_virtualmachine_info.py", line 355, in get_vm
  File "/tmp/ansible_azure_rm_virtualmachine_info_payload_o2js5d3j/ansible_azure_rm_virtualmachine_info_payload.zip/ansible/modules/cloud/azure/azure_rm_virtualmachine_info.py", line 417, in serialize_vm
localhost | FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "ad_user": null,
            "adfs_authority_url": null,
            "api_profile": "latest",
            "auth_source": null,
            "cert_validation_mode": null,
            "client_id": null,
            "cloud_environment": "AzureCloud",
            "name": null,
            "password": null,
            "profile": null,
            "resource_group": null,
            "secret": null,
            "subscription_id": null,
            "tags": [
                "environment:dev"
            ],
            "tenant": null
        }
    },
    "msg": "Error getting virtual machine None - 'storageUri'"
}
@Fred-sun
Copy link
Collaborator

Fred-sun commented Jun 4, 2020

@timmyreilly Thank you for your report, we will investigate and solve your problems as soon as possible. Thank you!

Fred-sun added a commit to Fred-sun/ansible_collections_azure that referenced this issue Jul 31, 2020
Fred-sun added a commit to Fred-sun/ansible_collections_azure that referenced this issue Jul 31, 2020
@Fred-sun
Copy link
Collaborator

Fred-sun commented Aug 3, 2020

fixes by #208!

@Fred-sun Fred-sun added the has_pr PR fixes have been made label Aug 5, 2020
@Fred-sun
Copy link
Collaborator

The #208 merged!

@Chrysostomus
Copy link

I'm getting this exact same issue with version 1.9. I checked that #208 code is present on the installation. Is there something else that could cause the issue?

@Fred-sun
Copy link
Collaborator

I'm getting this exact same issue with version 1.9. I checked that #208 code is present on the installation. Is there something else that could cause the issue?

@Chrysostomus Can you provide what results you return? Thank you very much!

@vijayreddiar
Copy link

@Fred-sun The code fix in azure_rm_virtualmachine_info.py and azure_rm_virtualmachine.py fixes the error related to empty storageUri, but I get a new error as below when the setting is Enable with managed storage account (recommended)

Error getting virtual machine None - 'consoleScreenshotBlobUri'

@Fred-sun
Copy link
Collaborator

Fred-sun commented Nov 3, 2021

@vijayreddiar Thanks for your feedback, I will check this parameter again. Thank you very much!

@vijayreddiar
Copy link

@Fred-sun After updating these two lines of code in azure_rm_virtualmachine_info.py as below, it works fine.

new_result['boot_diagnostics']['console_screenshot_uri'] = result['properties']['instanceView']['bootDiagnostics'].get('consoleScreenshotBlobUri', None)
new_result['boot_diagnostics']['serial_console_log_uri'] = result['properties']['instanceView']['bootDiagnostics'].get('serialConsoleLogBlobUri', None)

@Fred-sun
Copy link
Collaborator

Fred-sun commented Nov 3, 2021

@vijayreddiar Thank you for your contribution, welcome to submit PR, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has_pr PR fixes have been made
Projects
None yet
Development

No branches or pull requests

4 participants