Adds pip installation of python deps in deb package install 41/6541/25
authorBenjamin Diaz <bdiaz@whitestack.com>
Wed, 26 Sep 2018 23:12:58 +0000 (20:12 -0300)
committerBenjamin Diaz <bdiaz@whitestack.com>
Thu, 27 Sep 2018 21:02:33 +0000 (18:02 -0300)
Adds postinst script
Adds Makefile (there is an issue when using postinst with tox)
Adds stdeb.cfg declaring binary dependencies
Reenables flake8 in tox
Removes consumer timeout that should have never been there
Readds group_id in kafka consumer

Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
Change-Id: Ied0cb6135aee5f08cfd36c9cbaafa4c174b7434f

.gitignore
Dockerfile
MANIFEST.in
Makefile [new file with mode: 0644]
debian/python3-osm-policy-module.postinst [new file with mode: 0644]
devops-stages/stage-build.sh
osm_policy_module/core/agent.py
stdeb.cfg [new file with mode: 0644]
tox.ini

index f4d6bb1..88962fe 100644 (file)
@@ -76,3 +76,7 @@ ChangeLog
 .settings/
 __pycache__/
 .idea
+
+deb_dist
+*.tar.gz
+*.db
\ No newline at end of file
index 6738633..f3af477 100644 (file)
@@ -22,7 +22,7 @@
 
 FROM ubuntu:16.04
 RUN  apt-get update && \
-  DEBIAN_FRONTEND=noninteractive apt-get --yes install git tox make python python-pip python3 python3-pip debhelper && \
-  DEBIAN_FRONTEND=noninteractive apt-get --yes install wget python-dev python-software-properties python-stdeb && \
-  DEBIAN_FRONTEND=noninteractive apt-get --yes install default-jre libmysqlclient-dev && \
-  DEBIAN_FRONTEND=noninteractive apt-get --yes install libmysqlclient-dev libxml2 python3-all
+  DEBIAN_FRONTEND=noninteractive apt-get --yes install git tox make python-all python3 python3-pip debhelper wget && \
+  DEBIAN_FRONTEND=noninteractive apt-get --yes install libmysqlclient-dev libxml2 python3-all && \
+  DEBIAN_FRONTEND=noninteractive pip3 install -U setuptools setuptools-version-command stdeb
+
index ad2c95a..9dbb8cd 100644 (file)
@@ -24,5 +24,4 @@ include requirements.txt
 include test-requirements.txt
 include README.rst
 recursive-include osm_policy_module *.py *.xml *.sh
-recursive-include devops-stages *
-recursive-include test *.py
+recursive-include devops-stages *
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..586b73c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+all: clean package
+
+clean:
+       rm -rf dist deb_dist osm_policy_module-*.tar.gz osm_policy_module.egg-info .eggs
+
+package:
+       python3 setup.py --command-packages=stdeb.command sdist_dsc
+       cp debian/python3-osm-policy-module.postinst deb_dist/osm-policy-module*/debian
+       cd deb_dist/osm-policy-module*/  && dpkg-buildpackage -rfakeroot -uc -us
\ No newline at end of file
diff --git a/debian/python3-osm-policy-module.postinst b/debian/python3-osm-policy-module.postinst
new file mode 100644 (file)
index 0000000..3b24842
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+echo "Installing python dependencies via pip..."
+pip3 install kafka==1.3.*
+pip3 install peewee==3.1.*
+pip3 install jsonschema==2.6.*
+pip3 install six==1.11.*
+pip3 install pyyaml==3.*
+echo "Installation of python dependencies finished"
\ No newline at end of file
index 4251b1c..8a8d332 100755 (executable)
@@ -23,7 +23,4 @@
 #__date__   = "14/Sep/2017"
 
 #!/bin/bash
-rm -rf deb_dist
-rm -rf dist
-rm -rf osm_mon.egg-info
-tox -e build
+make
index 8309da1..410413f 100644 (file)
@@ -51,13 +51,10 @@ class PolicyModuleAgent:
                                            cfg.OSMPOL_MESSAGE_PORT)
 
     def run(self):
-        cfg = Config.instance()
-        cfg.read_environ()
-
         consumer = KafkaConsumer(bootstrap_servers=self.kafka_server,
                                  key_deserializer=bytes.decode,
                                  value_deserializer=bytes.decode,
-                                 consumer_timeout_ms=10000)
+                                 group_id='pol-consumer')
         consumer.subscribe(["ns", "alarm_response"])
 
         for message in consumer:
diff --git a/stdeb.cfg b/stdeb.cfg
new file mode 100644 (file)
index 0000000..021202c
--- /dev/null
+++ b/stdeb.cfg
@@ -0,0 +1,3 @@
+[DEFAULT]
+X-Python3-Version : >= 3.4
+Depends3 : libmysqlclient-dev, python3-pip, python3-osm-common
\ No newline at end of file
diff --git a/tox.ini b/tox.ini
index 4ef6a64..584efa7 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -25,7 +25,7 @@
 # test suite on all supported python versions. To use it, "pip install tox"
 # and then run "tox" from this directory.
 [tox]
-envlist = py3
+envlist = py3, flake8
 toxworkdir={homedir}/.tox
 
 [testenv]
@@ -40,12 +40,6 @@ deps = flake8
 commands =
     flake8 osm_policy_module
 
-[testenv:build]
-basepython = python3
-deps = stdeb
-       setuptools-version-command
-commands = python3 setup.py --command-packages=stdeb.command bdist_deb
-
 [flake8]
 # E123, E125 skipped as they are invalid PEP-8.
 max-line-length = 120
@@ -54,4 +48,8 @@ ignore = E123,E125,E241
 builtins = _
 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,devops_stages/*,.rst
 
-
+[testenv:build]
+basepython = python3
+deps = stdeb
+       setuptools-version-command
+commands = python3 setup.py --command-packages=stdeb.command bdist_deb