summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerry Flood <jf9860@att.com>2017-10-11 10:14:58 -0400
committerJerry Flood <jf9860@att.com>2017-10-11 10:15:10 -0400
commitc89a1635db884e64372ae48ccb953257be620302 (patch)
treeee90464ce7e8c00e24f82f28acb8c89b3d9dcf49
parent2dac53acebf05c7edcb9445e454995298f51a0a8 (diff)
Support WindRiver openstack in library
Issue: TEST-64 Change-Id: I87795d6d03a1a60df689e3d16486129dc32cf69b Signed-off-by: Jerry Flood <jf9860@att.com>
-rw-r--r--eteutils/OpenstackLibrary.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/eteutils/OpenstackLibrary.py b/eteutils/OpenstackLibrary.py
index 58324d9..99aba87 100644
--- a/eteutils/OpenstackLibrary.py
+++ b/eteutils/OpenstackLibrary.py
@@ -4,10 +4,10 @@ import json
class OpenstackLibrary:
"""OpenstackLibrary manages the connection state and service catalog of an openstack instance."""
-
+
ROBOT_LIBRARY_SCOPE = 'Global'
-
-
+
+
def __init__(self):
self._cache = robot.utils.ConnectionCache('No connections created')
self.builtin = BuiltIn()
@@ -16,7 +16,7 @@ class OpenstackLibrary:
"""Save Openstack Auth takes in an openstack auth response and saves it to allow easy retrival of token and service catalog"""
self.builtin.log('Creating connection: %s' % alias, 'DEBUG')
self._cache.register(response, alias=alias)
-
+
def get_openstack_token(self, alias):
"""Get Openstack auth token from the current alias"""
response = self._cache.switch(alias)
@@ -25,7 +25,7 @@ class OpenstackLibrary:
else:
jsonResponse = response;
return jsonResponse['access']['token']['id']
-
+
def get_openstack_catalog(self, alias):
"""Get Openstack service catalog from the current alias"""
response = self._cache.switch(alias)
@@ -34,7 +34,7 @@ class OpenstackLibrary:
else:
jsonResponse = response;
return jsonResponse['access']['serviceCatalog']
-
+
def get_current_openstack_tenant(self, alias):
"""Get Openstack tenant from the current alias"""
response = self._cache.switch(alias)
@@ -43,12 +43,12 @@ class OpenstackLibrary:
else:
jsonResponse = response;
return jsonResponse['access']['token']['tenant']
-
+
def get_current_openstack_tenant_id(self, alias):
"""Get Openstack tenant id from the current alias"""
tenant = self.get_current_openstack_tenant(alias);
return tenant['id']
-
+
def get_openstack_regions(self, alias):
"""Get all Openstack regions from the current alias"""
response = self._cache.switch(alias)
@@ -64,7 +64,7 @@ class OpenstackLibrary:
if endpoint['region'] not in regions:
regions.append(endpoint['region'])
return regions;
-
+
def get_openstack_service_url(self, alias, servicetype, region = None, tenant_id = None):
"""Get Openstack service catalog from the current alias"""
response = self._cache.switch(alias)
@@ -79,17 +79,20 @@ class OpenstackLibrary:
# filter out non matching regions if provided
listOfEndpoints[:] = [x for x in listOfEndpoints if self.__determine_match(x['region'], region)];
# filter out non matching tenants if provided
- listOfEndpoints[:] = [y for y in listOfEndpoints if self.__determine_match(y['tenantId'], tenant_id)];
+ # Only provide tenant id when authorizing without qualifying with tenant id
+ # WindRiver does not return the tenantId on the endpoint in this case.
+ if tenant_id is not None:
+ listOfEndpoints[:] = [y for y in listOfEndpoints if self.__determine_match(y['tenantId'], tenant_id)];
if len(listOfEndpoints) > 0:
endPoint = listOfEndpoints[0]['publicURL'];
if endPoint == None:
self.builtin.should_not_be_empty("", "Service Endpoint Url should not be empty")
return endPoint;
-
+
def __determine_match(self, listItem, item):
if item is None:
return True;
elif listItem == item:
return True;
else:
- return False; \ No newline at end of file
+ return False; \ No newline at end of file