add_us203_tasks.py 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import requests
  2. import urllib3
  3. import os
  4. urllib3.disable_warnings()
  5. TAIGA_USER = 'FrancoisLange'
  6. TAIGA_PASS = 'your_db_password_here'
  7. base_url = 'https://192.168.130.161/taiga/api/v1'
  8. project_id = 21
  9. us_id = 280 # US-203 ID
  10. def main():
  11. print("Connecting to Taiga...")
  12. auth_resp = requests.post(f'{base_url}/auth', json={'type': 'normal', 'username': TAIGA_USER, 'password': TAIGA_PASS}, verify=False)
  13. if auth_resp.status_code != 200:
  14. print("Auth failed!")
  15. return
  16. auth = auth_resp.json()
  17. headers = {
  18. 'Authorization': f'Bearer {auth["auth_token"]}',
  19. 'Content-Type': 'application/json',
  20. 'x-disable-pagination': 'true'
  21. }
  22. # Get user story details to find the correct milestone (sprint)
  23. us_resp = requests.get(f'{base_url}/userstories/{us_id}', headers=headers, verify=False)
  24. if us_resp.status_code != 200:
  25. print(f"Failed to fetch US-{us_id}")
  26. return
  27. us = us_resp.json()
  28. milestone_id = us.get('milestone')
  29. print(f"User story '{us['subject']}' is assigned to milestone {milestone_id}")
  30. tasks_to_add = [
  31. {
  32. "subject": "Configure Docker Log Rotation Limits",
  33. "description": "**Changes**: Configured max-size and max-file parameters inside `docker-compose.yml` to set strict limits on container log file sizes.\n**Why**: Prevents log growth from consuming 100% of host disk space during long-term continuous operations.\n**Commit Comment**: `TG-202: Add log rotation limits to prevent 100% disk usage and optimize container disk footprint.`"
  34. },
  35. {
  36. "subject": "Develop Automated Disaster Recovery Validation Script",
  37. "description": "**Changes**: Developed a robust automated verification bash script `test_dr.sh` that spins up a sandbox MySQL instance, restores the latest compressed database backup, and validates table counts and content.\n**Why**: To routinely and safely test database recovery readiness without risking production data integrity.\n**Commit Comment**: `TG-203: Deploy automated disaster recovery verification script test_dr.sh in developer sandbox.`"
  38. },
  39. {
  40. "subject": "Tune MySQL Database Buffer Pools and Performance Parameters",
  41. "description": "**Changes**: Adjusted InnoDB memory sizes, page cache parameters, and query buffers inside `my.cnf` configuration to handle optimized vertical partition sets.\n**Why**: Ensures sub-second execution times (<0.04s) for high-frequency clinical keyword lookups.\n**Commit Comment**: `TG-203: Tune InnoDB memory pools and database parameters inside my.cnf for optimized search scaling.`"
  42. }
  43. ]
  44. # Fetch existing tasks under this user story to avoid duplicates
  45. existing_tasks = requests.get(f'{base_url}/tasks?user_story={us_id}', headers=headers, verify=False).json()
  46. existing_subjects = {t['subject'] for t in existing_tasks}
  47. for task in tasks_to_add:
  48. subject = task['subject']
  49. if subject in existing_subjects:
  50. print(f"Task '{subject}' already exists. Skipping.")
  51. continue
  52. print(f"Creating task '{subject}'...")
  53. payload = {
  54. "project": project_id,
  55. "user_story": us_id,
  56. "subject": subject,
  57. "description": task['description'],
  58. "status": 104, # Closed
  59. "milestone": milestone_id
  60. }
  61. resp = requests.post(f'{base_url}/tasks', json=payload, headers=headers, verify=False)
  62. if resp.status_code == 201:
  63. print(f"Successfully created task '{subject}'!")
  64. else:
  65. print(f"Failed to create task '{subject}': {resp.status_code} {resp.text}")
  66. print("Task addition sequence completed.")
  67. if __name__ == '__main__':
  68. main()