From 8eb3953609f3dce00a00be95ccb4f609aafd2bb1 Mon Sep 17 00:00:00 2001 From: Izhmash Date: Thu, 11 Oct 2018 12:14:55 -0400 Subject: [PATCH 1/3] added hil ci container docker sources --- ci/docker_sources/hil_container/Dockerfile | 73 ++++++++++++++++++++++ ci/docker_sources/hil_container/hil.cfg | 36 +++++++++++ ci/docker_sources/hil_container/runhil.sh | 4 ++ ci/docker_sources/hil_container/setupdb.sh | 27 ++++++++ 4 files changed, 140 insertions(+) create mode 100644 ci/docker_sources/hil_container/Dockerfile create mode 100644 ci/docker_sources/hil_container/hil.cfg create mode 100644 ci/docker_sources/hil_container/runhil.sh create mode 100644 ci/docker_sources/hil_container/setupdb.sh diff --git a/ci/docker_sources/hil_container/Dockerfile b/ci/docker_sources/hil_container/Dockerfile new file mode 100644 index 0000000..2dfb617 --- /dev/null +++ b/ci/docker_sources/hil_container/Dockerfile @@ -0,0 +1,73 @@ +FROM centos + +RUN yum install -y epel-release + +RUN yum -y update && yum install -y bridge-utils gcc httpd ipmitool libvirt libxml2-devel libxslt-devel mod_wsgi net-tools python-pip python-psycopg2 python-virtinst qemu-kvm telnet vconfig virt-install + +RUN yum install -y git + +RUN yum install -y python-devel + +RUN pip install dumb-init + +RUN useradd -ms /bin/bash hil + +RUN passwd -d hil + +RUN passwd -d root + +RUN usermod -aG wheel hil + +WORKDIR /home/hil + +RUN git clone https://github.com/CCI-MOC/hil.git + +WORKDIR /home/hil/hil + +RUN git reset --hard f88d2fc92066c1e83e428ebeeca351971f306053 + +RUN pip install --upgrade pip setuptools + +RUN python setup.py install + +COPY hil.cfg /etc/hil.cfg + +COPY hil.cfg /home/hil + +COPY hil.cfg /home/hil/hil + +USER hil + +RUN hil-admin db create + +USER root + +RUN chmod 666 /home/hil/hil.db + +RUN chown hil:hil /home/hil/hil.db + +COPY setupdb.sh setupdb.sh + +RUN chmod a+x setupdb.sh + +USER hil + +ENV HIL_ENDPOINT=http://127.0.0.1:7000 + +RUN ./setupdb.sh + +USER root + +RUN cp hil.wsgi wsgi.py + +RUN pip install gunicorn + +COPY runhil.sh runhil.sh + +RUN chmod a+x runhil.sh + +EXPOSE 7000 + +user hil + +CMD dumb-init /home/hil/hil/runhil.sh diff --git a/ci/docker_sources/hil_container/hil.cfg b/ci/docker_sources/hil_container/hil.cfg new file mode 100644 index 0000000..218a885 --- /dev/null +++ b/ci/docker_sources/hil_container/hil.cfg @@ -0,0 +1,36 @@ +[general] +log_level = debug + +[auth] +require_authentication = False + +[headnode] +trunk_nic = eth0 +base_imgs = img1, img2, img3, img4 +libvirt_endpoint = qemu:///system + +[client] +endpoint = http://127.0.0.1:7000 + +[database] +uri = sqlite:////home/hil/hil.db +#uri = postgresql://:@
/ + +[devel] +dry_run=True + +[extensions] +hil.ext.switches.mock = +hil.ext.obm.mock = + +#hil.ext.network_allocators.null = + +# Depending on what you're trying to do, you may want to use the vlan_pool +# network allocator instead of the null allocator. To do this, comment out the +# null allocator extension above, and uncomment the following: +# +hil.ext.auth.null = +hil.ext.network_allocators.vlan_pool = + +[hil.ext.network_allocators.vlan_pool] +vlans = 100-200, 300-500 diff --git a/ci/docker_sources/hil_container/runhil.sh b/ci/docker_sources/hil_container/runhil.sh new file mode 100644 index 0000000..b821b0d --- /dev/null +++ b/ci/docker_sources/hil_container/runhil.sh @@ -0,0 +1,4 @@ +nohup gunicorn -w 5 -b 0.0.0.0:7000 wsgi:application >/dev/null 2>&1 & +sleep 1 +nohup hil-admin serve_networks >/dev/null 2>&1 & +sleep infinity diff --git a/ci/docker_sources/hil_container/setupdb.sh b/ci/docker_sources/hil_container/setupdb.sh new file mode 100644 index 0000000..2b79a9b --- /dev/null +++ b/ci/docker_sources/hil_container/setupdb.sh @@ -0,0 +1,27 @@ +hil-admin run-dev-server -p 7000 & + +sleep 5 + +hil-admin serve-networks & + +sleep 5 + +hil project create bmi_infra + +hil node register bmi_node mock mock-host mock-user mock-pass + +hil node nic register bmi_node bmi_nic aa:bb:cc:dd:ee:ff + +hil network create bmi_provision bmi_infra + +hil project node add bmi_infra bmi_node + +hil switch register bmi_switch mock mockhost mockuser mockpass + +hil port register bmi_switch gi1/0/1 *** Port here had to be renamed + +hil port nic add bmi_switch gi1/0/1 bmi_node bmi_nic + +hil node show bmi_node + +hil network show bmi_provision From 6309251bbb3aae4e4441d94fb14502b4f86e0aa7 Mon Sep 17 00:00:00 2001 From: Izhmash Date: Fri, 12 Oct 2018 12:15:38 -0400 Subject: [PATCH 2/3] add authentication, make gunicorn work properly, clean up redundant commands --- ci/docker_sources/hil_container/Dockerfile | 8 ++------ ci/docker_sources/hil_container/hil.cfg | 4 ++-- ci/docker_sources/hil_container/runhil.sh | 4 ++-- ci/docker_sources/hil_container/setupdb.sh | 8 +++++++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ci/docker_sources/hil_container/Dockerfile b/ci/docker_sources/hil_container/Dockerfile index 2dfb617..fed26de 100644 --- a/ci/docker_sources/hil_container/Dockerfile +++ b/ci/docker_sources/hil_container/Dockerfile @@ -20,20 +20,16 @@ RUN usermod -aG wheel hil WORKDIR /home/hil -RUN git clone https://github.com/CCI-MOC/hil.git +RUN git clone https://github.com/cci-moc/hil -b v0.3 WORKDIR /home/hil/hil -RUN git reset --hard f88d2fc92066c1e83e428ebeeca351971f306053 - RUN pip install --upgrade pip setuptools RUN python setup.py install COPY hil.cfg /etc/hil.cfg -COPY hil.cfg /home/hil - COPY hil.cfg /home/hil/hil USER hil @@ -54,7 +50,7 @@ USER hil ENV HIL_ENDPOINT=http://127.0.0.1:7000 -RUN ./setupdb.sh +RUN source ./setupdb.sh USER root diff --git a/ci/docker_sources/hil_container/hil.cfg b/ci/docker_sources/hil_container/hil.cfg index 218a885..778bae0 100644 --- a/ci/docker_sources/hil_container/hil.cfg +++ b/ci/docker_sources/hil_container/hil.cfg @@ -2,7 +2,7 @@ log_level = debug [auth] -require_authentication = False +require_authentication = True [headnode] trunk_nic = eth0 @@ -29,7 +29,7 @@ hil.ext.obm.mock = # network allocator instead of the null allocator. To do this, comment out the # null allocator extension above, and uncomment the following: # -hil.ext.auth.null = +hil.ext.auth.database = hil.ext.network_allocators.vlan_pool = [hil.ext.network_allocators.vlan_pool] diff --git a/ci/docker_sources/hil_container/runhil.sh b/ci/docker_sources/hil_container/runhil.sh index b821b0d..4f0fca2 100644 --- a/ci/docker_sources/hil_container/runhil.sh +++ b/ci/docker_sources/hil_container/runhil.sh @@ -1,4 +1,4 @@ -nohup gunicorn -w 5 -b 0.0.0.0:7000 wsgi:application >/dev/null 2>&1 & +nohup gunicorn -w 5 -b 0.0.0.0:7000 wsgi:application & sleep 1 -nohup hil-admin serve_networks >/dev/null 2>&1 & +nohup hil-admin serve-networks & sleep infinity diff --git a/ci/docker_sources/hil_container/setupdb.sh b/ci/docker_sources/hil_container/setupdb.sh index 2b79a9b..c534dc8 100644 --- a/ci/docker_sources/hil_container/setupdb.sh +++ b/ci/docker_sources/hil_container/setupdb.sh @@ -1,3 +1,7 @@ +export HIL_USERNAME=haasadmin + +export HIL_PASSWORD=admin1234 + hil-admin run-dev-server -p 7000 & sleep 5 @@ -6,6 +10,8 @@ hil-admin serve-networks & sleep 5 +hil-admin create-admin-user haasadmin admin1234 + hil project create bmi_infra hil node register bmi_node mock mock-host mock-user mock-pass @@ -18,7 +24,7 @@ hil project node add bmi_infra bmi_node hil switch register bmi_switch mock mockhost mockuser mockpass -hil port register bmi_switch gi1/0/1 *** Port here had to be renamed +hil port register bmi_switch gi1/0/1 hil port nic add bmi_switch gi1/0/1 bmi_node bmi_nic From daa9c8240df17cec9bc2bc16b1964faed2c8f1e5 Mon Sep 17 00:00:00 2001 From: Izhmash Date: Fri, 12 Oct 2018 12:52:22 -0400 Subject: [PATCH 3/3] fully detaching from the terminal now --- ci/docker_sources/hil_container/runhil.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/docker_sources/hil_container/runhil.sh b/ci/docker_sources/hil_container/runhil.sh index 4f0fca2..e510ba4 100644 --- a/ci/docker_sources/hil_container/runhil.sh +++ b/ci/docker_sources/hil_container/runhil.sh @@ -1,4 +1,4 @@ -nohup gunicorn -w 5 -b 0.0.0.0:7000 wsgi:application & +nohup gunicorn -w 5 -b 0.0.0.0:7000 wsgi:application >/dev/null 2>&1 & sleep 1 -nohup hil-admin serve-networks & +nohup hil-admin serve-networks >/dev/null 2>&1 & sleep infinity