Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new module DataMigration #4298

Merged
merged 23 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4434f5c
Adding initial settings to module
ashutoshsuman99 Jan 5, 2022
c7e0a66
Working on Linter, License and Cred scan errors
ashutoshsuman99 Jan 6, 2022
0a872ea
Working on Static analysis error
ashutoshsuman99 Jan 6, 2022
8f81634
Hiding Register-ir commands for now
ashutoshsuman99 Jan 6, 2022
7ec01a5
Lint and Integration Tests solving
ashutoshsuman99 Jan 6, 2022
56c1c53
Unhiding register-ir command and adding windows test to assessment co…
ashutoshsuman99 Jan 6, 2022
bccfbc4
Making error messages proper
ashutoshsuman99 Jan 6, 2022
3a219d5
Nit changes from comments
ashutoshsuman99 Jan 10, 2022
08453c2
MultiServer support for Assessment and nit changes
ashutoshsuman99 Jan 11, 2022
9b78ff2
Adding Proper Json format, lower case for access, seperate util for W…
ashutoshsuman99 Jan 13, 2022
61c2443
Correcting Lint and Static errors
ashutoshsuman99 Jan 13, 2022
b93ced7
Removing to-* from command names
ashutoshsuman99 Jan 14, 2022
353e310
Adding correct error formats
ashutoshsuman99 Jan 14, 2022
224c703
Removing Update operation from DatabaseMigration
ashutoshsuman99 Jan 17, 2022
0fda2bb
Updating readme and help
ashutoshsuman99 Jan 17, 2022
cff3ee7
Nit: Readme corrections
ashutoshsuman99 Jan 17, 2022
330453f
Added CLI Test Cases
sagangwar Jan 18, 2022
8acf3a7
Removed IR AuthKeys and Unused Imports
sagangwar Jan 18, 2022
699a966
Adding Default IR Program files path for 32-bit error
ashutoshsuman99 Jan 24, 2022
ac73167
Nit and Static analysis fix
ashutoshsuman99 Jan 24, 2022
5794c5a
Added File Extension Validation
sagangwar Jan 24, 2022
5d3366c
Removed unnecessary spaces and fixed static analysis Issues
sagangwar Jan 24, 2022
75edbf6
Deferred IR path and MSI Extension validations
sagangwar Jan 24, 2022
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
8 changes: 8 additions & 0 deletions src/datamigration/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

0.1.0
++++++
* Initial release.
139 changes: 139 additions & 0 deletions src/datamigration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Azure CLI datamigration Extension #
This is the extension for datamigration

### How to use ###
Install this extension using the below CLI command
```
az extension add --name datamigration
```

### Included Features ###
#### datamigration to-sql-managed-instance ####
##### Create #####
```
az datamigration to-sql-managed-instance create --managed-instance-name "managedInstance1" \
--source-location "{\\"fileShare\\":{\\"path\\":\\"C:\\\\\\\\aaa\\\\\\\\bbb\\\\\\\\ccc\\",\\"password\\":\\"placeholder\\",\\"username\\":\\"name\\"}}" \
--target-location account-key="abcd" storage-account-resource-id="account.database.windows.net" \
--migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent" \
ashutoshsuman99 marked this conversation as resolved.
Show resolved Hide resolved
--offline-configuration last-backup-name="last_backup_file_name" offline=true \
--scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance" \
--source-database-name "aaa" \
--source-sql-connection authentication="WindowsAuthentication" data-source="aaa" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" \
--resource-group "testrg" --target-db-name "db1"
```
##### Create #####
```
az datamigration to-sql-managed-instance create --managed-instance-name "managedInstance1" \
--source-location "{\\"fileShare\\":{\\"path\\":\\"C:\\\\\\\\aaa\\\\\\\\bbb\\\\\\\\ccc\\",\\"password\\":\\"placeholder\\",\\"username\\":\\"name\\"}}" \
ashutoshsuman99 marked this conversation as resolved.
Show resolved Hide resolved
--target-location account-key="abcd" storage-account-resource-id="account.database.windows.net" \
--migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent" \
--offline-configuration last-backup-name="last_backup_file_name" offline=true \
--scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance" \
--source-database-name "aaa" \
--source-sql-connection authentication="WindowsAuthentication" data-source="aaa" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" \
--resource-group "testrg" --target-db-name "db1"
```
##### Show #####
```
az datamigration to-sql-managed-instance show --managed-instance-name "managedInstance1" --resource-group "testrg" \
--target-db-name "db1"
```
##### Cancel #####
```
az datamigration to-sql-managed-instance cancel --managed-instance-name "managedInstance1" \
--migration-operation-id "4124fe90-d1b6-4b50-b4d9-46d02381f59a" --resource-group "testrg" --target-db-name "db1"
```
##### Cutover #####
```
az datamigration to-sql-managed-instance cutover --managed-instance-name "managedInstance1" \
--migration-operation-id "4124fe90-d1b6-4b50-b4d9-46d02381f59a" --resource-group "testrg" --target-db-name "db1"
```
#### datamigration to-sql-vm ####
##### Create #####
```
az datamigration to-sql-vm create \
--source-location "{\\"fileShare\\":{\\"path\\":\\"C:\\\\\\\\aaa\\\\\\\\bbb\\\\\\\\ccc\\",\\"password\\":\\"placeholder\\",\\"username\\":\\"name\\"}}" \
ashutoshsuman99 marked this conversation as resolved.
Show resolved Hide resolved
--target-location account-key="abcd" storage-account-resource-id="account.database.windows.net" \
--migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent" \
--offline-configuration last-backup-name="last_backup_file_name" offline=true \
--scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm" \
--source-database-name "aaa" \
--source-sql-connection authentication="WindowsAuthentication" data-source="aaa" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" \
--resource-group "testrg" --sql-virtual-machine-name "testvm" --target-db-name "db1"
```
##### Create #####
```
az datamigration to-sql-vm create \
--source-location "{\\"fileShare\\":{\\"path\\":\\"C:\\\\\\\\aaa\\\\\\\\bbb\\\\\\\\ccc\\",\\"password\\":\\"placeholder\\",\\"username\\":\\"name\\"}}" \
ashutoshsuman99 marked this conversation as resolved.
Show resolved Hide resolved
--target-location account-key="abcd" storage-account-resource-id="account.database.windows.net" \
--migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent" \
--offline-configuration last-backup-name="last_backup_file_name" offline=true \
--scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm" \
--source-database-name "aaa" \
--source-sql-connection authentication="WindowsAuthentication" data-source="aaa" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" \
--resource-group "testrg" --sql-virtual-machine-name "testvm" --target-db-name "db1"
```
##### Show #####
```
az datamigration to-sql-vm show --resource-group "testrg" --sql-virtual-machine-name "testvm" --target-db-name "db1"
```
##### Cancel #####
```
az datamigration to-sql-vm cancel --migration-operation-id "4124fe90-d1b6-4b50-b4d9-46d02381f59a" \
--resource-group "testrg" --sql-virtual-machine-name "testvm" --target-db-name "db1"
```
##### Cutover #####
```
az datamigration to-sql-vm cutover --migration-operation-id "4124fe90-d1b6-4b50-b4d9-46d02381f59a" \
--resource-group "testrg" --sql-virtual-machine-name "testvm" --target-db-name "db1"
```
#### datamigration sql-service ####
##### Create #####
```
az datamigration sql-service create --location "northeurope" --resource-group "testrg" --name "testagent"

az datamigration sql-service wait --created --resource-group "{rg}" --name "{mySqlMigrationService}"
```
##### Create #####
```
az datamigration sql-service create --location "northeurope" --resource-group "testrg" --name "testagent"

az datamigration sql-service wait --created --resource-group "{rg}" --name "{mySqlMigrationService}"
```
##### List #####
```
az datamigration sql-service list --resource-group "testrg"
```
##### Show #####
```
az datamigration sql-service show --resource-group "testrg" --name "service1"
```
##### Update #####
```
az datamigration sql-service update --tags mytag="myval" --resource-group "testrg" --name "testagent"
```
##### Delete-node #####
```
az datamigration sql-service delete-node --integration-runtime-name "IRName" --node-name "nodeName" \
--resource-group "testrg" --name "service1"
```
##### List-auth-key #####
```
az datamigration sql-service list-auth-key --resource-group "testrg" --name "service1"
```
##### List-integration-runtime-metric #####
```
az datamigration sql-service list-integration-runtime-metric --resource-group "testrg" --name "service1"
```
##### List-migration #####
```
az datamigration sql-service list-migration --resource-group "testrg" --name "service1"
```
##### Regenerate-auth-key #####
```
az datamigration sql-service regenerate-auth-key --key-name "authKey1" --resource-group "testrg" --name "service1"
```
##### Delete #####
```
az datamigration sql-service delete --resource-group "testrg" --name "service1"
```
53 changes: 53 additions & 0 deletions src/datamigration/azext_datamigration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=unused-import

from azure.cli.core import AzCommandsLoader
import azext_datamigration._help


class DataMigrationManagementClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_datamigration.generated._client_factory import cf_datamigration_cl
datamigration_custom = CliCommandType(
operations_tmpl='azext_datamigration.custom#{}',
client_factory=cf_datamigration_cl)
parent = super(DataMigrationManagementClientCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=datamigration_custom)

def load_command_table(self, args):
from azext_datamigration.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_datamigration.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError as e:
if e.name.endswith('manual.commands'):
pass
else:
raise e
return self.command_table

def load_arguments(self, command):
from azext_datamigration.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_datamigration.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError as e:
if e.name.endswith('manual._params'):
pass
else:
raise e


COMMAND_LOADER_CLS = DataMigrationManagementClientCommandsLoader
20 changes: 20 additions & 0 deletions src/datamigration/azext_datamigration/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import
# pylint: disable=unused-import
from .generated._help import helps # pylint: disable=reimported
try:
from .manual._help import helps # pylint: disable=reimported
except ImportError as e:
if e.name.endswith('manual._help'):
pass
else:
raise e
20 changes: 20 additions & 0 deletions src/datamigration/azext_datamigration/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError as e:
if e.name.endswith('manual.action'):
pass
else:
raise e
4 changes: 4 additions & 0 deletions src/datamigration/azext_datamigration/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.15.0"
}
20 changes: 20 additions & 0 deletions src/datamigration/azext_datamigration/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError as e:
if e.name.endswith('manual.custom'):
pass
else:
raise e
12 changes: 12 additions & 0 deletions src/datamigration/azext_datamigration/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__)
28 changes: 28 additions & 0 deletions src/datamigration/azext_datamigration/generated/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


def cf_datamigration_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_datamigration.vendored_sdks.datamigration import DataMigrationManagementClient
return get_mgmt_service_client(cli_ctx,
DataMigrationManagementClient)


def cf_database_migration_sqlmi(cli_ctx, *_):
return cf_datamigration_cl(cli_ctx).database_migrations_sql_mi


def cf_database_migration_sqlvm(cli_ctx, *_):
return cf_datamigration_cl(cli_ctx).database_migrations_sql_vm


def cf_sqlmigration_service(cli_ctx, *_):
return cf_datamigration_cl(cli_ctx).sql_migration_services
Loading