Deb package creation for NG-SA

Change-Id: I96bb72bfd77e0c57215ba62abdbdaf8df5bb8cde
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/.gitignore b/.gitignore
index 4f7530f..fb6947e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,4 @@
 *.local
 local
 
+src/osm_ngsa/_version.py
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..fc5b284
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,20 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
+
+include src/osm_ngsa/requirements.txt
+include src/osm_ngsa/README.rst
+
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..817570a
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,24 @@
+..
+  #######################################################################################
+  # Copyright ETSI Contributors and Others.
+  #
+  # 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.
+  #######################################################################################
+
+===========
+osm-ngsa
+===========
+
+osm-ngsa is the new Service Assurance Python library for OSM. It includes the different Airflow DAGs used for specific monitoring and alerting stages, as well as common libraries used by those DAGs to interact with VIM.
+
diff --git a/devops-stages/stage-archive.sh b/devops-stages/stage-archive.sh
index 7c88360..e70b172 100755
--- a/devops-stages/stage-archive.sh
+++ b/devops-stages/stage-archive.sh
@@ -16,4 +16,13 @@
 # limitations under the License.
 #
 
-echo "Nothing to be done"
+MDG=NG-SA
+rm -rf pool
+rm -rf dists
+mkdir -p pool/$MDG
+mv 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
+echo "dists/**,pool/$MDG/*.deb"
+
diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh
index 7c88360..7b483a8 100755
--- a/devops-stages/stage-build.sh
+++ b/devops-stages/stage-build.sh
@@ -16,4 +16,6 @@
 # limitations under the License.
 #
 
-echo "Nothing to be done"
+rm -rf dist deb_dist osm*.tar.gz *.egg-info .eggs
+
+tox -e dist
diff --git a/requirements-dev.txt b/requirements-dev.txt
index c848d9e..3d50187 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -175,7 +175,7 @@
     #   flask-babel
     #   python-nvd3
     #   swagger-ui-bundle
-jsonschema==4.17.0
+jsonschema==4.17.1
     # via
     #   apache-airflow
     #   connexion
diff --git a/requirements-dist.in b/requirements-dist.in
new file mode 100644
index 0000000..03ff6e9
--- /dev/null
+++ b/requirements-dist.in
@@ -0,0 +1,18 @@
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+
+stdeb
+setuptools-scm
+setuptools<60
diff --git a/requirements-dist.txt b/requirements-dist.txt
new file mode 100644
index 0000000..52c8aa0
--- /dev/null
+++ b/requirements-dist.txt
@@ -0,0 +1,34 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
+packaging==21.3
+    # via setuptools-scm
+pyparsing==3.0.9
+    # via packaging
+setuptools-scm==7.0.5
+    # via -r requirements-dist.in
+stdeb==0.10.0
+    # via -r requirements-dist.in
+tomli==2.0.1
+    # via setuptools-scm
+typing-extensions==4.4.0
+    # via setuptools-scm
+
+# The following packages are considered to be unsafe in a requirements file:
+setuptools==59.8.0
+    # via
+    #   -r requirements-dist.in
+    #   setuptools-scm
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..844bb93
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+#
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+
+import os
+from setuptools import setup, find_packages, find_namespace_packages
+
+_name = "osm_ngsa"
+_description = "OSM Service Assurance Airflow DAGs and libraries"
+with open(os.path.join(".", "README.rst")) as readme_file:
+    README = readme_file.read()
+
+setup(
+    name=_name,
+    description=_description,
+    long_description=README,
+    use_scm_version={
+        "write_to": "src/osm_ngsa/_version.py"
+    },
+    author="ETSI OSM",
+    author_email="osmsupport@etsi.org",
+    maintainer="ETSI OSM",
+    maintainer_email="osmsupport@etsi.org",
+    url="https://osm.etsi.org/gitweb/?p=osm/NG-SA.git;a=summary",
+    license="Apache 2.0",
+    package_dir={"": "src"},
+    packages=find_namespace_packages(where='src'),
+    include_package_data=True,
+    setup_requires=["setuptools-scm"],
+)
+
diff --git a/src/osm_mon/__init__.py b/src/osm_ngsa/__init__.py
similarity index 100%
copy from src/osm_mon/__init__.py
copy to src/osm_ngsa/__init__.py
diff --git a/src/dags/.airflowignore b/src/osm_ngsa/dags/.airflowignore
similarity index 100%
rename from src/dags/.airflowignore
rename to src/osm_ngsa/dags/.airflowignore
diff --git a/src/dags/__init__.py b/src/osm_ngsa/dags/__init__.py
similarity index 100%
rename from src/dags/__init__.py
rename to src/osm_ngsa/dags/__init__.py
diff --git a/src/dags/multivim_vim_status.py b/src/osm_ngsa/dags/multivim_vim_status.py
similarity index 100%
rename from src/dags/multivim_vim_status.py
rename to src/osm_ngsa/dags/multivim_vim_status.py
diff --git a/src/dags/multivim_vm_status.py b/src/osm_ngsa/dags/multivim_vm_status.py
similarity index 100%
rename from src/dags/multivim_vm_status.py
rename to src/osm_ngsa/dags/multivim_vm_status.py
diff --git a/src/dags/ns_topology.py b/src/osm_ngsa/dags/ns_topology.py
similarity index 100%
rename from src/dags/ns_topology.py
rename to src/osm_ngsa/dags/ns_topology.py
diff --git a/src/osm_mon/__init__.py b/src/osm_ngsa/osm_mon/__init__.py
similarity index 100%
rename from src/osm_mon/__init__.py
rename to src/osm_ngsa/osm_mon/__init__.py
diff --git a/src/osm_mon/core/__init__.py b/src/osm_ngsa/osm_mon/core/__init__.py
similarity index 100%
rename from src/osm_mon/core/__init__.py
rename to src/osm_ngsa/osm_mon/core/__init__.py
diff --git a/src/osm_mon/core/common_db.py b/src/osm_ngsa/osm_mon/core/common_db.py
similarity index 100%
rename from src/osm_mon/core/common_db.py
rename to src/osm_ngsa/osm_mon/core/common_db.py
diff --git a/src/osm_mon/core/config.py b/src/osm_ngsa/osm_mon/core/config.py
similarity index 100%
rename from src/osm_mon/core/config.py
rename to src/osm_ngsa/osm_mon/core/config.py
diff --git a/src/osm_mon/core/config.yaml b/src/osm_ngsa/osm_mon/core/config.yaml
similarity index 100%
rename from src/osm_mon/core/config.yaml
rename to src/osm_ngsa/osm_mon/core/config.yaml
diff --git a/src/osm_mon/vim_connectors/__init__.py b/src/osm_ngsa/osm_mon/vim_connectors/__init__.py
similarity index 100%
rename from src/osm_mon/vim_connectors/__init__.py
rename to src/osm_ngsa/osm_mon/vim_connectors/__init__.py
diff --git a/src/osm_mon/vim_connectors/azure.py b/src/osm_ngsa/osm_mon/vim_connectors/azure.py
similarity index 100%
rename from src/osm_mon/vim_connectors/azure.py
rename to src/osm_ngsa/osm_mon/vim_connectors/azure.py
diff --git a/src/osm_mon/vim_connectors/base_vim.py b/src/osm_ngsa/osm_mon/vim_connectors/base_vim.py
similarity index 100%
rename from src/osm_mon/vim_connectors/base_vim.py
rename to src/osm_ngsa/osm_mon/vim_connectors/base_vim.py
diff --git a/src/osm_mon/vim_connectors/gcp.py b/src/osm_ngsa/osm_mon/vim_connectors/gcp.py
similarity index 100%
rename from src/osm_mon/vim_connectors/gcp.py
rename to src/osm_ngsa/osm_mon/vim_connectors/gcp.py
diff --git a/src/osm_mon/vim_connectors/openstack.py b/src/osm_ngsa/osm_mon/vim_connectors/openstack.py
similarity index 100%
rename from src/osm_mon/vim_connectors/openstack.py
rename to src/osm_ngsa/osm_mon/vim_connectors/openstack.py
diff --git a/tox.ini b/tox.ini
index 7247cf3..4a9dcbf 100644
--- a/tox.ini
+++ b/tox.ini
@@ -104,6 +104,23 @@
 
 
 #######################################################################################
+[testenv:dist]
+deps =  {[testenv]deps}
+        -r{toxinidir}/requirements-dist.txt
+
+# In the commands, we copy the requirements.txt to be presented as a source file (.py)
+# so it gets included in the .deb package for others to consume
+commands =
+        sh -c 'cp requirements.txt src/osm_ngsa/requirements.txt'
+        sh -c 'cp README.rst src/osm_ngsa/README.rst'
+        python3 setup.py --command-packages=stdeb.command sdist_dsc
+        sh -c 'cd deb_dist/osm-ngsa*/ && dpkg-buildpackage -rfakeroot -uc -us'
+        sh -c 'rm src/osm_ngsa/requirements.txt'
+        sh -c 'rm src/osm_ngsa/README.rst'
+whitelist_externals = sh
+
+
+#######################################################################################
 [flake8]
 ignore =
         W291,