一、auth认证
集群后台:
1. cloudtool通过username+pwd+dyn 到 auth-manager获取session(实际就是一个字符串):
"http://ip:port/clusterAuth/SessionGenerate?
返回session后,构造请求头:header = {"X-Auth-Session": session}
以此为header,构造请求去集群后台请求。
2. 集群后台获取请求header, 取
"X-Auth-Session",
验证session是否有效(是否合法用户),并且拿到用户role等信息:
'/clusterAuth/SessionQuery?session_id=%s' % session_id)
3. 如果是内部接口,无username/pwd/dyn信息,则根据token来认证。即握手方式。
云主机API,产生一个token(uuid) --- > auth manager
auth manager拿着该token询问云主机API
云主机API验证该token是自己发出的,则向auth manger返回true。
那么
auth manger
产生一个session,表示通过了验证。
二 rabbit mq通迅技术
2.1 carrot_connection.BrokerConnection
broker是一个amqp服务端,rabbit-mq server需要安装,把服务开启。创建Conection类,
指定rabbit-mq server的地址。以供consumer连接。
class Connection(carrot_connection.BrokerConnection):
"""
Connection Instance Object
"""
@classmethod
def instance(cls, new=True):
"""
Return the Instance
"""
if new or not hasattr(cls, '_instance'):
params = {"hostname":config.getValue("BROKER_HOST", True),
"port":config.getValue("BROKER_PORT", True),
"virtual_host":config.getValue("BROKER_VHOST", True),
"userid":config.getValue("BROKER_USER", True),
"password":config.getValue("BROKER_PASSWORD", True)}
if new:
return cls(**params)
else:
cls._instance = cls(**params)
return cls._instance
@classmethod
def recreate(cls):
try:
del cls._instance
except AttributeError, e:
pass
return cls.instance()
2.2 compute-node/instance-manager/volume-manager.py分别是三个consumer
rpc.ManagerConsumer("Compute_Node",compute_node.ComuputeNode(), inner_ip).wait()
rpc.ManagerConsumer("INSTANCE_MANAGER",instance_manager.InstanceManager()).wait()
rpc.ManagerConsumer("VOLUME_MANAGE",volume.VolumeManager()).wait()
其中, managerComsumer继承自carrot.messaging.Consumer的构造参数是:
def __init__(self, role, proxy, hostid=None)。
其queue=routing_key=role+":"+hostid, auto_declare=True, exchange_type="topic".
managerComsumer会override receive函数,spawn a thead to deal with message.
如果是cast消息,则处理完就不管了。如果是call消息,则还需要把处理结果回复消息发送者。
class ManagerConsumer(messaging.Consumer):
"""
Base Consumer Class for kins of manager: Volume, Instance...
"""
def __init__(self, role, proxy, hostid=None):
if not proxy:
LOG.error("No PROXY INPUT!")
sys.exit(1)
self.proxy = proxy
self.pool = eventlet.greenpool.GreenPool(config.getValue("POOLS"))
node_exchange = role
if not hostid:
node_queue = role
else:
node_queue = role + ": " + str(hostid)
try:
super(ManagerConsumer, self).__init__(connection = Connection.instance(),
queue = node_queue,
exchange = node_exchange,
auto_declare = True,
exchange_type = "topic",
routing_key = node_queue)
except Exception,e:
print e
LOG.error("ERROR IN __init__ ManagerConsumer for %s" %e)
sys.exit(1)
def receive(self, message_data, message):
"""
spawn a thread to deal with the message by __receive
"""
self.pool.spawn_n(self.__receive, message_data, message)
eventlet.greenthread.sleep(0)
def __receive(self, message_data, message):
message.ack()
result = self.proxy.dispatch(message_data["rpc_info"])
if message_data["call_or_cast"] == "call":
msg_id = message_data["msg_id"]
msg_reply = {}
msg_reply["result"] = result
msg_reply["failure"] = False
cast(msg_reply,msg_id)
2.3生产者:publisher。发送消息,实际就是一个send操作。消息有可能是同步或异步的。
CAST:
def cast(message, dest=None):
"""
send the message to the dest with no resonse
if dest is None, the dest will be set by the message["dest"] if available
"""
message["call_or_cast"] = "cast"
if dest == None:
dest_exchange = message["dest"]
dest_queue = message["dest_queue"]
else:
dest_exchange = dest
dest_queue = dest
try:
publish_cast = messaging.Publisher(connection = Connection.instance(),
exchange = dest_exchange,
auto_declare = False,
routing_key = dest_queue,
)
publish_cast.send(message)
publish_cast.close()
except Exception,e:
LOG.error("ERROR IN CAST %s for %s" %(message,e))
CALL:生产者发出消息,希望得到同步执行的返回结果。如同步创建卷。
则call消息到volume-manger.具体流程是:
volume-api send to volume-manger, 同时构造一个consumer监听在msg_id上。
volume-manger(consumer) receive and dispatch. cast result to msg_id
def call(message):
"""
Send a message to the manager and wait response
"""
message["call_or_cast"] = "call"
dest_exchange = message["dest"]
dest_queue = message["dest_queue"]
try:
msg_id = uuid.uuid4().hex
#Set up a temp queue by generating a uuid
consum_call = messaging.Consumer(connection = Connection.instance(),
queue = msg_id,
exchange = msg_id,
auto_declare = True,
exchange_type = "direct",
exclusive = True,
routing_key = msg_id)
class WaitMessage(object):
def __call__(self, data, message):
message.ack()
if data["failure"]:
# self.result = RemoteError(*data["failure"])
pass
else:
self.result = data["result"]
wait_msg = WaitMessage()
consum_call.register_callback(wait_msg)
publish_call = messaging.Publisher(connection = Connection.instance(),
exchange = dest_exchange,
auto_declare = False,
routing_key = dest_queue
)
message["msg_id"] = msg_id
publish_call.send(message)
publish_call.close()
try:
consum_call.wait(limit =1)
except StopIteration:
pass
consum_call.close()
return wait_msg.result
except Exception, e:
LOG.error("ERROR IN CALL for %s" %e)
return None
2.2 而api-server.py是一个WEB server,在一个端口上监听http请求:
service = ApiService.create()
service.start()
service.wait()
分享到:
相关推荐
基于Linux的集群管理系统设计与实现.pdf
### 集群通信系统简介及关键技术解析 #### 引言 移动通信领域的快速发展,不仅推动了公众移动通信的普及,也催生了专业移动通信的需求,其中,集群通信系统作为专用移动通信的重要组成部分,以其独特的架构和服务...
### 云计算相关集群资源管理系统知识分享 #### 一、引言 随着信息技术的快速发展,云计算已成为企业提升竞争力的重要工具之一。在云计算环境下,资源管理变得尤为重要。本文将围绕集群资源调度管理系统,详细介绍几...
05-1汇文LibsysBS图书馆集群管理系统主要技术指标
中国电子技术标准化研究院(CESI)发布的《智能无人集群系统发展白皮书-2021版》重点对这一技术领域的现状、发展趋势、应用前景以及相关标准化工作进行了系统性的梳理和前瞻性预测。 从内容上看,该白皮书可能涵盖...
集群管理系统是集群技术的核心组成部分,它对集群的资源进行统一管理和控制,同时提供了用户界面以便用户监控和管理集群。现有的集群管理系统在人机交互界面方面存在不足,这直接导致了用户体验的不佳。为了改善这一...
Kubernetes是一个由Google开源的容器集群管理系统,它主要基于Docker容器技术构建。Kubernetes的目标是自动化容器的部署、调度和扩展,实现高效、弹性、高可用的服务运行。随着云计算和容器技术的兴起,Kubernetes...
本项目是一个基于Apache Hive的分布式大数据集群管理系统,旨在通过虚拟化技术(如Vagrant和VirtualBox)快速搭建和管理一个包含多个组件(如Hadoop、Spark、Flink、Kafka等)的分布式大数据环境。系统支持自定义...
LTE宽带集群通信技术(B-TrunC)作为宽带无线专网发展的一个方向,以其高速率、高频谱...通过持续的研究和发展,B-TrunC技术有望在国际市场上进一步开拓,并带动相关产业的发展,进一步提升我国专网系统的国际竞争力。
Interlib 集群管理系统采用以用户为中心的人性化设计,应用先进的技术,架构,网络条件仅需要 512k ADSL 即可满足各级分馆自动化系统的流畅应用,可运行于任何业界主流应用系统平台。系统采用基于 WEB 的 B/S 多层...
在集群文件系统中,数据的一致性和并发访问控制是核心问题,本文将深入探讨这些问题,并介绍主流厂商的文件系统技术架构和特点。 首先,要理解集群文件系统的基本概念。双机共享一个卷是集群文件系统的一个典型应用...
主题:Kubernetes:Google开源的容器集群管理系统 演讲人:孙长明,Yahoo北京研发中心技术专家 演讲简介:kubernetes是google开源的一个docker container管理容器。本演讲介绍一下它的concepts、基本安装与使用、...
本文主要探讨了网站集群管理系统的概念、发展历程以及关键技术。 首先,网站集群管理系统是基于统一标准和技术构架构建的,它可以实现分级管理和维护,确保各个网站之间的高度耦合,并允许信息在特定权限下共享。这...
### Google集群系统技术综述 #### 一、引言 Google作为全球领先的搜索引擎之一,以其卓越的搜索技术和高效的用户体验著称。为了实现快速且精准的搜索结果反馈,Google利用了大量的低成本计算机集群构建了一套高...
4. 研究结果在验证GLAR算法性能时,提供了数据通信服务性能的详细分析,为充电桩集群管理系统的优化提供了有力的技术支持。 在未来的工作中,研究团队计划将GLAR机制进一步完善,并探索更多的实际应用场景,如智慧...
总的来说,构建容器化的集群管理系统是一项复杂的工作,涉及到多个层面的技术集成,包括但不限于API设计、认证授权、日志监控、自动化部署和依赖管理。通过采用云原生架构,我们可以构建出更强大、更灵活且易于维护...
在本文中,我们将深入探讨基于Linux的集群存储系统的概念、技术特点、工作原理以及构建方法。 集群存储系统的主要目标是提高可用性、负载均衡和整体性能。当集群中的某个服务器出现故障时,其他服务器可以接管其...