aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/README.md
blob: 112338f3d3448e8c32adecca1afe41045a32120a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Modules for the Moon project

This directory contains all the modules for MoonV4


## Usage

### Prerequist

```bash
sudo apt install python3-dev python3-pip
sudo pip3 install pip --upgrade
sudo apt -y install docker-engine # ([Get Docker](https://docs.docker.com/engine/installation/))
echo 127.0.0.1 messenger db keystone | sudo tee -a /etc/hosts
```

### Install Docker

```bash
sudo apt-get remove docker docker-engine
sudo apt-get install     apt-transport-https     ca-certificates     curl     software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo docker run hello-world
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart
```

### Get the code

```bash
git clone https://opnfv.org/moon
cd moon/moonv4
export MOON_HOME=$(pwd)
sudo ln -s $(pwd)/conf /etc/moon
```

### Create an OpenStack environment

```bash
cd $MOON_HOME/templates/docker/keystone
# Check the proxy settings in Dockerfile
sudo docker build -t keystone:mitaka .
```

### Start RabbitMQ

```bash
sudo docker network create -d bridge --subnet=172.18.0.0/16 --gateway=172.18.0.1 moon
sudo docker run -dti --net=moon --hostname messenger --name messenger --link messenger:messenger -e RABBITMQ_DEFAULT_USER=moon -e RABBITMQ_DEFAULT_PASS=p4sswOrd1 -e RABBITMQ_NODENAME=rabbit@messenger -e RABBITMQ_DEFAULT_VHOST=moon -p 5671:5671 -p 5672:5672 rabbitmq:3-management
```

### Start MySQL server

```bash
sudo docker run -dti  --net=moon --hostname db --name db -e MYSQL_ROOT_PASSWORD=p4sswOrd1 -e MYSQL_DATABASE=moon -e MYSQL_USER=moon -e MYSQL_PASSWORD=p4sswOrd1 -p 3306:3306 mysql:latest
```

### Start an OpenStack environment

```bash
sudo docker run -dti --net moon --name keystone --hostname=keystone -e DB_HOST=db -e DB_PASSWORD_ROOT=p4sswOrd1 -p 35357:35357 -p 5000:5000 keystone:mitaka
```

### Build python packages for all components

```bash
cd ${MOON_HOME}/moon_orchestrator
sudo pip3 install pip --upgrade
cd ${MOON_HOME}/bin
source build_all.sh
```

### Start Orchestrator

To start the Moon platform, you have to run the Orchestrator.

```bash
cd ${MOON_HOME}/moon_orchestrator
sudo apt-get install python3-venv (or apt-get install -y python3 python-virtualenv on Ubuntu 14.04)
pyvenv tests/venv (or virtualenv tests/venv on Ubuntu 14.04)
. tests/venv/bin/activate
sudo pip3 install -r requirements.txt --upgrade
sudo pip3 install dist/moon_db-0.1.0.tar.gz --upgrade
sudo pip3 install dist/moon_utilities-0.1.0.tar.gz --upgrade
sudo pip3 install .  --upgrade
# Check the proxy settings and edit dist_dir variable  in $(MOON_HOME)/moon_orchestrator/etc/moon.conf
# Adapt the path used in the cd command in $(MOON_HOME)/bin/start.sh
source ../bin/start.sh
```

### Tests
```bash
sudo pip3 install pytest
cd ${MOON_HOME}/moon_interface/tests/apitests
pytest
```


### Relaunch Keystone docker
If error of `get_keystone_projects()`, then relaunch the Keystone docker, and wait 40 seconds!!!
```bash
docker rm -f keystone
docker run -dti --net moon --name keystone --hostname=keystone -e DB_HOST=db -e DB_PASSWORD_ROOT=p4sswOrd1 -p 35357:35357 -p 5000:5000 keystone:mitaka
```

### Add default data in DB
Pre-fill the DB with a RBAC policy
```bash
cd ${MOON_HOME}/moon_interface/tests/apitests
python3 populate_default_values.py scenario/ rbac.py
```


### Get some logs

```bash
docker ps
docker logs messenger
docker logs keystone
docker logs moon_router
docker logs moon_interface
```

### Get some statistics

```bash
docker stats --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.PIDs}}"
```

### Get the API in PDF

```bash
cd ${MOON_HOME}/moon_interface/tools
sudo pip3 install requests
sudo apt-get install pandoc
/usr/bin/python3 api2rst.py
sudo apt-get install texlive-latex-extra
pandoc api.rst -o api.pdf
evince api.pdf
```

## How to hack the Moon platform

### Force the build of components

If you want to rebuild one or more component, you have to modify the configuration file `moon.conf`. 

For example, if you want to rebuild the moon_interface, got to the `[interface]` section and delete the 
value of the container key like this:

```
[interface]
host=172.18.0.11
port=38001
# Name of the container to download (if empty build from scratch)
# example: container=moon/moon_interface:latest
container=
```

You can configure the interface, the router and both the security_function and security_policy.
You can also force the version of the component like this: `container=moon/moon_interface:4.0.0`

### Update the moon_interface

Go to the directory `${MOON_HOME}/moon_interface` and update the code accordingly to your needs,
then update the python package.

```bash
cd ${MOON_HOME}/moon_interface
python setup.py sdist
cp dist/moon_interface_* ../moon_orchestrator/dist
# kill moon_orchestrator if needed and restart it
```

### Update the moon_secrouter

Go to the directory `${MOON_HOME}/moon_secrouter` and update the code accordingly to your needs,
then update the python package.

```bash
cd ${MOON_HOME}/moon_secrouter
python setup.py sdist
cp dist/moon_secrouter* ../moon_orchestrator/dist
# kill moon_orchestrator if needed and restart it
```

## Problems that may arise

If the moon_orchestrator doesn't want to start
(with, for example, the following error: `docker.errors.APIError: 409 Client Error: Conflict`),
check if the router and interface containers still exist and kill and delete them:

```bash
docker kill moon_interface
docker kill moon_router
docker rm moon_interface
docker rm moon_router
```

If the moon_orchestrator complains that it cannot request the RabbitMQ server,
check if the messenger server is up and running:

```bash
docker ps
# you must see the messenger running here
# if not, restart it
docker run -dti --net=moon --hostname messenger --name messenger --link messenger:messenger -e RABBITMQ_DEFAULT_USER=moon -e RABBITMQ_DEFAULT_PASS=password -e RABBITMQ_NODENAME=rabbit@messenger -e RABBITMQ_DEFAULT_VHOST=moon -p 5671:5671 -p 5672:5672 rabbitmq:3-management
```