aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/networking/sfc_openstack.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios/networking/sfc_openstack.py')
-rw-r--r--yardstick/benchmark/scenarios/networking/sfc_openstack.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/yardstick/benchmark/scenarios/networking/sfc_openstack.py b/yardstick/benchmark/scenarios/networking/sfc_openstack.py
index d1d45d8e4..caaf10060 100644
--- a/yardstick/benchmark/scenarios/networking/sfc_openstack.py
+++ b/yardstick/benchmark/scenarios/networking/sfc_openstack.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+from __future__ import absolute_import
import os
from novaclient import client as novaclient
from neutronclient.v2_0 import client as neutronclient
@@ -40,8 +42,8 @@ def get_credentials(service): # pragma: no cover
"ca_file": cacert})
creds.update({"insecure": "True", "https_insecure": "True"})
if not os.path.isfile(cacert):
- print ("WARNING: The 'OS_CACERT' environment variable is " +
- "set to %s but the file does not exist." % cacert)
+ print(("WARNING: The 'OS_CACERT' environment variable is " +
+ "set to %s but the file does not exist." % cacert))
return creds
@@ -49,8 +51,8 @@ def get_instances(nova_client): # pragma: no cover
try:
instances = nova_client.servers.list(search_opts={'all_tenants': 1})
return instances
- except Exception, e:
- print "Error [get_instances(nova_client)]:", e
+ except Exception as e:
+ print("Error [get_instances(nova_client)]:", e)
return None
@@ -62,8 +64,8 @@ def get_SFs(nova_client): # pragma: no cover
if "sfc_test" not in instance.name:
SFs.append(instance)
return SFs
- except Exception, e:
- print "Error [get_SFs(nova_client)]:", e
+ except Exception as e:
+ print("Error [get_SFs(nova_client)]:", e)
return None
@@ -83,8 +85,8 @@ def create_floating_ips(neutron_client): # pragma: no cover
ip_json = neutron_client.create_floatingip({'floatingip': props})
fip_addr = ip_json['floatingip']['floating_ip_address']
ips.append(fip_addr)
- except Exception, e:
- print "Error [create_floating_ip(neutron_client)]:", e
+ except Exception as e:
+ print("Error [create_floating_ip(neutron_client)]:", e)
return None
return ips
@@ -96,9 +98,9 @@ def floatIPtoSFs(SFs, floatips): # pragma: no cover
SF.add_floating_ip(floatips[i])
i = i + 1
return True
- except Exception, e:
- print ("Error [add_floating_ip(nova_client, '%s', '%s')]:" %
- (SF, floatips[i]), e)
+ except Exception as e:
+ print(("Error [add_floating_ip(nova_client, '%s', '%s')]:" %
+ (SF, floatips[i]), e))
return False
@@ -113,5 +115,6 @@ def get_an_IP(): # pragma: no cover
floatIPtoSFs(SFs, floatips)
return floatips
+
if __name__ == '__main__': # pragma: no cover
get_an_IP()