Skip to content

Commit

Permalink
Handlie vm_instance_view.statuses being None (#2603)
Browse files Browse the repository at this point in the history
* Handlie vm_instance_view.statuses being None

* Update CHANGELOG
  • Loading branch information
stuartleeks authored Sep 15, 2022
1 parent a20b373 commit c83f2d7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ENHANCEMENTS:

BUG FIXES:

*
* Resource processor error on deploying user-resource: TypeError: 'NoneType' object is not iterable ([#2569](https://github.com/microsoft/AzureTRE/issues/2569))

## 0.4.3 (September 12, 2022)

Expand Down
2 changes: 1 addition & 1 deletion api_app/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.33"
__version__ = "0.4.34"
6 changes: 5 additions & 1 deletion api_app/services/azure_resource_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ def get_azure_resource_status(resource_id):
try:
if resource_type == 'Microsoft.Compute/virtualMachines':
vm_instance_view: models.VirtualMachineInstanceView = get_azure_vm_instance_view(resource_name, resource_group_name)
power_state = [x for x in vm_instance_view.statuses if x.code.startswith('PowerState')][0].display_status
power_state = None
if vm_instance_view.statuses is not None:
power_states = [x for x in vm_instance_view.statuses if x.code.startswith('PowerState')]
if len(power_states) > 0:
power_state = power_states[0].display_status
return {"powerState": power_state}
except ResourceNotFoundError:
logging.warning(f"Unable to query resource status for {resource_id}, as the resource was not found.")
Expand Down

0 comments on commit c83f2d7

Please sign in to comment.