From e9a1f71bc8c4d496332c27b29d4e413986338789 Mon Sep 17 00:00:00 2001 From: Boris Modylevsky Date: Sun, 28 Feb 2016 14:36:38 +0200 Subject: [PATCH] Refresh IP was fixed with the latest CloudShell API changes --- vCenterShell/commands/refresh_ip.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/vCenterShell/commands/refresh_ip.py b/vCenterShell/commands/refresh_ip.py index a691790f..6737add5 100644 --- a/vCenterShell/commands/refresh_ip.py +++ b/vCenterShell/commands/refresh_ip.py @@ -48,19 +48,9 @@ def _get_ip_match_function(session, resource_name): ip_regexes = [] ip_regex = '.*' - if resource.VmDetails \ - and hasattr(resource.VmDetails[0], 'VmCustomParam') \ - and resource.VmDetails[0].VmCustomParam\ - and hasattr(resource.VmDetails[0].VmCustomParam, 'Name') \ - and isinstance(resource.VmDetails[0].VmCustomParam.Name, str) \ - and resource.VmDetails[0].VmCustomParam.Name == 'ip_regex' \ - and hasattr(resource.VmDetails[0].VmCustomParam, 'Value') \ - and isinstance(resource.VmDetails[0].VmCustomParam.Value, str): - ip_regexes = [resource.VmDetails[0].VmCustomParam.Value] - elif resource.VmDetails \ - and hasattr(resource.VmDetails[0], 'VmCustomParams') \ - and resource.VmDetails[0].VmCustomParams: - custom_params = resource.VmDetails[0].VmCustomParams + vm_details = resource.VmDetails + if vm_details and hasattr(vm_details, 'VmCustomParams') and vm_details.VmCustomParams: + custom_params = vm_details.VmCustomParams params = custom_params if isinstance(custom_params, list) else [custom_params] ip_regexes = [custom_param.Value for custom_param in params