分享

OpenStack Cinder源码分析之三

shihailong123 发表于 2014-11-23 13:47:05 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 23050
阅读导读:
1.executor.py脚本的作用?
2.connector.py主要应用于什么方法中?
3.iscsi.py脚本的用途?






感谢朋友支持本博客,欢迎共同探讨交流,由于能力和时间有限,错误之处在所难免,欢迎指正!

我们继续来整理代码。
8 brick(/cinder/brick/)
/cinder/brick/exception.py:Brick library的异常处理;
/cinder/brick/executor.py:通用的执行单元;
/cinder/brick/initiator/connector.py:连接启动器类;主要应用于方法/cinder/utils.py----brick_get_connector中,实现获取块连接对象的操作;
  • def get_connector_properties(root_helper, my_ip):为所有协议获取连接的属性;
  • class InitiatorConnector(executor.Executor):连接启动器类;主要应用与方法/cinder/utils.py----brick_get_connector中,实现获取块连接对象的操作;        
  • def factory(protocol, root_helper, driver=None, execute=putils.execute,use_multipath=False, device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, *args,**kwargs):基于协议protocol(网络数据交换规则)建立连接对象;
  • def check_valid_device(self, path):实现将路径path指定的设备备份到/dev/null中;
  • def connect_volume(self, connection_properties):实现连接到卷;
  • def disconnect_volume(self, connection_properties, device_info):从本地主机断开卷的连接;
  • class ISCSIConnector(InitiatorConnector):实现附加/卸载iSCSI卷的连接器类;继承自类InitiatorConnector;主要用于类InitiatorConnector中的方法factory中;主要用于方法get_connector_properties中;
  • def connect_volume(self, connection_properties):实现附加卷到instance_name指定的实例;  
  • def disconnect_volume(self, connection_properties, device_info):实现从instance_name指定的实例卸载卷;
  • def_get_device_path(self, connection_properties):获取设备路径;
  • def get_initiator(self):输出帮助信息;
  • def _run_iscsiadm(self, connection_properties, iscsi_command, **kwargs):与target建立连接,实现登入操作;
  • def _iscsiadm_update(self, connection_properties, property_key,property_value, **kwargs):实现iscsiadm的更新操作;
  • def _disconnect_volume_multipath_iscsi(self, connection_properties,multipath_name):删除多路径iscsi设备卷;
  • def _connect_to_iscsi_portal(self, connection_properties):连接到iscsi协议;
  • def _disconnect_from_iscsi_portal(self, connection_properties):断开从iscsi协议的连接;
  • def _get_multipath_device_name(self, single_path_device):获取多路径设备名称;
  • def _get_iscsi_devices(self):获取iscsi设备;
  • def _disconnect_mpath(self, connection_properties):断开多路径设备卷的连接;
  • class FibreChannelConnector(InitiatorConnector):实现连接/卸载光纤通道卷的连接类;继承自类InitiatorConnector;主要用于类InitiatorConnector中的方法factory中;
  • def connect_volume(self, connection_properties):附加卷到instance_name;
  • def disconnect_volume(self, connection_properties, device_info):从instance_name卸载卷;
  • class AoEConnector(InitiatorConnector):用于连接/卸载AOE卷的连接类;继承自类InitiatorConnector;主要用于类InitiatorConnector中的方法factory中;
  • def connect_volume(self, connection_properties):发现并连接卷;
  • def disconnect_volume(self, connection_properties, device_info):卸载并删除卷;
  • class RemoteFsConnector(InitiatorConnector):实现连接/卸载NFS和GlusterFS卷的连接类;继承自类InitiatorConnector;主要用于类InitiatorConnector中的方法factory中;
  • def connect_volume(self, connection_properties):确保文件系统包含的卷已经挂载的;
  • def disconnect_volume(self, connection_properties, device_info):实现文件系统中卷的断开的操作;
  • class LocalConnector(InitiatorConnector):实现连接/卸载文件系统后端卷;继承自类InitiatorConnector;主要用于类InitiatorConnector中的方法factory中;
  • def connect_volume(self, connection_properties):连接到卷;
  • def disconnect_volume(self, connection_properties, device_info):断开卷到本地主机的连接;

/cinder/brick/initiator/host_driver.py:获取所有块设备的列表;
/cinder/brick/initiator/linuxfc.py:通用Linux光纤通道实用工具;

  • class LinuxFibreChannel(linuxscsi.LinuxSCSI):继承自类LinuxSCSI;Linux光纤通道管理类;主要用于实现类/cinder/brick/initiator/connector.py----FibreChannelConnector中的方法;
  • def rescan_hosts(self, hbas):主机的重新扫描;
  • def get_fc_hbas(self):获取光线通道主机总线适配器信息;HBA:主机总线适配器英文“Host Bus Adapter”;
  • def get_fc_hbas_info(self):获取光线通道WWNS的信息和设备路径;
  • def get_fc_wwpns(self):从系统获取光纤通道WWPN;
  • def get_fc_wwnns(self):从系统获取光纤通道WWNN;
/cinder/brick/initiator/linuxscsi.py:通用linux scsi子系统和多路径实用工具;
注:SCSI:小型计算机系统接口(英语:Small Computer System Interface; 简写:SCSI);
SCSI是一种用于计算机和智能设备之间(硬盘、软驱、光驱、打印机、扫描仪等)系统级接口的独立处理器标准;
SCSI是一种智能的通用接口标准,它是各种计算机与外部设备之间的接口标准;ISCSI:Internet小型计算机系统接口(iSCSI:InternetSmall Computer System Interface);
ISCSI:是一种基于TCP/IP的协议,用来建立和管理IP存储设备、主机和客户机等之间的相互连接,并创建存储区域网络(SAN);
SAN使得SCSI协议应用于高速数据传输网络成为可能,这种传输以数据块级别(block-level)在多个数据存储网络间进行;
class LinuxSCSI(executor.Executor):LINUX SCSI接口管理类;
主要用于类/cinder/brick/initiator/connector.py----ISCSIConnector中;
主要用于类/cinder/brick/initiator/connector.py----FibreChannelConnector中;        
  • def echo_scsi_command(self, path, content):将content的内容写到路径为path的scsi子系统中;
  • def get_name_from_path(self, path):通过路径path获取设备的文件名;
  • def remove_scsi_device(self, device):根据/dev/sdX的名称删除scsi设备;
  • def get_device_info(self, device):获取SCSI设备信息;
  • def remove_multipath_device(self, multipath_name):删除多路径设备;
  • def flush_multipath_device(self, device):删除多路径设备;注:multipath -F #删除现有路径;
  • def flush_multipath_devices(self):删除多路径设备;注:multipath -F #删除现有路径;
  • def find_multipath_device(self, device):查找与linux设备名称相关联的多路径设备;

设备可以是一个/dev/sdX条目或者是一个多路径id值;
/cinder/brick/iscsi/iscsi.py:各种iSCSI的目标管理的实现类;描述了类TargetAdmin,且派生了几个类:
classTargetAdmin(executor.Executor):iSCSI目标管理;
class TgtAdm(TargetAdmin):使用tgtadm实现iSCSI目标管理;
class IetAdm(TargetAdmin):使用ietadm实现管理的iSCSI目标管理类;
class LioAdm(TargetAdmin):使用python-rtslib实现LIO的iSCSI目标管理;

class TargetAdmin(executor.Executor):iSCSI目标管理;        
  • def create_iscsi_target(self, name, tid, lun, path, chap_auth=None,**kwargs):建立一个iSCSI目标和逻辑单元;
  • def remove_iscsi_target(self, tid, lun, vol_id, vol_name, **kwargs):删除一个iSCSI目标和逻辑单元;
  • def _new_target(self, name, tid, **kwargs):建立一个新的iSCSI目标;
  • def _delete_target(self, tid, **kwargs):删除一个目标;
  • def show_target(self, tid, iqn=None, **kwargs):查询给定目标的ID值;
  • def _new_logicalunit(self, tid, lun, path, **kwargs):使用指定的路径在目标上建立一个新的逻辑单元;
  • def _delete_logicalunit(self, tid, lun, **kwargs):从目标上删除一个逻辑单元;
  • class TgtAdm(TargetAdmin):使用tgtadm实现iSCSI目标管理;
    继承自类TargetAdmin,主要应用于/cinder/volume/driver.py----类ISCSIDriver----方法get_target_admin中;
    继承自类TargetAdmin,主要应用于/cinder/volume/driver.py----类ISERDriver----方法get_target_admin中;
    class IetAdm(TargetAdmin):使用ietadm实现iSCSI目标管理;使用ietadm实现管理的iSCSI目标管理类;继承自类TargetAdmin,主要应用于/cinder/volume/driver.py----类ISCSIDriver----方法get_target_admin中;
    class LioAdm(TargetAdmin):使用python-rtslib实现LIO的iSCSI目标管理;
/cinder/brick/iser/iser.py:ISER卷驱动的辅助代码;

  • class TargetAdmin(executor.Executor):ISER目标管理;
  • def create_iser_target(self, name, tid, lun, path, chap_auth=None,**kwargs):建立一个ISER目标和逻辑单元;
  • def remove_iser_target(self, tid, lun, vol_id, vol_name, **kwargs):删除一个ISER目标和逻辑单元;
  • def _new_target(self, name, tid, **kwargs):建立一个新的ISER目标;
  • def _delete_target(self, tid, **kwargs):删除一个目标;
  • def show_target(self, tid, iqn=None, **kwargs):查询给定的目标ID;
  • def _new_logicalunit(self, tid, lun, path, **kwargs):使用所提供的路径建立一个新的逻辑单元在目标上;
  • def _delete_logicalunit(self, tid, lun, **kwargs):删除一个逻辑单元从目标上;
  • class TgtAdm(TargetAdmin):应用tgtadm实现管理iSER目标类;使用tgtadm实现管理的iSCSI目标管理类;
  • def _get_target(self, iqn):获取目标;
  • def create_iser_target(self, name, tid, lun, path, chap_auth=None,**kwargs):建立ISER目标;
  • def remove_iser_target(self, tid, lun, vol_id, vol_name, **kwargs):实现删除ISER目标;
  • def show_target(self, tid, iqn=None, **kwargs):获取指定iqn的target;
/cinder/brick/local_dev/lvm.py:执行LVM操作的LVM类;
  • class LVM(executor.Executor):LVM对象来确保各种LVM相关的选项;   
  • def __init__(self, vg_name, root_helper, create_vg=False,physical_volumes=None, lvm_type='default', executor=putils.execute):实现LVM对象类的初始化;
  • def _vg_exists(self):简单检测VG是否存在;  
  • def _create_vg(self, pv_list):调用命令实现创建卷组;
  • def _get_vg_uuid(self):获取卷组的uuid;
  • def supports_thin_provisioning(root_helper):检测对精简LVM支持的静态方法;
  • def get_all_volumes(root_helper, vg_name=None, no_suffix=True):获取系统上所有逻辑卷的静态方法;
  • def get_volumes(self):获取与实例相关的所有的逻辑卷;
  • def get_volume(self, name):获取指定名称卷的引用对象;
  • def get_all_physical_volumes(root_helper, vg_name=None, no_suffix=True):获取系统上所有物理卷的静态方法;
  • def get_physical_volumes(self):获取与实例相关联的所有物理卷(physical volumes);
  • def get_all_volume_groups(root_helper, vg_name=None, no_suffix=True):获取系统上的所有VG的静态方法;
  • def update_volume_group_info(self):为实例更新VG信息;
  • def create_thin_pool(self, name=None, size_str=0):为VG建立一个精简供应池;
  • def create_volume(self, name,size_str, lv_type='default', mirror_count=0):在对象的VG上建立一个逻辑卷;  
  • def create_lv_snapshot(self, name, source_lv_name, lv_type='default'):为逻辑卷建立快照;
  • def delete(self, name):实现删除逻辑卷或者快照;
  • def revert(self, snapshot_name):实现从快照恢复一个卷;
  • def extend_volume(self, lv_name, new_size):为存在的卷实现大小的扩展;

/cinder/brick/remotefs/remotefs.py:远程文件系统客户端实用工具;
  • class RemoteFsClient(object):远程文件系统客户端类;
  • 主要应用于类/cinder/brick/initiator/connector.py----RemoteFsConnector中;
  • 主要应用于类/cinder/volume/drivers/nfs.py----NfsDriver中;

9 taskflow(/cinder/taskflow/)
/cinder/taskflow/decorators.py:flow的包装管理相关方法;
/cinder/taskflow/exceptions.py:针对taskflow库的异常处理类;
/cinder/taskflow/states.py:表示Job状态和Flow状态;
/cinder/taskflow/task.py:这里定义了task的抽象的概念;

  • class Task(object):这里定义了task的抽象的概念;
  • def __call__(self, context, *args, **kwargs):实现调用类的方法;
  • def revert(self, context, result, cause):task任务的逆转回滚方法;
/cinder/taskflow/utils.py:Flow管理相关的实用工具;
/cinder/taskflow/patterns/base.py:Flow抽象类;

  • class Flow(object):Flow抽象类;
  • def name(self):flow可读的非唯一的名称;
  • def uuid(self):flow唯一的标识;
  • def state(self):为flow提供了一个只读的状态信息;
  • def _change_state(self, context, new_state):改变目前的flow状态为新的状态new_state,并执行通知操作;
  • def add(self, task):添加一个给定的task到工作流中;
  • def add_many(self, tasks):添加给定的若干的task到工作流中;
  • def interrupt(self):尝试中断当前的flow和当前没有在flow中执行的task;
  • def soft_reset(self):部分地重置flow的内部状态,并允许flow从中止的状态再次运行;   
  • def run(self, context, *args, **kwargs):工作流(workflow)的执行操作;
  • def rollback(self, context, cause):执行workflow和其父workflow的回滚操作;
/cinder/taskflow/patterns/linear_flow.py:线性工作流管理类;
  • class Flow(base.Flow):继承自类Flow;线性工作流管理类;
  • def add(self, task):添加一个给定的task到flow;  
  • def remove(self, uuid):删除flow中uuid指定的任务;
  • def run(self, context, *args, **kwargs):工作流(workflow)的执行操作;
  • def reset(self):完全重置flow的内部的状态,并允许flow再次运行;
  • def rollback(self, context, cause):执行workflow和其父workflow的回滚操作;



相关文章



OpenStack Cinder源码分析之一
http://www.aboutyun.com/thread-10236-1-1.html


OpenStack Cinder源码分析之二
http://www.aboutyun.com/thread-10242-1-1.html



OpenStack Cinder源码分析之四
http://www.aboutyun.com/thread-10244-1-1.html

OpenStack Cinder源码分析之五
http://www.aboutyun.com/thread-10245-1-1.html

OpenStack Cinder源码分析之六
http://www.aboutyun.com/thread-10246-1-1.html


OpenStack Cinder源码分析之七
http://www.aboutyun.com/thread-10247-1-1.html


OpenStack Cinder源码分析之八
http://www.aboutyun.com/thread-10248-1-1.html





如果转载,请保留作者信息。
博客地址:http://blog.csdn.net/gaoxingnengjisuan
邮箱地址:dong.liu@siat.ac.cn











没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条