Skip to content

Commit

Permalink
[Network] az network nsg rule list: Fix ranges and prefixes disappe…
Browse files Browse the repository at this point in the history
…ared with `-o table` option (#27972)

* fix: table transformer of nsg rule list

* style: fix over-indented

* style: fix line too long
  • Loading branch information
necusjz authored Dec 19, 2023
1 parent 002466a commit 14f218e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/azure-cli/azure/cli/command_modules/network/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


#
# pylint: disable=line-too-long
from collections import OrderedDict


Expand Down Expand Up @@ -112,16 +112,15 @@ def transform_nsg_rule_table_output(result):
item['Name'] = result['name']
item['ResourceGroup'] = result['resourceGroup']
item['Priority'] = result['priority']
item['SourcePortRanges'] = result.get('sourcePortRange', ' '.join(result['sourcePortRanges']))
item['SourceAddressPrefixes'] = result.get('sourceAddressPrefix', ' '.join(result['sourceAddressPrefixes']))
item['SourceASG'] = result.get('sourceApplicationSecurityGroups', 'None')
item['SourcePortRanges'] = result.get('sourcePortRange', None) or ' '.join(result['sourcePortRanges'])
item['SourceAddressPrefixes'] = result.get('sourceAddressPrefix', None) or ' '.join(result['sourceAddressPrefixes'])
item['SourceASG'] = result.get('sourceApplicationSecurityGroups', None) or 'None'
item['Access'] = result['access']
item['Protocol'] = result['protocol']
item['Direction'] = result['direction']
item['DestinationPortRanges'] = result.get('destinationPortRange', ' '.join(result['destinationPortRanges']))
item['DestinationAddressPrefixes'] = result.get('destinationAddressPrefix',
' '.join(result['destinationAddressPrefixes']))
item['DestinationASG'] = result.get('destinationApplicationSecurityGroups', 'None')
item['DestinationPortRanges'] = result.get('destinationPortRange', None) or ' '.join(result['destinationPortRanges'])
item['DestinationAddressPrefixes'] = result.get('destinationAddressPrefix', None) or ' '.join(result['destinationAddressPrefixes'])
item['DestinationASG'] = result.get('destinationApplicationSecurityGroups', None) or 'None'
return item


Expand Down

0 comments on commit 14f218e

Please sign in to comment.