Initial delivery of IM python package build 63/2063/1
authorMike Marchetti <mmarchetti@sandvine.com>
Fri, 4 Aug 2017 18:33:54 +0000 (14:33 -0400)
committerMike Marchetti <mmarchetti@sandvine.com>
Fri, 4 Aug 2017 18:33:54 +0000 (14:33 -0400)
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
devops-stages/stage-archive.sh [new file with mode: 0755]
devops-stages/stage-build.sh [new file with mode: 0755]
devops-stages/stage-test.sh [new file with mode: 0755]
setup.py [new file with mode: 0644]
tox.ini [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..5fecc9a
--- /dev/null
@@ -0,0 +1,11 @@
+build
+.eggs
+*.pyc
+deb_dist
+dist
+*egg-info
+*.gz
+osm_im
+pyangbind
+dists
+pool
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..c72183e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,55 @@
+# Copyright 2017 Sandvine
+# All Rights Reserved.
+# 
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+# 
+#         http://www.apache.org/licenses/LICENSE-2.0
+# 
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+# NOTE: pyang and pyangbind are required for build
+
+PYANG:= pyang
+PYBINDPLUGIN:=$(shell /usr/bin/env python -c \
+                   'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)')
+
+YANG_MODELS := vnfd nsd
+PYTHON_MODELS := $(addsuffix .py, $(YANG_MODELS))
+
+OUT_DIR := osm_im
+MODEL_DIR := models/yang
+RW_PB_EXT := build/yang/rw-pb-ext.yang
+Q?=@
+
+PYANG_OPTIONS := -Wnone
+
+all: $(PYTHON_MODELS) pyangbind
+       $(MAKE) package
+
+$(OUT_DIR):
+       $(Q)mkdir -p $(OUT_DIR)
+       $(Q)touch $(OUT_DIR)/__init__.py
+
+%.py: $(OUT_DIR) $(RW_PB_EXT)
+       $(Q)echo generating $@ from $*.yang
+       $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
+
+$(RW_PB_EXT):
+       $(Q)mkdir -p $$(dirname $@)
+       $(Q)wget -q https://raw.githubusercontent.com/RIFTIO/RIFT.ware/RIFT.ware-4.4.1/modules/core/util/yangtools/yang/rw-pb-ext.yang -O $@
+
+package:
+       tox -e build
+
+pyangbind:
+       git clone https://github.com/robshakir/pyangbind
+       cd pyangbind; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
+
+clean:
+       $(Q)rm -rf build deb deb_dist *.gz pyangbind $(OUT_DIR)
diff --git a/devops-stages/stage-archive.sh b/devops-stages/stage-archive.sh
new file mode 100755 (executable)
index 0000000..9640bac
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+MDG=IM
+
+rm -rf pool
+rm -rf dists
+mkdir -p pool/$MDG
+mv deb_dist/*.deb pool/$MDG/
+mv pyangbind/deb_dist/*.deb pool/$MDG/
+
+mkdir -p dists/unstable/$MDG/binary-amd64/
+apt-ftparchive packages pool/$MDG > dists/unstable/$MDG/binary-amd64/Packages
+gzip -9fk dists/unstable/$MDG/binary-amd64/Packages
diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh
new file mode 100755 (executable)
index 0000000..2c0c17f
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+make clean
+make
diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh
new file mode 100755 (executable)
index 0000000..1a24852
--- /dev/null
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..84a8b05
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,15 @@
+from setuptools import setup, find_packages
+
+setup(
+    name='osm_im',
+    version_command=('git describe --tags --long --dirty', 'pep440-git'),
+    author='Mike Marchetti',
+    author_email='mmarchetti@sandvine.com',
+    packages=find_packages(),
+    include_package_data=True,
+    install_requires=[
+        'pyangbind'
+    ],
+    setup_requires=['setuptools-version-command'],
+    test_suite='nose.collector',
+)
diff --git a/tox.ini b/tox.ini
new file mode 100644 (file)
index 0000000..4493390
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,20 @@
+[tox]
+envlist = py27,py3
+toxworkdir={homedir}/.tox
+
+[testenv]
+deps=nose
+     mock
+commands=nosetests
+
+[testenv:flake8]
+basepython = python
+deps = flake8
+commands =
+    flake8 setup.py
+
+[testenv:build]
+basepython = python
+deps = stdeb
+       setuptools-version-command
+commands = python setup.py --command-packages=stdeb.command bdist_deb