From a3af2bfb68cd69751d81f4570eb2c5256540becf Mon Sep 17 00:00:00 2001 From: FisehaTessema4 <60725293+FisehaTessema4@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:09:35 -0800 Subject: [PATCH 1/4] Update Server.py --- Server.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Server.py b/Server.py index cb8697c..6657a37 100644 --- a/Server.py +++ b/Server.py @@ -1,10 +1,36 @@ + +import os class Server: """ Server class for representing and manipulating servers. """ def __init__(self, server_ip): # TODO - self.server_ip = server_ip + self.ping() def ping(self): # TODO - Use os module to ping the server - return \ No newline at end of file + # TODO - Use os module to ping the server + + print("The Server IP is", self.server_ip) + #Get the location from where the Python script is run + filepath = os.path.dirname(os.path.abspath(__file__)) + #Set the working directory to the path where the python source code is + os.chdir(filepath) + #pingresult = os.path.join(filepath,"pingResults__.txt") + #Create a text file Name to store the Ping results + pingresult = "pingResults__.txt" + pingText = 'ping ' + (self.server_ip) + ' > ' + pingresult + print("Command sent to the OS system for the ping is: ", pingText) + response = os.system(pingText) + #A response of 0 is returned for a sucessfull server response + f = open(pingresult, "r") + if (response == 0): + print("Ping Successfull for the server", self.server_ip) + print(f.read()) + else: + print("Check the server - Unsuccessfull ping response for ", self.server_ip) + print(f.read()) + + + From 5597e530c2ff8212d189a3e759e3af775d971819 Mon Sep 17 00:00:00 2001 From: FisehaTessema4 <60725293+FisehaTessema4@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:17:00 -0800 Subject: [PATCH 2/4] Added lines of code Added some lines of code to make it work --- Server.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Server.py b/Server.py index 6657a37..3fc90da 100644 --- a/Server.py +++ b/Server.py @@ -31,6 +31,8 @@ def ping(self): else: print("Check the server - Unsuccessfull ping response for ", self.server_ip) print(f.read()) + + return From 218b64a96999ae76f59f31aa8671b78925e6a122 Mon Sep 17 00:00:00 2001 From: FisehaTessema4 <60725293+FisehaTessema4@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:20:10 -0800 Subject: [PATCH 3/4] Added some lines of code Updated the code --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 2fb474f..bd8f41f 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,15 @@ # This is the template code for the CNA337 Final Project # Zachary Rubin, zrubin@rtc.edu # CNA 337 Fall 2020 - +import Server def print_program_info(): # TODO - Change your name - print("Server Automator v0.1 by Your Name") + print("Fiseha Tessema") # This is the entry point to our program if __name__ == '__main__': print_program_info() # TODO - Create a Server object - # TODO - Call Ping method and print the results \ No newline at end of file + # TODO - Call Ping method and print the results + #The IP address is passed as a string to the Server class in the server.py module + ec2Server = Server.Server("52.41.99.1") From afb57cd9ba1f57dadc0550e6c0db879075b7fa88 Mon Sep 17 00:00:00 2001 From: FisehaTessema4 <60725293+FisehaTessema4@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:26:10 -0800 Subject: [PATCH 4/4] Delete Server.py --- Server.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 Server.py diff --git a/Server.py b/Server.py deleted file mode 100644 index 3fc90da..0000000 --- a/Server.py +++ /dev/null @@ -1,38 +0,0 @@ - -import os -class Server: - """ Server class for representing and manipulating servers. """ - - def __init__(self, server_ip): - # TODO - - self.server_ip = server_ip - self.ping() - - def ping(self): - # TODO - Use os module to ping the server - # TODO - Use os module to ping the server - - print("The Server IP is", self.server_ip) - #Get the location from where the Python script is run - filepath = os.path.dirname(os.path.abspath(__file__)) - #Set the working directory to the path where the python source code is - os.chdir(filepath) - #pingresult = os.path.join(filepath,"pingResults__.txt") - #Create a text file Name to store the Ping results - pingresult = "pingResults__.txt" - pingText = 'ping ' + (self.server_ip) + ' > ' + pingresult - print("Command sent to the OS system for the ping is: ", pingText) - response = os.system(pingText) - #A response of 0 is returned for a sucessfull server response - f = open(pingresult, "r") - if (response == 0): - print("Ping Successfull for the server", self.server_ip) - print(f.read()) - else: - print("Check the server - Unsuccessfull ping response for ", self.server_ip) - print(f.read()) - - return - - -