Skip to content

Commit f1321da

Browse files
authored
Merge branch 'iam-veeramalla:main' into main
2 parents 9f88778 + 70f5215 commit f1321da

File tree

7 files changed

+167
-24
lines changed

7 files changed

+167
-24
lines changed

Day-11/04-demo-github-integration.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Program to demonstrate integration with GitHub to fetch the
2+
# details of Users who created Pull requests(Active) on Kubernetes Github repo.
3+
4+
import requests
5+
6+
# URL to fetch pull requests from the GitHub API
7+
url = f'https://api.github.com/repos/kubernetes/kubernetes/pulls'
8+
9+
# Make a GET request to fetch pull requests data from the GitHub API
10+
response = requests.get(url) # Add headers=headers inside get() for authentication
11+
12+
# Only if the response is successful
13+
if response.status_code == 200:
14+
# Convert the JSON response to a dictionary
15+
pull_requests = response.json()
16+
17+
# Create an empty dictionary to store PR creators and their counts
18+
pr_creators = {}
19+
20+
# Iterate through each pull request and extract the creator's name
21+
for pull in pull_requests:
22+
creator = pull['user']['login']
23+
if creator in pr_creators:
24+
pr_creators[creator] += 1
25+
else:
26+
pr_creators[creator] = 1
27+
28+
# Display the dictionary of PR creators and their counts
29+
print("PR Creators and Counts:")
30+
for creator, count in pr_creators.items():
31+
print(f"{creator}: {count} PR(s)")
32+
else:
33+
print(f"Failed to fetch data. Status code: {response.status_code}")

Day-12/README.md

Whitespace-only changes.

Day-12/server.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Server Configuration File
2+
3+
# Network Settings
4+
PORT = 8080
5+
MAX_CONNECTIONS=600
6+
TIMEOUT = 30
7+
8+
# Security Settings
9+
SSL_ENABLED = true
10+
SSL_CERT = /path/to/certificate.pem
11+
12+
# Logging Settings
13+
LOG_LEVEL = INFO
14+
LOG_FILE = /var/log/server.log
15+
16+
# Other Settings
17+
ENABLE_FEATURE_X = true

Day-12/update_server.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def update_server_config(file_path, key, value):
2+
# Read the existing content of the server configuration file
3+
with open(file_path, 'r') as file:
4+
lines = file.readlines()
5+
6+
# Update the configuration value for the specified key
7+
with open(file_path, 'w') as file:
8+
for line in lines:
9+
# Check if the line starts with the specified key
10+
if key in line:
11+
# Update the line with the new value
12+
file.write(key + "=" + value + "\n")
13+
else:
14+
# Keep the existing line as it is
15+
file.write(line)
16+
17+
# Path to the server configuration file
18+
server_config_file = 'server.conf'
19+
20+
# Key and new value for updating the server configuration
21+
key_to_update = 'MAX_CONNECTIONS'
22+
new_value = '600' # New maximum connections allowed
23+
24+
# Update the server configuration file
25+
update_server_config(server_config_file, key_to_update, new_value)

Day-14/examples/create-jira.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This code sample uses the 'requests' library:
2+
# http://docs.python-requests.org
3+
import requests
4+
from requests.auth import HTTPBasicAuth
5+
import json
6+
7+
url = "https://veeramallaabhishek.atlassian.net/rest/api/3/issue"
8+
9+
API_TOKEN = ""
10+
11+
auth = HTTPBasicAuth("", API_TOKEN)
12+
13+
headers = {
14+
"Accept": "application/json",
15+
"Content-Type": "application/json"
16+
}
17+
18+
payload = json.dumps( {
19+
"fields": {
20+
"description": {
21+
"content": [
22+
{
23+
"content": [
24+
{
25+
"text": "My first jira ticket",
26+
"type": "text"
27+
}
28+
],
29+
"type": "paragraph"
30+
}
31+
],
32+
"type": "doc",
33+
"version": 1
34+
},
35+
"project": {
36+
"key": "AB"
37+
},
38+
"issuetype": {
39+
"id": "10006"
40+
},
41+
"summary": "First JIRA Ticket",
42+
},
43+
"update": {}
44+
} )
45+
46+
response = requests.request(
47+
"POST",
48+
url,
49+
data=payload,
50+
headers=headers,
51+
auth=auth
52+
)
53+
54+
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

Day-14/examples/list_projects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This code sample uses the 'requests' library:
2+
# http://docs.python-requests.org
3+
import requests
4+
from requests.auth import HTTPBasicAuth
5+
import json
6+
7+
url = "https://veeramallaabhishek.atlassian.net/rest/api/3/project"
8+
9+
API_TOKEN=""
10+
11+
auth = HTTPBasicAuth("", API_TOKEN)
12+
13+
headers = {
14+
"Accept": "application/json"
15+
}
16+
17+
response = requests.request(
18+
"GET",
19+
url,
20+
headers=headers,
21+
auth=auth
22+
)
23+
24+
output = json.loads(response.text)
25+
26+
name = output[0]["name"]
27+
28+
print(name)

README.md

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,53 +67,39 @@
6767
- Practice exercises and examples:
6868
- Example: Managing a dictionary of server configurations and optimizing retrieval.
6969

70-
## Day 12: Functions and Modules
71-
- Introduction to functions in Python.
72-
- Writing functions and function parameters.
73-
- Return values and modular code.
70+
## Day 12: Python Tasks for DevOps (Part 1) - File Operations
71+
- Introduction to File Operations and Boto3.
72+
- Automating File operations.
7473
- Practice exercises and examples:
75-
- Example: Creating a function to automate server status checks.
74+
- Example: Update a server resources in the server.conf file up on external notification.
7675

77-
## Day 13: Functions and Modules (Part 2)
78-
- Advanced function topics (recursion, lambda functions).
79-
- Function libraries and built-in functions.
80-
- Practice exercises and examples:
81-
- Example: Developing a library of custom functions for DevOps automation.
82-
83-
## Day 14: Python Libraries for DevOps (Part 1)
84-
- Introduction to external libraries like Paramiko, Fabric, and Boto3.
85-
- Automating SSH connections with Paramiko.
86-
- Running commands on remote servers.
87-
- Practice exercises and examples:
88-
- Example: Using Paramiko to create a secure remote backup solution.
89-
90-
## Day 15: Python Libraries for DevOps (Part 2)
76+
## Day 13: Python Tasks for DevOps (Part 2)
9177
- Using Fabric for remote task automation.
9278
- AWS automation with Boto3.
9379
- Managing EC2 instances, S3 buckets, and more.
9480
- Practice exercises and examples:
95-
- Example: Creating a Fabric script for deploying applications to remote servers.
81+
- Example: Creating a aws script for deploying applications to remote servers.
9682

97-
## Day 16: Working with RESTful APIs
83+
## Day 14: Working with RESTful APIs
9884
- Introduction to RESTful APIs.
9985
- Making HTTP requests using Python.
10086
- Parsing JSON responses and error handling.
10187
- Practice exercises and examples:
10288
- Example: Developing a script to monitor RESTful API endpoints for your DevOps tools.
10389

104-
## Day 17: Data Serialization and Configuration Files
90+
## Day 15: Data Serialization and Configuration Files
10591
- Serializing and deserializing data (JSON, YAML).
10692
- Managing configuration data.
10793
- DevOps use cases for configuration files.
10894
- Practice exercises and examples:
10995
- Example: Building a configuration manager to handle application settings in JSON format.
11096

111-
## Day 18: Automation with Cron Jobs
97+
## Day 16: Automation with Cron Jobs
11298
- Scheduling automated tasks using cron.
11399
- Creating Python scripts for scheduled automation.
114100
- Handling periodic tasks and reports.
115101
- Practice exercises and examples:
116102
- Example: Using cron and Python to schedule regular backups of your data.
117103

118-
## Day 19: Python Interview Questions & Answers
104+
## Day 17: Python Interview Questions & Answers
119105

0 commit comments

Comments
 (0)