aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2019-01-24 18:40:47 -0800
committerDavid Reyna <David.Reyna@windriver.com>2019-01-24 18:40:47 -0800
commit1cd553d6f2afee77e65207ef34e73c450879380b (patch)
tree94d5cab39cbb3ada25a59be91ce135a69550bb4b
parent094ce7ccbc0ea9199e1dcbe262fe1187f78f8fe8 (diff)
downloadsrtool-1cd553d6f2afee77e65207ef34e73c450879380b.tar.gz
srtool-1cd553d6f2afee77e65207ef34e73c450879380b.tar.bz2
srtool-1cd553d6f2afee77e65207ef34e73c450879380b.zip
srtool: separate name/passwords for defect and email
Separate the environment variables of the username and password for the defect and email systems into separate values, in case they need separate credentials. Also, fix a Wind River-ism in the Jira template to reflect that the product key is not necessarily also defect name prefix. Signed-off-by: David Reyna <David.Reyna@windriver.com>
-rwxr-xr-xbin/acme/srtool_defect.py4
-rwxr-xr-xbin/acme/srtool_jira_acme.py28
-rw-r--r--bin/common/srtool_jira_template.py28
-rwxr-xr-xbin/dev_tools/srt_env.sh16
-rwxr-xr-xbin/yp/srtool_defect.py4
5 files changed, 42 insertions, 38 deletions
diff --git a/bin/acme/srtool_defect.py b/bin/acme/srtool_defect.py
index 77f8e030..0e189a3a 100755
--- a/bin/acme/srtool_defect.py
+++ b/bin/acme/srtool_defect.py
@@ -219,11 +219,11 @@ def main(argv):
if args.user:
srt_user = args.user
else:
- srt_user = os.environ.get('SRT_USER')
+ srt_user = os.environ.get('SRT_DEFECT_USER')
if args.passwd:
srt_passwd = args.passwd
else:
- srt_passwd = os.environ.get('SRT_PASSWD')
+ srt_passwd = os.environ.get('SRT_DEFECT_PASSWD')
if not srt_user or not srt_passwd:
msg = "FATAL ERROR: Missing user/password for Defect System access"
print(msg)
diff --git a/bin/acme/srtool_jira_acme.py b/bin/acme/srtool_jira_acme.py
index d7ef0507..dcfdb81a 100755
--- a/bin/acme/srtool_jira_acme.py
+++ b/bin/acme/srtool_jira_acme.py
@@ -211,7 +211,7 @@ def do_update_jira():
products = c.execute('''SELECT * FROM orm_product''').fetchall()
for i,product in enumerate(products):
# print("JIRA_PRODUCT_SCAN:%s,%s" % (product[ORM.PRODUCT_DEFECT_TAGS],get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')))
- product_defect_prefix = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
+ product_defect_key = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
if get_override('SRTDBG_MINIMAL_DB') and (i > 1):
break
@@ -227,7 +227,7 @@ def do_update_jira():
print("\tloading" + spinner[block_num % 4] + "\t" + product[ORM.PRODUCT_NAME] + " " + product[ORM.PRODUCT_VERSION] + " " + product[ORM.PRODUCT_PROFILE], end='\r', flush=True)
start_idx = block_num*block_size
#searches current project's bug issues that contain "cve" in their text
- issues = jira.search_issues('project=%s AND text ~ "cve*" AND type = Bug' % product_defect_prefix, start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD))
+ issues = jira.search_issues('project=%s AND text ~ "cve*" AND type = Bug' % product_defect_key, start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD))
if len(issues) == 0:
# Retrieve issues until there are no more to come
break
@@ -571,14 +571,14 @@ def jira_update_list(jira_list):
print("Updating:\t" + jira_name, flush=True)
# find the matching parent project
for i,product in enumerate(products):
- product_defect_prefix = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
- print("\tfrom:\t%s %s %s %s" %(product[ORM.PRODUCT_NAME],product[ORM.PRODUCT_VERSION],product[ORM.PRODUCT_PROFILE],product_defect_prefix), flush=True)
+ product_defect_key = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
+ print("\tfrom:\t%s %s %s %s" %(product[ORM.PRODUCT_NAME],product[ORM.PRODUCT_VERSION],product[ORM.PRODUCT_PROFILE],product_defect_key), flush=True)
block_size = 500
block_num = 0
while True:
start_idx = block_num*block_size
#searches current project's bug issues that contain "cve" in their text
- issues = jira.search_issues('project=%s AND text ~ "%s" AND type = Bug' % (product_defect_prefix,jira_name), start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD)) #project argument could be better written I guess :)
+ issues = jira.search_issues('project=%s AND text ~ "%s" AND type = Bug' % (product_defect_key,jira_name), start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD)) #project argument could be better written I guess :)
if len(issues) == 0:
# Retrieve issues until there are no more to come
break
@@ -720,8 +720,8 @@ def simulate_new_defect_name(product_prefix):
return defect_name
def simulate_new_defect(product_defect_tags,summary,cve_list,description,reason,priority,components,link,jira_url):
- product_defect_prefix = get_tag_key(product_defect_tags,'key')
- defect_name = simulate_new_defect_name(product_defect_prefix)
+ product_defect_key = get_tag_key(product_defect_tags,'key')
+ defect_name = simulate_new_defect_name(product_defect_key)
print("CREATED:%s,%s/browse/%s" % (defect_name,jira_url,defect_name))
def jira_new_defect(product_defect_tags,summary,cve_list,description,reason,priority,components,link):
@@ -751,19 +751,19 @@ def jira_new_defect(product_defect_tags,summary,cve_list,description,reason,prio
# append the jira link to description
description += "\n\n\n%s" % link
- product_defect_prefix = get_tag_key(product_defect_tags,'key')
+ product_defect_key = get_tag_key(product_defect_tags,'key')
# Translate the SRTool priority to Jira priority
priority = translate_priority_srt_to_jira(priority)
- #print("FOO1:%s,%s,%s" % (product_defect_prefix,summary,description))
+ #print("FOO1:%s,%s,%s" % (product_defect_key,summary,description))
jira_components=list()
for component in components.split(' '):
jira_components.append({'name' : component})
issue_dict = {
- 'project': {'key': product_defect_prefix},
+ 'project': {'key': product_defect_key},
'summary': summary,
'description': description,
'issuetype': {'name': 'Bug'},
@@ -784,10 +784,10 @@ def jira_new_defect(product_defect_tags,summary,cve_list,description,reason,prio
new_issue = jira.create_issue(fields=issue_dict)
#print("CREATE:%s" % issue_dict)
- #new_issue = '%s-%s' % (product_defect_prefix,datetime.now().strftime('%H%M%S'))
+ #new_issue = '%s-%s' % (product_defect_key,datetime.now().strftime('%H%M%S'))
new_issue = str(new_issue.key)
- if not new_issue.startswith(product_defect_prefix):
+ if not new_issue.startswith(product_defect_key):
print("ERROR:%s" % new_issue)
else:
print("CREATED:%s,%s/browse/%s" % (new_issue,jira_url,new_issue))
@@ -860,11 +860,11 @@ def main(argv):
if args.user:
srt_user = args.user
else:
- srt_user = os.environ.get('SRT_USER')
+ srt_user = os.environ.get('SRT_DEFECT_USER')
if args.passwd:
srt_passwd = args.passwd
else:
- srt_passwd = os.environ.get('SRT_PASSWD')
+ srt_passwd = os.environ.get('SRT_DEFECT_PASSWD')
if not srt_user or not srt_passwd:
msg = "FATAL ERROR: Missing user/password for Jira access"
print(msg)
diff --git a/bin/common/srtool_jira_template.py b/bin/common/srtool_jira_template.py
index 5f29355d..0c784e14 100644
--- a/bin/common/srtool_jira_template.py
+++ b/bin/common/srtool_jira_template.py
@@ -187,7 +187,7 @@ def do_update_jira():
products = c.execute('''SELECT * FROM orm_product''').fetchall()
for i,product in enumerate(products):
# print("JIRA_PRODUCT_SCAN:%s,%s" % (product[ORM.PRODUCT_DEFECT_TAGS],get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')))
- product_defect_prefix = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
+ product_defect_key = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
if get_override('SRTDBG_MINIMAL_DB') and (i > 1):
break
@@ -203,7 +203,7 @@ def do_update_jira():
print("\tloading" + spinner[block_num % 4] + "\t" + product[ORM.PRODUCT_NAME] + " " + product[ORM.PRODUCT_VERSION] + " " + product[ORM.PRODUCT_PROFILE], end='\r', flush=True)
start_idx = block_num*block_size
#searches current project's bug issues that contain "cve" in their text
- issues = jira.search_issues('project=%s AND text ~ "cve*" AND type = Bug' % product_defect_prefix, start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD))
+ issues = jira.search_issues('project=%s AND text ~ "cve*" AND type = Bug' % product_defect_key, start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD))
if len(issues) == 0:
# Retrieve issues until there are no more to come
break
@@ -547,14 +547,14 @@ def jira_update_list(jira_list):
print("Updating:\t" + jira_name, flush=True)
# find the matching parent project
for i,product in enumerate(products):
- product_defect_prefix = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
- print("\tfrom:\t%s %s %s %s" %(product[ORM.PRODUCT_NAME],product[ORM.PRODUCT_VERSION],product[ORM.PRODUCT_PROFILE],product_defect_prefix), flush=True)
+ product_defect_key = get_tag_key(product[ORM.PRODUCT_DEFECT_TAGS],'key')
+ print("\tfrom:\t%s %s %s %s" %(product[ORM.PRODUCT_NAME],product[ORM.PRODUCT_VERSION],product[ORM.PRODUCT_PROFILE],product_defect_key), flush=True)
block_size = 500
block_num = 0
while True:
start_idx = block_num*block_size
#searches current project's bug issues that contain "cve" in their text
- issues = jira.search_issues('project=%s AND text ~ "%s" AND type = Bug' % (product_defect_prefix,jira_name), start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD)) #project argument could be better written I guess :)
+ issues = jira.search_issues('project=%s AND text ~ "%s" AND type = Bug' % (product_defect_key,jira_name), start_idx, block_size, False, fields='key,summary,priority,status,resolution,project,updated,created,%s,%s' % (JIRA_PUBLISHED_FIELD, JIRA_FIX_VERSION_FIELD)) #project argument could be better written I guess :)
if len(issues) == 0:
# Retrieve issues until there are no more to come
break
@@ -696,8 +696,8 @@ def simulate_new_defect_name(product_prefix):
return defect_name
def simulate_new_defect(product_defect_tags,summary,cve_list,description,reason,priority,components,link,jira_url):
- product_defect_prefix = get_tag_key(product_defect_tags,'key')
- defect_name = simulate_new_defect_name(product_defect_prefix)
+ product_defect_key = get_tag_key(product_defect_tags,'key')
+ defect_name = simulate_new_defect_name(product_defect_key)
print("CREATED:%s,%s/browse/%s" % (defect_name,jira_url,defect_name))
def jira_new_defect(product_defect_tags,summary,cve_list,description,reason,priority,components,link):
@@ -727,19 +727,19 @@ def jira_new_defect(product_defect_tags,summary,cve_list,description,reason,prio
# append the jira link to description
description += "\n\n\n%s" % link
- product_defect_prefix = get_tag_key(product_defect_tags,'key')
+ product_defect_key = get_tag_key(product_defect_tags,'key')
# Translate the SRTool priority to Jira priority
priority = translate_priority_srt_to_jira(priority)
- #print("FOO1:%s,%s,%s" % (product_defect_prefix,summary,description))
+ #print("FOO1:%s,%s,%s" % (product_defect_key,summary,description))
jira_components=list()
for component in components.split(' '):
jira_components.append({'name' : component})
issue_dict = {
- 'project': {'key': product_defect_prefix},
+ 'project': {'key': product_defect_key},
'summary': summary,
'description': description,
'issuetype': {'name': 'Bug'},
@@ -755,10 +755,10 @@ def jira_new_defect(product_defect_tags,summary,cve_list,description,reason,prio
new_issue = jira.create_issue(fields=issue_dict)
#print("CREATE:%s" % issue_dict)
- #new_issue = '%s-%s' % (product_defect_prefix,datetime.now().strftime('%H%M%S'))
+ #new_issue = '%s-%s' % (product_defect_key,datetime.now().strftime('%H%M%S'))
new_issue = str(new_issue.key)
- if not new_issue.startswith(product_defect_prefix):
+ if not new_issue.startswith(product_defect_key):
print("ERROR:%s" % new_issue)
else:
print("CREATED:%s,%s/browse/%s" % (new_issue,jira_url,new_issue))
@@ -831,11 +831,11 @@ def main(argv):
if args.user:
srt_user = args.user
else:
- srt_user = os.environ.get('SRT_USER')
+ srt_user = os.environ.get('SRT_DEFECT_USER')
if args.passwd:
srt_passwd = args.passwd
else:
- srt_passwd = os.environ.get('SRT_PASSWD')
+ srt_passwd = os.environ.get('SRT_DEFECT_PASSWD')
if not srt_user or not srt_passwd:
msg = "FATAL ERROR: Missing user/password for Jira access"
print(msg)
diff --git a/bin/dev_tools/srt_env.sh b/bin/dev_tools/srt_env.sh
index 311a2af3..1cceb1c5 100755
--- a/bin/dev_tools/srt_env.sh
+++ b/bin/dev_tools/srt_env.sh
@@ -23,9 +23,11 @@ if [ "debug" != "$mode" ] ; then
export SRT_SKIP_AUTOUPDATE=0
# Email credentials
export SRT_SMTP=temp_smnp_server
- # Defect (Jira) and Email credentials
- export SRT_PASSWD=temp_password
- export SRT_USER=temp_user
+ export SRT_EMAIL_PASSWD=temp_password
+ export SRT_EMAIL_USER=temp_user
+ # Defect (e.g. Jira) credentials
+ export SRT_DEFECT_PASSWD=temp_password
+ export SRT_DEFECT_USER=temp_user
else
# Minimal Development Environment
# Standard Environment
@@ -41,9 +43,11 @@ else
export SRT_SKIP_AUTOUPDATE=1
# Email credentials
export SRT_SMTP=temp_smnp_server
- # Defect (Jira) and Email credentials
- export SRT_PASSWD=temp_password
- export SRT_USER=temp_user
+ export SRT_EMAIL_PASSWD=temp_password
+ export SRT_EMAIL_USER=temp_user
+ # Defect (e.g. Jira) credentials
+ export SRT_DEFECT_PASSWD=temp_password
+ export SRT_DEFECT_USER=temp_user
fi
echo "SRT_PORT=$SRT_PORT ; Change it with: export SRT_PORT=9123"
diff --git a/bin/yp/srtool_defect.py b/bin/yp/srtool_defect.py
index 77f8e030..0e189a3a 100755
--- a/bin/yp/srtool_defect.py
+++ b/bin/yp/srtool_defect.py
@@ -219,11 +219,11 @@ def main(argv):
if args.user:
srt_user = args.user
else:
- srt_user = os.environ.get('SRT_USER')
+ srt_user = os.environ.get('SRT_DEFECT_USER')
if args.passwd:
srt_passwd = args.passwd
else:
- srt_passwd = os.environ.get('SRT_PASSWD')
+ srt_passwd = os.environ.get('SRT_DEFECT_PASSWD')
if not srt_user or not srt_passwd:
msg = "FATAL ERROR: Missing user/password for Defect System access"
print(msg)