From a239e735d8904a92729c35230e5985bc48aa93d5 Mon Sep 17 00:00:00 2001
From: Ronan Le Martret <ronan.lemartret@iot.bzh>
Date: Thu, 11 Jan 2018 14:42:18 +0100
Subject: Update xds-server documentation

Change-Id: Idd4ca8a735b694e14d1ab63fa58c30dc68a5fbf3
Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
---
 docs/part-2/1_xds-server.md | 159 +++++++++++++++++++++++++++++---------------
 docs/part-2/2_xds-agent.md  |  24 ++++---
 docs/part-2/3_xds-cli.md    |  20 ++++--
 3 files changed, 132 insertions(+), 71 deletions(-)

(limited to 'docs/part-2')

diff --git a/docs/part-2/1_xds-server.md b/docs/part-2/1_xds-server.md
index 47e3e14..adc0012 100644
--- a/docs/part-2/1_xds-server.md
+++ b/docs/part-2/1_xds-server.md
@@ -2,12 +2,13 @@
 
 `xds-server` is a web server that allows user to remotely cross build applications.
 
-The first goal is to provide a multi-platform cross development tool with
-near-zero installation.
-The second goal is to keep application sources locally (on user's machine) to
-make it compatible with existing IT policies (e.g. corporate backup or SCM),
-and let user to continue to work as usual (use his favorite editor,
-keep performance while editing/browsing sources).
+- The first goal is to provide a multi-platform cross development tool with near-zero installation.
+- The second goal is to keep application sources locally (on user's machine).
+  - Make it compatible with existing IT policies (e.g. corporate backup or SCM).
+  - Let user to continue to work as usual.
+    - Use his favorite editor.
+    - keep performance while editing/browsing sources.
+    - Avoids manual operation
 
 This powerful and portable webserver (written in [Go](https://golang.org))
 exposes a REST interface over HTTP.
@@ -55,7 +56,7 @@ You should get `docker.automotivelinux.org/agl/worker-xds:X.Y` image
 # List image that we just built
 docker images | grep worker-xds
 
-docker.automotivelinux.org/agl/worker-xds       3.99.1              786d65b2792c        6 days ago          602MB
+docker.automotivelinux.org/agl/worker-xds       5.0                 02616f565535        5 hours ago         640MB
 ```
 
 ### Start xds-server within the container
@@ -64,18 +65,26 @@ Use provided script to create a new docker image and start a new container:
 
 ```bash
 # Get script
-wget https://raw.githubusercontent.com/iotbzh/xds-server/master/scripts/xds-docker-create-container.sh
+wget -O xds-docker-create-container.sh 'https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/xds/xds-server.git;a=blob_plain;f=scripts/xds-docker-create-container.sh;hb=master'
 
 # Create new XDS worker container
 bash ./xds-docker-create-container.sh
 
 # Check that new container is running
 docker ps | grep worker-xds
-
-b985d81af40c        docker.automotivelinux.org/agl/worker-xds:3.99.1       "/usr/bin/wait_for..."   6 days ago           Up 4 hours          0.0.0.0:8000->8000/tcp, 0.0.0.0:69->69/udp, 0.0.0.0:10809->10809/tcp, 0.0.0.0:2222->22/tcp    agl-xds-seb@laptop-0-seb
+f67079db4339        docker.automotivelinux.org/agl/worker-xds:5.0   "/usr/bin/wait_for..."   About a minute ago   Up 34 seconds       0.0.0.0:8000->8000/tcp, 0.0.0.0:69->69/udp, 0.0.0.0:10809->10809/tcp, 0.0.0.0:2222->22/tcp   agl-xds-HOSTNAME-0-USERNAME
 ```
 
-Note that you can also add a new shared directory using `--volume` option in order
+This container exposes following ports:
+
+- 8000 : `xds-server` to serve XDS webapp
+- 69   : TFTP
+- 2222 : ssh
+
+<!-- note -->
+**Note:**
+
+You can add a new shared directory using `--volume` option in order
 to use for example with Path-Mapping folder type.
 
 ```bash
@@ -83,27 +92,39 @@ to use for example with Path-Mapping folder type.
 bash ./xds-docker-create-container.sh --volume /my-workspace:$HOME/my-workspace
 ```
 
-This container (ID=0) exposes following ports:
+You can change docker used port with `-id` option
 
-- 8000 : `xds-server` to serve XDS webapp
-- 69   : TFTP
-- 2222 : ssh
+```bash
+# Create new XDS worker container with different port
+bash ./xds-docker-create-container.sh -id ${ID}
+
+# Check that new container is running
+docker ps | grep worker-xds
+f67079db4339        docker.automotivelinux.org/agl/worker-xds:5.0   "/usr/bin/wait_for..."   About a minute ago   Up 34 seconds       0.0.0.0:(2222+ID)->22/tcp, 0.0.0.0:(69+ID)->69/udp, 0.0.0.0:(8000+ID)->8000/tcp, 0.0.0.0:(10809+ID)->10809/tcp   agl-xds-HOSTNAME-ID-USERNAME
+```
+
+<!-- endnote -->
 
 #### Manually setup docker user id
 
 <!-- note -->
-**Note:** if you used `xds-docker-create-container.sh` script to create XDS
+**Note:**
+
+If you used `xds-docker-create-container.sh` script to create XDS
 docker container, user uid/gid inside docker has already been changed by this script.
 <!-- endnote -->
 
-If you plan to **use path-mapping sharing type for your projects**, you need to
-have the same user id and group id inside and outside docker. By default user
-and group name inside docker is set `devel` (id `1664`), use following commands
-to replace id `1664` with your user/group id:
+If you plan to use **path-mapping sharing type for your projects**, you need to
+have the same user id and group id inside and outside docker.
+
+By default user and group name inside docker is set `devel` (id `1664`).
+
+Use following commands to replace id `1664` with your user/group id:
 
 ```bash
 # Set docker container name to use (usually agl-xds-xxx where xxx is USERNAME@MACHINENAME-IDX-NAME)
 export CONTAINER_NAME=agl-xds-seb@laptop-0-seb
+docker ps | grep ${CONTAINER_NAME} || echo "ERROR: No container name \"${CONTAINER_NAME}\" please set a valid CONTAINER_NAME before you continue"
 
 # First kill all processes of devel user (including running xds-server)
 docker exec ${CONTAINER_NAME} bash -c "/bin/loginctl kill-user devel"
@@ -136,20 +157,17 @@ xdg-open http://localhost:8000
 If needed you can status / stop / start  it manually using following commands:
 
 ```bash
-# Log into docker container
-ssh -p 2222 devel@localhost
-
 # Status XDS server:
-devel@docker ~$ systemctl --user status xds-server.service
+ssh -p 2222 devel@localhost systemctl --user status xds-server.service
 
 # Stop XDS server
-devel@docker ~$ systemctl --user stop xds-server.service
+ssh -p 2222 devel@localhost systemctl --user stop xds-server.service
 
 # Start XDS server
-devel@docker ~$ systemctl --user start xds-server.service
+ssh -p 2222 devel@localhost systemctl --user start xds-server.service
 
 # Get XDS server logs
-devel@docker ~$ journalctl --user --unit=xds-server.service --output=cat
+ssh -p 2222 devel@localhost journalctl --user --unit=xds-server.service --output=cat
 ```
 
 ### Manually Start XDS server
@@ -160,18 +178,35 @@ XDS server is started as a service by Systemd.
 /lib/systemd/system/xds-server.service
 ```
 
-This Systemd service starts a bash script `/opt/AGL/xds/server/xds-server-start.sh`
+This Systemd service starts a bash script
+
+```bash
+/opt/AGL/xds/server/xds-server-start.sh
+```
 
-If you needed you can change default setting by defining specific environment
-variables in `/etc/default/xds-server`.
-For example to control log level, just set LOG_LEVEL env variable knowing that
-supported *level* are: panic, fatal, error, warn, info, debug.
+If needed you can change default setting by defining specific environment
+variables file
+
+```bash
+ssh -p 2222 devel@localhost vim /etc/default/xds-server
+```
+
+For example to control log level, just set LOG_LEVEL env variable.
+
+knowing that supported *level* are:
+
+- panic
+- fatal
+- error
+- warn
+- info
+- debug
 
 ```bash
 ssh -p 2222 devel@localhost
-devel@docker ~$ echo 'LOG_LEVEL=debug' | sudo tee --append /etc/default/xds-server > /dev/null
-devel@docker ~$ systemctl --user restart xds-server.service
-devel@docker ~$ tail -f /tmp/xds-server/logs/xds-server.log
+echo 'LOG_LEVEL=debug' | sudo tee --append /etc/default/xds-server > /dev/null
+systemctl --user restart xds-server.service
+tail -f /tmp/xds-server/logs/xds-server.log
 ```
 
 ### SDK cross-toolchain Management
@@ -184,6 +219,7 @@ devel@docker ~$ tail -f /tmp/xds-server/logs/xds-server.log
 
 `xds-server` dynamically detects supported SDKs by scanning sub-directories of
 `sdkScriptsDir` directory (see [Configuration chapter](#configuration)).
+
 Each sub-directory (usually name is the same as the SDK family) of `sdkScriptsDir`
 must contain a set of scripts that will be called by `xds-server` to managed SDKs
 of a specific family.
@@ -197,7 +233,7 @@ These scripts are:
 - `get-sdk-info`: extract SDK info (JSON format) from a SDK file/tarball
 - `remove`: used to remove an existing SDK
 
-For example, here 2 SDKs family (`agl` and `zephyr`) are defined :
+For example, here 2 SDKs family (`agl` and `zephyr`) are defined:
 
 ```bash
 # > tree ./sdks/
@@ -219,9 +255,10 @@ For example, here 2 SDKs family (`agl` and `zephyr`) are defined :
     └── remove
 ```
 
-On startup `xds-server` will call first `sdks/*/get-family-config` to get configuration
-of each SDK family and also call `sdks/*/db-dump` scripts to get the initial list
-of available and installed SDKs.
+On startup `xds-server` will call in order:
+
+- `sdks/*/get-family-config` to get configuration of each SDK family.
+- `sdks/*/db-dump` scripts to get the initial list of available and installed SDKs.
 
 Please refer to `sdks/README.md` for more information about scripts definition
 and to understand how to add support of a new SDK family.
@@ -266,14 +303,14 @@ Saving to: ‘/tmp/tmp.wuQzLdImCS/poky-agl-glibc-x86_64-agl-demo-platform-crosss
 
 2018-01-02 12:17:06 (1024 KB/s) - ‘/tmp/tmp.CWyEj3z76Q/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-4.99.5.sh’ saved [665996704/665996704]
 
-Automotive Grade Linux SDK installer version 4.99.5
+Automotive Grade Linux SDK installer version 5.0.0
 ===================================================
-You are about to install the SDK to "/xdt/sdk/poky-agl/4.99.5/corei7-64". Proceed[Y/n]? Y
+You are about to install the SDK to "/xdt/sdk/poky-agl/5.0.0/corei7-64". Proceed[Y/n]? Y
 Extracting SDK....................................................................................................................done
 Setting it up...done
 SDK has been successfully set up and is ready to be used.
 Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
- $ . /xdt/sdk/poky-agl/4.99.5/corei7-64/environment-setup-corei7-64-agl-linux
+ $ . /xdt/sdk/poky-agl/5.0.0/corei7-64/environment-setup-corei7-64-agl-linux
 
 SDK ID d65fe750-d3a7-38f5-83d8-3d3806054f8d successfully installed.
 
@@ -282,7 +319,7 @@ SDK ID d65fe750-d3a7-38f5-83d8-3d3806054f8d successfully installed.
 xds-cli sdks abort -id d65fe750
 
 # Install a SDK (using a local SDK package/file)
-xds-cli sdks install --file $HOME/xds-workspace/sdks/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-4.99.5.sh
+xds-cli sdks install --file $HOME/xds-workspace/sdks/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-5.0.0.sh
 
 ```
 
@@ -294,14 +331,15 @@ is located in `$HOME/xds-workspace/sdks` directory
 #### Install a new SDK from XDS Dashboard
 
 Open XDS-Dashboard in web-browser and select `SDKs` entry in left side menu.
+
 Then switch to `SDKs MANAGEMENT` view :
 
 ![](../part-1/pictures/xds-dashboard-sdks-mgt.png){:: style="margin:auto; display:flex"}
 
 Use filter boxes to find the SDK you want to install and then click on plus
-icon (Actions column) to start installation. SDK download and installation
-process may take several minutes and output of installation script (output of
-`add` script mentioned in above chapter).
+icon (Actions column) to start installation.
+
+SDK download and installation process may take several minutes and output of installation script (output of `add` script mentioned in above chapter).
 
 ![](../part-1/pictures/xds-dashboard-sdks-install.png){:: style="margin:auto; display:flex"}
 
@@ -331,6 +369,7 @@ SDK ID d65fe750-d3a7-38f5-83d8-3d3806054f8d successfully deleted.
 #### Un-install a SDK from XDS Dashboard
 
 Open XDS-Dashboard in web-browser and select `SDKs` entry in left side menu.
+
 If needed, switch to `BASIC SDKS VIEW` view and click on trash icon located
 in the top-right corner of SDK card.
 
@@ -370,7 +409,7 @@ Ubuntu:
 
 ```bash
  sudo apt-get install golang npm curl git zip unzip
- sudo npm install --global @angular/cli   # Angular Command Line Interface
+ sudo npm install --global n @angular/cli   # Angular Command Line Interface
  # Install LTS version of nodejs
  sudo n lts
 ```
@@ -379,7 +418,7 @@ openSUSE:
 
 ```bash
  sudo zypper install go npm git curl zip unzip
- sudo npm install --global @angular/cli   # Angular Command Line Interface
+ sudo npm install --global n @angular/cli   # Angular Command Line Interface
  # Install LTS version of nodejs
  sudo n lts
 ```
@@ -414,13 +453,18 @@ And to install `xds-server` (by default in `/opt/AGL/xds/server`):
 ```
 
 <!-- warning -->
-**Warning:** makefile install rule and default values in configuration file are set
-to fit the docker setup, so you may need to adapt some settings when you want to install
-xds-server natively.
+**Warning:**
+
+Makefile install rule and default values in configuration file are set
+to fit the docker setup.
+
+So you may need to adapt some settings when you want to install xds-server natively.
 <!-- endwarning -->
 
 <!-- note -->
-**Note:** Used `DESTDIR` to specify another install directory
+**Note:**
+
+Used `DESTDIR` to specify another install directory
 
 ```bash
 make install DESTDIR=$HOME/opt/xds-server
@@ -431,7 +475,9 @@ make install DESTDIR=$HOME/opt/xds-server
 #### XDS docker image
 
 As an alternative to a pre-build image, you can rebuild the container from scratch.
+
 `xds-server` has been integrated as a flavour of AGL SDK docker image.
+
 So to rebuild docker image just execute following commands:
 
 ```bash
@@ -453,8 +499,7 @@ Here is the logic to determine which `server-config.json` file will be used:
 1. `/etc/xds/server/server-config.json` file
 1. `<xds-server executable dir>/server-config.json` file
 
-Supported fields in configuration file are (all fields are optional and example
-below corresponds to the default values):
+Supported fields in configuration file are:
 
 - **httpPort** : HTTP port of client webapp/REST API
 - **webAppDir** : location of client web application (default: webapp/dist)
@@ -466,6 +511,8 @@ below corresponds to the default values):
 - **syncthing.gui-address** : syncthing gui url (default <http://localhost:8385>)
 - **syncthing.gui-apikey** : syncthing api-key to use (default auto-generated)
 
+All fields are optional and example below corresponds to the default values.
+
 ```json
 {
     "httpPort": 8000,
@@ -482,7 +529,9 @@ below corresponds to the default values):
 }
 ```
 
->**Note:** environment variables are supported by using `${MY_VAR}` syntax.
+>**Note:**
+
+Environment variables are supported by using `${MY_VAR}` syntax.
 
 ## Debugging
 
diff --git a/docs/part-2/2_xds-agent.md b/docs/part-2/2_xds-agent.md
index 5c9e114..7d08a16 100644
--- a/docs/part-2/2_xds-agent.md
+++ b/docs/part-2/2_xds-agent.md
@@ -82,7 +82,7 @@ Ubuntu:
 
 ```bash
  sudo apt-get install golang npm curl git zip unzip
- sudo npm install --global @angular/cli   # Angular Command Line Interface
+ sudo npm install --global n @angular/cli   # Angular Command Line Interface
  # Install LTS version of nodejs
  sudo n lts
 ```
@@ -91,7 +91,7 @@ openSUSE:
 
 ```bash
  sudo zypper install go npm git curl zip unzip
- sudo npm install --global @angular/cli   # Angular Command Line Interface
+ sudo npm install --global n @angular/cli   # Angular Command Line Interface
  # Install LTS version of nodejs
  sudo n lts
 ```
@@ -188,13 +188,19 @@ So clone first `xds-server` + `xds-common` sources next to `xds-agent` directory
 You should have the following tree:
 
 ```bash
-> tree -L 3 src
-src
-|-- github.com
-    |-- iotbzh
-       |-- xds-agent
-       |-- xds-common
-       |-- xds-server
+tree -L 5 --charset=ascii src/
+src/
+`-- gerrit.automotivelinux.org
+    `-- gerrit
+        `-- src
+            `-- xds
+                |-- backup.sh
+                |-- xds-agent
+                |-- xds-cli
+                |-- xds-common
+                |-- xds-docs
+                |-- xds-gdb
+                `-- xds-server
 ```
 
 Then invoke `vendor/debug` Makefile rule to create a symlink inside vendor
diff --git a/docs/part-2/3_xds-cli.md b/docs/part-2/3_xds-cli.md
index 74903f8..3820b22 100644
--- a/docs/part-2/3_xds-cli.md
+++ b/docs/part-2/3_xds-cli.md
@@ -195,13 +195,19 @@ So clone first `xds-agent` + `xds-common` sources next to `xds-cli` directory.
 You should have the following tree:
 
 ```bash
-> tree -L 3 src
-src
-|-- github.com
-    |-- iotbzh
-       |-- xds-agent
-       |-- xds-cli
-       |-- xds-common
+tree -L 5 --charset=ascii src/
+src/
+`-- gerrit.automotivelinux.org
+    `-- gerrit
+        `-- src
+            `-- xds
+                |-- backup.sh
+                |-- xds-agent
+                |-- xds-cli
+                |-- xds-common
+                |-- xds-docs
+                |-- xds-gdb
+                `-- xds-server
 ```
 
 Then invoke `vendor/debug` Makefile rule to create a symlink inside vendor
-- 
cgit