Yuvipanda has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/181773

Change subject: Minor cleanup
......................................................................

Minor cleanup

- Fix comments
- Remove all references to wikitech

Change-Id: I101a8bb8d512a7da165f5fab0c83e4d2d3fae3ad
---
M shingen/generators/generator.py
D shingen/wikitech.py
D tests/WikitechTests.py
3 files changed, 2 insertions(+), 70 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/software/shinkengen 
refs/changes/73/181773/1

diff --git a/shingen/generators/generator.py b/shingen/generators/generator.py
index c9f8384..3890b3a 100644
--- a/shingen/generators/generator.py
+++ b/shingen/generators/generator.py
@@ -2,9 +2,8 @@
 Generator script that generates hosts and service configuration.
 
 1. Checks config to figure out which projects to monitor
-2. Fetches instance information from wikitech
-3. Runs the instance info through a series of functions, which generate
-   config objects for shinken
+2. Fetches instance information from ldap
+3. Generates hosts info and hostgroups info for the instances
 """
 from ..ldapsource import LDAPSource
 
diff --git a/shingen/wikitech.py b/shingen/wikitech.py
deleted file mode 100644
index d2cc3ae..0000000
--- a/shingen/wikitech.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from urllib.request import urlopen
-import json
-import codecs
-
-
-class Wikitech():
-    '''
-    Represents a wikitech instance against which we can perform API queries
-    '''
-    def __init__(self):
-        self.api_url = 'https://wikitech.wikimedia.org/w/api.php'
-
-    def _fetch_json(self, url):
-        '''
-        Helper function to fetch JSON from a given URL
-
-        :param url: URL to fetch. Must return JSON data in utf-8
-        :return: The returned JSON parsed into appropriate python structures
-        '''
-        reader = codecs.getreader('utf-8')
-        data = json.load(reader(urlopen(url)))
-        return data
-
-    def fetch_projects(self):
-        '''
-        Fetch all projects defined in Wikitech
-
-        :return: List of project names defined in Wikitech
-        '''
-        url = '%s?action=query&list=novaprojects&format=json' % self.api_url
-        data = self._fetch_json(url)
-        return data['query']['novaprojects']
-
-    def fetch_instances(self, project, region):
-        '''
-        Fetch all instances for a particular project in a particular region
-
-        :param project: Name of project to fetch instances for
-        :param region: Region to fetch instances of the project for. Eg. 
eqiad, codfw
-        :return: A list of dicts containing instance info
-        '''
-        url = 
'%s?action=query&list=novainstances&niproject=%s&niregion=%s&format=json' % (
-            self.api_url, project, region
-        )
-        data = self._fetch_json(url)
-        return data['query']['novainstances']
diff --git a/tests/WikitechTests.py b/tests/WikitechTests.py
deleted file mode 100644
index d2c527b..0000000
--- a/tests/WikitechTests.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import unittest
-from shingen.wikitech import Wikitech
-
-
-class WikitechTests(unittest.TestCase):
-
-    def setUp(self):
-        super().setUp()
-        self.wikitech = Wikitech()
-
-    def test_projects(self):
-        projects = self.wikitech.fetch_projects()
-        self.assertNotEqual(len(projects), 0)
-        self.assertIn('tools', projects)
-
-    def test_instances(self):
-        tools_instances = self.wikitech.fetch_instances('tools', 'eqiad')
-        self.assertNotEqual(len(tools_instances), 0)
-
-if __name__ == '__main__':
-    unittest.main()

-- 
To view, visit https://gerrit.wikimedia.org/r/181773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I101a8bb8d512a7da165f5fab0c83e4d2d3fae3ad
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/shinkengen
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to