Added docker login before pulling, to pull images from internal registry

Change-Id: Ice7a4573200d7c8de19f08dadbc60371cab3534c
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh
index be2aed4..56ebcc1 100755
--- a/installers/full_install_osm.sh
+++ b/installers/full_install_osm.sh
@@ -513,8 +513,14 @@
     fi
 }
 
+function docker_login() {
+    echo "Docker login"
+    sg docker -c "docker login -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PASSWORD}"
+}
+
 function generate_docker_images() {
     echo "Pulling and generating docker images"
+    [ -n "${DOCKER_REGISTRY_URL}" ] && docker_login
 
     echo "Pulling docker images"
 
@@ -1532,6 +1538,12 @@
     wget -q -O /dev/null $url
 }
 
+function parse_docker_registry_url() {
+    DOCKER_REGISTRY_USER=$(echo "$DOCKER_REGISTRY_URL" | awk '{split($1,a,"@"); split(a[1],b,":"); print b[1]}')
+    DOCKER_REGISTRY_PASSWORD=$(echo "$DOCKER_REGISTRY_URL" | awk '{split($1,a,"@"); split(a[1],b,":"); print b[2]}')
+    DOCKER_REGISTRY_URL=$(echo "$DOCKER_REGISTRY_URL" | awk '{split($1,a,"@"); print a[2]}')
+}
+
 JUJU_AGENT_VERSION=2.8.6
 UNINSTALL=""
 DEVELOP=""
@@ -1775,6 +1787,7 @@
     esac
 done
 
+[ -n "$DOCKER_REGISTRY_URL" ] && parse_docker_registry_url
 [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option: -m NONE cannot be used with other -m options"
 [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" == " PLA" ] && [ -z "$INSTALL_PLA" ] && FATAL "Incompatible option: -m PLA cannot be used without --pla option"