Skip to content

WIP_v0_9_customize_containerize_utils_zh

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

v0.9 定制容器化客户端

定制容器化客户端, 需要覆盖 App 类型的以下成员函数

# 从 config 中创建统计客户端对象
#   - config: 全局配置
# 若不启用容器化功能, 则此函数返回 None
def init_container_client(self, config)

该函数返回的客户端对象应支持以下成员函数调用

# 获取 Redis 镜像版本列表
#   - offset, limit: 分页开始位置, 获取数量
# 返回值为列表; 其中每个元素是一个字典, 包括以下项
#   - name: 镜像版本名称
#   - description: 描述
#   - creation: 创建时间
def list_redis_images(self, offset, limit)

# 获取容器信息
#   - container_id: 容器标识
# 返回值为字典, 包括
#   - version: 镜像版本
#   - host: 所在宿主机
#   - created: 创建时间
def get_container(self, container_id)

# 列举资源组
# 返回值为列表, 其中每个元素是一个字典, 包括以下项
#   - name: 资源组标识符
#   - host_count: 宿主机数量
def list_pods(self)

# 列举资源组内的宿主机
#   - pod: 资源组标识符
# 返回值为列表, 其中每个元素是一个字典, 包括以下项
#   - name: 宿主机标识符
#   - addr: 宿主机地址
#   - is_alive: 是否可用
def list_pod_hosts(self, pod)

# 部署上线 Redis
#   - pod: 资源组标识符
#   - aof: 是否启用 AOF
#   - netmode: 网络模式
#   - cluster: 是否启用集群模式
#   - host: 指定宿主机; 不指定则随机
#   - port: 指定端口号
#   - image: 指定镜像版本; 不指定则由客户端自行决定
#   - args, kwargs: 未来此接口可能会扩展, 为了兼容性考量可加上这两个占位参数
# 返回值为字典, 包括
#   - version: 镜像版本
#   - container_id: 容器标识符
#   - address: 容器网卡地址
#   - host: 宿主机地址
#   - created: 创建时间
def deploy_redis(self, pod, aof, netmode, cluster=True, host=None, port=6379, image=None,
                 *args, **kwargs)

# 部署上线代理
#   - pod: 资源组标识符
#   - threads: 线程数
#   - read_slave: 是否只读
#   - netmode: 网络模式
#   - host: 指定宿主机; 不指定则随机
#   - port: 指定端口号
#   - args, kwargs: 未来此接口可能会扩展, 为了兼容性考量可加上这两个占位参数
# 返回值同 deploy_redis
def deploy_proxy(self, pod, threads, read_slave, netmode, host=None, port=8889,
                 *args, **kwargs)

# 删除一些容器
#   - container_ids: 列表, 每个元素为一个容器标识符
# 无返回值
def rm_containers(self, container_ids)

# 复活容器
#   - container_id: 容器标识符
# 无返回值
def revive_container(self, container_id)
Clone this wiki locally