From 2f39f64d010442e998ac49446a5e0760f63e2d21 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Thu, 20 Jul 2023 23:45:21 +0800 Subject: [PATCH 01/14] added sub --- .github/workflows/main_swaydevshello(stagingslot).yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_swaydevshello(stagingslot).yml b/.github/workflows/main_swaydevshello(stagingslot).yml index 843a880..2036c5d 100644 --- a/.github/workflows/main_swaydevshello(stagingslot).yml +++ b/.github/workflows/main_swaydevshello(stagingslot).yml @@ -60,4 +60,4 @@ jobs: with: app-name: 'swaydevshello' slot-name: 'stagingslot' - publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_7B57368891D74D8FA321093A5BE5C903 }} + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_7acf3d660e9a4eab85ba98463d240d40 }} From 4e5920f19e79b05f80ef06618b73cfee1adc0351 Mon Sep 17 00:00:00 2001 From: mahesws Date: Fri, 21 Jul 2023 00:17:45 +0800 Subject: [PATCH 02/14] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..2e0e73a --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,87 @@ +# Python to Linux Web App on Azure +# Build your Python project and deploy it to Azure as a Linux Web App. +# Change python version to one thats appropriate for your application. +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- main + +variables: + # Azure Resource Manager connection created during pipeline creation + azureServiceConnectionId: 'b207554c-1122-4a08-979e-72d513004407' + + # Web app name + webAppName: 'pythonwebappmahes' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'pythonwebappmahes' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + # Python version: 3.7 + pythonVersion: '3.7' + +stages: +- stage: Build + displayName: Build stage + jobs: + - job: BuildJob + pool: + vmImage: $(vmImageName) + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python $(pythonVersion)' + + - script: | + python -m venv antenv + source antenv/bin/activate + python -m pip install --upgrade pip + pip install setup + pip install -r requirements.txt + workingDirectory: $(projectRoot) + displayName: "Install requirements" + + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: '$(projectRoot)' + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + replaceExistingArchive: true + + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + displayName: 'Upload package' + artifact: drop + +- stage: Deploy + displayName: 'Deploy Web App' + dependsOn: Build + condition: succeeded() + jobs: + - deployment: DeploymentJob + pool: + vmImage: $(vmImageName) + environment: $(environmentName) + strategy: + runOnce: + deploy: + steps: + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python version' + + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : pythonwebappmahes' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From dbf5784849b415d1b531e332b3c2f341543e5c64 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 09:21:38 +0800 Subject: [PATCH 03/14] added subid --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2e0e73a..d83d2ad 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,8 +8,8 @@ trigger: variables: # Azure Resource Manager connection created during pipeline creation - azureServiceConnectionId: 'b207554c-1122-4a08-979e-72d513004407' - + azureServiceConnectionId: '7acf3d66-0e9a-4eab-85ba-98463d240d40' + # Web app name webAppName: 'pythonwebappmahes' From c43beec9dcac0f67cd16fd0c7d532624d77df141 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 09:50:41 +0800 Subject: [PATCH 04/14] added subid2 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d83d2ad..bc650a3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,7 +8,7 @@ trigger: variables: # Azure Resource Manager connection created during pipeline creation - azureServiceConnectionId: '7acf3d66-0e9a-4eab-85ba-98463d240d40' + azureServiceConnectionId: 'github.com_mahesws' # Web app name webAppName: 'pythonwebappmahes' From 5d0f939b668a00e62464f833b0bf11cf2d9776ad Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 09:55:06 +0800 Subject: [PATCH 05/14] removed subid --- azure-pipelines.yml | 87 --------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index bc650a3..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Python to Linux Web App on Azure -# Build your Python project and deploy it to Azure as a Linux Web App. -# Change python version to one thats appropriate for your application. -# https://docs.microsoft.com/azure/devops/pipelines/languages/python - -trigger: -- main - -variables: - # Azure Resource Manager connection created during pipeline creation - azureServiceConnectionId: 'github.com_mahesws' - - # Web app name - webAppName: 'pythonwebappmahes' - - # Agent VM image name - vmImageName: 'ubuntu-latest' - - # Environment name - environmentName: 'pythonwebappmahes' - - # Project root folder. Point to the folder containing manage.py file. - projectRoot: $(System.DefaultWorkingDirectory) - - # Python version: 3.7 - pythonVersion: '3.7' - -stages: -- stage: Build - displayName: Build stage - jobs: - - job: BuildJob - pool: - vmImage: $(vmImageName) - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(pythonVersion)' - displayName: 'Use Python $(pythonVersion)' - - - script: | - python -m venv antenv - source antenv/bin/activate - python -m pip install --upgrade pip - pip install setup - pip install -r requirements.txt - workingDirectory: $(projectRoot) - displayName: "Install requirements" - - - task: ArchiveFiles@2 - displayName: 'Archive files' - inputs: - rootFolderOrFile: '$(projectRoot)' - includeRootFolder: false - archiveType: zip - archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip - replaceExistingArchive: true - - - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip - displayName: 'Upload package' - artifact: drop - -- stage: Deploy - displayName: 'Deploy Web App' - dependsOn: Build - condition: succeeded() - jobs: - - deployment: DeploymentJob - pool: - vmImage: $(vmImageName) - environment: $(environmentName) - strategy: - runOnce: - deploy: - steps: - - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(pythonVersion)' - displayName: 'Use Python version' - - - task: AzureWebApp@1 - displayName: 'Deploy Azure Web App : pythonwebappmahes' - inputs: - azureSubscription: $(azureServiceConnectionId) - appName: $(webAppName) - package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From cc9d074a22dbb693c2595e2903895f09adc21604 Mon Sep 17 00:00:00 2001 From: mahesws Date: Fri, 21 Jul 2023 09:57:35 +0800 Subject: [PATCH 06/14] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..8c3fff8 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,87 @@ +# Python to Linux Web App on Azure +# Build your Python project and deploy it to Azure as a Linux Web App. +# Change python version to one thats appropriate for your application. +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- main + +variables: + # Azure Resource Manager connection created during pipeline creation + azureServiceConnectionId: '84f81cff-9c7a-4e64-a21e-2a77dd18fadc' + + # Web app name + webAppName: 'pythonwebappmahes' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'pythonwebappmahes' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + # Python version: 3.7 + pythonVersion: '3.7' + +stages: +- stage: Build + displayName: Build stage + jobs: + - job: BuildJob + pool: + vmImage: $(vmImageName) + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python $(pythonVersion)' + + - script: | + python -m venv antenv + source antenv/bin/activate + python -m pip install --upgrade pip + pip install setup + pip install -r requirements.txt + workingDirectory: $(projectRoot) + displayName: "Install requirements" + + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: '$(projectRoot)' + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + replaceExistingArchive: true + + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + displayName: 'Upload package' + artifact: drop + +- stage: Deploy + displayName: 'Deploy Web App' + dependsOn: Build + condition: succeeded() + jobs: + - deployment: DeploymentJob + pool: + vmImage: $(vmImageName) + environment: $(environmentName) + strategy: + runOnce: + deploy: + steps: + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python version' + + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : pythonwebappmahes' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From 227d687919086e3affbdfe1424b42253e616ef99 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 10:18:46 +0800 Subject: [PATCH 07/14] pool --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8c3fff8..19a72c6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,7 +31,7 @@ stages: jobs: - job: BuildJob pool: - vmImage: $(vmImageName) + name: default_pythonpool steps: - task: UsePythonVersion@0 inputs: From 04971dad7bb0c1ec0985e3807c91ba321c85cc64 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 11:18:24 +0800 Subject: [PATCH 08/14] default pool --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 19a72c6..e578fac 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,7 +31,7 @@ stages: jobs: - job: BuildJob pool: - name: default_pythonpool + name: Default steps: - task: UsePythonVersion@0 inputs: From 6dd7fe68d48804a4264dab2812bf52586d8b17e9 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 12:05:50 +0800 Subject: [PATCH 09/14] default pool 2 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e578fac..ee6fff9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,7 +23,7 @@ variables: projectRoot: $(System.DefaultWorkingDirectory) # Python version: 3.7 - pythonVersion: '3.7' + pythonVersion: "3.8" stages: - stage: Build From 34a1ca06cd5cba9778a385e70b2b69134e242de1 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 12:34:06 +0800 Subject: [PATCH 10/14] default pool 3 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ee6fff9..d898232 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -67,7 +67,7 @@ stages: jobs: - deployment: DeploymentJob pool: - vmImage: $(vmImageName) + name: Default environment: $(environmentName) strategy: runOnce: From c52e0ea9177fd386f048851d74b5f025ee1ccb76 Mon Sep 17 00:00:00 2001 From: Maheswaran Date: Fri, 21 Jul 2023 13:06:23 +0800 Subject: [PATCH 11/14] web page 4 --- templates/about.html | 4 ++-- templates/index.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/about.html b/templates/about.html index 10e2478..3899e26 100644 --- a/templates/about.html +++ b/templates/about.html @@ -4,14 +4,14 @@ - Stanley's Python WebApp + ADO Testing - Simple Python WebApp - Mahes {%extends "templates.html" %} {% block content %}

About

-

Just a sample Web Application made with Python and Flask

+

Just a sample Web Application made with Python and Flask for ADO pipeline

{% endblock %} diff --git a/templates/index.html b/templates/index.html index 6801871..da6635e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,7 +11,7 @@ {% block content %}

A Simple Pyton Web App

-

Hello Word!!!!!!!, Our Web App is up and running

+

Simple Web Application made with Python and Flask for ADO pipeline

{% endblock %} From 50e937bd02fd6b7bda65f72557f6a4e9db2a44eb Mon Sep 17 00:00:00 2001 From: mahesws Date: Thu, 25 Jul 2024 10:55:18 +0800 Subject: [PATCH 12/14] Create taskreport --- taskreport | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 taskreport diff --git a/taskreport b/taskreport new file mode 100644 index 0000000..4f184d0 --- /dev/null +++ b/taskreport @@ -0,0 +1,32 @@ +import requests +import json +from datetime import datetime, timedelta + +# Puppet master and API token +puppet_master = '' +api_token = '' + +# Calculate the time 24 hours ago in ISO 8601 format +since_time = (datetime.utcnow() - timedelta(hours=24)).strftime('%Y-%m-%dT%H:%M:%SZ') + +# API endpoint +url = f"https://{puppet_master}:8143/orchestrator/v1/jobs?since={since_time}" + +# Headers for the request +headers = { + 'X-Authentication': api_token, + 'Content-Type': 'application/json' +} + +# Make the API request +response = requests.get(url, headers=headers, verify=False) + +# Check if the request was successful +if response.status_code == 200: + jobs = response.json() + # Process the jobs to extract task logs + for job in jobs.get('items', []): + print(f"Job ID: {job['job_id']}, Task: {job['task']}, Status: {job['status']}") + # Add more detailed log extraction if needed +else: + print(f"Failed to fetch jobs: {response.status_code} - {response.text}") From 0a36fac90a6d37ef218b3aa1597da9440e014b44 Mon Sep 17 00:00:00 2001 From: mahesws Date: Thu, 25 Jul 2024 11:14:52 +0800 Subject: [PATCH 13/14] Create taskreport2 --- taskreport2 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 taskreport2 diff --git a/taskreport2 b/taskreport2 new file mode 100644 index 0000000..6215005 --- /dev/null +++ b/taskreport2 @@ -0,0 +1,32 @@ +import requests +from datetime import datetime, timedelta + +# Define Puppet master and API token +puppet_master = 'your_puppet_master' +api_token = 'your_api_token' + +# Calculate the time 24 hours ago in ISO 8601 format +since_time = datetime.utcnow() - timedelta(hours=24) + +# Construct the URL +url = f"https://{puppet_master}:8143/orchestrator/v1/jobs" + +# Set the headers for the request +headers = { + 'X-Authentication': api_token, + 'Content-Type': 'application/json' +} + +# Make the API request +response = requests.get(url, headers=headers, verify=False) + +# Check if the request was successful +if response.status_code == 200: + jobs = response.json() + # Filter jobs by the timestamp + filtered_jobs = [job for job in jobs.get('items', []) if datetime.strptime(job['timestamp'], '%Y-%m-%dT%H:%M:%SZ') > since_time] + # Process the filtered jobs + for job in filtered_jobs: + print(f"Job ID: {job['job_id']}, Task: {job['task']}, Status: {job['status']}, Timestamp: {job['timestamp']}") +else: + print(f"Failed to fetch jobs: {response.status_code} - {response.text}") From 1cf6a2f5d0ba7ee0bafe751724e902fecdf8c710 Mon Sep 17 00:00:00 2001 From: mahesws Date: Thu, 25 Jul 2024 11:22:03 +0800 Subject: [PATCH 14/14] Create taskreport3 --- taskreport3 | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 taskreport3 diff --git a/taskreport3 b/taskreport3 new file mode 100644 index 0000000..3f9b206 --- /dev/null +++ b/taskreport3 @@ -0,0 +1,48 @@ +import requests +from datetime import datetime, timedelta + +# Define Puppet master and API token +puppet_master = 'your_puppet_master' +api_token = 'your_api_token' + +# Calculate the time 24 hours ago in ISO 8601 format +since_time = (datetime.utcnow() - timedelta(hours=24)).strftime('%Y-%m-%dT%H:%M:%SZ') + +# Construct the URL +url = f"https://{puppet_master}:8143/orchestrator/v1/jobs" + +# Set the headers for the request +headers = { + 'X-Authentication': api_token, + 'Content-Type': 'application/json' +} + +# Make the API request +response = requests.get(url, headers=headers, verify=False) + +# Check if the request was successful +if response.status_code == 200: + jobs = response.json() + # Debug: Print the entire JSON response to understand its structure + print("Response JSON:", jobs) + + # Filter jobs by the timestamp + filtered_jobs = [ + job for job in jobs.get('items', []) + if datetime.strptime(job['timestamp'], '%Y-%m-%dT%H:%M:%SZ') > datetime.strptime(since_time, '%Y-%m-%dT%H:%M:%SZ') + ] + + # Process the filtered jobs + for job in filtered_jobs: + # Debug: Print each job to understand its structure + print("Job:", job) + + # Adjust keys according to the actual structure + job_id = job.get('job_id', 'N/A') + task = job.get('task', 'N/A') + status = job.get('status', 'N/A') + timestamp = job.get('timestamp', 'N/A') + + print(f"Job ID: {job_id}, Task: {task}, Status: {status}, Timestamp: {timestamp}") +else: + print(f"Failed to fetch jobs: {response.status_code} - {response.text}")