|
28 | 28 | get_mgmt_service_client, |
29 | 29 | get_subscription_id, |
30 | 30 | ) |
| 31 | +from azure.cli.core.profiles import ResourceType, get_sdk |
31 | 32 | from azure.core.exceptions import HttpResponseError |
32 | 33 | from azure.mgmt.core.tools import is_valid_resource_id, parse_resource_id, resource_id |
33 | 34 | from knack.log import get_logger |
@@ -98,24 +99,20 @@ def aks_kollect_cmd(cmd, # pylint: disable=too-many-statements,too-many-local |
98 | 99 | cmd.cli_ctx, parsed_storage_account['subscription']) |
99 | 100 | storage_account_keys = storage_client.storage_accounts.list_keys(parsed_storage_account['resource_group'], |
100 | 101 | storage_account_name) |
101 | | - kwargs = { |
102 | | - 'account_name': storage_account_name, |
103 | | - 'account_key': storage_account_keys.keys[0].value |
104 | | - } |
105 | | - cloud_storage_client = _cloud_storage_account_service_factory( |
106 | | - cmd.cli_ctx, kwargs) |
107 | | - |
108 | | - sas_token = cloud_storage_client.generate_shared_access_signature( |
109 | | - 'b', |
110 | | - 'sco', |
111 | | - 'rwdlacup', |
112 | | - datetime.datetime.utcnow() + datetime.timedelta(days=1)) |
113 | | - |
114 | | - readonly_sas_token = cloud_storage_client.generate_shared_access_signature( |
115 | | - 'b', |
116 | | - 'sco', |
117 | | - 'rl', |
118 | | - datetime.datetime.utcnow() + datetime.timedelta(days=1)) |
| 102 | + |
| 103 | + t_generate_blob_service_sas = get_sdk(cmd.cli_ctx, ResourceType.DATA_STORAGE_BLOB, '#generate_account_sas') |
| 104 | + |
| 105 | + sas_token = t_generate_blob_service_sas(storage_account_name, |
| 106 | + storage_account_keys.keys[0].value, |
| 107 | + resource_types='sco', |
| 108 | + permission='rwdlacup', |
| 109 | + expiry=datetime.datetime.utcnow() + datetime.timedelta(days=1)) |
| 110 | + |
| 111 | + readonly_sas_token = t_generate_blob_service_sas(storage_account_name, |
| 112 | + storage_account_keys.keys[0].value, |
| 113 | + resource_types='sco', |
| 114 | + permission='rl', |
| 115 | + expiry=datetime.datetime.utcnow() + datetime.timedelta(days=1)) |
119 | 116 |
|
120 | 117 | readonly_sas_token = readonly_sas_token.strip('?') |
121 | 118 |
|
@@ -483,17 +480,6 @@ def _display_diagnostics_report(temp_kubeconfig_path): # pylint: disable=too-m |
483 | 480 | "Please run 'az aks kanalyze' command later to get the analysis results.") |
484 | 481 |
|
485 | 482 |
|
486 | | -def _cloud_storage_account_service_factory(cli_ctx, kwargs): |
487 | | - from azure.cli.core.profiles import ResourceType, get_sdk |
488 | | - t_cloud_storage_account = get_sdk( |
489 | | - cli_ctx, ResourceType.DATA_STORAGE, 'common#CloudStorageAccount') |
490 | | - account_name = kwargs.pop('account_name', None) |
491 | | - account_key = kwargs.pop('account_key', None) |
492 | | - sas_token = kwargs.pop('sas_token', None) |
493 | | - kwargs.pop('connection_string', None) |
494 | | - return t_cloud_storage_account(account_name, account_key, sas_token) |
495 | | - |
496 | | - |
497 | 483 | def _format_hyperlink(the_link): |
498 | 484 | return f'\033[1m{colorama.Style.BRIGHT}{colorama.Fore.BLUE}{the_link}{colorama.Style.RESET_ALL}' |
499 | 485 |
|
|
0 commit comments