Skip to content

Commit a74693c

Browse files
committed
fixed problem not being able to find ETM configuraitons for opt-in projects - not sure about opt-out
1 parent b08b76e commit a74693c

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

elmclient/_qm.py

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defa
4040
self.is_singlemode = False # this is only true if config enabled is true and single mode is true
4141
self.gcconfiguri = None
4242
self.default_query_resource = "oslc_qm:TestCaseQuery"
43+
self._confs_to_load = []
4344

4445
def load_components_and_configurations(self,force=False):
4546
if self._components is not None and self._configurations is not None and not force:
@@ -70,7 +71,7 @@ def load_components_and_configurations(self,force=False):
7071
assert compuri is not None, "compuri is None"
7172

7273
ncomps += 1
73-
self._components[compuri] = {'name': self.name, 'configurations': {}}
74+
self._components[compuri] = {'name': self.name, 'configurations': {}, 'confs_to_load': []}
7475
configs = self.execute_get_xml( compuri+"/configurations", intent="Retrieve all project/component configurations (singlemode)" )
7576
for conf in rdfxml.xml_find_elements(configs,'.//rdfs:member'):
7677
confu = rdfxml.xmlrdf_get_resource_uri(conf)
@@ -121,9 +122,10 @@ def load_components_and_configurations(self,force=False):
121122
compu = rdfxml.xmlrdf_get_resource_uri(component_el)
122123
comptitle = rdfxml.xmlrdf_get_resource_text(component_el, './/dcterms:title')
123124
logger.info( f"Found component {comptitle}" )
124-
self._components[compu] = {'name': comptitle, 'configurations': {}}
125125
ncomps += 1
126126
confu = rdfxml.xmlrdf_get_resource_uri(component_el, './/oslc_config:configurations')
127+
self._components[compu] = {'name': comptitle, 'configurations': {}, 'confs_to_load': [confu]}
128+
127129
configs_xml = self.execute_get_rdf_xml( confu, intent="Retrieve all project/component configuration definitions" )
128130
# Each config: <ldp:contains rdf:resource="https://jazz.ibm.com:9443/qm/oslc_config/resources/com.ibm.team.vvc.Configuration/_qT1EcEB4Eeus6Zk4qsm_Cw"/>
129131

@@ -149,6 +151,8 @@ def load_components_and_configurations(self,force=False):
149151
else:
150152
c = self._create_component_api(cu, cname)
151153
c._configurations = self._components[cu]['configurations']
154+
c._confs_to_load = self._components[cu]['confs_to_load']
155+
self._confs_to_load.extend(self._components[cu]['confs_to_load'])
152156
self._components[cu]['component'] = c
153157
return (ncomps, nconfs)
154158

@@ -174,6 +178,61 @@ def get_local_config(self, name_or_uri, global_config_uri=None):
174178
return cu
175179
return None
176180

181+
def load_configs(self):
182+
# load configurations
183+
while self._confs_to_load:
184+
confu = self._confs_to_load.pop()
185+
if not confu:
186+
# skip None in list
187+
continue
188+
logger.debug( f"Retrieving config {confu}" )
189+
try:
190+
configs_xml = self.execute_get_rdf_xml(confu, intent="Retrieve a configuration definition")
191+
except:
192+
logger.info( f"Config ERROR {thisconfu} !!!!!!!" )
193+
continue
194+
confmemberx = rdfxml.xml_find_elements(configs_xml, './/rdfs:member[@rdf:resource]')
195+
if confmemberx:
196+
# a list of members
197+
for confmember in confmemberx:
198+
thisconfu = confmember.get("{%s}resource" % rdfxml.RDF_DEFAULT_PREFIX["rdf"])
199+
self._confs_to_load.append(thisconfu)
200+
# maybe it's got configuration(s)
201+
confmemberx = rdfxml.xml_find_elements(configs_xml, './/oslc_config:Configuration') + rdfxml.xml_find_elements(configs_xml, './/oslc_config:Stream') + rdfxml.xml_find_elements(configs_xml, './/oslc_config:Baseline') + rdfxml.xml_find_elements(configs_xml, './/oslc_config:ChangeSet')
202+
203+
for confmember in confmemberx:
204+
thisconfu = rdfxml.xmlrdf_get_resource_uri( confmember )
205+
logger.debug( f"{thisconfu=}" )
206+
conftitle = rdfxml.xmlrdf_get_resource_text(confmember, './/dcterms:title')
207+
if rdfxml.xmlrdf_get_resource_uri( confmember,'.//rdf:type[@rdf:resource="http://open-services.net/ns/config#ChangeSet"]') is not None:
208+
conftype = "ChangeSet"
209+
elif rdfxml.xmlrdf_get_resource_uri( confmember,'.//rdf:type[@rdf:resource="http://open-services.net/ns/config#Baseline"]') is not None:
210+
conftype = "Baseline"
211+
elif rdfxml.xmlrdf_get_resource_uri( confmember,'.//rdf:type[@rdf:resource="http://open-services.net/ns/config#Stream"]') is not None:
212+
conftype = "Stream"
213+
elif rdfxml.xmlrdf_get_resource_uri( confmember,'.//rdf:type[@rdf:resource="http://open-services.net/ns/config#Configuration"]') is not None:
214+
conftype = "Stream"
215+
else:
216+
print( ET.tostring(confmember) )
217+
raise Exception( f"Unrecognized configuration type" )
218+
created = rdfxml.xmlrdf_get_resource_uri(confmember, './/dcterms:created')
219+
if thisconfu not in self._configurations:
220+
logger.debug( f"Adding {conftitle}" )
221+
self._configurations[thisconfu] = {
222+
'name': conftitle
223+
, 'conftype': conftype
224+
,'confXml': confmember
225+
,'created': created
226+
}
227+
# self._configurations[thisconfu] = self._components[self.project_uri]['configurations'][thisconfu]
228+
else:
229+
logger.debug( f"Skipping {thisconfu} because already defined" )
230+
# add baselines and changesets
231+
self._confs_to_load.append( rdfxml.xmlrdf_get_resource_uri(confmember, './oslc_config:streams') )
232+
self._confs_to_load.append( rdfxml.xmlrdf_get_resource_uri(confmember, './oslc_config:baselines') )
233+
self._confs_to_load.append( rdfxml.xmlrdf_get_resource_uri(confmember, './rm_config:changesets') )
234+
235+
177236
def list_configs( self ):
178237
configs = []
179238
self.load_configs()

elmclient/examples/oslcquery.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ def do_oslc_query(inputargs=None):
297297
raise Exception( f"Multiple matches for GC configuration {args.globalconfiguration}" )
298298
gcconfiguri = list(conf.keys())[0]
299299
logger.info( f"{gcconfiguri=}" )
300-
logger.debug( f"{gcconfiguri=}" )
301300
# check the gc config uri exists - a GET from it shouldn't fail!
302301
if not gcapp.check_valid_config_uri(gcconfiguri,raise_exception=False):
303302
raise Exception( f"GC configuration URI {gcconfiguri} not valid!" )
@@ -385,6 +384,7 @@ def do_oslc_query(inputargs=None):
385384
for c in c.list_configs():
386385
print( f" '{c}'" )
387386
raise Exception( f"Configuration '{args.configuration}' not found in component {args.component}" )
387+
388388
queryon = c
389389

390390
elif gcconfiguri:
@@ -413,6 +413,12 @@ def do_oslc_query(inputargs=None):
413413
queryon = p
414414
queryon.set_local_config(config,gcconfiguri)
415415
logger.debug( f"setting {config=} {gcconfiguri=}" )
416+
if args.verbose:
417+
if config:
418+
print( f"Local config {config}" )
419+
if gcconfiguri:
420+
print( f"Global config {gcconfiguri}" )
421+
416422
# we're querying the component
417423
else:
418424
if args.saveconfigs:

elmclient/httpops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def get_auth_path(self, request_url, response):
467467
def tidy_cookies(self):
468468
'''
469469
LQE 7.0.2SR1 and 7.0.3 has the unpleasant habit of including double-quotes in the auth cookie path so it looks like "/lqe" (which includes the quotation marks in the path) rather than /lqe, and then the path is never matched so authentication is lost
470-
This code cleans up the path on all cookies on the session4
470+
This code cleans up the path on all cookies on the session
471471
# return True if any cookie changed
472472
'''
473473
result = False

elmclient/oslcqueryapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def _execute_vanilla_oslc_query(self, querycapabilityuri, query_params, orderby=
584584
fullurl = f"{query_url}?{urllib.parse.urlencode( params, quote_via=urllib.parse.quote, safe='/')}"
585585
if verbose:
586586
print( f"Full query URL is {fullurl}" )
587+
587588
# print( f"Full query URL is {fullurl}" )
588589
# retrieve all pages of results - they will be processed later
589590
total = 1
@@ -808,7 +809,7 @@ def _execute_vanilla_oslc_query(self, querycapabilityuri, query_params, orderby=
808809
# dup = False
809810
else:
810811
# dup = True
811-
# print( f"DUP {about}" )
812+
print( f"DUPLICATED RESULT {about}" )
812813
# print( f"{result[about]=}" )
813814
# print( f"{desc=}" )
814815
# print( f"{ET.tostring(desc)=}" )

0 commit comments

Comments
 (0)