Installing xosapi in the virtualenv

Change-Id: I8bb12cc1c1039b90b106eb298d0c42fd2448689d
diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md
index a5819ca..f15a03c 100644
--- a/docs/SUMMARY.md
+++ b/docs/SUMMARY.md
@@ -5,5 +5,6 @@
 * Modules
 	- [Xos Config](modules/xosconfig.md)
 * Developer How Tos
-    - [xproto](xproto.md)
+	- [Local Dev Environmet](dev/local_env.md)
+    - [xproto](dev/xproto.md)
 
diff --git a/docs/dev/local_env.md b/docs/dev/local_env.md
new file mode 100644
index 0000000..330877b
--- /dev/null
+++ b/docs/dev/local_env.md
@@ -0,0 +1,22 @@
+# How to setup a local dev environmnet
+
+As now this is useful for working on libraries and will give you access to the `xossh` cli tool.
+
+## Create a python virtual-env
+
+We are providing an helper script to setup a python virtual environment and install all the required dependencies, to use it: 
+```bash
+source scripts/setup_venv.sh
+```
+
+At this point xos libraries are installed as python modules, so you can use any cli tool, for instance:
+```bash
+xossh
+```
+will open an xos shell to operate on models.
+For more informations on `xossh` look at `xos/xos_client/README.md`
+
+>NOTE: The `xossh` tool accept parameters to be configured, for example to use it against a local installation (frontend VM) you use:
+>```bash
+> xossh -G 192.168.46.100:50055 -S 192.168.46.100:50051
+>```
\ No newline at end of file
diff --git a/docs/toolchain.png b/docs/dev/toolchain.png
similarity index 100%
rename from docs/toolchain.png
rename to docs/dev/toolchain.png
Binary files differ
diff --git a/docs/xproto.md b/docs/dev/xproto.md
similarity index 100%
rename from docs/xproto.md
rename to docs/dev/xproto.md
diff --git a/scripts/setup_venv.sh b/scripts/setup_venv.sh
index a8d620d..9a8ef07 100644
--- a/scripts/setup_venv.sh
+++ b/scripts/setup_venv.sh
@@ -26,7 +26,14 @@
 if \
 pip install cryptography --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" && \
 pip install -r $REQUIREMENTS && \
-cd $BASEDIR/lib/xos-config; python setup.py install
+cd $BASEDIR/lib/xos-config; python setup.py install && \
+#install xos-client
+cp -R $BASEDIR/containers/xos/tmp.chameleon $BASEDIR/xos/xos_client/xosapi/chameleon && \
+cd $BASEDIR/xos/xos_client/xosapi/chameleon/protos; VOLTHA_BASE=anything make && \
+cd $BASEDIR/xos/xos_client; python setup.py install && \
+chmod 777 $BASEDIR/venv-xos/lib/python2.7/site-packages/xosapi/chameleon/protoc_plugins/gw_gen.py && \
+chmod 777 $BASEDIR/venv-xos/lib/python2.7/site-packages/xosapi/chameleon/protoc_plugins/swagger_gen.py
+
   then
     echo "Requirements installed."
     echo "Virtualenv ready"
diff --git a/xos/xos_client/.gitignore b/xos/xos_client/.gitignore
new file mode 100644
index 0000000..608c120
--- /dev/null
+++ b/xos/xos_client/.gitignore
@@ -0,0 +1,2 @@
+build
+xosapi/chameleon
diff --git a/xos/xos_client/setup.py b/xos/xos_client/setup.py
index 0892a33..5b072e2 100644
--- a/xos/xos_client/setup.py
+++ b/xos/xos_client/setup.py
@@ -1,6 +1,7 @@
 #! /usr/bin/env python
 
 import os
+import sys
 import site
 from distutils.core import setup
 
@@ -32,14 +33,16 @@
       scripts = ['xossh'],
      )
 
-# Chameleon needs the following files set as executable
-for dir in site.getsitepackages():
-   fn = os.path.join(dir, "xosapi/chameleon/protoc_plugins/gw_gen.py")
-   if os.path.exists(fn):
-       os.chmod(fn, 0777)
-   fn = os.path.join(dir, "xosapi/chameleon/protoc_plugins/swagger_gen.py")
-   if os.path.exists(fn):
-       os.chmod(fn, 0777)
+# If we're not running a Virtual Env
+if not hasattr(sys, 'real_prefix'):
+    # Chameleon needs the following files set as executable
+    for dir in site.getsitepackages():
+       fn = os.path.join(dir, "xosapi/chameleon/protoc_plugins/gw_gen.py")
+       if os.path.exists(fn):
+           os.chmod(fn, 0777)
+       fn = os.path.join(dir, "xosapi/chameleon/protoc_plugins/swagger_gen.py")
+       if os.path.exists(fn):
+           os.chmod(fn, 0777)
 
 
 """