Skip to content

Customize_Containerization

Neuron Teckid edited this page May 11, 2016 · 2 revisions

By enabling containerization, Redises and proxies could be deployed via the web. Each containerized Redis or proxy also contains a unique container ID of string type besides its integral database PK. Override this function in RedisCtl for containerization customization

# Create a client from config
#   - config: the config passed to `RedisCtl` app
# by default it returns None
def init_container_client(self, config)

The client returned from the above function should implement the following member functions. The term "pod" is used to describe a group of physical resource, or you can just ignore it and treat all your resource as one pod.

# List Redis images
#   - offset, limit: pagination args
# returns a list of dict objects, each of them contains
#   - name: the name of the image, will be the primary key
#   - description: description
#   - creation: create time
# by default this function returns an empty list thus you are using "image" values to deploy Redis (see deploy_redis function below)
def list_redis_images(self, offset, limit)

# get container info
#   - container_id: container id
# returns a dict object with
#   - version: the image version
#   - host: what host it runs on
#   - created: created time
def get_container(self, container_id)

# list pods, each element in the returned list is a dict object with
#   - name: the identifier of the pod
#   - host_count: amount of resource in the pod, generally, the number of physics machines
# the list should contains at least one element
def list_pods(self)

# list resource in a pod
#   - pod: the identifier
# each element in the returned list is a dict object with
#   - name: identifier of resource
#   - addr: the IP address of the resource
#   - is_alive: if it is available
def list_pod_hosts(self, pod)

# deploy a Redis
#   - pod: pod identifer
#   - aof: enable AOF (boolean)
#   - netmode: network mode
#   - cluster: enable cluster mode (boolean)
#   - host: specify a resource identifier, by default, None
#   - port: specify a port number, by default, 6379
#   - image: specify an image, by default, None
#   - *args, **kwargs: placeholders for compatibility; some arguments may be added in the future
# return a dict object representing info of the deployed container, at least contains
#   - version: image version
#   - container_id: container ID
#   - address: IP address of the container, may be a virtual IP
#   - host: IP address of the host resource
#   - created: create time
def deploy_redis(self, pod, aof, netmode, cluster=True, host=None, port=6379, image=None,
                 *args, **kwargs)

# deploy a proxy
#   - pod: pod identifier
#   - threads: number of threads
#   - read_slave: enable read-slave (boolean)
#   - netmode: (same in deploy_redis)
#   - host: (same in deploy_redis)
#   - port: (same in deploy_redis)
#   - *args, **kwargs: placeholders for compatibility; some arguments may be added in the future
# returns info of the deployed container, in the same form as deploy_redis
def deploy_proxy(self, pod, threads, read_slave, netmode, host=None, port=8889,
                 *args, **kwargs)

# delete containers
#   - container_ids: a list of container IDs
def rm_containers(self, container_ids)

# revive a container
#   - container_id: container ID
def revive_container(self, container_id)