azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

ComputeManagementClient doesn't return response when list of snapshots is requested.

Open sopeal opened this issue 6 years ago • 16 comments

  • Package Name: azure-mgmt-compute
  • Package Version: 12.0.0
  • Operating System: Ubuntu
  • Python Version: Python 2.7.17

Describe the bug Instance of ComputeManagementClient doesn't return any response when list of snapshots is requested. It doesn't even return error code when wrong resource group name is provided.

self.compute_client.snapshots.list_by_resource_group(self.resource_group_name)

sopeal avatar Apr 20 '20 15:04 sopeal

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection, @Drewm3, @avirishuv, @axayjo, @vaibhav-agar.

ghost avatar Apr 20 '20 16:04 ghost

@Vaibhav-Agar, could you take a look at this.

Drewm3 avatar Apr 22 '20 02:04 Drewm3

Thanks @sopeal for bringing this to our notice. We are investigating and will get back to you shortly on this.

Vaibhav-Agar avatar Apr 22 '20 19:04 Vaibhav-Agar

Hi @sopeal , I wonder if you created a snapshot? If not, you can follow the official document(or az command) to create a snapshot. @jongio

v-xuto avatar Apr 24 '20 02:04 v-xuto

Incorrect resource group name should result in an error code. The REST API returns: "Resource group 'xyz' could not be found." I am following up with the team to see if a fix can be implemented.

Vaibhav-Agar avatar Apr 29 '20 23:04 Vaibhav-Agar

@sopeal, Would it be possible to see how you instantiated the ComputeManagementClient?

MS-syh2qs avatar May 26 '20 19:05 MS-syh2qs

I am initiating ComputeManagementClient and trying to loop through resource groups, it works for disks , not for snapshots.

`# Intialize the compute management client with the RunAs credential and subscription compute_client = ComputeManagementClient( azure_credential, str(runas_connection["SubscriptionId"]), base_url=resourceManager_url)

Intialize the resource management client with the RunAs credential and subscription

resource_client = azure.mgmt.resource.ResourceManagementClient( azure_credential, str(runas_connection["SubscriptionId"]), base_url=resourceManager_url)

Get list of resource groups and print them out

groups = resource_client.resource_groups.list() for group in groups: print ("#############################################################################") print ("Resource Group Name Disks: "),group.name.encode('utf-8'), ("Location: "),group.location disks = compute_client.disks.list_by_resource_group(group.name.encode('utf-8')) for disk in disks: print ("#############################################################################") print ("Disk Name: "),disk.name print ("#############################################################################") print ("Resource Group Name Snapshots: "),group.name.encode('utf-8'), ("Location: "),group.location snapshots = compute_client.snapshots.list_by_resource_group(group.name.encode('utf-8')) print ("Snapshots: "),snapshots`

Error is Below, I have tried for loop and printing snap.name also but get syntax error

Error Snapshots: <azure.mgmt.compute.compute.v2016_04_30_preview.models.snapshot_paged.SnapshotPaged object at 0x0000000589781080>

infa-dgowran avatar Jun 04 '20 11:06 infa-dgowran

@infa-dgowran,

  1. Are you the same person as @sopeal?

  2. <azure.mgmt.compute.compute.v2016_04_30_preview.models.snapshot_paged.SnapshotPaged object at 0x0000000589781080> isn't an error message. It's just trying to print an object but that object doesn't have a toString method. It's just printing out the memory location of that object. You should be printing the snapshots by using a for loop like you did with the disks. Could you try to use a for loop and print snap.name and show me what error you get?

MS-syh2qs avatar Jun 04 '20 16:06 MS-syh2qs

no , not same person as @sopeal , as mentioned tried for loop below. the disks list correctly , snapshots not so tried couple of options for snap.

groups = resource_client.resource_groups.list() for group in groups: print ("#############################################################################") print ("Resource Group Name Disks: "),group.name.encode('utf-8'), ("Location: "),group.location disks = compute_client.disks.list_by_resource_group(group.name.encode('utf-8')) for disk in disks: print ("#############################################################################") print ("Disk Name: "),disk.name print ("#############################################################################") print ("Resource Group Name Snapshots: "),group.name.encode('utf-8'), ("Location: "),group.location snapshots = compute_client.snapshots.list_by_resource_group(group.name.encode('utf-8')) for snap in snapshots print ("Snapshot Name: "),snap.name

infa-dgowran avatar Jun 04 '20 16:06 infa-dgowran

@infa-dgowran, does it not print anything out for snapshots when you run that code?

MS-syh2qs avatar Jun 04 '20 16:06 MS-syh2qs

syntax error , invalid syntax

infa-dgowran avatar Jun 04 '20 16:06 infa-dgowran

@infa-dgowran Are you missing the : after for snap in snapshots?

If that's not it, could you maybe take a screen shot of what the out looks like?

MS-syh2qs avatar Jun 04 '20 16:06 MS-syh2qs

sorry typo, output below and screenshot attached. this is via azure automation and appears to be still using python 2.7 which was deprecated.

Failed Traceback (most recent call last): File "C:\Temp\shfapard.t2p\da9346ae-9996-413e-a0f0-1c876cb3538b", line 80, in <module> for snap in snapshots: File "C:\Python27\lib\site-packages\msrest\paging.py", line 109, in __next__ self.advance_page() File "C:\Python27\lib\site-packages\msrest\paging.py", line 96, in advance_page self._derserializer(self, self._response) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 984, in __call__ value = self.deserialize_data(raw_value, attr_desc['type']) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 1093, in deserialize_data return self.deserialize_type[iter_type](data, data_type[1:-1]) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 1115, in deserialize_iter return [self.deserialize_data(a, iter_type) for a in attr] File "C:\Python27\lib\site-packages\msrest\serialization.py", line 1104, in deserialize_data return self(obj_type, data) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 984, in __call__ value = self.deserialize_data(raw_value, attr_desc['type']) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 1097, in deserialize_data return self.deserialize_enum(data, obj_type) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 1242, in deserialize_enum raise DeserializationError(error.format(data, enum_obj))msrest.exceptions.DeserializationError: u'Standard_ZRS' is not valid value for enum <enum 'StorageAccountTypes'>

image

infa-dgowran avatar Jun 04 '20 16:06 infa-dgowran

Hi @infa-dgowran Could you confirm with a pip list what version of msrest your are using? Could you try to update to latest one pip install -U msrest Thanks

lmazuel avatar Jun 04 '20 21:06 lmazuel

Hi @infa-dgowran,

Since your issue seems like different issue from @sopeal's isuse. I'm going to go ahead and close this issue. If you are still having issues after updating msrest, you can submit a new issue.

MS-syh2qs avatar Jun 05 '20 15:06 MS-syh2qs

@sopeal,

Here's my test result printing out the snapshots.

image

Here's my result from using an invalid resource group name.

image

MS-syh2qs avatar Jun 05 '20 15:06 MS-syh2qs