Mridubhatnagar has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/381296 )
Change subject: Explaination of what scripts/webservice does when a user runs
it as: webservice --backend kubernetes start webservice --backend kubernetes
stop Along with this the file contains line by line explaination of source code
present in scripts/webservice.
..
Explaination of what scripts/webservice does when a user runs it as:
webservice --backend kubernetes start
webservice --backend kubernetes stop
Along with this the file contains line by line explaination of
source code present in scripts/webservice.
Change-Id: I537663a2c92a725eccee4448d8f772f6fc619fb3
---
A Outreachy-task.mridub.txt
1 file changed, 259 insertions(+), 0 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/operations/software/tools-webservice
refs/changes/96/381296/1
diff --git a/Outreachy-task.mridub.txt b/Outreachy-task.mridub.txt
new file mode 100644
index 000..a9b05b2
--- /dev/null
+++ b/Outreachy-task.mridub.txt
@@ -0,0 +1,259 @@
+Microtask for Outreachy Round 15
+
+*Read over the source code and try to understand what scripts/webservice does
when a user runs it as:
+ -webservice --backend kubernetes start
+ -webservice --backend kubernetes stop
+
+
+Line 65 if __name__ == '__main__':
+ Signifies that file script/webservice must be run from the python
interpreter directly and must not be
+ imported.
+
+Line 66 log_command_invocation('webservice', ' '.join(sys.argv))
+Function call is made to log_command_invocation(commandname, commandline)
+commandname - 'webservice'
+commandline - ' '.join(sys.argv)
+
+tools-webservice/toollabs/common/el.py - file path where
log_command_invocation is defined.
+
+log_command_invocation(commandname, commandline)- in this method username
and hostname are setup.
+This queries the user by userid.
+
+a) os.getuid() - returns the userid.(Integer)
+b) pwd.getpwd(uid) - returns (pwd_name, pw_passwd, pw_uid, pw_gid,
pw_gecos, pw_dir, pw_shell)
+ password database entry for numeric user ID.
+ example:
+ pw_name='mridu'(username)
+ pw_passwd = 'X'
+ pw_uid = 1000
+ pw_gid = 1000
+ pw_gecos = 'Mridu,,,'
+ pw_dir = '/home/mridu'
+ pw_shell = '/bin/bash'
+
+ username = pwd.getpwuid(os.getuid()).pw_name # Sets username to mridu
+ hostname = socket.getfqdn() # returns a domain name for name. Incase
the name is empty, it is interpreted as localhost.
+ event variable is assigned a dictionary. Dictionary consists of keys
like username, commandname, commandline, hostname,
+ parentcommandline.
+
+ Once the command is invoked. Logging of events takes place. And method
log_event(schema, rev_id, wiki, event) is called.
+
+ schema - 'CommandInvocation'
+ rev_id - 15243810
+ wiki - 'metawiki'
+ event - event ( dictionary consisting of username,hostname,commandname,
commandline)
+ Events are sent to the client-side Event logging endpoint.
+
+ URL = 'https://meta.wikimedia.org/beacon/event'
+
+ A valid url is assigned to variable url.
+ a)url = "%s?%s" % (URL, urllib.quote_plus(json.dumps(payload)))
+ urllib.quote_plus(string, safe='') - Replaces ' '(space) with a '+'.
Example urllib.quote_plus(' connolly') would return '+connolly'.
+
+ b)urllib2.urlopen(url).read() # fetches the data present in the url.
fetched data is string.
+
+Line 67 args = argparser.parse_args()
+ Argument parser parses the arguments through parse_args(). The arguments
that are added to be parsed include
+ type - type of webservice to start.
+ backend - Which cluster backend to use run the webservice. Ex -
gridengine or kubernetes
+ action - Action to perform. Ex - start, stop, shell etc
+ extra_args- extra arguments are optional.
+ release -
+ Once the arguments are parsed. They can be accessed as args.type,
args.backend, args.action, args.release etc.
+
+Line 69 tool = Tool.from_currentuser()
+Creates a tools instance from the current running user.
+pwd_entry = pwd.getpwuid(os.geteuid())
+from_currentuser() method consists of details of the user. pwd_entry
will have (pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir,
+pw_shell)
+Example:
+pw_name='mridu'(username)
+pw_passwd = 'X'
+pw_uid = 1000
+pw_gid = 1000
+pw_gecos = 'Mridu,,,'
+pw_dir = '/home/mridu'
+pw_shell = '/bin/bash'
+This method returns Tool.from_pwd(pwd_entry). from_pwd(pwd_entry)
method gets called.
+
+a) from_pwd(pwd_entry)
+ Creates tool instance from a given pwd entry.
+ If pw_name does not start with Tools.PREFIX--->'tools.'. Invalid
tool exception will be raised. If userid is less than 50,000
+