summaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/asserts
diff options
context:
space:
mode:
authorVictor Morales <victor.morales@intel.com>2017-07-26 16:06:35 -0500
committerVictor Morales <victor.morales@intel.com>2017-07-26 16:06:35 -0500
commitdd074806ad51761392a9cca3f1f04fbbebd3de22 (patch)
tree9088768b55bf307875369e7368f56c7e66149424 /bootstrap/vagrant-onap/lib/asserts
parent8805879b4dc92014381ba55b75955b295944ded6 (diff)
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>
Diffstat (limited to 'bootstrap/vagrant-onap/lib/asserts')
-rwxr-xr-xbootstrap/vagrant-onap/lib/asserts36
1 files changed, 33 insertions, 3 deletions
diff --git a/bootstrap/vagrant-onap/lib/asserts b/bootstrap/vagrant-onap/lib/asserts
index 0e455382a..d02cb5da8 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
+}