Fix bug 1614 - fixing build to allow python3 -m build

Change-Id: Id2db32f81dd4f4e7b411ebc2a189f6817a26d63c
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
diff --git a/.gitignore b/.gitignore
index f1e4221..fc7eb3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+venv
+
+.tox
+
 *.pyc
 .cache
 
@@ -36,7 +40,10 @@
 osm_im/nsi.py
 osm_im/osm.yaml
 osm_im/etsi-nfv-nsd.py
+osm_im/etsi_nfv_nsd.py
 osm_im/etsi-nfv-vnfd.py
+osm_im/etsi_nfv_vnfd.py
+sol006_model
 
 #Pyang and other tools' folders
 pyangbind
diff --git a/MANIFEST.in b/MANIFEST.in
index a4fe252..93778db 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -12,5 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+include Makefile
 recursive-include osm_im *.py *.txt
-recursive-include models *.yang
\ No newline at end of file
+recursive-include models *.yang
+recursive-include patch *.patch
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 703f73c..e7e9978 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,7 @@
 all: models trees openapi_schemas
 	$(MAKE) package
 
-models: sol006_deps $(PYTHON_MODELS)
+models: sol006_deps $(PYTHON_MODELS) rename_etsi_nfv_py
 
 trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
 
@@ -89,7 +89,7 @@
 
 osm.yaml: yang-ietf yang2swagger
 	$(Q)echo generating $@
-	$(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/1.1.11/swagger-generator-cli-1.1.11-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@
+	$(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/1.1.14/swagger-generator-cli-1.1.14-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@
 
 yang-ietf:
 	$(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-yang-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-yang-types.yang
@@ -101,7 +101,7 @@
 	$(Q)mkdir -p ${HOME}/.m2
 	$(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml
 	git clone https://github.com/bartoszm/yang2swagger.git
-	git -C yang2swagger checkout tags/1.1.11
+	git -C yang2swagger checkout tags/1.1.14
 	mvn -f yang2swagger/pom.xml clean install
 
 package:
@@ -116,5 +116,11 @@
 	$(Q)patch -p2 < patch/deref_warnings.patch
 	$(Q)patch -p2 < patch/nested_workaround.patch
 
+rename_etsi_nfv_py:
+	mv osm_im/etsi-nfv-nsd.py osm_im/etsi_nfv_nsd.py
+	mv osm_im/etsi-nfv-vnfd.py osm_im/etsi_nfv_vnfd.py
+
 clean:
 	$(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR)
+	$(Q)rm -rf debian/osm-imdocs.install osm_im/etsi_nfv_nsd.py osm_im/etsi_nfv_vnfd.py osm_im/nsd.py
+	$(Q)rm -rf osm_im/nsi.py osm_im/nst.py osm_im/osm.yaml osm_im/vnfd.py
diff --git a/osm_im/validation.py b/osm_im/validation.py
index 6cc4f0d..561e716 100644
--- a/osm_im/validation.py
+++ b/osm_im/validation.py
@@ -18,8 +18,7 @@
 from osm_im.vnfd import vnfd as vnfd_im
 from osm_im.nsd import nsd as nsd_im
 from osm_im.nst import nst as nst_im
-etsi_nfv_vnfd = importlib.import_module("osm_im.etsi-nfv-vnfd")
-etsi_nfv_nsd = importlib.import_module("osm_im.etsi-nfv-nsd")
+from osm_im import etsi_nfv_vnfd, etsi_nfv_nsd
 from pyangbind.lib.serialise import pybindJSONDecoder
 import pyangbind.lib.pybindJSON as pybindJSON
 
diff --git a/setup.py b/setup.py
index 71c7eae..ec75988 100644
--- a/setup.py
+++ b/setup.py
@@ -35,11 +35,23 @@
         import pyangbind
         print("Using dir {}/{} for python artifacts".format(os.getcwd(), self.im_dir))
         path = "{}/{}".format(os.getcwd(), self.im_dir)
+
         protoc_command = ["make", "models"]
         if subprocess.call(protoc_command) != 0:
             sys.exit(-1)
+
         # To ensure generated files are copied to the python installation folder
-        self.copy_tree(self.im_dir, "{}{}".format(self.install_lib, self.im_dir))
+        install_path = "{}{}".format(self.install_lib, self.im_dir)
+        self.copy_tree(self.im_dir, install_path)
+        if os.path.isfile("{}/etsi-nfv-nsd.py".format(install_path)):
+            self.move_file(
+                "{}/etsi-nfv-nsd.py".format(install_path), "{}/etsi_nfv_nsd.py".format(install_path)
+            )
+        if os.path.isfile("{}/etsi-nfv-vnfd.py".format(install_path)):
+            self.move_file(
+                "{}/etsi-nfv-vnfd.py".format(install_path), "{}/etsi_nfv_vnfd.py".format(install_path)
+            )
+
         install.run(self)