Skip to content

Commit 831e036

Browse files
committed
Initial import from ansible/ansible.
1 parent d3a484f commit 831e036

8 files changed

+479
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

Dockerfile

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
FROM ubuntu:16.04
2+
3+
MAINTAINER "René Moser" <[email protected]>
4+
5+
RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections; \
6+
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections;
7+
8+
RUN apt-get -y update && apt-get install -y \
9+
genisoimage \
10+
libffi-dev \
11+
libssl-dev \
12+
sudo \
13+
ipmitool \
14+
maven \
15+
netcat \
16+
openjdk-8-jdk \
17+
python-dev \
18+
python-mysql.connector \
19+
python-pip \
20+
python-setuptools \
21+
supervisor \
22+
wget \
23+
nginx \
24+
jq \
25+
mysql-server \
26+
openssh-client \
27+
&& apt-get clean all \
28+
&& rm -rf /var/lib/apt/lists/*;
29+
30+
# TODO: check if and why this is needed
31+
RUN mkdir -p /root/.ssh \
32+
&& chmod 0700 /root/.ssh \
33+
&& ssh-keygen -t rsa -N "" -f id_rsa.cloud
34+
35+
RUN mkdir -p /var/run/mysqld; \
36+
chown mysql /var/run/mysqld; \
37+
echo '''sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"''' >> /etc/mysql/mysql.conf.d/mysqld.cnf
38+
39+
RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot password ''
40+
41+
RUN wget https://github.com/apache/cloudstack/archive/4.9.2.0.tar.gz -O /opt/cloudstack.tar.gz; \
42+
mkdir -p /opt/cloudstack; \
43+
tar xvzf /opt/cloudstack.tar.gz -C /opt/cloudstack --strip-components=1
44+
45+
WORKDIR /opt/cloudstack
46+
47+
RUN mvn -Pdeveloper -Dsimulator -DskipTests clean install
48+
RUN mvn -Pdeveloper -Dsimulator dependency:go-offline
49+
RUN mvn -pl client jetty:run -Dsimulator -Djetty.skip -Dorg.eclipse.jetty.annotations.maxWait=120
50+
51+
RUN (/usr/bin/mysqld_safe &); \
52+
sleep 5; \
53+
mvn -Pdeveloper -pl developer -Ddeploydb; \
54+
mvn -Pdeveloper -pl developer -Ddeploydb-simulator; \
55+
MARVIN_FILE=$(find /opt/cloudstack/tools/marvin/dist/ -name "Marvin*.tar.gz"); \
56+
pip install $MARVIN_FILE;
57+
58+
COPY zones.cfg /opt/zones.cfg
59+
COPY nginx_default.conf /etc/nginx/sites-available/default
60+
RUN pip install cs
61+
COPY run.sh /opt/run.sh
62+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
63+
64+
EXPOSE 8888 8080 8096
65+
66+
CMD ["/usr/bin/supervisord"]

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
build:
2+
docker build -t cloudstack-sim .
3+
4+
clean:
5+
docker rm -f cloudstack
6+
7+
run:
8+
docker run --name cloudstack -d -p 8080:8080 -p 8888:8888 cloudstack-sim
9+
10+
shell:
11+
docker exec -it cloudstack /bin/bash
12+
13+
logs:
14+
docker logs -f cloudstack

README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# cloudstack-test-container
2-
CloudStack simulator container for testing.
2+
The purpose of this docker image is to run automated integration tests for the CloudStack modules in Ansible.
3+
4+
## Setup
5+
6+
The docker image runs the CloudStack simulator and contains two zones for the different network setups: `basic` and `advanced` networking.
7+
8+
- CloudStack Zone: Sandbox-simulator-advanced
9+
- Zone: Sandbox-simulator-basic
10+
11+
## Build
12+
13+
```bash
14+
docker build -t ansible/cloudstack-simulator .
15+
```
16+
17+
## Run
18+
19+
```bash
20+
docker run --name cloudstack-simulator -d -p 8888:8888 ansible/cloudstack-simulator
21+
```
22+
23+
> It may take some time until the zones are deployed. The web server will respond with HTTP 503 on port 8888 unless the zones are fully deployed.

nginx_default.conf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
upstream cloudstack-backend {
2+
server 127.0.0.1:8080;
3+
}
4+
5+
server {
6+
listen 8888 default_server;
7+
8+
root /var/www/html;
9+
10+
server_name _;
11+
12+
# waiting for zone to be deployed
13+
if (!-f /var/www/html/admin.json) {
14+
return 503;
15+
}
16+
17+
location /client {
18+
proxy_pass http://cloudstack-backend;
19+
}
20+
location / {
21+
22+
}
23+
}

run.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
until nc -z localhost 8096; do
3+
echo "waiting for port 8096..."
4+
sleep 3
5+
done
6+
7+
sleep 3
8+
if [ ! -e /var/www/html/admin.json ]
9+
then
10+
python /opt/cloudstack/tools/marvin/marvin/deployDataCenter.py -i /opt/zones.cfg
11+
export CLOUDSTACK_ENDPOINT=http://127.0.0.1:8096
12+
export CLOUDSTACK_KEY=""
13+
export CLOUDSTACK_SECRET=""
14+
cs listUsers account=admin | jq .user[0] > /var/www/html/admin.json
15+
fi

supervisord.conf

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:mysqld]
5+
command=/usr/bin/mysqld_safe
6+
autostart=true
7+
autorestart=true
8+
user=root
9+
10+
[program:cloudstack]
11+
command=/bin/bash -c "mvn -pl client jetty:run-forked -Dsimulator -Dorg.eclipse.jetty.annotations.maxWait=120"
12+
directory=/opt/cloudstack
13+
stdout_logfile=/dev/stdout
14+
stdout_logfile_maxbytes=0
15+
user=root
16+
17+
[program:nginx]
18+
command=/usr/sbin/nginx
19+
autostart=true
20+
autorestart=false
21+
user=root
22+
23+
[program:deploy-zones]
24+
command = /opt/run.sh
25+
startsecs = 0
26+
autorestart = false
27+
startretries = 1
28+
user=root

0 commit comments

Comments
 (0)