Skip to content

Commit

Permalink
Fix #6031. (#6184)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott authored Apr 23, 2018
1 parent a59fb9b commit d859a0a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ def transform_nsg_create_output(result):
return {'NewNSG': result.result()}


def transform_nsg_rule_table_output(result):
item = OrderedDict()
item['Name'] = result['name']
item['ResourceGroup'] = result['resourceGroup']
item['Priority'] = result['priority']
item['SourcePortRanges'] = result['sourcePortRange'] or ' '.join(result['sourcePortRanges'])
item['SourceAddressPrefixes'] = result['sourceAddressPrefix'] or ' '.join(result['sourceAddressPrefixes'])
item['SourceASG'] = result['sourceApplicationSecurityGroups'] or 'None'
item['Access'] = result['access']
item['Protocol'] = result['protocol']
item['Direction'] = result['direction']
item['DestinationPortRanges'] = result['destinationPortRange'] or ' '.join(result['destinationPortRanges'])
item['DestinationAddressPrefixes'] = result['destinationAddressPrefix'] or \
' '.join(result['destinationAddressPrefixes'])
item['DestinationASG'] = result['destinationApplicationSecurityGroups'] or 'None'
return item


def transform_vnet_gateway_create_output(result):
result = {'vnetGateway': result.result()} if result else result
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
transform_vpn_connection, transform_vpn_connection_list,
transform_geographic_hierachy_table_output,
transform_service_community_table_output, transform_waf_rule_sets_table_output,
transform_network_usage_list, transform_network_usage_table)
transform_network_usage_list, transform_network_usage_table, transform_nsg_rule_table_output)
from azure.cli.command_modules.network._validators import (
process_ag_create_namespace, process_ag_listener_create_namespace, process_ag_http_settings_create_namespace,
process_ag_rule_create_namespace, process_ag_ssl_policy_set_namespace, process_ag_url_path_map_create_namespace,
Expand Down Expand Up @@ -488,8 +488,8 @@ def _make_singular(value):

with self.command_group('network nsg rule', network_nsg_rule_sdk) as g:
g.command('delete', 'delete')
g.command('show', 'get', exception_handler=empty_on_404)
g.command('list', 'list')
g.command('show', 'get', exception_handler=empty_on_404, table_transformer=transform_nsg_rule_table_output)
g.command('list', 'list', table_transformer=lambda x: [transform_nsg_rule_table_output(i) for i in x])
g.custom_command('create', 'create_nsg_rule_2017_06_01', min_api='2017-06-01')
g.generic_update_command('update', setter_arg_name='security_rule_parameters', min_api='2017-06-01',
custom_func_name='update_nsg_rule_2017_06_01', doc_string_source='SecurityRule')
Expand Down

0 comments on commit d859a0a

Please sign in to comment.