1.  各个组件之间可以互相调用(都是common sense)

conductor 负责DB的操作。

各个组件之间通过RPC, 序列化通过oslo_versionedobjects。

2. 具体调用:

Agent(如nova-computer) 访问DB, 通过调用conductor。 实例, 搜索remotable_classmethod

这个调用比较隐性, 通过versionedobjects (ppt)的remote方法。

def remotable_classmethod(fn)

# These are decorators that mark an object's method as remotable.
# If the metaclass is configured to forward object methods to an
# indirection service, these will result in making an RPC call
# instead of directly calling the implementation in the object. Instead,
# the object implementation on the remote end will perform the
# requested action and the result will be returned here.
def remotable_classmethod(fn):
"""Decorator for remotable classmethods."""
@six.wraps(fn)
def wrapper(cls, context, *args, **kwargs):
if cls.indirection_api:
version_manifest = obj_tree_get_versions(cls.obj_name())
try:
# 需要设置indirection_api, 还需要提供 object_class_action_versions方法
result = cls.indirection_api.object_class_action_versions(
context, cls.obj_name(), fn.__name__, version_manifest,
args, kwargs)
except NotImplementedError:
# FIXME(danms): Maybe start to warn here about deprecation?
result = cls.indirection_api.object_class_action(
context, cls.obj_name(), fn.__name__, cls.VERSION,
args, kwargs)
else:
result = fn(cls, context, *args, **kwargs)
if isinstance(result, VersionedObject):
result._context = context
return result # NOTE(danms): Make this discoverable
wrapper.remotable = True
wrapper.original_fn = fn
return classmethod(wrapper)

def remotable(fn)

# See comment above for remotable_classmethod()
#
# Note that this will use either the provided context, or the one
# stashed in the object. If neither are present, the object is
# "orphaned" and remotable methods cannot be called.
def remotable(fn):
"""Decorator for remotable object methods."""
@six.wraps(fn)
def wrapper(self, *args, **kwargs):
ctxt = self._context
if ctxt is None:
raise exception.OrphanedObjectError(method=fn.__name__,
objtype=self.obj_name())
if self.indirection_api:
# 需要设置indirection_api 及其 object_action 方法
updates, result = self.indirection_api.object_action(
ctxt, self, fn.__name__, args, kwargs)
for key, value in updates.items():
if key in self.fields:
field = self.fields[key]
# NOTE(ndipanov): Since VersionedObjectSerializer will have
# deserialized any object fields into objects already,
# we do not try to deserialize them again here.
if isinstance(value, VersionedObject):
setattr(self, key, value)
else:
setattr(self, key,
field.from_primitive(self, key, value))
self.obj_reset_changes()
self._changed_fields = set(updates.get('obj_what_changed', []))
return result
else:
return fn(self, *args, **kwargs) wrapper.remotable = True
wrapper.original_fn = fn
return wrapper

3. Agent调用conductor。

objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()

def main():
config.parse_args(sys.argv)
logging.setup(CONF, 'nova')
priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
utils.monkey_patch()
objects.register_all()
gmr_opts.set_defaults(CONF)
# Ensure os-vif objects are registered and plugins loaded
os_vif.initialize() gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) cmd_common.block_db_access('nova-compute')
objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()
objects.Service.enable_min_version_cache()
server = service.Service.create(binary='nova-compute',
topic=compute_rpcapi.RPC_TOPIC)
service.serve(server)
service.wait()

4. API调用 其他组件

调用agent(nova-compute):

classServersController(wsgi.Controller) 的初始化 def __init__(self, **kwargs)

self.compute_api = compute.API()

from nova import compute

class ServersController(wsgi.Controller):
"""The Server API base controller class for the OpenStack API.""" _view_builder_class = views_servers.ViewBuilder ...... def __init__(self, **kwargs): super(ServersController, self).__init__(**kwargs)
self.compute_api = compute.API()

5. nova objects隐性的调用conductor

def conductor(self)

class NovaObjectSerializer(messaging.NoOpSerializer):
"""A NovaObject-aware Serializer.
This implements the Oslo Serializer interface and provides the
ability to serialize and deserialize NovaObject entities. Any service
that needs to accept or return NovaObjects as arguments or result values
should pass this to its RPCClient and RPCServer objects.
""" @property
def conductor(self):
if not hasattr(self, '_conductor'):
from nova import conductor
self._conductor = conductor.API()
return self._conductor

class CyborgObjectSerializer 没有实现。

5. nova 其他地方调用conductor

$ git grep "from.*conductor"
cells/scheduler.py:from nova import conductor
cmd/api_metadata.py:from nova.conductor import rpcapi as conductor_rpcapi
cmd/compute.py:from nova.conductor import rpcapi as conductor_rpcapi
cells/scheduler.py:from nova import conductor
cmd/api_metadata.py:from nova.conductor import rpcapi as conductor_rpcapi
cmd/compute.py:from nova.conductor import rpcapi as conductor_rpcapi
cmd/dhcpbridge.py:from nova.conductor import rpcapi as conductor_rpcapi
cells/scheduler.py:from nova import conductor
cmd/api_metadata.py:from nova.conductor import rpcapi as conductor_rpcapi
cmd/compute.py:from nova.conductor import rpcapi as conductor_rpcapi
cmd/dhcpbridge.py:from nova.conductor import rpcapi as conductor_rpcapi
cmd/network.py:from nova.conductor import rpcapi as conductor_rpcapi
compute/api.py:from nova import conductor
compute/api.py: # from the conductor LiveMigrationTask. Yes this is tightly-coupled
compute/manager.py:from nova import conductor
compute/manager.py: This is initiated from conductor and runs on the destination host.
conductor/__init__.py:from nova.conductor import api as conductor_api
conductor/api.py:from nova.conductor import rpcapi
conductor/manager.py:from nova.conductor.tasks import live_migrate
conductor/manager.py:from nova.conductor.tasks import migrate
conductor/manager.py: # can't reach the API DB from the cell conductor.
conductor/tasks/live_migrate.py:from nova.conductor.tasks import base
conductor/tasks/live_migrate.py:from nova.conductor.tasks import migrate
conductor/tasks/migrate.py:from nova.conductor.tasks import base
conf/__init__.py:from nova.conf import conductor
objects/base.py: from nova import conductor
service.py:from nova import conductor

service.py 调用 conductor

from nova import conductor
...... class Service(service.Service):
"""Service object for binaries running on hosts.
A service takes a manager and enables rpc by listening to queues based
on topic. It also periodically runs tasks on the manager and reports
its state to the database services table.
""" def __init__(self, host, binary, topic, manager, report_interval=None,
periodic_enable=None, periodic_fuzzy_delay=None,
periodic_interval_max=None, *args, **kwargs):
super(Service, self).__init__()
self.host = host
self.binary = binary
self.topic = topic
self.manager_class_name = manager
self.servicegroup_api = servicegroup.API()
manager_class = importutils.import_class(self.manager_class_name)
self.manager = manager_class(host=self.host, *args, **kwargs)
self.rpcserver = None
self.report_interval = report_interval
self.periodic_enable = periodic_enable
self.periodic_fuzzy_delay = periodic_fuzzy_delay
self.periodic_interval_max = periodic_interval_max
self.saved_args, self.saved_kwargs = args, kwargs
self.backdoor_port = None
if objects_base.NovaObject.indirection_api:
conductor_api = conductor.API()
conductor_api.wait_until_ready(context.get_admin_context())
setup_profiler(binary, self.host)

6. conductor 调用了 agent(nova-computer)

$ cd conductor/ ; git grep "from.*compute"
-bash: cd: conductor/: No such file or directory
manager.py:from nova.compute import instance_actions
manager.py:from nova.compute import rpcapi as compute_rpcapi
manager.py:from nova.compute import task_states
manager.py:from nova.compute import utils as compute_utils
manager.py:from nova.compute.utils import wrap_instance_event
manager.py:from nova.compute import vm_states
manager.py: # or during a reschedule from a pre-Queens compute. In all other cases,
manager.py: # could have come from a compute via reschedule and it would
tasks/live_migrate.py:from nova.compute import power_state

7.  openstack Logical architecture

 

openstack components internal relations的更多相关文章

  1. [转载]OpenStack OVS GRE/VXLAN网络

      学习或者使用OpenStack普遍有这样的现象:50%的时间花费在了网络部分:30%的时间花费在了存储方面:20%的时间花费在了计算方面.OpenStack网络是不得不逾越的鸿沟,接下来我们一起尝 ...

  2. [转]Request Flow for Provisioning Instance in Openstack

      One of the most important use-case in any cloud is provisioning a VM . In this article we shall do ...

  3. 使用openstack部署云计算服务环境

    环境: 系统       硬盘 IP hostname redhat 7 sda 20G 192.168.0.70 openstack.com 64位 sdb 20G 配置网卡 [root@opens ...

  4. CentOS RDO方式快速安装OpenStack

    一.了解RDO RDO是什么? RDO是红帽Red Hat Enterprise Linux OpenStack Platform的社区版,类似RHEL和Fedora,RHEV和oVirt这样的关系. ...

  5. Linux(CentOS、Ububtu)一键安装Openstack及其它参考文档汇总

    原文链接  http://www.aboutyun.com/thread-10920-1-1.html openstack相关资料 CentOS下一键安装Openstack  http://blog. ...

  6. CentOS下一键安装Openstack

    CentOS下一键安装Openstack 系统环境:Oracle VirtualBox 4.38CentOS-6.5-x86_64-bin-DVD1.iso 安装前需要修改 /etc/hosts文件, ...

  7. openstack中彻底删除计算节点的操作记录

    在使用openstack的过程中,我们经常会添加好几台计算节点来部署虚拟机,在后续使用中由于某些原因,一些计算节点出现了问题,需要将这些出了问题的计算节点从openstack的控制节点中踢出去!但是很 ...

  8. Openstack REST API

    There are some high quality resources that already cover the OpenStack API, so this is a YEA (yet an ...

  9. openstack API debug OpenstackEveryProject_CLI,curl_based

    1,基于Openstack 每个服务组件client客户端,eg,nova 客户端软件包名称是python-novaclient, 别的都一样,把python-novaclient (nova替换成组 ...

随机推荐

  1. VS2017gets的使用

    由于动态规划的LCS问题,需要从第一个字符开始读取比较方便.所以用gets_s();第一个参数是起始位置,第二个参数是字读取字符的长度. #include<bits/stdc++.h> # ...

  2. .Net拾忆:CodeDom动态源代码生成器和编译器

    代码文档模型CodeDom命名空间下主要有两个,很明显第一个代码逻辑分析,第二个负责代码的编译 using System.CodeDom; using System.CodeDom.Compiler; ...

  3. WebService/WCF/WebAPI 之间的区别

    Web Service 1.数据的格式基于SOAP协议 2.数据的传输只支持HTTP协议 3.它只能部署在IIS上 WCF 1.数据的格式基于SOAP协议 2.数据的传输支持HTTP,HTTPS,TC ...

  4. LeetCode108.将有序数组转换为二叉搜索树

    将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树. 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1. 示例: 给定有序数组: [-10,-3,0, ...

  5. 三级菜单(低端版VS高端版)

    >>>低端版 menu={'山西': {'太原': {'迎泽':['柳巷','五一广场','太原站'], '小店':['山西财经大学','山西大学','武宿机场'], '晋源':[' ...

  6. Python记录4:文件操作

    ###文件 ''' 1. 什麽是文件     文件是操作系統為用戶/应用程序提供一種操作硬盤的虚拟单位 2. 爲何要用文件     为了存取硬盘数据 3. 如何用文件 #1. 打開文件 #2. 读写文 ...

  7. 2. Python3输入与输出

    数据的输入和输出操作是计算机最基本的操作,本节只研究基本的输入与输出,基本输入是指从键盘上输入数据的操作,基本输出是指屏幕上显示输出结果的操作. 2.1基本输入和输出 常用的输入与输出设备有很多,如摄 ...

  8. discuz用户组

    非公众用户组当用户组设置为“非公众用户组”时,无论是以主用户组的形式,还是以扩展用户组的形式,均只能由管理员手工将用户加入本组. 公众用户组当本用户组设置为“公众用户组”,且用户当前所在的用户组被允许 ...

  9. STL之Deque容器

    1.Deque容器 1)deque是“double-ended queue”的缩写,和vector一样都是STL的容器,deque是双端数组,而vector是单端的. 2)deque在接口上和vect ...

  10. sitecore系统教程之媒体库

    您可以管理媒体库中的所有媒体项目,例如要嵌入网页的图像或供访问者下载的图像.媒体库包含所有媒体项目,例如图像,文档,视频和音频文件. 在媒体库中,您可以: 将所有媒体文件保存在一个位置,并将其组织在与 ...