Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2fe3ae4
updated sdk version
Jun 15, 2020
0d8a926
replaced ipRangeFilter by IpRules
Jun 15, 2020
e222acc
fixing IpRules
Jun 16, 2020
6224d47
Added autoscale related changes
Jun 16, 2020
063bfa4
tests for autoscale
Jun 16, 2020
3c52f90
Changes for ip_rules
Jun 17, 2020
939f147
init for updates in database account properties
Jun 16, 2020
9ea26bd
final changes and tests for enableFreeTier, serverVersion and enableA…
Jun 17, 2020
4bc3129
error message
Jun 17, 2020
8d48d6e
added analytical ttl in mongo collection
Jun 17, 2020
27bd4d7
fixes
Jun 17, 2020
e62c0b5
analytical_storage_ttl in cassandra table
Jun 17, 2020
0f46ce8
updated all tests
Jun 17, 2020
7a8cfab
[CosmosDB] Allow creating fixed collections (#13950)
MehaKaushik Jun 17, 2020
40beea1
Cherrypicking latest master CosmosDB
shurd Jun 17, 2020
d5be0d4
updated tests
Jun 18, 2020
abd4c7c
Merge upstream/dev
Jun 18, 2020
9516285
fixing lint issue
Jun 18, 2020
71adb50
fixing style check
Jun 19, 2020
5d1f99f
Addressed comments
Jun 26, 2020
39d2ab7
Removed preview tag from RuntimeResources
Jun 26, 2020
ee920e4
fixing cosmosdb in network
Jun 30, 2020
7852ac3
Fixing cosmosdb network tests
Jun 30, 2020
b20c3d7
missed private_endpint_connection yaml
Jun 30, 2020
202bf3a
Merge remote-tracking branch 'upstream/dev' into temp
Jul 2, 2020
665d105
missed private_endpint_connection yaml
Jun 30, 2020
2d07475
re-added network tests
Jul 2, 2020
db0cd1e
re-running tests
Jul 2, 2020
e3e04c1
fixture for CI
Jul 2, 2020
fe96d0a
changes to address github issue 14191
Jul 2, 2020
de2e4bf
nit
Jul 2, 2020
ec6def8
addressed PR comments
Jul 7, 2020
ec8e363
re-ran the network tests for cosmosdb
Jul 7, 2020
d11513c
lint fix
Jul 7, 2020
7c0cd0c
re-added network module tests
Jul 7, 2020
d185e0f
addressed comment
Jul 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changes for ip_rules
  • Loading branch information
Meha Kaushik committed Jun 17, 2020
commit 3c52f909f732e943c216f87ff342771916212527
5 changes: 2 additions & 3 deletions src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@ def load_arguments(self, _):
c.argument('default_consistency_level', arg_type=get_enum_type(DefaultConsistencyLevel), help="default consistency level of the Cosmos DB database account")
c.argument('max_staleness_prefix', type=int, help="when used with Bounded Staleness consistency, this value represents the number of stale requests tolerated. Accepted range for this value is 1 - 2,147,483,647")
c.argument('max_interval', type=int, help="when used with Bounded Staleness consistency, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 1 - 100")
c.argument('ip_rules', type=shell_safe_json_parse, completer=FilesCompleter(), help="firewall support. Specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma-separated and must not contain any spaces")
c.argument('ip_rules', nargs='+', help="firewall support. Specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma-separated and must not contain any spaces")
c.argument('kind', arg_type=get_enum_type(DatabaseAccountKind), help='The type of Cosmos DB database account to create')
c.argument('enable_automatic_failover', arg_type=get_three_state_flag(), help='Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account.')
c.argument('capabilities', nargs='+', validator=validate_capabilities, help='set custom capabilities on the Cosmos DB database account.')
c.argument('enable_virtual_network', arg_type=get_three_state_flag(), help='Enables virtual network on the Cosmos DB database account')
c.argument('virtual_network_rules', nargs='+', validator=validate_virtual_network_rules, help='ACL\'s for virtual network')
c.argument('enable_multiple_write_locations', arg_type=get_three_state_flag(), help="Enable Multiple Write Locations")
c.argument('disable_key_based_metadata_write_access', arg_type=get_three_state_flag(), help="Disable write operations on metadata resources (databases, containers, throughput) via account keys")
c.argument('enable_public_network', options_list=['--enable-public-network', '-e'],
arg_type=get_three_state_flag(), help="Enable or disable public network access to server.")
c.argument('enable_public_network', options_list=['--enable-public-network', '-e'],arg_type=get_three_state_flag(), help="Enable or disable public network access to server.")

for scope in ['cosmosdb regenerate-key', 'cosmosdb keys regenerate']:
with self.argument_context(scope) as c:
Expand Down
24 changes: 20 additions & 4 deletions src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
ThroughputSettingsResource,
ThroughputSettingsUpdateParameters,
CreateUpdateOptions,
AutoscaleSettings
AutoscaleSettings,
IpAddressOrRange
)

logger = get_logger(__name__)
Expand Down Expand Up @@ -109,6 +110,10 @@ def cli_cosmosdb_create(cmd, client,
locations = []
locations.append(Location(location_name=resource_group_location, failover_priority=0, is_zone_redundant=False))

_ip_rules = None
if ip_rules is not None:
_ip_rules = _get_ip_rules(ip_rules)

public_network_access = None
if enable_public_network is not None:
public_network_access = 'Enabled' if enable_public_network else 'Disabled'
Expand All @@ -119,7 +124,7 @@ def cli_cosmosdb_create(cmd, client,
tags=tags,
kind=kind,
consistency_policy=consistency_policy,
ip_rules=ip_rules,
ip_rules=_ip_rules,
is_virtual_network_filter_enabled=enable_virtual_network,
enable_automatic_failover=enable_automatic_failover,
capabilities=capabilities,
Expand Down Expand Up @@ -180,11 +185,15 @@ def cli_cosmosdb_update(client,
if enable_public_network is not None:
public_network_access = 'Enabled' if enable_public_network else 'Disabled'

_ip_rules = None
if ip_rules is not None:
_ip_rules = get_ip_rules(ip_rules)

params = DatabaseAccountUpdateParameters(
locations=locations,
tags=tags,
consistency_policy=consistency_policy,
ip_rules=ip_rules,
ip_rules=_ip_rules,
is_virtual_network_filter_enabled=enable_virtual_network,
enable_automatic_failover=enable_automatic_failover,
capabilities=capabilities,
Expand All @@ -198,6 +207,14 @@ def cli_cosmosdb_update(client,
docdb_account = client.get(resource_group_name, account_name) # Workaround
return docdb_account

def get_ip_rules(ip_rules):
_ip_rules=[]
if ip_rules:
for ip_address in ip_rules:
_ip_address_or_range = {}
_ip_address_or_range['IpAddressOrRange'] = ip_address
_ip_rules.append(_ip_address_or_range)
return _ip_rules

def cli_cosmosdb_list(client, resource_group_name=None):
""" Lists all Azure Cosmos DB database accounts within a given resource group or subscription. """
Expand All @@ -206,7 +223,6 @@ def cli_cosmosdb_list(client, resource_group_name=None):

return client.list()


# pylint: disable=line-too-long
def cli_cosmosdb_keys(client, resource_group_name, account_name, key_type=CosmosKeyTypes.keys.value):
if key_type == CosmosKeyTypes.keys.value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ def test_update_database_account(self, resource_group):
'acc': self.create_random_name(prefix='cli', length=40)
})

self.cmd('az cosmosdb create -n {acc} -g {rg} --kind MongoDB --ip-rules "{\\"ipAddressOrRange\\": \\"10.10.10.10\\"}" ')
self.cmd('az cosmosdb create -n {acc} -g {rg} --kind MongoDB --ip-rules "20.10.10.10" ')
self.cmd('az cosmosdb show -n {acc} -g {rg}', checks=[
JMESPathCheck('kind', 'MongoDB'),
self.check('ipRules[0].ipAddressOrRange', "10.10.10.10"),
self.check('ipRules[0].ipAddressOrRange', "20.10.10.10"),
])

self.cmd('az cosmosdb update -n {acc} -g {rg} --capabilities EnableAggregationPipeline')
account = self.cmd('az cosmosdb show -n {acc} -g {rg}', checks=[
JMESPathCheck('kind', 'MongoDB'),
self.check('ipRules[0].ipAddressOrRange', "10.10.10.10"),
self.check('ipRules[0].ipAddressOrRange', "20.10.10.10"),
]).get_output_in_json()
assert len(account['capabilities']) == 1
assert account['capabilities'][0]['name'] == "EnableAggregationPipeline"
Expand Down