This commit is contained in:
Travis Prescott 2016-03-23 16:48:10 -07:00
Родитель 53f1d1382a
Коммит d464c1dfec
2 изменённых файлов: 41 добавлений и 35 удалений

Просмотреть файл

@ -12,7 +12,7 @@
<OutputPath>.</OutputPath>
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
<LaunchProvider>Standard Python launcher</LaunchProvider>
<InterpreterId>{1dd9c42b-5980-42ce-a2c3-46d3bf0eede4}</InterpreterId>
<InterpreterId>{57bd5ed7-271b-440d-b2db-891dd01f2420}</InterpreterId>
<InterpreterVersion>3.5</InterpreterVersion>
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
<CommandLineArguments>
@ -82,11 +82,28 @@
<Folder Include="azure\cli\tests\recordings\" />
</ItemGroup>
<ItemGroup>
<Interpreter Include="..\env\">
<Id>{1dd9c42b-5980-42ce-a2c3-46d3bf0eede4}</Id>
<Content Include="azure\cli\tests\recordings\command_specs.test_spec_network.test_network_usage_list.yaml" />
<Content Include="azure\cli\tests\recordings\command_specs.test_spec_resource.test_resource_group_list.yaml" />
<Content Include="azure\cli\tests\recordings\command_specs.test_spec_vm.test_vm_usage_list_westus.yaml" />
<Content Include="azure\cli\tests\recordings\README.rst" />
</ItemGroup>
<ItemGroup>
<Interpreter Include="..\..\env2\">
<Id>{2b08b5e4-e4b0-4433-a27d-1c323ce4dd70}</Id>
<BaseInterpreter>{2af0f10d-7135-4994-9156-5d01c9c11b7e}</BaseInterpreter>
<Version>2.7</Version>
<Description>env2 (Python 2.7)</Description>
<InterpreterPath>Scripts\python.exe</InterpreterPath>
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
<LibraryPath>Lib\</LibraryPath>
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
<Architecture>X86</Architecture>
</Interpreter>
<Interpreter Include="..\..\env3\">
<Id>{57bd5ed7-271b-440d-b2db-891dd01f2420}</Id>
<BaseInterpreter>{2af0f10d-7135-4994-9156-5d01c9c11b7e}</BaseInterpreter>
<Version>3.5</Version>
<Description>env (Python 3.5)</Description>
<Description>env3 (Python 3.5)</Description>
<InterpreterPath>Scripts\python.exe</InterpreterPath>
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
<LibraryPath>Lib\</LibraryPath>
@ -94,12 +111,6 @@
<Architecture>X86</Architecture>
</Interpreter>
</ItemGroup>
<ItemGroup>
<Content Include="azure\cli\tests\recordings\command_specs.test_spec_network.test_network_usage_list.yaml" />
<Content Include="azure\cli\tests\recordings\command_specs.test_spec_resource.test_resource_group_list.yaml" />
<Content Include="azure\cli\tests\recordings\command_specs.test_spec_vm.test_vm_usage_list_westus.yaml" />
<Content Include="azure\cli\tests\recordings\README.rst" />
</ItemGroup>
<Import Project="$(PtvsTargetsFile)" Condition="Exists($(PtvsTargetsFile))" />
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="!Exists($(PtvsTargetsFile))" />
</Project>

Просмотреть файл

@ -112,7 +112,7 @@ storage_account_type_string = ' | '.join(storage_account_types)
L('Values: {}'.format(storage_account_type_string)), required=True)
@option('--tags <tags>',
L('storage account tags. Tags are key=value pairs separated with semicolon(;)'))
def set_container(args, unexpected): #pylint: disable=unused-argument
def create_account(args, unexpected): #pylint: disable=unused-argument
from azure.mgmt.storage.models import StorageAccountCreateParameters
smc = _storage_client_factory()
@ -125,17 +125,9 @@ def set_container(args, unexpected): #pylint: disable=unused-argument
except KeyError:
raise IncorrectUsageError(L('type must be: {}'
.format(storage_account_type_string)))
tags = dict() if args.get('tags') else None
for tag in args.get('tags').split(';'):
tag_components = tag.split('=')
try:
tags[tag_components[0]] = tag_components[1]
except IndexError:
pass
params = StorageAccountCreateParameters(args.get('location'),
account_type,
tags)
_resolve_tags(args))
return smc.storage_accounts.create(resource_group, account_name, params)
@ -155,23 +147,13 @@ def set_account(args, unexpected): #pylint: disable=unused-argument
resource_group = args.get('resource-group')
account_name = args.get('account-name')
domain = args.get('custom-domain')
try:
account_type = storage_account_types[args.get('type')] if args.get('type') else None
except KeyError:
raise IncorrectUsageError(L('type must be: {}'
.format(storage_account_type_string)))
tags = dict() if args.get('tags') else None
if tags:
for tag in args.get('tags').split(';'):
tag_components = tag.split('=')
try:
tags[tag_components[0]] = tag_components[1]
except IndexError:
pass
domain = CustomDomain(
args.get('custom-domain'),
use_sub_domain=args.get('subdomain')) if args.get('custom-domain') else None
params = StorageAccountUpdateParameters(tags, account_type, domain)
params = StorageAccountUpdateParameters(_resolve_tags(args), account_type, domain)
return smc.storage_accounts.update(resource_group, account_name, params)
@ -280,7 +262,7 @@ def acquire_container_lease(args, unexpected): #pylint: disable=unused-argument
@command('storage container lease renew')
@description(L('Renew a lock on a container for delete operations.'))
@option('--container-name -c <containerName>', L('the name of the container'), required=True)
@option('--lease-id --lid <id>', L('lease id to renew in GUID format'))
@option('--lease-id --lid <id>', L('lease id to renew in GUID format'), required=True)
@option('--account-name -n <accountName>', L('the storage account name'))
@option('--account-key -k <accountKey>', L('the storage account key'))
@option('--connection-string -t <connectionString>', L('the storage connection string'))
@ -330,7 +312,7 @@ def break_container_lease(args, unexpected): #pylint: disable=unused-argument
raise ValueError('Valid durations are: {}'.format(lease_duration_values_string))
bbs.break_container_lease(container_name=args.get('container-name'),
lease_break_period=lease_break_period)
lease_break_period=lease_duration_values[lease_break_period])
# BLOB COMMANDS
# TODO: Evaluate for removing hand-authored commands in favor of auto-commands (task ##115068835)
@ -562,8 +544,8 @@ def storage_file_download(args, unexpected): #pylint: disable=unused-argument
@command('storage file exists')
@description(L('Check if a file exists.'))
@option('--share-name -s <shareName>', L('the file share name'), required=True)
@option('--directory-name -d <directoryName>', L('the directory to delete'), required=True)
@option('--file-name -f <fileName>', L('the file name'), required=True)
@option('--directory-name -d <directoryName>', L('subdirectory path to the file'))
@option('--account-name -n <accountName>', L('the storage account name'))
@option('--account-key -k <accountKey>', L('the storage account key'))
@option('--connection-string -t <connectionString>', L('the storage connection string'))
@ -616,6 +598,19 @@ def _get_file_service_client(args):
_resolve_storage_account_key(args),
_resolve_connection_string(args))
def _resolve_tags(args):
tag_string = args.get('tags')
if tag_string:
tags = dict()
for tag in tag_string.split(';'):
comps = tag.split('=', 1)
key = comps[0]
value = comps[1] if len(comps) > 1 else ''
tags[key] = value
else:
tags = None
return tags
# TODO: Remove once these parameters are supported first-class by @option (task #116054675)
def _resolve_storage_account(args):
return args.get('account-name') or environ.get('AZURE_STORAGE_ACCOUNT')