Update ci-health url if not present in CIX card desc
This patch modifies tripleo-critical-bugs to Update ci-health url if not present in CIX card desc Change-Id: I14c841e5516a80a9e04cf5a182da8cb4f027710a
This commit is contained in:
parent
99470767ac
commit
e4d0b68976
|
@ -1,11 +1,40 @@
|
|||
import requests
|
||||
import re
|
||||
|
||||
base_url = "https://opendev.org/openstack/tripleo-ci-health-queries/raw/branch/master/output/elastic-recheck/"
|
||||
health_url = "http://health.sbarnea.com/"
|
||||
health_url = "http://ci-health.tripleo.org/"
|
||||
|
||||
|
||||
def get_health_link(bug_id):
|
||||
response = requests.get(base_url + str(bug_id) + ".yaml")
|
||||
if response.status_code == 200:
|
||||
return health_url + "#" + str(bug_id)
|
||||
return "\n" + health_url + "#" + str(bug_id)
|
||||
return ""
|
||||
|
||||
|
||||
def get_bug_id_from_card(card):
|
||||
"""Finds LP bug id in card name"""
|
||||
pattern = "^\\[CIX]\\[LP:((.*?))]"
|
||||
match_found = re.search(pattern, card["name"])
|
||||
if match_found:
|
||||
bug_id = match_found.group(1)
|
||||
return bug_id
|
||||
return None
|
||||
|
||||
|
||||
def is_health_link_in_desc(card):
|
||||
"""Checks if card has health link in desc"""
|
||||
pattern = health_url
|
||||
return re.search(pattern, card["desc"])
|
||||
|
||||
|
||||
def add_health_link(card):
|
||||
"""Adds health link if present to card"""
|
||||
# Updates health link in each card for now
|
||||
# This doesn't check if health link is already present
|
||||
bug_id = get_bug_id_from_card(card)
|
||||
if bug_id:
|
||||
health_link = get_health_link(bug_id)
|
||||
desc = card["desc"] + health_link
|
||||
return desc
|
||||
return card["desc"]
|
||||
|
|
|
@ -183,6 +183,21 @@ class Members(object):
|
|||
else:
|
||||
raise TypeError()
|
||||
|
||||
def get_member_cards(self, memberId):
|
||||
# get all the open cards from a particular member
|
||||
membersUrl = '{0}/members/{1}/cards/open'.format(self._api.ApiRootUrl, memberId)
|
||||
response = requests.get(membersUrl, params=self._api.Payload)
|
||||
response.raise_for_status()
|
||||
|
||||
# scrub trello cards for blacklisted boards
|
||||
data = json.loads(response.text)
|
||||
remove_list = []
|
||||
# create a list of cards that are blacklisted
|
||||
for i in range(len(data)):
|
||||
if BOARD_BLACKLIST == data[i]['idBoard'].encode("ascii"):
|
||||
remove_list.append(i)
|
||||
return data
|
||||
|
||||
|
||||
#
|
||||
# CARDS
|
||||
|
@ -263,3 +278,10 @@ class Cards(object):
|
|||
response = requests.get(getCardsUrl, params=self._api.Payload)
|
||||
response.raise_for_status()
|
||||
return json.loads(response.text)
|
||||
|
||||
def update(self, card_id, desc):
|
||||
"update card"
|
||||
url = "%s/cards/%s" % (self._api.ApiRootUrl, card_id)
|
||||
response = requests.put(url, params=self._api.Payload, data=dict(desc=desc))
|
||||
response.raise_for_status()
|
||||
return json.loads(response.text)
|
||||
|
|
|
@ -27,13 +27,12 @@ then compares the list to cards on the cix trello board. If there
|
|||
is a lp bug that does not have a card it will open a trello card
|
||||
"""
|
||||
|
||||
import click
|
||||
import configparser
|
||||
|
||||
import click
|
||||
|
||||
import reports.trello as trello
|
||||
from reports.erhealth import get_health_link
|
||||
from reports.erhealth import get_health_link, add_health_link, is_health_link_in_desc
|
||||
from reports.launchpad import LaunchpadReport
|
||||
import reports.trello as trello
|
||||
|
||||
|
||||
class StatusReport(object):
|
||||
|
@ -127,7 +126,7 @@ class StatusReport(object):
|
|||
trello_api_context = trello.ApiContext(config)
|
||||
trello_cards = trello.Cards(trello_api_context)
|
||||
trello_cards.create(
|
||||
card_title, trello_list, desc=bug_link + "\n" + health_link
|
||||
card_title, trello_list, desc=bug_link + health_link
|
||||
)
|
||||
|
||||
|
||||
|
@ -158,7 +157,6 @@ def main(config_file, trello_token, trello_api_key, trello_board_id):
|
|||
bugs_with_alerts_open, bugs_with_alerts_closed = report.summarise_launchpad_bugs()
|
||||
|
||||
print("*** open critical bugs ***")
|
||||
report.print_report(bugs_with_alerts_open)
|
||||
print("*** closed critical bugs ***")
|
||||
report.print_report(bugs_with_alerts_closed)
|
||||
|
||||
|
@ -172,6 +170,15 @@ def main(config_file, trello_token, trello_api_key, trello_board_id):
|
|||
|
||||
all_cards_on_board = trello_boards.get_cards(config.get('TrelloConfig', 'board_id'))
|
||||
print("all cards " + str(len(all_cards_on_board)))
|
||||
|
||||
# Add health link if available to card without health link
|
||||
for card in all_cards_on_board:
|
||||
if not is_health_link_in_desc(card):
|
||||
desc = add_health_link(card)
|
||||
trello_api_context = trello.ApiContext(config)
|
||||
trello_cards = trello.Cards(trello_api_context)
|
||||
trello_cards.update(card["id"], desc)
|
||||
print("Updated card " + card["name"])
|
||||
cards_outtage = all_cards_on_board
|
||||
|
||||
critical_bugs_with_out_escalation_cards = report.compare_bugs_with_cards(
|
||||
|
|
Loading…
Reference in New Issue