Skip to content

Commit

Permalink
[Redis] Update dependencies (Azure#7082)
Browse files Browse the repository at this point in the history
  • Loading branch information
troydai authored Aug 17, 2018
1 parent fdcf101 commit ee2b8d1
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 115 deletions.
4 changes: 4 additions & 0 deletions src/command_modules/azure-cli-redis/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.3.2
+++++
* Minor fixes

0.3.1
+++++
* Minor fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long

from azure.cli.core.commands.parameters import get_resource_name_completion_list, name_type, tags_type
import azure.cli.command_modules.redis._help # pylint: disable=unused-import
from azure.cli.command_modules.redis._validators import JsonString, ScheduleEntryList

from azure.mgmt.redis.models import RebootType, RedisKeyType, SkuName

from azure.cli.core.commands.parameters import get_enum_type # TODO: Move this into Knack


def load_arguments(self, _):
from azure.mgmt.redis.models import RebootType, RedisKeyType, SkuName
from azure.cli.command_modules.redis._validators import JsonString, ScheduleEntryList
from azure.cli.core.commands.parameters import get_enum_type # TODO: Move this into Knack
from azure.cli.core.commands.parameters import get_resource_name_completion_list, name_type, tags_type

with self.argument_context('redis') as c:
c.argument('name', options_list=['--name', '-n'], help='Name of the Redis cache.', id_part='name', completer=get_resource_name_completion_list('Microsoft.Cache/redis'))
c.argument('redis_configuration', help='JSON encoded configuration settings. Use @{file} to load from a file.', type=JsonString)
c.argument('name', options_list=['--name', '-n'], help='Name of the Redis cache.', id_part='name',
completer=get_resource_name_completion_list('Microsoft.Cache/redis'))
c.argument('redis_configuration', help='JSON encoded configuration settings. Use @{file} to load from a file.',
type=JsonString)
c.argument('reboot_type', arg_type=get_enum_type(RebootType))
c.argument('key_type', arg_type=get_enum_type(RedisKeyType))
c.argument('shard_id', type=int)
c.argument('sku', help='Type of Redis cache.', arg_type=get_enum_type(SkuName))
c.argument('vm_size', help='Size of Redis cache to deploy. Example : values for C family (C0, C1, C2, C3, C4, C5, C6). For P family (P1, P2, P3, P4)')
c.argument('vm_size', help='Size of Redis cache to deploy. Example : values for C family (C0, C1, C2, C3, C4, '
'C5, C6). For P family (P1, P2, P3, P4)')
c.argument('enable_non_ssl_port', action='store_true')
c.argument('shard_count', type=int)
c.argument('tags', tags_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# --------------------------------------------------------------------------------------------

from azure.cli.core.util import shell_safe_json_parse
from azure.mgmt.redis.models import ScheduleEntry


class JsonString(dict):
Expand All @@ -20,10 +19,13 @@ def __init__(self, value):
class ScheduleEntryList(list):
def __init__(self, value):
super(ScheduleEntryList, self).__init__()

from azure.mgmt.redis.models import ScheduleEntry

if value[0] in ("'", '"') and value[-1] == value[0]:
# Remove leading and trailing quotes for dos/cmd.exe users
value = value[1:-1]
dictval = shell_safe_json_parse(value)
self.extend([ScheduleEntry(row['dayOfWeek'],
int(row['startHourUtc']),
row.get('maintenanceWindow', None)) for row in dictval])
self.extend([ScheduleEntry(day_of_week=row['dayOfWeek'],
start_hour_utc=int(row['startHourUtc']),
maintenance_window=row.get('maintenanceWindow', None)) for row in dictval])
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

from azure.cli.core.commands import CliCommandType

from azure.cli.command_modules.redis._client_factory import cf_redis, cf_patch_schedules
from azure.cli.command_modules.redis.custom import wrong_vmsize_argument_exception_handler


def load_command_table(self, _):
from azure.cli.command_modules.redis._client_factory import cf_redis, cf_patch_schedules
from azure.cli.command_modules.redis.custom import wrong_vmsize_argument_exception_handler

redis_sdk = CliCommandType(
operations_tmpl='azure.mgmt.redis.operations.redis_operations#RedisOperations.{}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def cli_redis_update_settings(cmd, client, resource_group_name, name, redis_conf

# Due to swagger/mgmt SDK quirkiness, we have to manually copy over
# the resource retrieved to a create_parameters object
update_params = RedisUpdateParameters(
update_params = RedisUpdateParameters( # pylint: disable=too-many-function-args
existing.redis_configuration,
existing.enable_non_ssl_port,
existing.tenant_settings,
Expand All @@ -79,7 +79,7 @@ def cli_redis_update(cmd, instance, sku=None, vm_size=None):
instance.sku.family = vm_size[0]
instance.sku.capacity = vm_size[1:]

update_params = RedisUpdateParameters(
update_params = RedisUpdateParameters( # pylint: disable=too-many-function-args
instance.redis_configuration,
instance.enable_non_ssl_port,
instance.tenant_settings,
Expand Down Expand Up @@ -113,15 +113,15 @@ def cli_redis_create(cmd, client,
"""
from azure.mgmt.redis.models import RedisCreateParameters, Sku
params = RedisCreateParameters(
location,
Sku(sku, vm_size[0], vm_size[1:]),
tags,
redis_configuration,
enable_non_ssl_port,
tenant_settings,
shard_count,
subnet_id,
static_ip)
location=location,
sku=Sku(sku, vm_size[0], vm_size[1:]),
tags=tags,
redis_configuration=redis_configuration,
enable_non_ssl_port=enable_non_ssl_port,
tenant_settings=tenant_settings,
shard_count=shard_count,
subnet_id=subnet_id,
static_ip=static_ip)
return client.create(resource_group_name, name, params)

# endregion
Loading

0 comments on commit ee2b8d1

Please sign in to comment.