Yuvipanda has uploaded a new change for review.
https://gerrit.wikimedia.org/r/202293
Change subject: Introduce Tool objects
......................................................................
Introduce Tool objects
Fully encapsulate a valid tool
Change-Id: Ia6fd5fcfa606f759f0c152e5e02a8834430a0fc2
---
M destiny/collector.py
M destiny/manifest.py
A destiny/tool.py
3 files changed, 26 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/software/tools-manifest
refs/changes/93/202293/1
diff --git a/destiny/collector.py b/destiny/collector.py
index e981818..3508819 100644
--- a/destiny/collector.py
+++ b/destiny/collector.py
@@ -8,6 +8,7 @@
from .manifest import Manifest
+from .tool import Tool
class ManifestCollector(object):
@@ -63,7 +64,8 @@
continue
with open(manifest_file) as f:
- manifest = Manifest(toolname, yaml.safe_load(f))
+ tool = Tool.from_name(toolname)
+ manifest = Manifest(tool, yaml.safe_load(f))
manifests.append(manifest)
self.manifests = manifests
self.log.info("Collected %s manifests", len(self.manifests))
diff --git a/destiny/manifest.py b/destiny/manifest.py
index e8a8789..1a2c9e4 100644
--- a/destiny/manifest.py
+++ b/destiny/manifest.py
@@ -8,13 +8,13 @@
class InvalidManifestException(Exception):
pass
- def __init__(self, toolname, data):
+ def __init__(self, tool, data):
"""
Constructs a manifest object from manifest data.
It will ignore extra keys, but throw exceptions on invalid values.
- :param toolname: str Name of tool for which this is the manifest
+ :param tool: tools.Tool Tool object representing the tool this is a
manifest for
:param data: dict containing manifest structure. Currently supported
keys are:
web: Type of webservice to run for this tool. Currently
supported
values are lighttpd, lighttpd-precise, nodejs,
uwsgi-python, tomcat
@@ -22,7 +22,7 @@
if data is None:
data = {} # Handle empty service manifests
self.data = data
- self.toolname = toolname
+ self.tool = tool
if 'web' in data and data['web'] not in Manifest.WEBSERVICE_TYPES:
raise Manifest.InvalidManifestException('webservice type should be
one of %s', Manifest.WEBSERVICE_TYPES)
diff --git a/destiny/tool.py b/destiny/tool.py
new file mode 100644
index 0000000..635cc06
--- /dev/null
+++ b/destiny/tool.py
@@ -0,0 +1,20 @@
+import pwd
+
+
+class Tool(object):
+ USER_NAME_PATTERN = 'tools.%s'
+
+ def __init__(self, name, username, uid, home):
+ self.name = name
+ self.uid = uid
+ self.username = username
+ self.home = home
+
+ @classmethod
+ def from_name(cls, name):
+ """
+ Create a Tool instance from a tool name
+ """
+ username = Tool.USER_NAME_PATTERN % (name, )
+ user_info = pwd.getpwnam(username)
+ return cls(name, user_info.pw_name, user_info.pw_uid, user_info.pw_dir)
--
To view, visit https://gerrit.wikimedia.org/r/202293
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6fd5fcfa606f759f0c152e5e02a8834430a0fc2
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/tools-manifest
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits