Skip to content

Commit abf98e0

Browse files
authored
{dls} az dls account: Gen1 account management sdk upgrade (#30094)
* Revert "{Packaging} Vendor `azure-mgmt-datalake-store` (#29275)" This reverts commit acec6c3. * Update package versions * Working tests test_dls_file_access_mgmt and test_dls_file_mgmt * Tests passing apart from 2 update commands * Fix update commands * Fix style violations * Updating recordings with live test. Disabled network rules tests * Fix style, linter errors after removing network rules commands. Update recordings
1 parent d021840 commit abf98e0

File tree

96 files changed

+801
-7935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+801
-7935
lines changed

src/azure-cli-core/azure/cli/core/profiles/_shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods
101101
MGMT_CONTAINERINSTANCE = ('azure.mgmt.containerinstance', None)
102102
MGMT_COSMOSDB = ('azure.mgmt.cosmosdb', None)
103103
MGMT_DATALAKE_ANALYTICS = ('azure.cli.command_modules.dla.vendored_sdks.azure_mgmt_datalake_analytics', None)
104-
MGMT_DATALAKE_STORE = ('azure.cli.command_modules.dls.vendored_sdks.azure_mgmt_datalake_store', None)
104+
MGMT_DATALAKE_STORE = ('azure.mgmt.datalake.store', None)
105105
MGMT_DATAMIGRATION = ('azure.mgmt.datamigration', None)
106106
MGMT_EVENTGRID = ('azure.mgmt.eventgrid', None)
107107
MGMT_MAPS = ('azure.mgmt.maps', None)

src/azure-cli/azure/cli/command_modules/dls/_client_factory.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,19 @@
66

77
def cf_dls_account(cli_ctx, _):
88
from azure.cli.core.commands.client_factory import get_mgmt_service_client
9-
from .vendored_sdks.azure_mgmt_datalake_store import DataLakeStoreAccountManagementClient
9+
from azure.mgmt.datalake.store import DataLakeStoreAccountManagementClient
1010
return get_mgmt_service_client(cli_ctx, DataLakeStoreAccountManagementClient).accounts
1111

1212

1313
def cf_dls_account_firewall(cli_ctx, _):
1414
from azure.cli.core.commands.client_factory import get_mgmt_service_client
15-
from .vendored_sdks.azure_mgmt_datalake_store import DataLakeStoreAccountManagementClient
15+
from azure.mgmt.datalake.store import DataLakeStoreAccountManagementClient
1616
return get_mgmt_service_client(cli_ctx, DataLakeStoreAccountManagementClient).firewall_rules
1717

1818

19-
def cf_dls_account_virtual_network(cli_ctx, _):
20-
from azure.cli.core.commands.client_factory import get_mgmt_service_client
21-
from .vendored_sdks.azure_mgmt_datalake_store import DataLakeStoreAccountManagementClient
22-
return get_mgmt_service_client(cli_ctx, DataLakeStoreAccountManagementClient).virtual_network_rules
23-
24-
2519
def cf_dls_account_trusted_provider(cli_ctx, _):
2620
from azure.cli.core.commands.client_factory import get_mgmt_service_client
27-
from .vendored_sdks.azure_mgmt_datalake_store import DataLakeStoreAccountManagementClient
21+
from azure.mgmt.datalake.store import DataLakeStoreAccountManagementClient
2822
return get_mgmt_service_client(cli_ctx, DataLakeStoreAccountManagementClient).trusted_id_providers
2923

3024

src/azure-cli/azure/cli/command_modules/dls/_help.py

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@
9393
helps['dls account firewall update'] = """
9494
type: command
9595
short-summary: Updates a firewall rule in a Data Lake Store account.
96+
parameters:
97+
- name: --end-ip-address
98+
type: string
99+
short-summary: 'The end of the valid ip range for the firewall rule. This can be either ipv4 or ipv6. Start and End should be in the same protocol.'
100+
- name: --start-ip-address
101+
type: string
102+
short-summary: 'The start of the valid ip range for the firewall rule. This can be either ipv4 or ipv6. Start and End should be in the same protocol.'
103+
- name: --firewall-rule-name
104+
type: string
105+
short-summary: 'The name of the firewall rule.'
96106
"""
97107

98108
helps['dls account list'] = """
@@ -104,43 +114,6 @@
104114
crafted: true
105115
"""
106116

107-
helps['dls account network-rule'] = """
108-
type: group
109-
short-summary: Manage Data Lake Store account virtual network rules.
110-
"""
111-
112-
helps['dls account network-rule create'] = """
113-
type: command
114-
short-summary: Creates a virtual network rule in a Data Lake Store account.
115-
parameters:
116-
- name: --subnet
117-
type: string
118-
short-summary: 'The subnet name or id for the virtual network rule.'
119-
- name: --vnet-name
120-
type: string
121-
short-summary: 'The name of the virtual network rule.'
122-
"""
123-
124-
helps['dls account network-rule delete'] = """
125-
type: command
126-
short-summary: Deletes a virtual network rule in a Data Lake Store account.
127-
"""
128-
129-
helps['dls account network-rule list'] = """
130-
type: command
131-
short-summary: Lists virtual network rules in a Data Lake Store account.
132-
"""
133-
134-
helps['dls account network-rule show'] = """
135-
type: command
136-
short-summary: Get the details of a virtual network rule in a Data Lake Store account.
137-
"""
138-
139-
helps['dls account network-rule update'] = """
140-
type: command
141-
short-summary: Updates a virtual network rule in a Data Lake Store account.
142-
"""
143-
144117
helps['dls account show'] = """
145118
type: command
146119
short-summary: Get the details of a Data Lake Store account.
@@ -155,6 +128,30 @@
155128
short-summary: Manage Data Lake Store account trusted identity providers.
156129
"""
157130

131+
helps['dls account trusted-provider create'] = """
132+
type: command
133+
short-summary: Creates or updates the specified trusted identity provider.
134+
parameters:
135+
- name: --id-provider
136+
type: string
137+
short-summary: 'The URL of this trusted identity provider.'
138+
- name: --trusted-id-provider-name
139+
type: string
140+
short-summary: 'The name of the trusted identity provider. This is used for differentiation of providers in the account.'
141+
"""
142+
143+
helps['dls account trusted-provider update'] = """
144+
type: command
145+
short-summary: Updates the specified trusted identity provider.
146+
parameters:
147+
- name: --id-provider
148+
type: string
149+
short-summary: 'The URL of this trusted identity provider.'
150+
- name: --trusted-id-provider-name
151+
type: string
152+
short-summary: 'The name of the trusted identity provider. This is used for differentiation of providers in the account.'
153+
"""
154+
158155
helps['dls account update'] = """
159156
type: command
160157
short-summary: Updates a Data Lake Store account.

src/azure-cli/azure/cli/command_modules/dls/_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
tags_type, get_resource_name_completion_list, resource_group_name_type, get_enum_type)
1010

1111
from azure.cli.command_modules.dls._validators import validate_resource_group_name
12-
from .vendored_sdks.azure_mgmt_datalake_store.models import (
12+
from azure.mgmt.datalake.store.models import (
1313
FirewallState,
1414
TrustedIdProviderState,
1515
TierType,
1616
FirewallAllowAzureIpsState)
1717

18-
from .vendored_sdks.azure_mgmt_datalake_store.models import EncryptionConfigType
18+
from azure.mgmt.datalake.store.models import EncryptionConfigType
1919

2020

2121
# pylint: disable=line-too-long, too-many-statements

src/azure-cli/azure/cli/command_modules/dls/_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _get_resource_group_from_account_name(client, account_name):
2929

3030
# COMMAND NAMESPACE VALIDATORS
3131
def validate_resource_group_name(cmd, ns):
32-
from .vendored_sdks.azure_mgmt_datalake_store import DataLakeStoreAccountManagementClient
32+
from azure.mgmt.datalake.store import DataLakeStoreAccountManagementClient
3333
if not ns.resource_group_name:
3434
try:
3535
account_name = ns.name

src/azure-cli/azure/cli/command_modules/dls/commands.py

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,27 @@
88
from azure.cli.command_modules.dls._client_factory import (
99
cf_dls_account,
1010
cf_dls_account_firewall,
11-
cf_dls_account_virtual_network,
1211
cf_dls_account_trusted_provider)
1312

1413

1514
# pylint: disable=too-many-statements
1615
def load_command_table(self, _):
17-
from ._validators import (
18-
validate_subnet
19-
)
20-
adls_format_path = 'azure.cli.command_modules.dls.vendored_sdks.azure_mgmt_datalake_store.operations.{}#{}.{{}}'
16+
adls_format_path = 'azure.mgmt.datalake.store.operations#{}.{{}}'
2117

2218
dls_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.dls.custom#{}')
2319

2420
dls_account_sdk = CliCommandType(
25-
operations_tmpl=adls_format_path.format('accounts_operations', 'AccountsOperations'),
21+
operations_tmpl=adls_format_path.format('AccountsOperations'),
2622
client_factory=cf_dls_account
2723
)
2824

2925
dls_firewall_sdk = CliCommandType(
30-
operations_tmpl=adls_format_path.format('firewall_rules_operations', 'FirewallRulesOperations'),
31-
client_factory=cf_dls_account
32-
)
33-
34-
dls_virtual_network_sdk = CliCommandType(
35-
operations_tmpl=adls_format_path.format('virtual_network_rules_operations', 'VirtualNetworkRulesOperations'),
26+
operations_tmpl=adls_format_path.format('FirewallRulesOperations'),
3627
client_factory=cf_dls_account
3728
)
3829

3930
dls_provider_sdk = CliCommandType(
40-
operations_tmpl=adls_format_path.format('trusted_id_providers_operations', 'TrustedIdProvidersOperations'),
31+
operations_tmpl=adls_format_path.format('TrustedIdProvidersOperations'),
4132
client_factory=cf_dls_account_trusted_provider
4233
)
4334

@@ -46,32 +37,22 @@ def load_command_table(self, _):
4637
g.custom_command('create', 'create_adls_account')
4738
g.custom_command('update', 'update_adls_account')
4839
g.custom_command('list', 'list_adls_account')
49-
g.command('delete', 'delete')
40+
g.command('delete', 'begin_delete')
5041
g.show_command('show', 'get')
5142
g.command('enable-key-vault', 'enable_key_vault')
5243

5344
# account firewall operations
5445
with self.command_group('dls account firewall', dls_firewall_sdk, client_factory=cf_dls_account_firewall) as g:
5546
g.custom_command('create', 'add_adls_firewall_rule')
56-
g.command('update', 'update')
57-
g.command('list', 'list_by_account')
58-
g.show_command('show', 'get')
59-
g.command('delete', 'delete')
60-
61-
# account virtual network rule operations
62-
with self.command_group('dls account network-rule',
63-
dls_virtual_network_sdk,
64-
client_factory=cf_dls_account_virtual_network) as g:
65-
g.custom_command('create', 'add_adls_virtual_network_rule', validator=validate_subnet)
66-
g.generic_update_command('update')
47+
g.custom_command('update', 'update_adls_firewall_rule')
6748
g.command('list', 'list_by_account')
6849
g.show_command('show', 'get')
6950
g.command('delete', 'delete')
7051

7152
# account trusted id provider operations
72-
with self.command_group('dls account trusted-provider', dls_provider_sdk) as g:
73-
g.command('create', 'create_or_update')
74-
g.command('update', 'update')
53+
with self.command_group('dls account trusted-provider', dls_provider_sdk, client_factory=cf_dls_account_trusted_provider) as g:
54+
g.custom_command('create', 'add_trusted_provider_rule')
55+
g.custom_command('update', 'update_trusted_provider_rule')
7556
g.command('list', 'list_by_account')
7657
g.show_command('show', 'get')
7758
g.command('delete', 'delete')

src/azure-cli/azure/cli/command_modules/dls/custom.py

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from knack.log import get_logger
77
from knack.util import CLIError
88

9-
from .vendored_sdks.azure_mgmt_datalake_store.models import (
9+
from azure.mgmt.datalake.store.models import (
1010
UpdateDataLakeStoreAccountParameters,
1111
CreateDataLakeStoreAccountParameters,
1212
EncryptionConfigType,
@@ -22,7 +22,11 @@
2222
from azure.cli.command_modules.dls._client_factory import (cf_dls_filesystem)
2323
from azure.cli.core.commands.client_factory import get_mgmt_service_client
2424
from azure.cli.core.profiles import ResourceType
25-
25+
from azure.mgmt.datalake.store.models import (
26+
CreateOrUpdateFirewallRuleParameters,
27+
UpdateFirewallRuleParameters,
28+
CreateOrUpdateTrustedIdProviderParameters,
29+
UpdateTrustedIdProviderParameters)
2630

2731
logger = get_logger(__name__)
2832

@@ -78,8 +82,7 @@ def create_adls_account(cmd, client, resource_group_name, account_name, location
7882
create_params.encryption_state = EncryptionState.disabled
7983
create_params.identity = None
8084
create_params.encryption_config = None
81-
82-
return client.create(resource_group_name, account_name, create_params).result()
85+
return client.begin_create(resource_group_name, account_name, create_params)
8386

8487

8588
def update_adls_account(client, account_name, resource_group_name, tags=None, default_group=None, firewall_state=None,
@@ -97,7 +100,7 @@ def update_adls_account(client, account_name, resource_group_name, tags=None, de
97100
update_params.encryption_config = UpdateEncryptionConfig(
98101
key_vault_meta_info=UpdateKeyVaultMetaInfo(encryption_key_version=key_version))
99102

100-
return client.update(resource_group_name, account_name, update_params).result()
103+
return client.begin_update(resource_group_name, account_name, update_params)
101104
# endregion
102105

103106

@@ -111,21 +114,49 @@ def add_adls_firewall_rule(client,
111114
return client.create_or_update(resource_group_name,
112115
account_name,
113116
firewall_rule_name,
114-
start_ip_address,
115-
end_ip_address)
117+
CreateOrUpdateFirewallRuleParameters(
118+
start_ip_address=start_ip_address,
119+
end_ip_address=end_ip_address))
120+
121+
122+
def update_adls_firewall_rule(client,
123+
account_name,
124+
firewall_rule_name,
125+
resource_group_name,
126+
start_ip_address=None,
127+
end_ip_address=None):
128+
return client.update(resource_group_name,
129+
account_name,
130+
firewall_rule_name,
131+
UpdateFirewallRuleParameters(
132+
start_ip_address=start_ip_address,
133+
end_ip_address=end_ip_address))
134+
116135
# endregion
117136

118137

119-
# region virtual network
120-
def add_adls_virtual_network_rule(client,
121-
account_name,
122-
virtual_network_rule_name,
123-
subnet,
124-
resource_group_name):
125-
return client.create_or_update(resource_group_name,
126-
account_name,
127-
virtual_network_rule_name,
128-
subnet)
138+
# region trusted provider
139+
def add_trusted_provider_rule(client,
140+
account_name,
141+
trusted_id_provider_name,
142+
id_provider,
143+
resource_group_name):
144+
return client.create_or_update(resource_group_name=resource_group_name,
145+
account_name=account_name,
146+
trusted_id_provider_name=trusted_id_provider_name,
147+
parameters=CreateOrUpdateTrustedIdProviderParameters(id_provider=id_provider))
148+
149+
150+
def update_trusted_provider_rule(client,
151+
account_name,
152+
resource_group_name,
153+
trusted_id_provider_name,
154+
id_provider=None):
155+
return client.update(resource_group_name=resource_group_name,
156+
account_name=account_name,
157+
trusted_id_provider_name=trusted_id_provider_name,
158+
parameters=UpdateTrustedIdProviderParameters(
159+
id_provider=id_provider))
129160
# endregion
130161

131162

@@ -216,16 +247,10 @@ def test_adls_item(cmd, account_name, path):
216247
def preview_adls_item(cmd, account_name, path, length=None, offset=0, force=False):
217248
client = cf_dls_filesystem(cmd.cli_ctx, account_name)
218249
if length:
219-
try:
220-
length = long(length)
221-
except NameError:
222-
length = int(length)
250+
length = int(length)
223251

224252
if offset:
225-
try:
226-
offset = long(offset)
227-
except NameError:
228-
offset = int(offset)
253+
offset = int(offset)
229254

230255
if not length or length <= 0:
231256
length = client.info(path)['length'] - offset
@@ -258,10 +283,7 @@ def set_adls_item_expiry(cmd, account_name, path, expiration_time):
258283
raise CLIError('The specified path does not exist or is not a file. Please ensure the path points to a file and it exists. Path supplied: {}'.format(path))
259284

260285
expiration_time = float(expiration_time)
261-
try:
262-
expiration_time = long(expiration_time)
263-
except NameError:
264-
expiration_time = int(expiration_time)
286+
expiration_time = int(expiration_time)
265287
client.set_expiry(path, ExpiryOptionType.absolute.value, expiration_time)
266288

267289

0 commit comments

Comments
 (0)