Distributed Cache Service (DCS)

Redis is a NoSQL database. It can handle various data structures, but should not be used for complex data structures; relational databases are better suited for these. While caching the storage in the RAM allows fast data access, Redis is ideal for all applications in which speed is the main focus. However, the storage cache not persistent, meaning that the stored data is deleted if the virtual machine is switched off. The Distributed Cache Service is ideal for use as a cache server (e.g. in order to accelerate the loading times of websites), for real-time analyses, high-speed transactions, and message queuing. Clusters made up of individual DCS instances can be used for applications with extremely high performance requirements. Redis is available in the Open Telekom Cloud as the Distributed Cache Service. Via the console, the database can be defined in three variants: as a single-node database for temporary data storage, as a master/standby database for higher availability, and as a cluster for high performance. The Distributed Cache Service is billed on an hourly basis in accordance with the chosen RAM size and type (master/standby or single-node database).

Instances

A Distributed Cache Service Instance is a Redis instance on top of Open Telekom Cloud.

List Instances

This interface is used to query all DCS Instances and to filter the output with query parameters.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


for instance in conn.dcs.instances():
    print(instance)

Create Instance

This interface is used to create a DCS instance with parameters.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = conn.dcs.create_instance(
    name="dcs-test",
    available_zones=["eu-de-03"],
    capacity=2,
    engine="Redis",
    engine_version="3.0.7",
    maintain_begin="02:00:00",
    maintain_end="06:00:00",
    password="Password.123",
    product_id="OTC_DCS_SINGLE",
    resource_spec_code="dcs.single_node",
    security_group_id="bb0e60ab-b6e0-4c61-a503-63213c18effa",
    subnet_id="25d24fc8-d019-4a34-9fff-0a09fde6a9cb",
    vpc_id="26ca2783-dc40-4e3a-95b1-5a0756441e12",
)
print(instance)

'''
attrs = {
    "name": "dcs-test",
    "engine": "Redis",
    "capacity": 2,
    "resource_spec_code": "dcs.single_node",
    "engine_version": "3.0.7",
    "vpc_id": "26ca2783-dc40-4e3a-95b1-5a0756441e12",
    "product_id": "OTC_DCS_SINGLE",
    "password": "Password.123",
    "user_id": "18569c6d589c4be3a300b6401c74d936",
    "user_name": "iam_user",
    "maintain_begin": "02:00:00",
    "maintain_end": "06:00:00",
    "enable_publicip": False,
    "enable_ssl": False,
    "service_upgrade": False,
    "service_task_id": "",
    "available_zones": [
        "eu-de-03"
    ],
    "subnet_id": "25d24fc8-d019-4a34-9fff-0a09fde6a9cb",
    "security_group_id": "bb0e60ab-b6e0-4c61-a503-63213c18effa"
}

instance = conn.dcs.create_instance(**attrs)
print(instance)
'''

Get Instance

This interface is used to get a DCS instance by ID or an instance of class Instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = "instance_id"
instance = conn.dcs.get_instance(instance)
print(instance)

Find Instance

This interface is used to find a DCS instance by name or id.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = "dcs-test"
instance = conn.dcs.find_instance(instance)
print(instance)

Update Instance

This interface is used to update a DCS instance by name or id.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

attrs = {
    "name": "dcs002",
    "description": "instance description",
}

instance = conn.dcs.get_instance("ca9697c4-9ddb-4474-9304-576dbf973b00")
conn.dcs.update_instance(instance, **attrs)

Delete Instance

This interface is used to delete a DCS instance by id or an instance of class Instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance_id = "instance_id"
conn.dcs.delete_instance(instance_id)

Extend Instance

This interface is used to extend a DCS instance with additional RAM.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

instance = 'instance_id_or_class_instance'
capacity = 8
conn.dcs.extend_instance(instance, capacity)

Stop Instance

This interface is used to stop a DCS instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = "instance_id_or_name"
conn.dcs.stop_instance(instance)

Start Instance

This interface is used to start a DCS instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = "instance_id_or_name"
conn.dcs.start_instance(instance)

Restart Instance

This interface is used to restart a DCS instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = "instance_id_or_name"
conn.dcs.restart_instance(instance)

Change Instance Password

This interface is used to change the login password of a DCS instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = 'name_or_id'
old_password = 'old_pwd'
new_password = 'new_pwd'
conn.dcs.change_instance_password(
    instance=instance,
    current_password=old_password,
    new_password=new_password)

List Statistics of all Instances

This interface is used to query all Statistics of all DCS Instances and to filter the output with query parameters.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


for statistic in conn.dcs.statistics():
    print(statistic)

List Config Parameters

This interface is used to query all Config Parameters of a DCS Instance and to filter the output with query parameters.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = 'name_or_id'
instance = conn.dcs.find_instance(instance)
for param in conn.dcs.instance_params(instance):
    print(param)

Update Instance Config Parameters

This interface is used to update config parameters of a DCS instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


params = [
    {
        'param_id': '1',
        'param_name': 'timeout',
        'default_value': '0',
        'value_range': '0-7200',
        'value_type': 'Interger',
        'param_value': '11'
    },
    {
        'param_id': '2',
        'param_name': 'maxmemory-policy',
        'default_value': 'noeviction',
        'value_range':
            'volatile-lru,allkeys-lru,volatile-random,'
            'allkeys-random,volatile-ttl,noeviction',
        'value_type': 'Enum',
        'param_value': 'allkeys-random'
    }
]
instance = 'name_or_id'
instance = conn.dcs.find_instance(instance)
conn.dcs.update_instance_params(
    instance=instance,
    params=params
)

Backup DCS Instance

This API is used to backup a Distributed Cache Service instance.

List Backups

This interface is used to query all Backups of a DCS Instance and to filter the output with query parameters.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = "instance_id"
for backup in conn.dcs.backups(instance):
    print(backup)

Create Instance Backup

This interface is used to backup a DCS Instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = 'instance_id'
backup = conn.dcs.backup_instance(
    instance=instance,
    description='My new backup.'
)
print(backup)

Delete Instance Backup

This interface is used to backup a DCS Instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


backup_id = 'backup_id'
instance = 'instance_name_or_id'
instance = conn.dcs.find_instance(name_or_id=instance)
conn.dcs.delete_instance_backup(
    backup=backup_id,
    instance=instance,
    ignore_missing=True)

Restore DCS Instances

This API is used to restore a Distributed Cache Service instance.

List Restore Records

This interface is used to query all Restore Records.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = 'instance_id'
for rr in conn.dcs.restore_records(instance):
    print(rr)

Restore Instance

This interface is used to restore a DCS Instance.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


instance = 'instance_id'
backup_id = 'backup_id'
restore = conn.dcs.restore_instance(
    instance=instance,
    backup_id=backup_id,
    description='Test restore of DCS instance'

DCS Quotas

This API is used to query the default instance quota and total memory quota of a tenant and the maximum and minimum quotas a tenant can apply for. Different tenants have different quotas in different regions.

List Quotas

This interface is used to query all DCS Quotas.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


for quota in conn.dcs.quotas():
    print(quota)

DCS Maintenance Time Windows

The API is used to query the start time and end time of the maintenance time window.

List Maintenance Time Windows

This interface is used to query all maintenance time windows.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


for mtw in conn.dcs.maintenance_time_windows():
    print(mtw)

DCS Service Specifications

This API is used to query the product ID (parameter product_id) which indicates the specifications of the DCS service you created.

List Service Specifications

This interface is used to query all DCS Service Specifications

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


for specification in conn.dcs.service_specifications():
    print(specification)

DCS Availability Zones

This API is used to query the ID of the AZ where a DCS instance resides.

List Availability Zones

This interface is used to query all AZ where a DCS instance resides.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


for az in conn.dcs.availability_zones():
    print(az)