[OpenNebula]中间件訪问驱动程序
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */ #ifndef MAD_H_
#define MAD_H_ #include <pthread.h>
#include <sys/types.h> #include <map>
#include <string>
#include <sstream> #include <unistd.h> #include "Log.h" using namespace std; /**
* Base class to build specific middleware access drivers (MAD).
* This class provides generic MAD functionality.
*/
class Mad
{
protected:
/**
* The constructor initialize the class members but DOES NOT start the
* driver. A subsequent call to the start() method is needed.
* @param userid user running this MAD
* @param attrs configuration attributes for the driver
* @param sudo the driver is started through sudo if true
*/
Mad(
int userid,
const map<string,string> &attrs,
bool sudo):
uid(userid),
attributes(attrs),
sudo_execution(sudo),
pid(-1)
{}; /**
* The destructor of the class finalizes the driver process, and all its
* associated resources (i.e. pipes)
*/
virtual ~Mad(); /**
* Send a command to the driver
* @param os an output string stream with the message, it must be
* terminated with the end of line character.
*/
void write(
ostringstream& os) const
{
string str;
const char * cstr; str = os.str();
cstr = str.c_str(); ::write(nebula_mad_pipe, cstr, str.size());
}; /**
* Send a DRIVER_CANCEL command to the driver
* @param oid identifies the action (that associated with oid)
*/
void driver_cancel (const int oid) const
{
ostringstream os; os << "DRIVER_CANCEL " << oid << endl; write(os);
}; /**
* Sets the log message type as specify by the driver.
* @param first character of the type string
* @return the message type
*/
Log::MessageType log_type(const char r) const
{
Log::MessageType lt; switch (r)
{
case 'E':
lt = Log::ERROR;
break;
case 'I':
lt = Log::INFO;
break;
case 'D':
lt = Log::DEBUG;
break;
default:
lt = Log::INFO;
} return lt;
} private:
friend class MadManager; /**
* Communication pipe file descriptor. Represents the MAD to nebula
* communication stream (nebula<-mad)
*/
int mad_nebula_pipe; /**
* Communication pipe file descriptor. Represents the nebula to MAD
* communication stream (nebula->mad)
*/
int nebula_mad_pipe; /**
* User running this MAD as defined in the upool DB
*/
int uid; /**
* Mad configuration attributes (e.g. executable, attributes...). Attribute
* names MUST be lowecase.
*/
map<string,string> attributes; /**
* True if the mad is to be executed through sudo, with the identity of the
* Mad owner (uid).
*/
bool sudo_execution; /**
* Process ID of the running MAD.
*/
pid_t pid; /**
* Starts the MAD. This function creates a new process, sets up the
* communication pipes and sends the initialization command to the driver.
* @return 0 on success
*/
int start(); /**
* Reloads the driver: sends the finalize command, "waits" for the
* driver process and closes the communication pipes. Then the driver is
* started again by calling the start() function
* @return 0 on success
*/
int reload(); /**
* Implements the driver specific protocol, this function should trigger
* actions on the associated manager.
* @param message the string read from the driver
*/
virtual void protocol(const string& message) const = 0; /**
* This function is called whenever the driver crashes. This function
* should perform the actions needed to recover the VMs.
*/
virtual void recover() = 0;
}; #endif /*MAD_H_*/
上面这个类是OpenNebula 中间件訪问驱动的接口.
[OpenNebula]中间件訪问驱动程序的更多相关文章
- 实战DeviceIoControl 之中的一个:通过API訪问设备驱动程序
P.bhw98 { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 9pt; PADDING-BOTTOM: 0px; MARGIN: 10px 0 ...
- Linux 下IOport编程訪问
曾经写的一篇笔记.偶尔翻出来了,放在这里做个纪念 Linux 下IOport编程訪问 这里记录的方法是在用户态訪问IOport,不涉及驱动程序的编写. 首先要包括头文件 /usr/include/as ...
- 数据库訪问技术之JDBC
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/zhuojiajin/article/details/32150883 在了解JDBC之前呢, ...
- Windows server2008 搭建ASP接口訪问连接oracle数据库全过程记录
真的是太不easy了,曾经的时候在window server 2003上面搭建了一套asp+oracle的接口系统.就费了好大的劲儿,事实上那会迷迷瞪瞪的也不知道怎么的就弄好了,也懒得管了.OK,从昨 ...
- https双向认证訪问管理后台,採用USBKEY进行系统訪问的身份鉴别,KEY的证书长度大于128位,使用USBKEY登录
近期项目需求,须要实现用USBKEY识别用户登录,採用https双向认证訪问管理后台管理界面,期间碰到过一些小问题,写出来给大家參考下. 1:前期准备工作 USBKEY 硬件:我买的是飞天诚信 epa ...
- juniper 550M訪问自身公网IP回流内部IP
拓扑图示意: 网关设备juniper 550M, untrust 区: 公网地址段22.22.22.22/29 trust区: 内部员工PC地址:172.16.4.x /24 trust区: ...
- MySQL数据库能够用随意ip连接訪问的方法
通过CMD命令行改动数据库表的一个字段的值.实现连接,訪问. 第一步.找到MYSQL软件安装所在的bin文件夹. (1)cd\当前文件夹 (2)指定MYSQL安装的bin文件夹 (3)输入 -h lo ...
- ios 7.1 7.1.1 半完美越狱后 电脑訪问手机越狱文件夹的方法
7.1和7.1.1因为越狱不成熟,半完美越狱后电脑上无法訪问系统越狱文件夹,如var usr 等等. 今天有些意外地发现,能够在电脑上使用手机的越狱文件夹我手机 i4 7.1.1 联通 半完美越狱,没 ...
- jQuery訪问属性,绝对定位
一. jQuery訪问属性 <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
随机推荐
- (转)PHP中构造函数和析构函数解析
--http://www.jb51.net/article/56047.htm 构造函数 void __construct ([ mixed $args [, $... ]] ) PHP 5 允行开发 ...
- ajax无刷新方式收集表单并提交表单
ajax无刷新方式收集表单有两种方式, 一个是使用html5的FormData.一个是传统的方式. 一,FormData,在主流的浏览器中可以用,IE不好用啊. 另外,FormData使用有两个条件, ...
- 在VMware安装Centos再安装Oracle数据库(个人学习使用)
打开VMware 选择稍后安装 自定义安装 小生安装的是64位的Centos 给虚拟机设置名称和安装位置 设置虚拟机打处理器并分配内存(oracle12G我建议内存为2G以上) 网络类型选择仅主机模式 ...
- Java学习----你可以告诉对象该怎么做(方法中传参)
对象根据参数传递来的条件执行相应的功能. package org.demo.app2; public class App2 { public void print(String msg, int nu ...
- WPS 去掉自动打开的文档漫游和在线模板
关闭文档漫游 在cmd(命令提示符)中输入regedit.exe回车,将弹出”注册表编辑器“,选择HKEY_CURRENT_USER>>Software>>Kingsoft& ...
- 解决VS2010使用comboBox死机问题
今天,在10下使用combobox总是不响应,原来是和翻译软件冲突,关掉有道立即解决.
- python+flask+mongodb+whoosh实现自己的搜索引擎(一):目录
python+flask+jieba+mongodb+whoosh实现自己的搜索引擎 一.目录 二.基于python的爬虫 三.网页去燥,URL去重 四.基于mongodb的数据存储 五.基于whoo ...
- IIS6中ASP.NET实现对静态文件的授权控制
后台使用html+ashx+js开发 在VS2008调试并未发现问题 发布到IIS6才发现不需要验证也能访问html文件 解决这个问题配置IIS即可了 方法如下: IIS配置:网站->属性-&g ...
- TCP回射服务器程序:main函数
TCP回射并发服务器 1.创建套接字,绑定服务器的众所周知端口 创建一个TCP套接字,在待绑定到该TCP套接字的网际网套接字地址结构中填入通配地址(INADDR_ANY) 和服务器的众所知周(SERV ...
- sql char类型的空处理
对是varchar类型的数据进行不是空的判断时,可以采用 --<>''或者!='' int类型的数据可以采用 is not null,但是它对char类型的数据没用 distinct 用于 ...