分享

OpenStack Cinder源码分析之四

shihailong123 发表于 2014-11-23 13:47:06 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 16907
阅读导读:
1.__init__.py中定义了哪些内容?
2.configuration.py的用途?
3.manager.py的作用?




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

我们继续来整理代码,看cinder中volume部分的代码,这部分代码比较多,可能需要两到三篇博客才能整理完成。
9 volume(/cinder/volume/)
/cinder/volume/__init__.py:定义了所使用的卷API类;
/cinder/volume/api.py:处理卷相关的所有请求;
  • class API(base.Base):卷的管理操作接口API;
  • def list_availability_zones(self):描述已知可用的zone;
  • def update(self, context, volume, fields):在卷上设置给定的属性,并进行更新;
  • def get(self, context, volume_id):根据volume_id获取相应的volume;
  • def get_all(self, context, marker=None, limit=None,sort_key='created_at', sort_dir='desc', filters={}):获取所有卷的信息;
  • def get_snapshot(self, context, snapshot_id):获取指定卷的快照;
  • def get_volume(self, context, volume_id):根据volume_id获取volume;
  • def get_all_snapshots(self, context, search_opts=None):获取属于指定上下文环境中用户的所有的卷的快照;
  • def reserve_volume(self, context, volume):卷信息的预留保存;
  • def attach(self, context, volume, instance_uuid, host_name, mountpoint,mode):实现卷的附加操作;
  • def detach(self, context, volume):实现卷的卸载操作;
  • def initialize_connection(self, context, volume, connector):初始化卷的连接操作;
  • def terminate_connection(self, context, volume, connector, force=False):通过连接器从主机清理连接;
  • def accept_transfer(self, context, volume, new_user, new_project):实现存储器上卷的所有权的转换;指定了要转换所有权的卷volume、新的用户new_user和新的对象new_project;
  • def _create_snapshot(self, context, volume, name, description,force=False, metadata=None):实现建立并导出快照;
  • def create_snapshot(self, context, volume, name, description,metadata=None):实现建立并导出快照;
  • def create_snapshot_force(self, context, volume, name, description,metadata=None):实现建立并导出快照;
  • def delete_snapshot(self, context, snapshot, force=False):实现删除快照;
  • def update_snapshot(self, context, snapshot, fields):为一个快照设置给定属性并进行更新;
  • def get_volume_metadata(self, context, volume):获取卷相关联的所有元数据;
  • def delete_volume_metadata(self, context, volume, key):删除卷的元数据序列;
  • def _check_metadata_properties(self, context, metadata=None):检测卷元数据的属性;
  • def update_volume_metadata(self, context, volume, metadata,delete=False):更新或建立卷的元数据;
  • def get_volume_metadata_value(self, volume, key):获取卷的元数据中key对应的值;
  • def get_volume_admin_metadata(self, context, volume):管理员用户获取指定volume_id的卷的元数据信息;
  • def delete_volume_admin_metadata(self, context, volume, key):删除给定卷的元数据项;
  • def update_volume_admin_metadata(self, context, volume, metadata,delete=False):更新或建立卷的管理元数据;
  • def get_snapshot_metadata(self, context, snapshot):获取一个快照的所有相关联的元数据;
  • def delete_snapshot_metadata(self, context, snapshot, key):在数据库中删除给定快照的元数据序列;
  • def update_snapshot_metadata(self, context, snapshot, metadata,delete=False):如果数据库中指定快照的元数据存在,则进行更新,如果快照的元数据不存在,则建立相应的条目信息;
  • def get_volume_image_metadata(self, context, volume):获取指定卷的glance中的元数据;
  • def_check_volume_availability(self, context, volume, force):检测卷是可用的;
  • def copy_volume_to_image(self, context, volume, metadata, force):为指定的卷建立一个新的镜像,并实现上传指定的卷到Glance;
  • def extend(self, context, volume, new_size):调用存储后端的extend_volume方法,实现卷大小的扩展操作;
  • def migrate_volume(self, context, volume, host, force_host_copy):调用存储后端的migrate_volume_to_host方法,实现迁移卷到指定的主机;
  • def migrate_volume_completion(self, context, volume, new_volume, error):调用存储后端的migrate_volume_completion方法,实现卷的迁移的完成操作;
/cinder/volume/configuration.py:为所有卷的驱动器提供配置支持;
/cinder/volume/driver.py:卷的驱动类;

  • class VolumeDriver(object):执行和存储卷相关的命令;  
  • def get_version(self):获取驱动器当前的版本信息;
  • def create_volume_from_snapshot(self, volume, snapshot):根据快照建立卷;
  • defcreate_cloned_volume(self, volume, src_vref):创建指定卷的克隆;
  • def delete_volume(self, volume):卷的删除;
  • def create_snapshot(self, snapshot):快照的建立;
  • def delete_snapshot(self, snapshot):快照的删除;
  • def create_export(self, context, volume):创建target,并将指定的逻辑卷加入LUN;
  • def remove_export(self, context, volume):删除卷的导出;
  • def initialize_connection(self, volume, connector):允许连接到连接器并返回连接信息;
  • def terminate_connection(self, volume, connector, **kwargs):断开从连接器的连接;
  • def attach_volume(self, context, volume, instance_uuid, host_name,mountpoint):附加到实例或主机的卷的回调方法;
  • def detach_volume(self, context, volume):卷的卸载的回调方法;
  • def get_volume_stats(self, refresh=False):返回卷的服务的当前状态;
  • def do_setup(self, context):初始化volume driver的操作;
  • def validate_connector(self, connector):如果连接器不包含驱动所需的所有数据,则结果为fail;
  • def _copy_volume_data_cleanup(self, context, volume, properties,attach_info, remote, force=False):实现从主机断开卷的连接,并清理连接的数据信息;
  • def copy_volume_data(self, context, src_vol, dest_vol, remote=None):从src_vol到dest_vol复制数据;
  • def copy_image_to_volume(self, context, volume, image_service,image_id):从image_service获取镜像数据并写入卷;
  • def copy_volume_to_image(self, context, volume, image_service,image_meta):拷贝卷到指定的镜像;
  • def _attach_volume(self, context, volume, properties, remote=False):实现附加一个卷;
  • def _detach_volume(self, attach_info):从主机断开卷的连接;
  • def clone_image(self, volume, image_location, image_id):从现有的镜像有效的建立一个卷;
  • def backup_volume(self, context, backup, backup_service):为一个已存在的卷创建新的备份;
  • def restore_backup(self, context, backup, volume, backup_service):恢复一个备份到一个新的或者是存在的卷;
  • def clear_download(self, context, volume):中断一个镜像的拷贝之后清理缓存信息;
  • def migrate_volume(self, context, volume, host):迁移卷到指定的主机;
  •     class ISCSIDriver(VolumeDriver):执行与ISCSI卷相关的命令;执行支持ISCSI协议的存储卷相关的命令;
  •     class ISERDriver(ISCSIDriver):执行与ISER卷相关的命令;
  •     class FibreChannelDriver(VolumeDriver):执行Fibre Channel volumes的相关命令;
/cinder/volume/manager.py:卷的管理,管理卷的建立、挂载、卸载以及持久性存储等功能;
  •     class VolumeManager(manager.SchedulerDependentManager):管理可连接的块存储设备;
  • def create_volume(self, context, volume_id, request_spec=None,filter_properties=None, allow_reschedule=True, snapshot_id=None, image_id=None,source_volid=None):建立并导出卷;
  • def delete_volume(self, context, volume_id):删除卷的操作;
  • def create_snapshot(self, context, volume_id, snapshot_id):调用存储后端的create_snapshot方法,实现调用实现建立并导出快照;
  • def delete_snapshot(self, context, snapshot_id):调用存储后端的delete_snapshot方法,实现删除快照;
  • def attach_volume(self, context, volume_id, instance_uuid, host_name,mountpoint, mode):调用具体存储后端的attach_volume方法,实现卷的附加操作,并更新数据库表明卷已经附加;
  • def detach_volume(self, context, volume_id):调用存储后端的detach_volume方法,实现卷的卸载操作,并更新数据库来表明卷已经卸载;
  • def copy_volume_to_image(self, context, volume_id, image_meta):调用存储后端的copy_volume_to_image方法,实现上传指定的卷到Glance;
  • def initialize_connection(self, context, volume_id, connector):调用存储后端的initialize_connection方法,实现初始化卷的连接操作;
  • def terminate_connection(self, context, volume_id, connector,force=False):调用存储后端的terminate_connection方法,实现通过连接器从主机清理连接;
  • def accept_transfer(self, context, volume_id, new_user, new_project):调用存储后端的accept_transfer方法,实现存储器上卷的所有权的转换;指定了要转换所有权的卷volume、新的用户new_user和新的对象new_project;
  • def _migrate_volume_generic(self, ctxt, volume, host):普通的卷的迁移方法;
  • def migrate_volume_completion(self, ctxt, volume_id, new_volume_id,error=False):卷的迁移结束之后的操作;
  • def migrate_volume(self, ctxt, volume_id, host, force_host_copy=False):迁移卷到指定的主机;
  • def _report_driver_status(self, context):获取卷的状态信息;
  • def publish_service_capabilities(self, context):收集驱动的状态和capabilities信息,并进行信息的发布;
  • def _notify_about_volume_usage(self, context, volume, event_suffix,extra_usage_info=None):获取指定卷的使用率信息,并进行通知操作;
  • def _notify_about_snapshot_usage(self, context, snapshot, event_suffix,extra_usage_info=None):从卷的快照获取卷的使用率信息,并进行通知操作;
  • def extend_volume(self, context, volume_id, new_size):卷的扩展;调用存储后端的extend_volume方法,实现卷大小的扩展操作;


相关文章



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-10243-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 下一条