Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/resource-mover/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.1.1
++++++
* Support the copying of tags and user managed identities associated with the resource.
* Support 'system-data' for the resource types in resource mover.

0.1.0
++++++
* Initial release.
21 changes: 12 additions & 9 deletions src/resource-mover/azext_resource_mover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=unused-import

import azext_resource_mover._help
from azure.cli.core import AzCommandsLoader
from azext_resource_mover.generated._help import helps # pylint: disable=unused-import
try:
from azext_resource_mover.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class ResourceMoverServiceAPICommandsLoader(AzCommandsLoader):
Expand All @@ -33,8 +30,11 @@ def load_command_table(self, args):
try:
from azext_resource_mover.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.commands'):
pass
else:
raise e
return self.command_table

def load_arguments(self, command):
Expand All @@ -43,8 +43,11 @@ def load_arguments(self, command):
try:
from azext_resource_mover.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual._params'):
pass
else:
raise e


COMMAND_LOADER_CLS = ResourceMoverServiceAPICommandsLoader
20 changes: 20 additions & 0 deletions src/resource-mover/azext_resource_mover/_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
7 changes: 5 additions & 2 deletions src/resource-mover/azext_resource_mover/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.action'):
pass
else:
raise e
7 changes: 5 additions & 2 deletions src/resource-mover/azext_resource_mover/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.custom'):
pass
else:
raise e
12 changes: 9 additions & 3 deletions src/resource-mover/azext_resource_mover/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from knack.help_files import helps


helps['resource-mover'] = '''
type: group
short-summary: Manage Resource Mover Service API
'''

helps['resource-mover move-collection'] = """
type: group
short-summary: Manage move collection with resource mover
Expand Down Expand Up @@ -240,9 +245,10 @@
target-id="/subscriptions/c4488a3f-a7f7-4ad4-aa72-0e1f4d9c0756/resourceGroups/westusRG/providers/Microsoft.Network/netw\
orkInterfaces/eastusvm140" --resource-settings "{\\"resourceType\\":\\"Microsoft.Compute/virtualMachines\\",\\"targetAv\
ailabilitySetId\\":\\"/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/availabilitySets/avset1\
\\",\\"targetAvailabilityZone\\":\\"2\\",\\"targetResourceName\\":\\"westusvm1\\",\\"targetVmSize\\":null}" \
--source-id "/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/virtualMachines/eastusvm1" \
--move-collection-name "movecollection1" --name "moveresourcename1" --resource-group "rg1"
\\",\\"targetAvailabilityZone\\":\\"2\\",\\"targetResourceName\\":\\"westusvm1\\",\\"targetVmSize\\":null,\\"userManage\
dIdentities\\":[\\"/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.ManagedIdentity/userAssignedIdentit\
ies/umi1\\"]}" --source-id "/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/virtualMachines/ea\
stusvm1" --move-collection-name "movecollection1" --name "moveresourcename1" --resource-group "rg1"
"""

helps['resource-mover move-resource wait'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def load_arguments(self, _):
c.argument('source_id', type=str, help='Gets or sets the Source ARM Id of the resource.')
c.argument('existing_target_id', type=str, help='Gets or sets the existing target ARM Id of the resource.')
c.argument('resource_settings', type=validate_file_or_dict, help='Gets or sets the resource settings. Expected '
'value: json-string/@json-file.')
'value: json-string/json-file/@json-file.')
c.argument('depends_on_overrides', action=AddDependsOnOverrides, nargs='+', help='Gets or sets the move '
'resource dependencies overrides.')

Expand Down
30 changes: 24 additions & 6 deletions src/resource-mover/azext_resource_mover/generated/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


# pylint: disable=protected-access

# pylint: disable=no-self-use


import argparse
from collections import defaultdict
from knack.util import CLIError
Expand All @@ -19,7 +24,7 @@ def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
namespace.identity = action

def get_action(self, values, option_string): # pylint: disable=no-self-use
def get_action(self, values, option_string):
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
Expand All @@ -31,15 +36,22 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
for k in properties:
kl = k.lower()
v = properties[k]

if kl == 'type':
d['type'] = v[0]

elif kl == 'principal-id':
d['principal_id'] = v[0]

elif kl == 'tenant-id':
d['tenant_id'] = v[0]

else:
raise CLIError('Unsupported Key {} is provided for parameter identity. All possible keys are: type, '
'principal-id, tenant-id'.format(k))
raise CLIError(
'Unsupported Key {} is provided for parameter identity. All possible keys are: type, principal-id,'
' tenant-id'.format(k)
)

return d


Expand All @@ -48,7 +60,7 @@ def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
super(AddDependsOnOverrides, self).__call__(parser, namespace, action, option_string)

def get_action(self, values, option_string): # pylint: disable=no-self-use
def get_action(self, values, option_string):
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
Expand All @@ -60,11 +72,17 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
for k in properties:
kl = k.lower()
v = properties[k]

if kl == 'id':
d['id'] = v[0]

elif kl == 'target-id':
d['target_id'] = v[0]

else:
raise CLIError('Unsupported Key {} is provided for parameter depends_on_overrides. All possible keys '
'are: id, target-id'.format(k))
raise CLIError(
'Unsupported Key {} is provided for parameter depends-on-overrides. All possible keys are: id,'
' target-id'.format(k)
)

return d
64 changes: 39 additions & 25 deletions src/resource-mover/azext_resource_mover/generated/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,40 @@
# --------------------------------------------------------------------------
# pylint: disable=too-many-statements
# pylint: disable=too-many-locals
# pylint: disable=bad-continuation
# pylint: disable=line-too-long

from azure.cli.core.commands import CliCommandType
from azext_resource_mover.generated._client_factory import (
cf_move_collection,
cf_move_resource,
cf_unresolved_dependency,
)


resource_mover_move_collection = CliCommandType(
operations_tmpl='azext_resource_mover.vendored_sdks.resourcemover.operations._move_collections_operations#MoveCollectionsOperations.{}',
client_factory=cf_move_collection,
)


resource_mover_unresolved_dependency = CliCommandType(
operations_tmpl='azext_resource_mover.vendored_sdks.resourcemover.operations._unresolved_dependencies_operations#UnresolvedDependenciesOperations.{}',
client_factory=cf_unresolved_dependency,
)


resource_mover_move_resource = CliCommandType(
operations_tmpl='azext_resource_mover.vendored_sdks.resourcemover.operations._move_resources_operations#MoveResourcesOperations.{}',
client_factory=cf_move_resource,
)


def load_command_table(self, _):

from azext_resource_mover.generated._client_factory import cf_move_collection
resource_mover_move_collection = CliCommandType(
operations_tmpl='azext_resource_mover.vendored_sdks.resourcemover.operations._move_collections_operations#MoveC'
'ollectionsOperations.{}',
client_factory=cf_move_collection)
with self.command_group('resource-mover move-collection', resource_mover_move_collection,
client_factory=cf_move_collection) as g:
with self.command_group(
'resource-mover move-collection', resource_mover_move_collection, client_factory=cf_move_collection
) as g:
g.custom_command('list', 'resource_mover_move_collection_list')
g.custom_show_command('show', 'resource_mover_move_collection_show')
g.custom_command('create', 'resource_mover_move_collection_create')
Expand All @@ -33,31 +54,24 @@ def load_command_table(self, _):
g.custom_command('initiate-move', 'resource_mover_move_collection_initiate_move', supports_no_wait=True)
g.custom_command('list-required-for', 'resource_mover_move_collection_list_required_for')
g.custom_command('prepare', 'resource_mover_move_collection_prepare', supports_no_wait=True)
g.custom_command('resolve-dependency', 'resource_mover_move_collection_resolve_dependency',
supports_no_wait=True)
g.custom_command(
'resolve-dependency', 'resource_mover_move_collection_resolve_dependency', supports_no_wait=True
)
g.custom_wait_command('wait', 'resource_mover_move_collection_show')

from azext_resource_mover.generated._client_factory import cf_move_resource
resource_mover_move_resource = CliCommandType(
operations_tmpl='azext_resource_mover.vendored_sdks.resourcemover.operations._move_resources_operations#MoveRes'
'ourcesOperations.{}',
client_factory=cf_move_resource)
with self.command_group('resource-mover move-resource', resource_mover_move_resource,
client_factory=cf_move_resource) as g:
with self.command_group(
'resource-mover move-collection', resource_mover_unresolved_dependency, client_factory=cf_unresolved_dependency
) as g:
g.custom_command('list-unresolved-dependency', 'resource_mover_move_collection_list_unresolved_dependency')

with self.command_group(
'resource-mover move-resource', resource_mover_move_resource, client_factory=cf_move_resource
) as g:
g.custom_command('list', 'resource_mover_move_resource_list')
g.custom_show_command('show', 'resource_mover_move_resource_show')
g.custom_command('delete', 'resource_mover_move_resource_delete', supports_no_wait=True, confirmation=True)
g.custom_command('add', 'resource_mover_move_resource_add', supports_no_wait=True)
g.custom_wait_command('wait', 'resource_mover_move_resource_show')

from azext_resource_mover.generated._client_factory import cf_unresolved_dependency
resource_mover_unresolved_dependency = CliCommandType(
operations_tmpl='azext_resource_mover.vendored_sdks.resourcemover.operations._unresolved_dependencies_operation'
's#UnresolvedDependenciesOperations.{}',
client_factory=cf_unresolved_dependency)
with self.command_group('resource-mover move-collection', resource_mover_unresolved_dependency,
client_factory=cf_unresolved_dependency) as g:
g.custom_command('list-unresolved-dependency', 'resource_mover_move_collection_list_unresolved_dependency')

with self.command_group('resource-mover', is_experimental=True):
pass
Loading