OpenStack 开发

发布时间: 更新时间: 总字数:640 阅读时间:2m 作者:IP:上海 网址

OpenStack 开发汇总,总结一下 OpenStack 开发流程和代码规范等。

开发环境配置

git 环境配置

[root@xiexianbin_cn xiexianbin.github.io]# git config --global user.name "xie xianbin"
[root@xiexianbin_cn xiexianbin.github.io]# git config --global user.email "me@xiexianbin.cn"
[root@xiexianbin_cn xiexianbin.github.io]# git config --list
user.name=xie xianbin
user.email=me@xiexianbin.cn
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=https://github.com/xiexianbin/xiexianbin.github.io.git
branch.master.remote=origin
branch.master.merge=refs/heads/master
[root@xiexianbin_cn xiexianbin.github.io]# cat /root/.gitconfig
[user]
	name = xie xianbin
	email = me@xiexianbin.cn

git-review 安装

yum install git-review -y

获取代码

[root@xiexianbin_cn ~]# git clone https://github.com/openstack/nova

或

[root@xiexianbin_cn ~]# git clone https://github.com/openstack/nova —-branch=stable/juno

提交代码

git commit -a --amend

specs 项目作用

OpenStack 项目都有个-specs 的代码库,用于存储已经被审核通过的设计定义,如https://github.com/openstack/nova-specs

代码开发规范

  1. 不要使用 Tab,使用空格
  2. 每行最多 79 个字符
  3. 类定义和类的第一个方法中间隔两行
  4. 类方法之间隔一个空行
  5. [H903]使用 UNIX 格式的换行(\n),不要使用 Windows 格式(\r\n)
  6. 对于较长的行,尽量在括号内换行,而不要使用续行符()
  7. [H101]添加 TODO 时候要写名字,格式是# TODO(名字)
  8. [H306]按照模块全路径排序导入(import), 如https://github.com/openstack/nova/blob/137ddac8ef23bb0c4c8572f10a5066f34c9e8b20/nova/tests/unit/compute/test_compute_mgr.py 分 3 段导入

提交信息

  • 第一行为概要信息,不能超过 50 个字符,并且结尾不加任何标点
  • 第二行为空行
  • 第三行开始为具体描述信息,每行不要超过 72 个字符
  • 在最后空行隔开并附上 ‘Change-Id’、‘Closes-Bug: #NNNNN’ 或 ‘Implements: blueprint NNNNNNNNNNN’,便于问题跟踪