trove-taskmanager服务在配置实例,管理实例的生命周期以及对数据库实例执行操作方面做了很多工作。
taskmanager会通过Nova、Swift的API访问Openstack基础的服务,而且是有状态的,是整个系统的核心。
本文通过trove api的代码,来解读taskmanger所具有的功能 from oslo_log import log as logging
import oslo_messaging as messaging from trove.common import cfg
from trove.common import exception
from trove.common.notification import NotificationCastWrapper
import trove.common.rpc.version as rpc_version
from trove.common.strategies.cluster import strategy
from trove.guestagent import models as agent_models
from trove import rpc CONF = cfg.CONF
LOG = logging.getLogger(__name__) class API(object):
"""API for interacting with the task manager.""" def __init__(self, context):
self.context = context
super(API, self).__init__() target = messaging.Target(topic=CONF.taskmanager_queue,
version=rpc_version.RPC_API_VERSION) self.version_cap = rpc_version.VERSION_ALIASES.get(
CONF.upgrade_levels.taskmanager)
self.client = self.get_client(target, self.version_cap) def _cast(self, method_name, version, **kwargs):
LOG.debug("Casting %s" % method_name)
with NotificationCastWrapper(self.context, 'taskmanager'):
cctxt = self.client.prepare(version=version)
cctxt.cast(self.context, method_name, **kwargs) def get_client(self, target, version_cap, serializer=None):
return rpc.get_client(target,
version_cap=version_cap,
serializer=serializer) def _transform_obj(self, obj_ref):
# Turn the object into a dictionary and remove the mgr
if "__dict__" in dir(obj_ref): #dir()显示对象的属性 __dict__ : 类的属性(包含一个字典,由类的数据属性组成)
obj_dict = obj_ref.__dict__
# We assume manager contains a object due to the *clients
if obj_dict.get('manager'):
del obj_dict['manager']
return obj_dict
raise ValueError("Could not transform %s" % obj_ref) def _delete_heartbeat(self, instance_id): #删除心跳
agent_heart_beat = agent_models.AgentHeartBeat()
try:
heartbeat = agent_heart_beat.find_by_instance_id(instance_id)
heartbeat.delete()
except exception.ModelNotFoundError as e:
LOG.error(e.message) def resize_volume(self, new_size, instance_id): #重新设置卷大小
LOG.debug("Making async call to resize volume for instance: %s"
% instance_id) self._cast("resize_volume", self.version_cap,
new_size=new_size,
instance_id=instance_id) def resize_flavor(self, instance_id, old_flavor, new_flavor): #重新设置instance的flavor
LOG.debug("Making async call to resize flavor for instance: %s" %
instance_id) self._cast("resize_flavor", self.version_cap,
instance_id=instance_id,
old_flavor=self._transform_obj(old_flavor),
new_flavor=self._transform_obj(new_flavor)) def reboot(self, instance_id): #重启(instance)
LOG.debug("Making async call to reboot instance: %s" % instance_id) self._cast("reboot", self.version_cap, instance_id=instance_id) def restart(self, instance_id): #重启(数据库)
LOG.debug("Making async call to restart instance: %s" % instance_id) self._cast("restart", self.version_cap, instance_id=instance_id) def detach_replica(self, instance_id): #分离副本
LOG.debug("Making async call to detach replica: %s" % instance_id) self._cast("detach_replica", self.version_cap,
instance_id=instance_id) def promote_to_replica_source(self, instance_id): #使副本与来源同步
LOG.debug("Making async call to promote replica to source: %s" %
instance_id)
self._cast("promote_to_replica_source", self.version_cap,
instance_id=instance_id) def eject_replica_source(self, instance_id): #弹出复制源
LOG.debug("Making async call to eject replica source: %s" %
instance_id)
self._cast("eject_replica_source", self.version_cap,
instance_id=instance_id) def migrate(self, instance_id, host): #迁移
LOG.debug("Making async call to migrate instance: %s" % instance_id) self._cast("migrate", self.version_cap,
instance_id=instance_id, host=host) def delete_instance(self, instance_id): #删除instance
LOG.debug("Making async call to delete instance: %s" % instance_id) self._cast("delete_instance", self.version_cap,
instance_id=instance_id) def create_backup(self, backup_info, instance_id): #创建备份
LOG.debug("Making async call to create a backup for instance: %s" %
instance_id) self._cast("create_backup", self.version_cap,
backup_info=backup_info,
instance_id=instance_id) def delete_backup(self, backup_id): #删除备份
LOG.debug("Making async call to delete backup: %s" % backup_id) self._cast("delete_backup", self.version_cap, backup_id=backup_id) def create_instance(self, instance_id, name, flavor, #创建实例
image_id, databases, users, datastore_manager,
packages, volume_size, backup_id=None,
availability_zone=None, root_password=None,
nics=None, overrides=None, slave_of_id=None,
cluster_config=None, volume_type=None,
modules=None, locality=None): LOG.debug("Making async call to create instance %s " % instance_id)
self._cast("create_instance", self.version_cap,
instance_id=instance_id, name=name,
flavor=self._transform_obj(flavor),
image_id=image_id,
databases=databases,
users=users,
datastore_manager=datastore_manager,
packages=packages,
volume_size=volume_size,
backup_id=backup_id,
availability_zone=availability_zone,
root_password=root_password,
nics=nics,
overrides=overrides,
slave_of_id=slave_of_id,
cluster_config=cluster_config,
volume_type=volume_type,
modules=modules, locality=locality) def create_cluster(self, cluster_id): #创建集群
LOG.debug("Making async call to create cluster %s " % cluster_id) self._cast("create_cluster", self.version_cap, cluster_id=cluster_id) def grow_cluster(self, cluster_id, new_instance_ids): #扩展集群
LOG.debug("Making async call to grow cluster %s " % cluster_id) cctxt = self.client.prepare(version=self.version_cap)
cctxt.cast(self.context, "grow_cluster",
cluster_id=cluster_id, new_instance_ids=new_instance_ids) def shrink_cluster(self, cluster_id, instance_ids): #收缩
LOG.debug("Making async call to shrink cluster %s " % cluster_id) cctxt = self.client.prepare(version=self.version_cap)
cctxt.cast(self.context, "shrink_cluster",
cluster_id=cluster_id, instance_ids=instance_ids) def delete_cluster(self, cluster_id): #删除集群
LOG.debug("Making async call to delete cluster %s " % cluster_id) self._cast("delete_cluster", self.version_cap, cluster_id=cluster_id) def upgrade(self, instance_id, datastore_version_id): #升级数据库版本
LOG.debug("Making async call to upgrade guest to datastore "
"version %s " % datastore_version_id) cctxt = self.client.prepare(version=self.version_cap)
cctxt.cast(self.context, "upgrade", instance_id=instance_id,
datastore_version_id=datastore_version_id) def load(context, manager=None):
if manager:
task_manager_api_class = (strategy.load_taskmanager_strategy(manager)
.task_manager_api_class)
else:
task_manager_api_class = API
return task_manager_api_class(context)

更多信息:http://www.cnblogs.com/S-tec-songjian/

此文章属博客园用户S-tec原创作品,受国家《著作权法》保护,未经许可,任何单位及个人不得做营利性使用;若仅做个人学习、交流等非营利性使用,应当指明作者姓名、作品名称,原文地址,并且不得侵犯作者依法享有的其他权利。

trove taskmanger api的更多相关文章

  1. trove manual installation 翻译

    目标 此文件提供了一步一步的指导手动安装trove在一个现有OpenStack的环境为了开发. 该文件将不包括: OpenStack的设置 trove服务配置 要求 正在运行的OpenStack的环境 ...

  2. trove design翻译

    trove的设计 高水平的描述 trove的目的是支持单租户数据库,在一个nova的实例中.没有限制nova是如何配置的,因为trove与其他OpenStack组件纯粹通过API. Trove-api ...

  3. Trove系列(八)——Trove的配置管理相关的功能介绍

    概述MySQL 配置管理功能允许Trove 用户重载由Trove服务的操作者提供的缺省MySQL配置环境.这是通过影响MySQL 的includedir 命令来实现的.这些MySQL 的include ...

  4. Trove系列(二)—Trove 的架构和流程介绍

    Trove主要逻辑目前Trove支持用户创建一个数据库服务实例,在实例里可以创建多个数据库并进行管理.数据库服务实例目前通过Nova API来创建,然后同样通过Nova API创建一个Volume(未 ...

  5. 十件你需要知道的事,关于openstack-trove(翻译)

    开源数据库即服务OpenStack Trove应该知道的10件事情 作者:Ken Rugg,Tesora首席执行官 Ken Rugg是Tesora的创始人,CEO和董事会成员. Ken的大部分职业都是 ...

  6. Openstack的打包方法

    使用setup.cfg和setup.py进行管理 1.setup.py文件内容 # THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO ...

  7. Linux运维----03.制作trove-mysql5.7镜像

    安装mysql yum install http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm yum remove m ...

  8. trove datastore 浅析

    以下代码来自trove/datastore该目录下一共有4个文件__init__,views,models,service大概关系(主要是wsgi吧,没仔细学过,简单的从代码上做推测),service ...

  9. trove最新命令简单分类解析

    usage: trove [--version] [--debug] [--service-type <service-type>] [--service-name <service ...

随机推荐

  1. 【转】【Android UI设计与开发】第07期:底部菜单栏(二)Fragment的详细介绍和使用方法

    原始地址:http://blog.csdn.net/yangyu20121224/article/category/1431917/1 由于TabActivity在Android4.0以后已经被完全弃 ...

  2. Image 对象

    <html> <body> <img id="compman" src="0387.jpg" alt="Computer ...

  3. IQueryable与IQEnumberable的区别

    IEnumberable接口: 公开枚举器,该枚举器支持在指定类型的集合上进行简单迭代.也就是说:实现了此接口的object,就可以直接使用froeach遍历此object; IQueryable接口 ...

  4. Windows使用SSH管理Ubuntu

    欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/manage-ubuntu-on-wind ...

  5. 关于HTTP头标

    对于HTTP中的头字段,我表示真的好麻烦,特找来一段资料共享.希望能对大家有用. HTTP的头域包括通用头,请求头,响应头和实体头四个部分.每个头域由一个域名,冒号(:)和域值三部分组成.域名是大小写 ...

  6. C++中内存泄露的检测

    C++没有java的内存垃圾回收机制,在程序短的时候可能比较容易发现问题,在程序长的时候是否有什么检测的方法呢? 假设有一个函数可以某点检测程序的内存使用情况,那是否可以在程序开始的时候设置一个点,在 ...

  7. rcp(插件开发) The activator X for bundle Y is invalid 解决办法

    最近在做插件产品的重构,重构的过程当中难免有一些细节的地方 忘记修改 ,导致出现莫名的问题. 比如这个问题: The activator X for bundle Y is invalid 这个问题从 ...

  8. [转]ARM/Thumb/Thumb-2

    ref:http://kmittal82.wordpress.com/2012/02/17/armthumbthumb-2/ A few months ago I gave a presentatio ...

  9. .NET并行计算基本介绍、并行循环使用模式

    .NET并行计算基本介绍.并行循环使用模式) 阅读目录: 1.开篇介绍 2.NET并行计算基本介绍 3.并行循环使用模式 3.1并行For循环 3.2并行ForEach循环 3.3并行LINQ(PLI ...

  10. UISearchDisplayController UISearchBar

    分组表+本地搜索 UISearchDisplayController  UISearchBar 的使用 效果图 @interface CityListViewController :UIViewCon ...