def create_rediscache(self): ''' Creates redis cache instance with the specified configuration. :return: deserialized redis cache instance state dictionary ''' self.log("Creating redis cache instance {0}".format(self.name)) try: redis_config = dict() for key in self.redis_configuration_properties: if getattr(self, key, None): redis_config[underline_to_hyphen( key)] = underline_to_hyphen(getattr(self, key)) params = RedisCreateParameters( location=self.location, sku=Sku(self.sku['name'].title(), self.sku['size'][0], self.sku['size'][1:]), tags=self.tags, redis_configuration=redis_config, enable_non_ssl_port=self.enable_non_ssl_port, tenant_settings=self.tenant_settings, shard_count=self.shard_count, subnet_id=self.subnet, static_ip=self.static_ip) response = self._client.redis.create( resource_group_name=self.resource_group, name=self.name, parameters=params) if isinstance(response, AzureOperationPoller): response = self.get_poller_result(response) except CloudError as exc: self.log('Error attempting to create the redis cache instance.') self.fail("Error creating the redis cache instance: {0}".format( str(exc))) return rediscache_to_dict(response)
def update_rediscache(self): ''' Updates Azure Cache for Redis instance with the specified configuration. :return: Azure Cache for Redis instance state dictionary ''' self.log( "Updating Azure Cache for Redis instance {0}".format(self.name)) try: redis_config = dict() for key in self.redis_configuration_properties: if getattr(self, key, None): redis_config[underline_to_hyphen(key)] = underline_to_hyphen(getattr(self, key)) params = RedisUpdateParameters( redis_configuration=redis_config, enable_non_ssl_port=self.enable_non_ssl_port, tenant_settings=self.tenant_settings, shard_count=self.shard_count, sku=Sku(self.sku['name'].title(), self.sku['size'][0], self.sku['size'][1:]), tags=self.tags ) response = self._client.redis.update(resource_group_name=self.resource_group, name=self.name, parameters=params) if isinstance(response, AzureOperationPoller) or isinstance(response, LROPoller): response = self.get_poller_result(response) if self.wait_for_provisioning: self.wait_for_redis_running() except CloudError as exc: self.log('Error attempting to update the Azure Cache for Redis instance.') self.fail( "Error updating the Azure Cache for Redis instance: {0}".format(str(exc))) return rediscache_to_dict(response)