diff --git a/Day-11/test.py b/Day-11/test.py new file mode 100644 index 00000000..eb2d944c --- /dev/null +++ b/Day-11/test.py @@ -0,0 +1,8 @@ +import requests + +response = requests.get("https://api.github.com/repos/kubernetes/kubernetes/pulls") + +complete_response = response.json() + +for i in range(len(complete_response)): + print (complete_response[i]["user"]["login"]) \ No newline at end of file diff --git a/Day-11/test2.py b/Day-11/test2.py new file mode 100644 index 00000000..e7f6a27d --- /dev/null +++ b/Day-11/test2.py @@ -0,0 +1,12 @@ +server_config = { + 'server1': {'ip': '192.168.1.1', 'port': 8080, 'status': 'active'}, + 'server2': {'ip': '192.168.1.2', 'port': 8000, 'status': 'inactive'}, + 'server3': {'ip': '192.168.1.3', 'port': 9000, 'status': 'active'} +} + +def get_server_status(server_name): + return server_config.get(server_name, {}).get('status', 'Server not found') + +server_name = 'server22' +status = get_server_status(server_name) +print(f"{server_name} status: {status}") \ No newline at end of file diff --git a/Day-12/server.conf b/Day-12/server.conf index e9d46d83..553be495 100644 --- a/Day-12/server.conf +++ b/Day-12/server.conf @@ -2,7 +2,7 @@ # Network Settings PORT = 8080 -MAX_CONNECTIONS=600 +MAX_CONNECTIONS=1000 TIMEOUT = 30 # Security Settings @@ -14,4 +14,4 @@ LOG_LEVEL = INFO LOG_FILE = /var/log/server.log # Other Settings -ENABLE_FEATURE_X = true \ No newline at end of file +ENABLE_FEATURE_X = true diff --git a/Day-12/test.py b/Day-12/test.py new file mode 100644 index 00000000..6e02bde8 --- /dev/null +++ b/Day-12/test.py @@ -0,0 +1,42 @@ +def update_server_config(file_path, key, value): + + with open(file_path, "r") as file: + lines = file.readline() + + with open(file_path, "w") as file: + for line in lines: + if key in line: + file.write(key + "=" + value +"\n") + else: + file.write(line) + + +def update_server_config(file_path, key, value): + # Read the existing content of the server configuration file + with open(file_path, 'r') as file: + lines = file.readlines() + + # Update the configuration value for the specified key + with open(file_path, 'w') as file: + for line in lines: + # Check if the line starts with the specified key + if key in line: + # Update the line with the new value + file.write(key + "=" + value + "\n") + else: + # Keep the existing line as it is + file.write(line) + +# Path to the server configuration file +server_config_file = 'server.conf' + +# Key and new value for updating the server configuration +key_to_update = 'MAX_CONNECTIONS' +new_value = '1000' # New maximum connections allowed + +# Update the server configuration file +update_server_config(server_config_file, key_to_update, new_value) + + + + \ No newline at end of file diff --git a/Day-12/update_server.py b/Day-12/update_server.py index 65677891..1c55b9bc 100644 --- a/Day-12/update_server.py +++ b/Day-12/update_server.py @@ -19,7 +19,7 @@ def update_server_config(file_path, key, value): # Key and new value for updating the server configuration key_to_update = 'MAX_CONNECTIONS' -new_value = '600' # New maximum connections allowed +new_value = '1000' # New maximum connections allowed # Update the server configuration file update_server_config(server_config_file, key_to_update, new_value) diff --git a/Day-14/examples/create-jira.py b/Day-14/examples/create-jira.py index e9618ad0..a185f81c 100644 --- a/Day-14/examples/create-jira.py +++ b/Day-14/examples/create-jira.py @@ -8,7 +8,7 @@ API_TOKEN = "" -auth = HTTPBasicAuth("", API_TOKEN) +auth = HTTPBasicAuth("@gmail.com", API_TOKEN) headers = { "Accept": "application/json", diff --git a/Day-14/examples/create_jira_tick_hima.py b/Day-14/examples/create_jira_tick_hima.py new file mode 100644 index 00000000..3610e054 --- /dev/null +++ b/Day-14/examples/create_jira_tick_hima.py @@ -0,0 +1,62 @@ + +# This code sample uses the 'requests' library: +# http://docs.python-requests.org +import requests +from requests.auth import HTTPBasicAuth +import json + +url = "https://himamounikag.atlassian.net/rest/api/3/issue" + +API_TOKEN="ATATT3xFfGF0wgrCabZu1d7RG5g9uJ-38GYyM2sVOlxVcfLqRMVoJXl_s6KMa1F8BVFQbbT7Im3oS0AI5gqdrC6p61rWhP4fI0-4teC4XFQfH8n4CcsOcWupRhnrY9Hmn_A-nZmeKutgDEOqUPs26Kitl_GXEbZ4dVWnyyVUr2YcQ0tyJVg0igQ=550C5A06" + +auth = HTTPBasicAuth("tech2hima@gmail.com", API_TOKEN) + +headers = { + "Accept": "application/json", + "Content-Type": "application/json" +} + +payload = json.dumps( { + "fields": { + + + "description": { + "content": [ + { + "content": [ + { + "text": "My first jira ticket", + "type": "text" + } + ], + "type": "paragraph" + } + ], + "type": "doc", + "version": 1 + }, + + + "issuetype": { + "id": "10001" + }, + + "project": { + "key": "HG" + }, + + + "summary": "My first jira ticket", + }, + "update": {} +} ) + +response = requests.request( + "POST", + url, + data=payload, + headers=headers, + auth=auth +) + +print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))) \ No newline at end of file diff --git a/Day-14/list-projects-hima.py b/Day-14/list-projects-hima.py new file mode 100644 index 00000000..dd6bdb67 --- /dev/null +++ b/Day-14/list-projects-hima.py @@ -0,0 +1,27 @@ +# This code sample uses the 'requests' library: +# http://docs.python-requests.org +import requests +from requests.auth import HTTPBasicAuth +import json + +url = "https://himamounikag.atlassian.net/rest/api/3/project" + +API_TOKEN="ATATT3xFfGF0wgrCabZu1d7RG5g9uJ-38GYyM2sVOlxVcfLqRMVoJXl_s6KMa1F8BVFQbbT7Im3oS0AI5gqdrC6p61rWhP4fI0-4teC4XFQfH8n4CcsOcWupRhnrY9Hmn_A-nZmeKutgDEOqUPs26Kitl_GXEbZ4dVWnyyVUr2YcQ0tyJVg0igQ=550C5A06" + +auth = HTTPBasicAuth("tech2hima@gmail.com", API_TOKEN) + +headers = { + "Accept": "application/json" +} + +response = requests.request( + "GET", + url, + headers=headers, + auth=auth +) + +output = json.loads(response.text) +name = output[0]["name"] + +print(name) \ No newline at end of file diff --git a/Day-15/github-jira.py b/Day-15/github-jira.py index c5003813..9f5e7a1b 100644 --- a/Day-15/github-jira.py +++ b/Day-15/github-jira.py @@ -11,12 +11,11 @@ @app.route('/createJira', methods=['POST']) def createJira(): - url = "https://veeramallaabhishek.atlassian.net/rest/api/3/issue" + url = "https://himamounikag.atlassian.net/rest/api/3/issue" - API_TOKEN="" - - auth = HTTPBasicAuth("", API_TOKEN) + API_TOKEN="ATATT3xFfGF0wgrCabZu1d7RG5g9uJ-38GYyM2sVOlxVcfLqRMVoJXl_s6KMa1F8BVFQbbT7Im3oS0AI5gqdrC6p61rWhP4fI0-4teC4XFQfH8n4CcsOcWupRhnrY9Hmn_A-nZmeKutgDEOqUPs26Kitl_GXEbZ4dVWnyyVUr2YcQ0tyJVg0igQ=550C5A06" + auth = HTTPBasicAuth("tech2hima@gmail.com", API_TOKEN) headers = { "Accept": "application/json", "Content-Type": "application/json" diff --git a/Day-15/sample-flask-ex.py b/Day-15/sample-flask-ex.py new file mode 100644 index 00000000..ece2f7af --- /dev/null +++ b/Day-15/sample-flask-ex.py @@ -0,0 +1,11 @@ +from flask import Flask + + +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'Hello, World!' + +if __name__ == '__main__': + app.run("0.0.0.0") \ No newline at end of file diff --git a/README.md b/README.md index 0dc09cb5..e5cf600a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # Python Zero to Hero for DevOps Engineers - Screenshot 2023-10-12 at 9 57 40 PM ## Day 1: Introduction to Python, Installation, and Configuration @@ -57,8 +56,7 @@ - Example: Automating a log file analysis with a loop to find errors. ## Day 10: Working with Lists (Part 2) -- List comprehensions. -- Nested lists and advanced list operations. +- Advanced list operations. - Practice exercises and examples: - Example: Print list of files in the list of folders provided @@ -79,7 +77,7 @@ - AWS automation with Boto3. - Managing EC2 instances, S3 buckets, and more. - Practice exercises and examples: - - Example: Creating a aws script for deploying applications to remote servers. + - Example: Creating a python script using boto3 to implement serverless functions. ## Day 14: Github-JIRA intergration Project - (Project-4) - Introduction to RESTful APIs.