好人
分类: 云计算
2015-12-29 20:50:18
wget -q -O- | bash
rally-manage db recreate
2.部署环境
$ source openrc $ rally deployment create --fromenv --name=existing或者rally deployment create --filename$rally deployment check
3.执行json
rally task start samples/tasks/scenarios/nova/boot-and-delete.json
rally 新测试用例开发(以rename为例)
boot-and-rename.json文件
{% set flavor_name = flavor_name or "m1.small" %}{"NovaServers.boot_and_rename_changepwd":[{% for i in range(1, 3, 1) %}{"args": {"flavor": {"name": "{{flavor_name}}"},# "nics":[{"net-id": "51f4dd6e-d9e9-4579-be22-2c403a8e8289"}],"image": {"name": "bcec-centos-6.4-amd64-10G-v2.qcow2"},"password":{"password":"123456"},"to_name": {"name": "bcectest"}},"runner": {"type": "constant","times": {{i}},"concurrency": {{i}}},"context": {"users": {"tenants": 1,"users_per_tenant": 1},"network": {# "start_cidr": "143.1.0.0/16","networks_per_tenant": 1}}},{% endfor %}]}
代码流程调用过程json→server.py→utils.py→docker 里面的openstack nova-clients→控制节点openstack apiclinet路径:vim /usr/lib/python2.7/site-packages/novaclient/v2/servers.py里面有两个类class Server 和class ServerManager
如果是新增功能 要在docker里面添加对应client的方法,注意不要不要放错类,同名不可能在同一类。
@types.set(image=types.ImageResourceType,//rally验证输入参数的准确性,flavor和镜像是否匹配flavor=types.FlavorResourceType)@validation.image_valid_on_flavor("flavor", "image")@validation.required_services(consts.Service.NOVA)@validation.required_openstack(users=True)@scenario.configure(context={"cleanup": ["nova"]})
servers.py------def boot_and_rename(self, image, flavor,to_name,**kwargs)://定义一个方法server = self._boot_server(image, flavor, **kwargs) //调用boot-server创建一个server对象(类实例)。LOG.info("[BCEC] create server OK") //输出日志time.sleep(30) //加30s是为了防止虚拟起来后等待qemu-guset-agent起来# print (to_name,server)//自己验证的self._rename_server(server,to_name) //调用utils.py的函数LOG.info("[BCEC] rename OK")self._delete_server(server)LOG.info("[BCEC] delete OK")
@atomic.action_timer("nova.rename_server")//统计执行的时间输出在报告表格中def _rename_server(self, server, name):print(name)server.update(name['name']) //server在_boot-server函数中已经调用过clients,所以有server的所有属性和方法能够直接调用update方法,还有一种是直接调用clients,一般都是get。
具体的信息要看各个openstack python-novaclient的源码servers.py定义了哪些方法,如何使用参数。
rename和change_password组合server.py
-----------------------def boot_and_rename_changepwd(self, image, flavor,to_name,password,**kwargs):server = self._boot_server(image, flavor, **kwargs)LOG.info("[BCEC] create server OK")time.sleep(30)self._rename_server(server,to_name)LOG.info("[BCEC] rename OK")
time.sleep(10)self._chpassword_server(server,password)LOG.info("[BCEC] change passwd OK")self._delete_server(server)
utils.py-------------------------------------def _rename_server(self, server, name):print(name)server.update(name['name'])
@atomic.action_timer("nova.changepasswd_server")def _chpassword_server(self, server, password):print(password)server.change_password(password['password'])