Skip to content
This repository was archived by the owner on Apr 27, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM ubuntu

# RUN echo "deb http://ceph.com/packages/ceph-extras/debian $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/ceph-extras.list
RUN apt-get -y update && apt-get install -y tgt-rbd ceph-common python python-dev python-setuptools build-essential python-pip sudo sqlite3

# Dev doesnt need dnsmasq for now, will require for prod
# RUN apt-get install -y dnsmasq

# TODO update dnsmasq.conf and other stuff when updating for prod

RUN pip install dumb-init

RUN useradd -ms /bin/bash bmi
RUN passwd -d bmi
RUN passwd -d root
RUN usermod -aG sudo bmi

RUN mkdir /etc/bmi/
RUN mkdir /var/log/bmi/
RUN mkdir /var/lib/tftpboot/
RUN mkdir /var/lib/tftpboot/pxelinux.cfg/
RUN mkdir /var/lib/bmi/

COPY docker/bmi_config.cfg /etc/bmi/bmiconfig.cfg
ENV BMI_CONFIG=/etc/bmi/bmiconfig.cfg

RUN chown bmi:bmi /etc/tgt/conf.d/
RUN chown bmi:bmi /var/log/bmi/
RUN chown bmi:bmi /var/lib/tftpboot/
RUN chown bmi:bmi /var/lib/tftpboot/pxelinux.cfg/
RUN chown bmi:bmi /var/lib/bmi/

COPY docker/runbmi.sh /home/bmi/runbmi.sh
RUN chmod a+x /home/bmi/runbmi.sh

ENV HAAS_USERNAME=admin
ENV HAAS_PASSWORD=admin

VOLUME /etc/ceph

USER bmi
COPY ims/ /home/bmi/ims/
COPY tests/ /home/bmi/tests/
COPY scripts/ /home/bmi/scripts/
COPY setup.py /home/bmi/setup.py

USER root
WORKDIR /home/bmi
RUN python setup.py develop

USER bmi
RUN bmi db ls
RUN sqlite3 /var/lib/bmi/bmi.db "insert into project values(1,'bmi_infra','bmi_provision')"

# Dev Stuff
#RUN sudo apt-get install -y openssh-server vim git
#RUN sudo pip install pytest
#RUN mkdir /home/bmi/.ssh
#COPY docker/pubkey /home/bmi/.ssh/authorized_keys


CMD dumb-init /home/bmi/runbmi.sh
45 changes: 45 additions & 0 deletions Dockerfile_hil
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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 477e12097ce7f379056184d43d8f72dfcbe30b5f
RUN python setup.py install
COPY docker/haas.cfg /etc/haas.cfg
COPY docker/haas.cfg ./haas.cfg

USER hil
RUN haas-admin db create

USER root
COPY docker/setupdb.sh ./setupdb.sh
RUN chmod a+x setupdb.sh

USER hil
ENV HAAS_ENDPOINT=http://127.0.0.1:7000
RUN ./setupdb.sh

USER root
RUN chmod 666 /home/hil/haas.db
RUN chown hil:hil /home/hil/haas.db

COPY docker/runhil.sh ./runhil.sh
RUN chmod a+x runhil.sh

RUN cp ./haas.wsgi ./wsgi.py

RUN pip install gunicorn

EXPOSE 7000
USER hil
CMD dumb-init /home/hil/hil/runhil.sh
70 changes: 70 additions & 0 deletions docker/bmi_config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# this section is for basic bmi settings
[bmi]
# uid is given so that images dont clash in ceph pool
uid = 1
service = False

# this section is for db settings
[db]
path = /var/lib/bmi/bmi.db

# This section is filesystem related config
[fs]
id = admin
pool = rbd
conf_file = /etc/ceph/ceph.conf
keyring = /etc/ceph/ceph.client.admin.keyring

[driver]
net_isolator = <driver to load>
iscsi = <driver to load>
fs = <driver to load>

# This section is for network isolator (HIL) related config
[net_isolator]
url = http://172.17.0.3:7000

# This section is for iscsi related config
[iscsi]
ip = 127.0.0.1
password = password

# this section is for rpc server config
[rpc]
name_server_ip = 127.0.0.1
name_server_port = 9000
rpc_server_ip = 127.0.0.1
rpc_server_port = 9001

# this section is for specifying tftp settings
[tftp]
pxelinux_path = /var/lib/tftpboot/pxelinux.cfg/
ipxe_path = /var/lib/tftpboot/

# this section is for http config
[rest_api]
ip = 127.0.0.1
port = 8000

# this section is for logs
[logs]
path = /var/log/bmi/
debug = True
verbose = False

[tests]
picasso_url = http://127.0.0.1:8000/
correct_hil_username = haasadmin
correct_hil_password = admin1234
incorrect_hil_password = admin123##

node_name = bmi_node
nic = bmi_nic

project = bmi_infra
network = bmi_provision

exist_img_name = bmi_test
new_snap_name = test_snap
not_exist_snap_name = hello
not_exist_img_name = i12
61 changes: 61 additions & 0 deletions docker/haas.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is an example haas.cfg file suitable for use for development without a
# full set of hardware (switches, nodes, libvirtd...). It can be used as-is,
# but using the vlan_pool allocator may also be desirable (see the comments
# below).
[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/haas.db
#uri = postgresql://<username>:<password>@<address>/<dbname>

[devel]
dry_run=True

[extensions]
haas.ext.switches.mock =
haas.ext.obm.mock =

#haas.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:
#
haas.ext.auth.null =
haas.ext.network_allocators.vlan_pool =

[haas.ext.network_allocators.vlan_pool]
vlans = 100-200, 300-500

# Again, depending on what you're doing, you may want to change this to a
# diffefrent authentication backend:
#haas.ext.auth.database =
# haas.ext.auth.keystone =
#
# If using the keystone backend, you'll also need to fill out this section:
# [haas.ext.auth.keystone]
# # This is equivalent to the [keystone_auth] section described at:
# # http://docs.openstack.org/developer/keystonemiddleware/middlewarearchitecture.html
# #
# # Below is a reasoanble configuration *for development*. It is not suitable
# # for production, If for no other reason than because it forces plaintext
# # (non-TLS) connections to keystone:
# auth_url = http://127.0.0.1:35357/v3
# auth_protocol = http
# username = admin
# password = s3cr3t
# project_name = admin
# admin_user = admin
# admin_password = s3cr3t
4 changes: 4 additions & 0 deletions docker/runbmi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sudo tgtd &
sudo chown bmi:bmi /etc/ceph/ceph.client.admin.keyring
sudo service ssh start
sleep infinity
4 changes: 4 additions & 0 deletions docker/runhil.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nohup gunicorn -w 5 -b 0.0.0.0:7000 wsgi:application >/dev/null 2>&1 &
sleep 1
nohup haas serve_networks >/dev/null 2>&1 &
sleep infinity
14 changes: 14 additions & 0 deletions docker/setupdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
haas serve 7000 &
sleep 1
haas serve_networks &
sleep 1
haas project_create bmi_infra
haas node_register bmi_node mock mock-host mock-user mock-pass
haas node_register_nic bmi_node bmi_nic aa:bb:cc:dd:ee:ff
haas network_create_simple bmi_provision bmi_infra
haas project_connect_node bmi_infra bmi_node
haas switch_register bmi_switch mock mockhost mockuser mockpass
haas port_register bmi_switch bmi_port
haas port_connect_nic bmi_switch bmi_port bmi_node bmi_nic
haas show_node bmi_node
haas show_network bmi_provision
76 changes: 76 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Docker for Dev

## Prerequisites

* Docker

## Creating Containers

### Ceph

To Run Ceph Container execute
```
docker pull ceph/demo
docker run -d -v ceph:/etc/ceph -e MON_IP=172.17.0.2 -e CEPH_PUBLIC_NETWORK=172.17.0.0/24 --name ceph -h ceph ceph/demo
```

Do a ``` docker ps ``` and check if ceph container is running and to check if ceph is running probably do ``` docker exec ceph ceph -s ```
and if the output contains HEALTH_OK then all is good.

### HIL

To build HIL image, first cd to the project root folder then execute
```
docker build -t hil -f ./Dockerfile_hil
```

After Successful build of image execute
```
docker run -d --name hil -h hil hil
```
Then run ``` docker ps ``` to check if container is running

### BMI

Similar to HIL, first cd to the project root folder then execute
```
docker build -t bmi .
```

After successful build of image execute
```
docker run -d -v ceph:/etc/ceph --link hil:hil --name bmi -h bmi bmi
```
Then run ``` docker ps ``` to check if container is running

Hopefully you have a successful deployment of BMI running on your system in containers!!

## Running

Like after system reboot it is advised to start containers in the following order using ``` docker start <name> ```
* ceph
* hil
* bmi
To get the correct ips.

## Getting in the container

To get in the bmi container run the command ``` docker exec -it bmi bash ```, You can configure the container any way you want. BMI is already
installed as develop with production configuration. The src files are in /home/bmi.

## Post Config Stuff for BMI

Even though bmi is technically ready to run you will probably need to do some more stuff to run it properly.
* Create new image using ``` rbd create --image-format 2 --size 10 bmi_test ```, this will create a 10 MB blank image called bmi_test in
ceph.
* import the created image using ``` bmi import bmi_infra bmi_test ```
* Change HIL_BMI_CHANNEL to null in ims/common/constants.py (Temporary)

This should allow you to run test cases.

## HIL side stuff
* network = bmi_provision
* node = bmi_node
* nic = bmi_nic
* port = bmi_port
* switch = bmi_switch