From b8554584c2c0deefcca3694a699acbc1b9c9f070 Mon Sep 17 00:00:00 2001 From: Kyle Ruddy Date: Wed, 21 Mar 2018 17:34:28 -0400 Subject: [PATCH] Remove DHCP Column from Output Not every logical switch contains DHCP IP Pool information. Removing the DHCP column from being output. Resolving the Following Error: (VMWonAWSDemo) kruddy-m02:vsphere-automation-sdk-python kyleruddy$ python3 ./samples/vmc/networks/logical_network_crud.py -r $refreshtoken -o $orgid -s $sddcid --network-name 'Python-SDK-LogicalNetwork' -c # Example: Add a logical network to the compute gateway Compute Gateway ID: edge-2 # New logical network "Python-SDK-LogicalNetwork" is added # Example: List all logical networks Traceback (most recent call last): File "./samples/vmc/networks/logical_network_crud.py", line 208, in main() File "./samples/vmc/networks/logical_network_crud.py", line 201, in main logical_network_crud.get_logical_network() File "./samples/vmc/networks/logical_network_crud.py", line 134, in get_logical_network self.print_output(networks) File "./samples/vmc/networks/logical_network_crud.py", line 192, in print_output network.dhcp_configs.ip_pools[0].ip_range]) AttributeError: 'NoneType' object has no attribute 'ip_pools' --- samples/vmc/networks/logical_network_crud.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/vmc/networks/logical_network_crud.py b/samples/vmc/networks/logical_network_crud.py index 69a53481..bf8ffe96 100644 --- a/samples/vmc/networks/logical_network_crud.py +++ b/samples/vmc/networks/logical_network_crud.py @@ -188,10 +188,9 @@ class LogicalNetworkCrud(object): table.append([network.cgw_name, network.id, network.name, '{}/{}'.format( network.subnets.address_groups[0].primary_address, - network.subnets.address_groups[0].prefix_length), - network.dhcp_configs.ip_pools[0].ip_range]) + network.subnets.address_groups[0].prefix_length)]) print(tabulate(table, ['Gateway', 'Network ID', 'Network Name', - 'Subnets', 'DHCP'])) + 'Subnets'])) def main():