diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2016-07-09 12:34:42 +0200 |
---|---|---|
committer | Jose Lausuch <jose.lausuch@ericsson.com> | 2016-07-11 14:27:46 +0000 |
commit | 845f2072c13ebc5cbced6f3643d768b53dae36de (patch) | |
tree | 883cdb4bf2ddceae270d46f87d98aa8f6374f5d9 | |
parent | 31c050bb5c5afa48f77e16db21d2bd19935fe9ea (diff) |
Add fixed_ip and files parameters in openstack_utils in create_instance
This is needed i.e. for sdnvpn test case
Change-Id: I235a6871a86b7a0c4a9ab27a3aef4bfd62ba4d43
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
-rw-r--r-- | utils/openstack_utils.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py index 8788fd1fc..2103c7fef 100644 --- a/utils/openstack_utils.py +++ b/utils/openstack_utils.py @@ -207,32 +207,40 @@ def create_instance(flavor_name, instance_name="functest-vm", confdrive=True, userdata=None, - av_zone=''): + av_zone='', + fixed_ip=None, + files=None): nova_client = get_nova_client() try: flavor = nova_client.flavors.find(name=flavor_name) except: print("Error: Flavor '%s' not found. Available flavors are:" % flavor_name) - print(nova_client.flavor.list()) + print(nova_client.flavors.list()) return -1 + if fixed_ip is not None: + nics = {"net-id": network_id, "v4-fixed-ip": fixed_ip} + else: + nics = {"net-id": network_id} if userdata is None: instance = nova_client.servers.create( name=instance_name, flavor=flavor, image=image_id, - nics=[{"net-id": network_id}], - availability_zone=av_zone + nics=[nics], + availability_zone=av_zone, + files=files ) else: instance = nova_client.servers.create( name=instance_name, flavor=flavor, image=image_id, - nics=[{"net-id": network_id}], + nics=[nics], config_drive=confdrive, userdata=userdata, - availability_zone=av_zone + availability_zone=av_zone, + files=files ) return instance @@ -243,7 +251,9 @@ def create_instance_and_wait_for_active(flavor_name, instance_name="", config_drive=False, userdata="", - av_zone=''): + av_zone='', + fixed_ip=None, + files=None): SLEEP = 3 VM_BOOT_TIMEOUT = 180 nova_client = get_nova_client() @@ -253,8 +263,9 @@ def create_instance_and_wait_for_active(flavor_name, instance_name, config_drive, userdata, - av_zone) - + av_zone=av_zone, + fixed_ip=fixed_ip, + files=files) count = VM_BOOT_TIMEOUT / SLEEP for n in range(count, -1, -1): status = get_instance_status(nova_client, instance) @@ -635,7 +646,6 @@ def update_bgpvpn(neutron_client, bgpvpn_id, **kwargs): def delete_bgpvpn(neutron_client, bgpvpn_id): return neutron_client.delete_bgpvpn(bgpvpn_id) - # ********************************************* # SEC GROUPS # ********************************************* |