一、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图书馆集群管理系统主要技术指标
介绍集群资源调度管理系统的常用的几套框架技术软件平台
2. 什么是Kubernetes Kubernetes是Google开源的容器集群管理系统,其提供应用部署、维护、 扩展机制等功能,利用Kubernetes能方便地管理跨机器运行容器化的应用,其主要功能如下:1) 使用Docker对应用程序包装...
主题:Kubernetes:Google开源的容器集群管理系统 演讲人:孙长明,Yahoo北京研发中心技术专家 演讲简介:kubernetes是google开源的一个docker container管理容器。本演讲介绍一下它的concepts、基本安装与使用、...
应用分层架构和面向服务的软件开发思想,采用ICE中间件的网络通信技术,使用XML格式作为数据交换模式,研究并实现C/S(Client/Server)架构的灵活、友好、高效的遥感数据集群处理作业调度管理系统。
RFID宠物管理系统使用自行设计的手持机读写器,采用基于Web的B/S模式结合WebSevice、SSL、动态缓存、负载均衡、集群和ActiveX控件技术,使得系统扩展性好、安全性能高;用户使用方便、操作灵活,可大大提高宠物管理...
诺基亚提供TETRA系统的全套解决方案包括TETRA数字交换机(DXT),TETRA基站(TBS)、TETRA无线终端、TETRA调度系统以及网管中心(NMC),可以为集群用户、调度员和网络管理员提供了一个广泛的业务范围,为许多专业...
适于电动汽车充电桩集群管理系统的WSN路由算法研究.pdf
本文以在中移软件研发中心工作期间参与的大数据项目为背景,着重研究Hadoop相关系统的设计思想和基本框架,并设计和实现一个自动化、可扩展、可监控、可管理的应用于大规模Hadoop集群的部署管理系统,本文主要研究...
环境准备:首先需要准备好Redis集群的基本环境,包括安装多个Redis实例、Redis哨兵和集群管理工具等。 集群配置:配置redis.conf文件,修改相关设置使其支持集群模式。 节点启动:启动每个Redis节点,确保它们可以...
管理系统是一种通过计算机技术实现的用于组织、监控和控制各种活动的软件系统。这些系统通常被设计用来提高效率、减少错误、加强安全性,同时提供数据和信息支持。以下是一些常见类型的管理系统: 学校管理系统: ...
集群技术的介绍,高可用集群,负载均衡集群,高性能集群,集群文件系统,大规模集群管理。
在梳理产业集群管理服务体系相关研究基础上,界定了产业集群管理创新服务体系的功能,确立了建设基于网络的产业集群协同平台、开展产业集群诊断与决策咨询服务以及开展技术转移协同管理服务等功能;提出了产业集群管理...
目前,350兆无线模拟集群通信网具有单呼、组呼...从提高和改善基站接收性能的角度,提出了优化无线集群通信系统的方案,尤其是分集接收优化方案,并通过分析,得出采用分集接收技术来优化无线集群通信系统是较理想的。
企业信息化管理系统,内置模块如:部门管理、角色用户、菜单及按钮授权、数据权限、系统参数、日志管理、通知公告等。在线定时任务配置;支持集群,支持多数据源。 适用范围:毕业设计、课程设计、学习等等。 文件...