Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bf63231
flexible server migration
DaeunYim Feb 7, 2021
a018b7d
single server migration draft
DaeunYim Feb 8, 2021
65fe403
style fixed
DaeunYim Feb 8, 2021
5abef3c
allow large reponse for proxy test
DaeunYim Feb 8, 2021
8b16281
singles server test fixed
DaeunYim Feb 9, 2021
75cd854
minor bugs fixed
DaeunYim Feb 9, 2021
822c738
linter and style issues fixed
DaeunYim Feb 9, 2021
dfe3896
config files added
DaeunYim Feb 10, 2021
bdd876c
empty commit
DaeunYim Feb 10, 2021
7a144d7
empty commit
DaeunYim Feb 18, 2021
ecd6dd2
pulled dev repo
DaeunYim Mar 2, 2021
6d83a71
pulled from dev
DaeunYim Mar 3, 2021
221f2e4
fix recording files for the migration code
DaeunYim Mar 3, 2021
f037cac
fixed mariadb failing test case
DaeunYim Mar 3, 2021
8acc000
fix for failing test cases
DaeunYim Mar 4, 2021
8fd0fa0
fixed typo
DaeunYim Mar 4, 2021
0c25766
Merge branch 'dev' of https://github.com/Azure/azure-cli into python-…
DaeunYim Mar 5, 2021
fdce3c9
change datetime function to accomodate python 3.6
DaeunYim Mar 6, 2021
cc30375
takes care of two different time input
DaeunYim Mar 6, 2021
ab1eb2e
style fixed
DaeunYim Mar 6, 2021
7486023
bug fix auth, LRO polling commands, object create by dict
DaeunYim Mar 10, 2021
0ef1240
empty commit
DaeunYim Mar 11, 2021
98b9265
Merge branch 'dev' into python-sdk-migration-2
DaeunYim Mar 11, 2021
3d71790
id = child name fix
DaeunYim Mar 12, 2021
bb840b3
Merge branch 'python-sdk-migration-2' of https://github.com/DaeunYim/…
DaeunYim Mar 12, 2021
45703ac
Merge branch 'dev' of https://github.com/Azure/azure-cli into python-…
DaeunYim Mar 15, 2021
945de4d
network module test failure fixed
DaeunYim Mar 15, 2021
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
1 change: 1 addition & 0 deletions scripts/sdk_process/patch_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def find_autorest_generated_folder(module_prefix="azure.mgmt"):
'azure.mgmt.network',
'azure.mgmt.monitor',
'azure-mgmt-loganalytics'
'azure.mgmt.rdbms'
]
prefix = sys.argv[1] if len(sys.argv) >= 2 else "azure.mgmt"
for autorest_package in find_autorest_generated_folder(prefix):
Expand Down

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions src/azure-cli/azure/cli/command_modules/rdbms/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ def get_mariadb_management_client(cli_ctx, **_):
if rm_uri_override:
client_id = getenv(CLIENT_ID)
if client_id:
from azure.common.credentials import ServicePrincipalCredentials
credentials = ServicePrincipalCredentials(
from azure.identity import ClientSecretCredential
credentials = ClientSecretCredential(
client_id=client_id,
secret=getenv(CLIENT_SECRET),
tenant=getenv(TENANT_ID))
client_secret=getenv(CLIENT_SECRET),
tenant_id=getenv(TENANT_ID))
else:
from msrest.authentication import Authentication # pylint: disable=import-error
credentials = Authentication()

return MariaDBManagementClient(
subscription_id=getenv(SUB_ID_OVERRIDE),
base_url=rm_uri_override,
credentials=credentials)
credential=credentials)
# Normal production scenario.
return get_mgmt_service_client(cli_ctx, MariaDBManagementClient)

Expand All @@ -54,19 +54,19 @@ def get_mysql_management_client(cli_ctx, **_):
if rm_uri_override:
client_id = getenv(CLIENT_ID)
if client_id:
from azure.common.credentials import ServicePrincipalCredentials
credentials = ServicePrincipalCredentials(
from azure.identity import ClientSecretCredential
credentials = ClientSecretCredential(
client_id=client_id,
secret=getenv(CLIENT_SECRET),
tenant=getenv(TENANT_ID))
client_secret=getenv(CLIENT_SECRET),
tenant_id=getenv(TENANT_ID))
Comment on lines +57 to +61
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless AZURE_AUTHORITY_HOST is specified, this doesn't work for sovereign clouds or Azure stacks, since authority of cli_ctx is not passed to ClientSecretCredential.

else:
from msrest.authentication import Authentication # pylint: disable=import-error
credentials = Authentication()

return MySQLManagementClient(
subscription_id=getenv(SUB_ID_OVERRIDE),
base_url=rm_uri_override,
credentials=credentials)
credential=credentials)
# Normal production scenario.
return get_mgmt_service_client(cli_ctx, MySQLManagementClient)

Expand All @@ -82,19 +82,19 @@ def get_mysql_flexible_management_client(cli_ctx, **_):
if rm_uri_override:
client_id = getenv(CLIENT_ID)
if client_id:
from azure.common.credentials import ServicePrincipalCredentials
credentials = ServicePrincipalCredentials(
from azure.identity import ClientSecretCredential
credentials = ClientSecretCredential(
client_id=client_id,
secret=getenv(CLIENT_SECRET),
tenant=getenv(TENANT_ID))
client_secret=getenv(CLIENT_SECRET),
tenant_id=getenv(TENANT_ID))
else:
from msrest.authentication import Authentication # pylint: disable=import-error
credentials = Authentication()

return MySQLManagementClient(
subscription_id=getenv(SUB_ID_OVERRIDE),
base_url=rm_uri_override,
credentials=credentials)
credential=credentials)
# Normal production scenario.
return get_mgmt_service_client(cli_ctx, MySQLManagementClient)

Expand All @@ -110,19 +110,19 @@ def get_postgresql_management_client(cli_ctx, **_):
if rm_uri_override:
client_id = getenv(CLIENT_ID)
if client_id:
from azure.common.credentials import ServicePrincipalCredentials
credentials = ServicePrincipalCredentials(
from azure.identity import ClientSecretCredential
credentials = ClientSecretCredential(
client_id=client_id,
secret=getenv(CLIENT_SECRET),
tenant=getenv(TENANT_ID))
client_secret=getenv(CLIENT_SECRET),
tenant_id=getenv(TENANT_ID))
else:
from msrest.authentication import Authentication # pylint: disable=import-error
credentials = Authentication()

return PostgreSQLManagementClient(
subscription_id=getenv(SUB_ID_OVERRIDE),
base_url=rm_uri_override,
credentials=credentials)
credential=credentials)
# Normal production scenario.
return get_mgmt_service_client(cli_ctx, PostgreSQLManagementClient)

Expand All @@ -137,19 +137,19 @@ def get_postgresql_flexible_management_client(cli_ctx, **_):
if rm_uri_override:
client_id = getenv(CLIENT_ID)
if client_id:
from azure.common.credentials import ServicePrincipalCredentials
credentials = ServicePrincipalCredentials(
from azure.identity import ClientSecretCredential
credentials = ClientSecretCredential(
client_id=client_id,
secret=getenv(CLIENT_SECRET),
tenant=getenv(TENANT_ID))
client_secret=getenv(CLIENT_SECRET),
tenant_id=getenv(TENANT_ID))
else:
from msrest.authentication import Authentication # pylint: disable=import-error
credentials = Authentication()

return PostgreSQLManagementClient(
subscription_id=getenv(SUB_ID_OVERRIDE),
base_url=rm_uri_override,
credentials=credentials)
credential=credentials)
# Normal production scenario.
return get_mgmt_service_client(cli_ctx, PostgreSQLManagementClient)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import random
from knack.log import get_logger
from msrest.paging import Paged
from azure.core.paging import ItemPaged

from azure.cli.core.commands import LongRunningOperation, _is_poller
from azure.cli.core.util import CLIError
from azure.mgmt.resource.resources.models import ResourceGroup
from ._client_factory import resource_client_factory, cf_mysql_flexible_location_capabilities, cf_postgres_flexible_location_capabilities

from .flexible_server_custom_common import firewall_rule_create_func
logger = get_logger(__name__)

DEFAULT_LOCATION_PG = 'eastus' # For testing: 'eastus2euap'
Expand Down Expand Up @@ -106,9 +106,10 @@ def create_firewall_rule(db_context, cmd, resource_group_name, server_name, star
# firewall_client.create_or_update(resource_group_name, server_name, firewall_name , start_ip, end_ip),
# cmd.cli_ctx, '{} Firewall Rule Create/Update'.format(logging_name))

firewall = firewall_client.create_or_update(resource_group_name, server_name, firewall_name, start_ip,
end_ip).result()
return firewall.name
firewall = firewall_rule_create_func(firewall_client, resource_group_name, server_name, firewall_rule_name=firewall_name,
start_ip_address=start_ip, end_ip_address=end_ip)

return firewall.result().name


# pylint: disable=inconsistent-return-statements
Expand Down Expand Up @@ -253,7 +254,7 @@ def _get_available_values(sku_info, argument, tier=None):


def _get_list_from_paged_response(obj_list):
return list(obj_list) if isinstance(obj_list, Paged) else obj_list
return list(obj_list) if isinstance(obj_list, ItemPaged) else obj_list


def _update_location(cmd, resource_group_name):
Expand Down
19 changes: 12 additions & 7 deletions src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def _complex_params(command_group):

with self.argument_context('{} server configuration set'.format(command_group)) as c:
c.argument('value', help='Value of the configuration. If not provided, configuration value will be set to default.', validator=configuration_value_validator)
c.argument('configuration_name', options_list=['--name', '-n'], id_part='child_name_1', help='The name of the configuration')
c.ignore('source')

with self.argument_context('{} server wait'.format(command_group)) as c:
Expand All @@ -133,7 +134,9 @@ def _complex_params(command_group):
c.argument('server_name', id_part=None, help='Name of the Server.')

with self.argument_context('{} db'.format(command_group)) as c:
c.argument('database_name', options_list=['--name', '-n'])
c.argument('database_name', options_list=['--name', '-n'], help='The name of the database')
c.argument('charset', options_list=['--charset'], help='The charset of the database')
c.argument('collation', options_list=['--collation'], help='The collation of the database')

with self.argument_context('{} db list'.format(command_group)) as c:
c.argument('server_name', id_part=None, help='Name of the Server.')
Expand All @@ -159,7 +162,7 @@ def _complex_params(command_group):

with self.argument_context('{} server configuration'.format(command_group)) as c:
c.argument('server_name', options_list=['--server-name', '-s'])
c.argument('configuration_name', id_part='child_name_1', options_list=['--name', '-n'])
c.argument('configuration_name', options_list=['--name', '-n'], id_part='child_name_1')

with self.argument_context('{} server replica list'.format(command_group)) as c:
c.argument('server_name', options_list=['--server-name', '-s'], help='Name of the master server.')
Expand Down Expand Up @@ -421,17 +424,19 @@ def _flexible_server_params(command_group):
if command_group == "mysql":
with self.argument_context('{} flexible-server db'.format(command_group)) as c:
c.argument('server_name', options_list=['--server-name', '-s'], help='Name of the server.')
c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
c.argument('database_name', id_part='child_name_1', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of the database.')

with self.argument_context('{} flexible-server db create'.format(command_group)) as c:
c.argument('database_name', arg_type=database_name_setter_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
c.argument('charset', options_list=['--charset'], help='The charset of the database')
c.argument('collation', options_list=['--collation'], help='The collation of the database')
c.argument('database_name', arg_type=database_name_setter_arg_type, options_list=['--database-name', '-d'], help='The name of the database.')

with self.argument_context('{} flexible-server db list'.format(command_group)) as c:
c.argument('server_name', id_part=None, options_list=['--server-name', '-s'], arg_type=server_name_arg_type)
c.argument('database_name', id_part=None, arg_type=database_name_setter_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
c.argument('database_name', id_part=None, arg_type=database_name_setter_arg_type, options_list=['--database-name', '-d'], help='The name of the database.')

with self.argument_context('{} flexible-server db delete'.format(command_group)) as c:
c.argument('database_name', arg_type=database_name_getter_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
c.argument('database_name', arg_type=database_name_getter_arg_type, options_list=['--database-name', '-d'], help='The name of the database.')
c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation.')

with self.argument_context('{} flexible-server show-connection-string'.format(command_group)) as c:
Expand All @@ -440,7 +445,7 @@ def _flexible_server_params(command_group):
help='The login username of the administrator.')
c.argument('administrator_login_password', options_list=['--admin-password', '-p'],
help='The login password of the administrator.')
c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of the database.')

with self.argument_context('{} flexible-server replica list'.format(command_group)) as c:
c.argument('server_name', id_part=None, options_list=['--name', '-n'], help='Name of the source server.')
Expand Down
8 changes: 5 additions & 3 deletions src/azure-cli/azure/cli/command_modules/rdbms/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def create_firewall_rule(cmd, resource_group_name, server_name, start_ip, end_ip
elif db_engine == 'mariadb':
firewall_client = cf_mariadb_firewall_rules(cmd.cli_ctx, None)

firewall = firewall_client.create_or_update(resource_group_name, server_name, firewall_name, start_ip,
end_ip).result()
return firewall.name
parameters = {'name': firewall_name, 'start_ip_address': start_ip, 'end_ip_address': end_ip}

firewall = firewall_client.begin_create_or_update(resource_group_name, server_name, firewall_name, parameters)

return firewall.result().name
Loading