3 # jose.lausuch@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # pylint: disable=missing-docstring
14 from six.moves import urllib
16 from functest.ci import check_deployment
17 from functest.utils.constants import CONST
20 class OpenStack(object):
23 self.os_auth_url = os.environ['OS_AUTH_URL']
24 self.endpoint_ip = None
25 self.endpoint_port = None
26 self.openstack_creds = getattr(CONST, 'env_file')
28 self.endpoint_ip = urllib.parse.urlparse(self.os_auth_url).hostname
29 self.endpoint_port = urllib.parse.urlparse(self.os_auth_url).port
31 def ping_endpoint(self):
32 if self.os_auth_url is None:
33 click.echo("Source the OpenStack credentials first")
35 response = os.system("ping -c 1 " + self.endpoint_ip + ">/dev/null")
39 click.echo("Cannot talk to the endpoint %s\n" % self.endpoint_ip)
43 def show_credentials():
45 for key, value in os.environ.items():
46 if key.startswith('OS_'):
47 dic_credentials.update({key: value})
48 return dic_credentials
52 deployment = check_deployment.CheckDeployment()
53 deployment.check_all()
56 class CliOpenStack(OpenStack):
59 def show_credentials():
60 dic_credentials = OpenStack.show_credentials()
61 for key, value in dic_credentials.items():
62 if key.startswith('OS_'):
63 click.echo("{}={}".format(key, value))