Skip to content

Commit

Permalink
Update from rc4 to rc5 of Azure SDK for Python (Azure#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
derekbekoe authored Jun 28, 2016
1 parent 6f4ce26 commit 89d09bb
Show file tree
Hide file tree
Showing 29 changed files with 1,981 additions and 1,673 deletions.
4 changes: 1 addition & 3 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ max-locals=25
# Maximum number of branch for function / method body
max-branches=20
[SIMILARITIES]
# TODO: to workaround the dupe lines between 'command_test_script' and 'vcr_test_base'
# this should not be needed once we remove the 'command_test_script' in near future.
min-similarity-lines=50
min-similarity-lines=10

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
applicationinsights==0.10.0
argcomplete==1.3.0
azure==2.0.0rc4
azure==2.0.0rc5
jmespath
pip
mock==1.3.0
Expand Down
2 changes: 1 addition & 1 deletion scripts/sdk_command_gen/gen_command_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from gen_generated_file import main as get_generated_file

AZURE_SDK = 'azure==2.0.0rc4'
AZURE_SDK = 'azure==2.0.0rc5'
COMMAND_MODULE_PREFIX = 'azure-cli-'

INIT_TEMPLATE = """import pkg_resources
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
'adal>=0.3.0',
'applicationinsights',
'argcomplete>=1.3.0',
'azure==2.0.0rc4',
'azure==2.0.0rc5',
'colorama',
'jmespath',
'msrest>=0.4.0',
Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-network/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
azure==2.0.0rc4
azure==2.0.0rc5
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-network/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]

DEPENDENCIES = [
'azure==2.0.0rc4',
'azure==2.0.0rc5',
]

with open('README.rst', 'r', encoding='utf-8') as f:
Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-profile/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
azure==2.0.0rc4
azure==2.0.0rc5
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-profile/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]

DEPENDENCIES = [
'azure==2.0.0rc4',
'azure==2.0.0rc5',
'adal>=0.3.0'
]

Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-resource/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
azure==2.0.0rc4
azure==2.0.0rc5
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-resource/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]

DEPENDENCIES = [
'azure==2.0.0rc4',
'azure==2.0.0rc5',
]

with open('README.rst', 'r', encoding='utf-8') as f:
Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-role/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
azure==2.0.0rc4
azure==2.0.0rc5
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-role/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]

DEPENDENCIES = [
'azure==2.0.0rc4',
'azure==2.0.0rc5',
]

with open('README.rst', 'r', encoding='utf-8') as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from azure.cli.commands import register_cli_argument, CliArgumentType
from azure.cli.commands.validators import validate_key_value_pairs

from azure.mgmt.storage.models import AccountType
from azure.mgmt.storage.models import SkuName

from azure.storage.blob import PublicAccess, BlockBlobService, PageBlobService, AppendBlobService

Expand All @@ -19,11 +19,11 @@
storage_account_key_options = {'primary': 'key1', 'secondary': 'key2'}

# TODO: update this once enums are supported in commands first-class (task #115175885)
storage_account_types = {'Standard_LRS': AccountType.standard_lrs,
'Standard_ZRS': AccountType.standard_zrs,
'Standard_GRS': AccountType.standard_grs,
'Standard_RAGRS': AccountType.standard_ragrs,
'Premium_LRS': AccountType.premium_lrs}
storage_account_types = {'Standard_LRS': SkuName.standard_lrs,
'Standard_ZRS': SkuName.standard_zrs,
'Standard_GRS': SkuName.standard_grs,
'Standard_RAGRS': SkuName.standard_ragrs,
'Premium_LRS': SkuName.premium_lrs}

# TODO: update this once enums are supported in commands first-class (task #115175885)
public_access_types = {'none': None, 'blob': PublicAccess.Blob, 'container': PublicAccess.Container}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,40 @@ def renew_storage_account_keys(resource_group_name, account_name, key=None):
def show_storage_account_usage():
''' Show the current count and limit of the storage accounts under the subscription. '''
scf = storage_client_factory()
return next((x for x in scf.usage.list() if x.name.value == 'StorageAccounts'), None)
return next((x for x in scf.usage.list().value if x.name.value == 'StorageAccounts'), None) #pylint: disable=no-member

def show_storage_account_connection_string(resource_group_name, account_name, use_http='https'):
''' Show the connection string for a storage account.
:param str use_http:use http as the default endpoint protocol '''
scf = storage_client_factory()
keys = scf.storage_accounts.list_keys(resource_group_name, account_name)
keys = scf.storage_accounts.list_keys(resource_group_name, account_name).keys #pylint: disable=no-member
connection_string = 'DefaultEndpointsProtocol={};AccountName={};AccountKey={}'.format(
use_http,
account_name,
keys.key1) #pylint: disable=no-member
keys[0].value) #pylint: disable=no-member
return {'ConnectionString':connection_string}

def create_storage_account(resource_group_name, account_name, location, account_type, tags=None):
''' Create a storage account. '''
from azure.mgmt.storage.models import StorageAccountCreateParameters
from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku
scf = storage_client_factory()
params = StorageAccountCreateParameters(location, account_type, tags)
# TODO Add the other new params from rc5
# https://github.com/Azure/azure-sdk-for-python/blob/v2.0.0rc5/
# azure-mgmt-storage/azure/mgmt/storage/models/storage_account_create_parameters.py
# accountType is now called sku.name also.
params = StorageAccountCreateParameters(Sku(account_type), 'Storage', location, tags)
return scf.storage_accounts.create(resource_group_name, account_name, params)

def set_storage_account_properties(
resource_group_name, account_name, account_type=None, tags='', custom_domain=None):
''' Update storage account property (only one at a time).
:param str custom_domain:the custom domain name
'''
from azure.mgmt.storage.models import StorageAccountUpdateParameters, CustomDomain
from azure.mgmt.storage.models import StorageAccountUpdateParameters, CustomDomain, Sku
scf = storage_client_factory()
params = StorageAccountUpdateParameters(tags, account_type, custom_domain)
# TODO Add the new params encryption and access_tier after rc5 update
sku = Sku(account_type) if account_type else None
params = StorageAccountUpdateParameters(sku=sku, tags=tags, custom_domain=custom_domain)
return scf.storage_accounts.update(resource_group_name, account_name, params)

def container_exists(client, container_name, snapshot=None, timeout=None):
Expand Down
Empty file.
Loading

0 comments on commit 89d09bb

Please sign in to comment.