From fc12fe83562430bc406877583111ed725d08edc8 Mon Sep 17 00:00:00 2001 From: zhongjun Date: Thu, 21 Sep 2017 09:40:12 +0800 Subject: Add some unittest files such as test_nova.py 1.Add test_glance.py, test_neutron.py and test_nova.py unittest files, and modify the neutron.py to adapt the unittest. 2.Add some unittest functions in test_post_execute.py, test_deploy.py, test_keystoneauth.py. 3.rename test_prepare_execure.py to test_prepare_execute.py. Change-Id: Ie0640d133e27c558648416a6a5cf044a00ffa67f Signed-off-by: zhongjun --- deploy/post/execute.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'deploy') diff --git a/deploy/post/execute.py b/deploy/post/execute.py index 75abaacb..fe4185b8 100644 --- a/deploy/post/execute.py +++ b/deploy/post/execute.py @@ -59,20 +59,20 @@ def _config_external_subnet(ext_id, network_conf): } -def _create_external_network(network_file): +def _create_external_network(network_file, openrc=None): network_conf = NetworkConfig(network_file=network_file) ext_name = network_conf.ext_network_name physnet = network_conf.ext_mapping if hasattr(network_conf, 'ext_mapping') else 'physnet1' - neutronclient = neutron.Neutron() + neutronclient = neutron.Neutron(openrc=openrc) ext_id = neutronclient.create_network(ext_name, _config_external_network(ext_name, physnet)) if ext_id: neutronclient.create_subnet(_config_external_subnet(ext_id, network_conf)) -def _create_flavor_m1_micro(): +def _create_flavor_m1_micro(openrc=None): name = 'm1.micro' - novaclient = nova.Nova() + novaclient = nova.Nova(openrc=openrc) if not novaclient.get_flavor_by_name(name): try: return novaclient.create_flavor(name, ram=64, vcpus=1, disk=0) @@ -118,8 +118,8 @@ def _prepare_cirros(): return img -def _create_image_TestVM(): - glanceclient = glance.Glance() +def _create_image_TestVM(openrc=None): + glanceclient = glance.Glance(openrc=openrc) image = 'TestVM' if not glanceclient.get_by_name(image): try: @@ -162,8 +162,8 @@ def _config_ssh_security_group_rule(security_group_id): return body -def _create_security_group_rules(): - neutronclient = neutron.Neutron() +def _create_security_group_rules(openrc=None): + neutronclient = neutron.Neutron(openrc=openrc) try: security_group_name = 'default' security_group = neutronclient.get_security_group_by_name(security_group_name) -- cgit 1.2.3-korg