1
0
-1

Following Tutorial: Creating a Service Instance from a Design Model

./demo.sh appc DemoModule returns an error KeyError: 'tenantId'

<kw name="Internal Get Openstack With Region" library="openstack_common">
<doc>Runs an Openstack Get Request and returns the response</doc>
<arguments>
<arg>${alias}</arg>
<arg>${service_type}</arg>
<arg>${region}</arg>
<arg>${url_ext}</arg>
<arg>${data_path}</arg>
</arguments>
<assign>
<var>${resp}</var>
</assign>
<msg timestamp="20170612 20:22:48.261" level="TRACE">Arguments: [ ${alias}='auth' | ${service_type}='orchestration' | ${region}=b'RegionOne' | ${url_ext}='/stacks' | ${data_path}='/DemoModule' ]</msg>
<kw name="Log" library="BuiltIn">
<doc>Logs the given message with the given level.</doc>
<arguments>
<arg>Internal Get Openstack values alias=${alias} service_type=${service_type} region=${region} url_ext=${url_ext} data_path=${data_path}</arg>
</arguments>
<msg timestamp="20170612 20:22:48.262" level="TRACE">Arguments: [ 'Internal Get Openstack values alias=auth service_type=orchestration region=RegionOne url_ext=/stacks data_path=/DemoModule' ]</msg>
<msg timestamp="20170612 20:22:48.262" level="INFO">Internal Get Openstack values alias=auth service_type=orchestration region=RegionOne url_ext=/stacks data_path=/DemoModule</msg>
<msg timestamp="20170612 20:22:48.262" level="TRACE">Return: None</msg>
<status status="PASS" endtime="20170612 20:22:48.262" starttime="20170612 20:22:48.261"></status>
</kw>
<kw name="Get Openstack Service Url" library="OpenstackLibrary">
<doc>Get Openstack service catalog from the current alias</doc>

<arguments>
<arg>${alias}</arg>
<arg>${service_type}</arg>
<arg>${region}</arg>
</arguments>
<assign>
<var>${url}</var>
</assign>
<msg timestamp="20170612 20:22:48.263" level="TRACE">Arguments: [ 'auth' | 'orchestration' | b'RegionOne' ]</msg>
<msg timestamp="20170612 20:22:48.264" level="FAIL">KeyError: 'tenantId'</msg>
<msg timestamp="20170612 20:22:48.264" level="DEBUG">Traceback (most recent call last):
File "/var/opt/OpenECOMP_ETE/robot/library/eteutils/OpenstackLibrary.py", line 82, in get_openstack_service_url
listOfEndpoints[:] = [y for y in listOfEndpoints if self.__determine_match(y['tenantId'], tenant_id)];</msg>
<status status="FAIL" endtime="20170612 20:22:48.264" starttime="20170612 20:22:48.263"></status>
</kw>

    CommentAdd your comment...

    1 answer

    1.  
      3
      2
      1

      Figured out the problem. I am seeing the problem with openstack + Contrail setup. From the file robot/library/eteutils/OpenstackLibrary.py function get_openstack_service_url we are trying to fetch the public endpoint and filter tenant_id. Also I don't see any value coming as tenant_id to this function


      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)
      if isinstance(response, basestring):
      jsonResponse = json.loads(response);
      else:
      jsonResponse = response;
      endPoint = None;
      #print "Kranthi: jsonResponse is %s" % jsonResponse
      for catalogEntry in jsonResponse['access']['serviceCatalog']:
      if self.__determine_match(catalogEntry['type'], servicetype):
      listOfEndpoints = catalogEntry['endpoints'];
      print "Kranthi: listOfEndpoints %s" % listOfEndpoints
      # 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)];
      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;


      Not sure why we are trying to match tenant_id from endpoint list and tenant_id in argument. Perhaps we can retrieve the tenant_id information from endpoint URL like below

      Kranthi: listOfEndpoints [{u'adminURL': u'http://192.168.105.11:8004/v1/c15a42323a454987a15e634d704efe32', u'region': u'RegionOne', u'publicURL': u'http://192.168.105.11:8004/v1/c15a42323a454987a15e634d704efe32', u'id': u'0fb5ecb2dcfd4e1aa6b4ed4fd54b6ac6', u'internalURL': u'http://192.168.105.11:8004/v1/c15a42323a454987a15e634d704efe32'}]

      where c15a42323a454987a15e634d704efe32 is tenant-id because we pass tenantName

      As a workaround add a condition if tenat_id is present then only validate tenant_id from endpoint list. However this also doesn't make any sense by fetching tenant_id directly from endpoint as an attribute


      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)
      if isinstance(response, basestring):
      jsonResponse = json.loads(response);
      else:
      jsonResponse = response;
      endPoint = None;
      #print "Kranthi: jsonResponse is %s" % jsonResponse
      for catalogEntry in jsonResponse['access']['serviceCatalog']:
      if self.__determine_match(catalogEntry['type'], servicetype):
      listOfEndpoints = catalogEntry['endpoints'];
      print "Kranthi: listOfEndpoints %s" % listOfEndpoints
      # 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
      if tenant_id:
      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;

        CommentAdd your comment...