Sync latest changes for vagrant-onap
Given some internal procedures was not possible to submit all the
changes. In the meantime, those changes were placed into an
non-official project. This change syncronizes the latest changes
into the official repository.
Issue-id: INT-17
Change-Id: Ia4125f4b70273401e4ed3cc1908d2e2ad7d1c2e9
Signed-off-by: Victor Morales <victor.morales@intel.com>
diff --git a/bootstrap/vagrant-onap/lib/asserts b/bootstrap/vagrant-onap/lib/asserts
index 0e45538..d02cb5d 100755
--- a/bootstrap/vagrant-onap/lib/asserts
+++ b/bootstrap/vagrant-onap/lib/asserts
@@ -2,10 +2,40 @@
set -o xtrace
+source /var/onap/commons
+
# asserts_image() - Function that verifies if a specific image was created
function asserts_image {
- if [[ "$(docker images -q $1 2> /dev/null)" == "" ]]; then
- echo "There is no $1 image"
- exit 1
+ local image=$1
+ local error_msg=${2:-"There is no $image image"}
+
+ if [[ "$(docker images -q $image 2> /dev/null)" == "" ]]; then
+ raise_error $error_msg
fi
}
+
+# asserts_installed_package() - Function that verifies if a specific package was installed.
+function asserts_installed_package {
+ local package=$1
+ local error_msg=${2:-"$package wasn't installed"}
+
+ if ! is_package_installed $package; then
+ raise_error $error_msg
+ fi
+}
+
+# asserts_file_exist() - Function that verifies if a specific file exists
+function asserts_file_exist {
+ local file=$1
+ local error_msg=${2:-"$file doesn't exist"}
+
+ if [ ! -f $file ]; then
+ raise_error $error_msg
+ fi
+}
+
+# raise_error() - Function that prints and exits the execution
+function raise_error {
+ echo $@
+ exit 1
+}