OpenStack 开发

发布时间: 更新时间: 总字数:715 阅读时间:2m 作者: 分享 复制网址

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个字符,否则无法通过Gate测试
  • 其余行不要超过72个字符
  • 在最后一行写上’Change-id’, ‘Closes-Bug #NNNNN’ 和’blueprint NNNNNNNNNNN’,便于问题跟踪
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数