Adding release notes and enabling import order check

Enabling Flake8 library import order check,
adding release_notes, enabling stage-test failing by tox results.

Change-Id: I490b4cb3fe5904f54d84f0ce9b41fe91ec8b4f5d
Signed-off-by: aticig <gulsum.atici@canonical.com>
diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh
index e5a8e85..8c684dd 100755
--- a/devops-stages/stage-test.sh
+++ b/devops-stages/stage-test.sh
@@ -12,6 +12,18 @@
 # implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
-OUTPUT=$(TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto)
-printf "$OUTPUT"
+set -e
+echo Launching tox
+tox --parallel=auto
+echo "Checking the presence of release notes ..."
+nb_rn=$(git diff --diff-filter=A --name-only HEAD~1 |grep "releasenotes\/notes" |wc -l)
+if [ "${nb_rn}" -lt 1 ]; then
+    echo "The commit needs release notes"
+    echo "Run the following command to generate release notes: tox -e release_notes '<release_note_title>'"
+    echo "Please read README.md for more details"
+    exit 1
+elif [ "${nb_rn}" -gt 1 ]; then
+    echo "Only one release notes file should be added in a commit"
+    exit 1
+fi
+echo "OK. Release notes present in commit"
diff --git a/osm_common/dbbase.py b/osm_common/dbbase.py
index 74378d0..4021805 100644
--- a/osm_common/dbbase.py
+++ b/osm_common/dbbase.py
@@ -15,16 +15,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import yaml
+from base64 import b64decode, b64encode
+from copy import deepcopy
+from http import HTTPStatus
 import logging
 import re
-from http import HTTPStatus
-from copy import deepcopy
-from Crypto.Cipher import AES
-from base64 import b64decode, b64encode
-from osm_common.common_utils import FakeLock
 from threading import Lock
 
+from Crypto.Cipher import AES
+from osm_common.common_utils import FakeLock
+import yaml
+
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
 
 
diff --git a/osm_common/dbmemory.py b/osm_common/dbmemory.py
index d089575..9f8c571 100644
--- a/osm_common/dbmemory.py
+++ b/osm_common/dbmemory.py
@@ -15,12 +15,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import logging
-from osm_common.dbbase import DbException, DbBase
-from osm_common.dbmongo import deep_update
-from http import HTTPStatus
-from uuid import uuid4
 from copy import deepcopy
+from http import HTTPStatus
+import logging
+from uuid import uuid4
+
+from osm_common.dbbase import DbBase, DbException
+from osm_common.dbmongo import deep_update
+
 
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
 
diff --git a/osm_common/dbmongo.py b/osm_common/dbmongo.py
index d8b373a..8561e96 100644
--- a/osm_common/dbmongo.py
+++ b/osm_common/dbmongo.py
@@ -16,15 +16,16 @@
 # limitations under the License.
 
 
-import logging
-from pymongo import MongoClient, errors
-from osm_common.dbbase import DbException, DbBase
-from http import HTTPStatus
-from time import time, sleep
-from copy import deepcopy
 from base64 import b64decode
+from copy import deepcopy
+from http import HTTPStatus
+import logging
+from time import sleep, time
 from uuid import uuid4
 
+from osm_common.dbbase import DbBase, DbException
+from pymongo import errors, MongoClient
+
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
 
 # TODO consider use this decorator for database access retries
diff --git a/osm_common/fsbase.py b/osm_common/fsbase.py
index 219dbe1..a03fb32 100644
--- a/osm_common/fsbase.py
+++ b/osm_common/fsbase.py
@@ -16,11 +16,13 @@
 # limitations under the License.
 
 
-import logging
 from http import HTTPStatus
-from osm_common.common_utils import FakeLock
+import logging
 from threading import Lock
 
+from osm_common.common_utils import FakeLock
+
+
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
 
 
diff --git a/osm_common/fslocal.py b/osm_common/fslocal.py
index ae22c6a..5bae0e9 100644
--- a/osm_common/fslocal.py
+++ b/osm_common/fslocal.py
@@ -15,14 +15,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from http import HTTPStatus
+import logging
 import os
+from shutil import rmtree
 import tarfile
 import zipfile
-import logging
 
-# import tarfile
-from http import HTTPStatus
-from shutil import rmtree
 from osm_common.fsbase import FsBase, FsException
 
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
diff --git a/osm_common/fsmongo.py b/osm_common/fsmongo.py
index d923842..1ce5909 100644
--- a/osm_common/fsmongo.py
+++ b/osm_common/fsmongo.py
@@ -15,17 +15,16 @@
 # For those usages not covered by the Apache License, Version 2.0 please
 # contact: eduardo.sousa@canonical.com
 ##
-
+import datetime
 import errno
 from http import HTTPStatus
 from io import BytesIO, StringIO
 import logging
 import os
-import datetime
 import tarfile
 import zipfile
 
-from gridfs import GridFSBucket, errors
+from gridfs import errors, GridFSBucket
 from osm_common.fsbase import FsBase, FsException
 from pymongo import MongoClient
 
diff --git a/osm_common/msgbase.py b/osm_common/msgbase.py
index 49adcb8..80c5be5 100644
--- a/osm_common/msgbase.py
+++ b/osm_common/msgbase.py
@@ -15,11 +15,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import logging
 from http import HTTPStatus
-from osm_common.common_utils import FakeLock
+import logging
 from threading import Lock
 
+from osm_common.common_utils import FakeLock
+
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
 
 
diff --git a/osm_common/msgkafka.py b/osm_common/msgkafka.py
index 5caa5b1..5487093 100644
--- a/osm_common/msgkafka.py
+++ b/osm_common/msgkafka.py
@@ -13,13 +13,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import logging
 import asyncio
-import yaml
+import logging
+
 from aiokafka import AIOKafkaConsumer
 from aiokafka import AIOKafkaProducer
 from aiokafka.errors import KafkaError
 from osm_common.msgbase import MsgBase, MsgException
+import yaml
 
 __author__ = (
     "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>, "
diff --git a/osm_common/msglocal.py b/osm_common/msglocal.py
index c10ff17..2f90307 100644
--- a/osm_common/msglocal.py
+++ b/osm_common/msglocal.py
@@ -15,16 +15,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import asyncio
+from http import HTTPStatus
 import logging
 import os
-import yaml
-import asyncio
-from osm_common.msgbase import MsgBase, MsgException
 from time import sleep
-from http import HTTPStatus
+
+from osm_common.msgbase import MsgBase, MsgException
+import yaml
 
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
-
 """
 This emulated kafka bus by just using a shared file system. Useful for testing or devops.
 One file is used per topic. Only one producer and one consumer is allowed per topic. Both consumer and producer
diff --git a/osm_common/sol004_package.py b/osm_common/sol004_package.py
index 813e52d..8a3cb95 100644
--- a/osm_common/sol004_package.py
+++ b/osm_common/sol004_package.py
@@ -55,9 +55,11 @@
                 └── charm.py
 """
 
-import yaml
 import datetime
 import os
+
+import yaml
+
 from .sol_package import SOLPackage
 
 
diff --git a/osm_common/sol007_package.py b/osm_common/sol007_package.py
index 4add8a9..ca14ce8 100644
--- a/osm_common/sol007_package.py
+++ b/osm_common/sol007_package.py
@@ -55,9 +55,11 @@
                 └── charm.py
 """
 
-import yaml
 import datetime
 import os
+
+import yaml
+
 from .sol_package import SOLPackage
 
 
diff --git a/osm_common/sol_package.py b/osm_common/sol_package.py
index e336cd5..8af52b9 100644
--- a/osm_common/sol_package.py
+++ b/osm_common/sol_package.py
@@ -21,10 +21,10 @@
 # For those usages not covered by the Apache License, Version 2.0 please
 # contact: fbravo@whitestack.com or agarcia@whitestack.com
 ##
-
-import os
-import yaml
 import hashlib
+import os
+
+import yaml
 
 
 class SOLPackageException(Exception):
diff --git a/osm_common/tests/packages/invalid_package_vnf/Scripts/charms/simple/src/charm.py b/osm_common/tests/packages/invalid_package_vnf/Scripts/charms/simple/src/charm.py
index 54cefc4..8607b1f 100755
--- a/osm_common/tests/packages/invalid_package_vnf/Scripts/charms/simple/src/charm.py
+++ b/osm_common/tests/packages/invalid_package_vnf/Scripts/charms/simple/src/charm.py
@@ -16,8 +16,8 @@
 # under the License.
 ##
 
-import sys
 import subprocess
+import sys
 
 from ops.charm import CharmBase
 from ops.main import main
diff --git a/osm_common/tests/packages/native_charm_with_metadata_dir_vnf/Scripts/charms/simple/src/charm.py b/osm_common/tests/packages/native_charm_with_metadata_dir_vnf/Scripts/charms/simple/src/charm.py
index 54cefc4..8607b1f 100755
--- a/osm_common/tests/packages/native_charm_with_metadata_dir_vnf/Scripts/charms/simple/src/charm.py
+++ b/osm_common/tests/packages/native_charm_with_metadata_dir_vnf/Scripts/charms/simple/src/charm.py
@@ -16,8 +16,8 @@
 # under the License.
 ##
 
-import sys
 import subprocess
+import sys
 
 from ops.charm import CharmBase
 from ops.main import main
diff --git a/osm_common/tests/packages/native_charm_without_metadata_dir_vnf/Scripts/charms/simple/src/charm.py b/osm_common/tests/packages/native_charm_without_metadata_dir_vnf/Scripts/charms/simple/src/charm.py
index 54cefc4..8607b1f 100755
--- a/osm_common/tests/packages/native_charm_without_metadata_dir_vnf/Scripts/charms/simple/src/charm.py
+++ b/osm_common/tests/packages/native_charm_without_metadata_dir_vnf/Scripts/charms/simple/src/charm.py
@@ -16,8 +16,8 @@
 # under the License.
 ##
 
-import sys
 import subprocess
+import sys
 
 from ops.charm import CharmBase
 from ops.main import main
diff --git a/osm_common/tests/test_dbbase.py b/osm_common/tests/test_dbbase.py
index 117350e..eabf5e0 100644
--- a/osm_common/tests/test_dbbase.py
+++ b/osm_common/tests/test_dbbase.py
@@ -18,11 +18,12 @@
 ##
 
 import http
-import pytest
-import unittest
-from osm_common.dbbase import DbBase, DbException, deep_update
-from os import urandom
 from http import HTTPStatus
+from os import urandom
+import unittest
+
+from osm_common.dbbase import DbBase, DbException, deep_update
+import pytest
 
 
 def exception_message(message):
@@ -124,10 +125,6 @@
         TEST = (
             ("plain text 1 ! ", None),
             ("plain text 2 with salt ! ", "1afd5d1a-4a7e-4d9c-8c65-251290183106"),
-            ("plain text 3 with usalt ! ", u"1afd5d1a-4a7e-4d9c-8c65-251290183106"),
-            (u"plain unicode 4 ! ", None),
-            (u"plain unicode 5 with salt ! ", "1a000d1a-4a7e-4d9c-8c65-251290183106"),
-            (u"plain unicode 6 with usalt ! ", u"1abcdd1a-4a7e-4d9c-8c65-251290183106"),
         )
         for db_base in self.db_bases:
             for value, salt in TEST:
diff --git a/osm_common/tests/test_dbmemory.py b/osm_common/tests/test_dbmemory.py
index 3c45527..9a0e749 100644
--- a/osm_common/tests/test_dbmemory.py
+++ b/osm_common/tests/test_dbmemory.py
@@ -16,17 +16,15 @@
 # For those usages not covered by the Apache License, Version 2.0 please
 # contact: esousa@whitestack.com or alfonso.tiernosepulveda@telefonica.com
 ##
-
+from copy import deepcopy
 import http
 import logging
-import pytest
 import unittest
-from unittest.mock import Mock
+from unittest.mock import MagicMock, Mock
 
-from unittest.mock import MagicMock
 from osm_common.dbbase import DbException
 from osm_common.dbmemory import DbMemory
-from copy import deepcopy
+import pytest
 
 __author__ = "Eduardo Sousa <eduardosousa@av.it.pt>"
 
diff --git a/osm_common/tests/test_fsbase.py b/osm_common/tests/test_fsbase.py
index 43349ad..cb5c560 100644
--- a/osm_common/tests/test_fsbase.py
+++ b/osm_common/tests/test_fsbase.py
@@ -18,9 +18,9 @@
 ##
 
 import http
-import pytest
 
 from osm_common.fsbase import FsBase, FsException
+import pytest
 
 
 def exception_message(message):
diff --git a/osm_common/tests/test_fslocal.py b/osm_common/tests/test_fslocal.py
index 6f52984..6336211 100644
--- a/osm_common/tests/test_fslocal.py
+++ b/osm_common/tests/test_fslocal.py
@@ -17,18 +17,18 @@
 # contact: esousa@whitestack.com or alfonso.tiernosepulveda@telefonica.com
 ##
 
+import http
 import io
 import logging
-import http
 import os
-import pytest
+import shutil
 import tarfile
 import tempfile
 import uuid
-import shutil
 
 from osm_common.fsbase import FsException
 from osm_common.fslocal import FsLocal
+import pytest
 
 __author__ = "Eduardo Sousa <eduardosousa@av.it.pt>"
 
diff --git a/osm_common/tests/test_fsmongo.py b/osm_common/tests/test_fsmongo.py
index da01ff3..01a8ef2 100644
--- a/osm_common/tests/test_fsmongo.py
+++ b/osm_common/tests/test_fsmongo.py
@@ -16,23 +16,20 @@
 # contact: eduardo.sousa@canonical.com
 ##
 
-import logging
-import pytest
-import tempfile
-import tarfile
-import os
-import subprocess
-
-from pymongo import MongoClient
-from gridfs import GridFSBucket
-
 from io import BytesIO
-
+import logging
+import os
+from pathlib import Path
+import subprocess
+import tarfile
+import tempfile
 from unittest.mock import Mock
 
+from gridfs import GridFSBucket
 from osm_common.fsbase import FsException
 from osm_common.fsmongo import FsMongo
-from pathlib import Path
+from pymongo import MongoClient
+import pytest
 
 __author__ = "Eduardo Sousa <eduardo.sousa@canonical.com>"
 
diff --git a/osm_common/tests/test_msgbase.py b/osm_common/tests/test_msgbase.py
index 665968e..d5092b1 100644
--- a/osm_common/tests/test_msgbase.py
+++ b/osm_common/tests/test_msgbase.py
@@ -18,9 +18,9 @@
 ##
 
 import http
-import pytest
 
 from osm_common.msgbase import MsgBase, MsgException
+import pytest
 
 
 def exception_message(message):
diff --git a/osm_common/tests/test_msglocal.py b/osm_common/tests/test_msglocal.py
index 9548885..fb74586 100644
--- a/osm_common/tests/test_msglocal.py
+++ b/osm_common/tests/test_msglocal.py
@@ -19,18 +19,18 @@
 
 import http
 import logging
-import pytest
-import tempfile
-import shutil
-import uuid
 import os
-import yaml
-import time
+import shutil
+import tempfile
 import threading
-
+import time
 from unittest.mock import MagicMock
+import uuid
+
 from osm_common.msgbase import MsgException
 from osm_common.msglocal import MsgLocal
+import pytest
+import yaml
 
 __author__ = "Eduardo Sousa <eduardosousa@av.it.pt>"
 
diff --git a/releasenotes/notes/cleanup_release_notes-2eaaface039a3179.yaml b/releasenotes/notes/cleanup_release_notes-2eaaface039a3179.yaml
new file mode 100644
index 0000000..4163b1f
--- /dev/null
+++ b/releasenotes/notes/cleanup_release_notes-2eaaface039a3179.yaml
@@ -0,0 +1,22 @@
+#######################################################################################
+# 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.
+#######################################################################################
+---
+other:
+  - |
+    Flake8 import order check is added in tox.ini, library import order is arranged in all files.
+    Release note creation is added in tox.ini, stage-test failing by tox results is enabled, release note
+    checking script is added.
\ No newline at end of file
diff --git a/setup.py b/setup.py
index cb19584..390ca7d 100644
--- a/setup.py
+++ b/setup.py
@@ -18,6 +18,7 @@
 
 
 import os
+
 from setuptools import setup
 
 here = os.path.abspath(os.path.dirname(__file__))
diff --git a/tox.ini b/tox.ini
index ce0ffcb..e763ca2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -52,7 +52,9 @@
 
 #######################################################################################
 [testenv:flake8]
-deps = flake8
+deps =
+        flake8
+        flake8-import-order
 commands =
         flake8 osm_common/ setup.py
 
@@ -104,6 +106,15 @@
 whitelist_externals = sh
 
 #######################################################################################
+[testenv:release_notes]
+deps = reno
+skip_install = true
+whitelist_externals = bash
+commands =
+        reno new {posargs:new_feature}
+        bash -c "sed -i -e '1 e head -16 tox.ini' releasenotes/notes/{posargs:new_feature}*.yaml"
+
+#######################################################################################
 [flake8]
 ignore =
         W291,
@@ -121,3 +132,4 @@
 max-line-length = 120
 show-source = True
 builtins = _
+import-order-style = google