Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a891095
Added initial models for the database and the business logic
Jan 12, 2021
5ac2ef4
removed machine store (refactored to general store)
jdonszelmann Jan 12, 2021
8aef262
added machines api
jdonszelmann Jan 12, 2021
c10358a
sqlite CRUD
jdonszelmann Jan 13, 2021
d85cdbc
images CRUD
jdonszelmann Jan 13, 2021
fb059e6
zfs pool
jdonszelmann Feb 2, 2021
fe4c9e2
refactored some things
jdonszelmann Feb 3, 2021
d667572
Update README & Use Debian Stable instead of Arch Linux
ValentijnvdBeek Sep 29, 2021
10342ff
Fix typos & update packages
ValentijnvdBeek Oct 3, 2021
7442d4b
Add a configuration file for the management OS
ValentijnvdBeek Oct 3, 2021
81c6615
Use a custom logger for easier reading
ValentijnvdBeek Oct 3, 2021
e39cb6c
Implement Gzip compression; Auto-reboot on completion; Restart into t…
ValentijnvdBeek Oct 3, 2021
7f18859
Merge branch 'debian-stable' into database
ValentijnvdBeek Oct 20, 2021
a3a63aa
Merge debian-stable branch
ValentijnvdBeek Oct 20, 2021
79859b5
Cleanup the JSON responses and fix a big where it would always add th…
ValentijnvdBeek Oct 20, 2021
b161359
Dummy user & email fields; Check empty fields GET user; Unique values…
ValentijnvdBeek Oct 20, 2021
6dc8768
Documentation upgrade with HTTP request examples
ValentijnvdBeek Nov 1, 2021
64b60da
Actually link the machine and the disks
ValentijnvdBeek Nov 1, 2021
ee71a94
Fixes to the endpoints, implements GetAllImagesByName and GetAllImage…
ValentijnvdBeek Nov 1, 2021
f1c19f3
Endpoint Documentation; Get images by user id and name since names ar…
ValentijnvdBeek Nov 2, 2021
7a619a3
Embedd version in image responses & implement download image
ValentijnvdBeek Nov 2, 2021
63b6611
Implement uploading images; Downloading images; Downloading the lates…
ValentijnvdBeek Nov 2, 2021
ba13cce
Fix CI errors
ValentijnvdBeek Nov 2, 2021
989c390
Images are fetched from the database
ValentijnvdBeek Nov 7, 2021
feec453
Commit the changes to the images if requested
ValentijnvdBeek Nov 11, 2021
85466ac
Remove the kernel build files
ValentijnvdBeek Nov 11, 2021
0da509f
Utility package; Use new image uploading endpoint; Fix memory allocat…
ValentijnvdBeek Nov 11, 2021
6e9731c
Convert TODOs to issues; Remove the obselete CurrentSetup/NextSetup m…
ValentijnvdBeek Nov 11, 2021
13855d7
Fix CI creating file
u5surf Nov 13, 2021
a3b04f4
Add an authors file
u5surf Nov 15, 2021
b11a89c
Merge pull request #39 from u5surf/fix_ci
ValentijnvdBeek Nov 15, 2021
1d9a89b
Merge pull request #27 from baas-project/integrating-database-ipxe
ValentijnvdBeek Nov 16, 2021
e6d7941
Merge pull request #26 from baas-project/database
ValentijnvdBeek Nov 16, 2021
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
management_os/build/linux
control_server/disks
control_server/disks
control_server/old_disks
baas.qcow2
.git/
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: go test ./...
run: |
sudo cp management_os/config/config.toml /etc/baas.toml
sudo /opt/hostedtoolcache/go/1.16.10/x64/bin/go test ./...
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
- name: Checkout code
uses: actions/checkout@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ Sessionx.vim
# Temporary
.netrwhist
*~
#*

# Auto-generated tag files
tags
# Persistent undo
Expand All @@ -273,4 +275,7 @@ tags

# for jonathan because I need to run a dhcp server to test things and I put files for that here
dhcp
*,iso

# Don't upload the database
store.db
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

7 changes: 7 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is the list of baas-project/baas's authors for copyright purposes.
# This does not necessarily list everyone who has contributed code, since
# in some cases,
# their employer may be the copyright holder. To see the full list of
# contributors, see the revision history in source control.

u5surf <u5.horie@gmail.com>
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mkfile_dir := $(shell dirname $(mkfile_path))
# Change this to your own local ip address for testing,
# or to the ip address of the control server when ~~testing~~ running in production.
# This will be put in the hosts file.
export CONTROL_SERVER_IP ?= 192.168.0.4
export CONTROL_SERVER_IP ?= 192.168.2.76

lint_fix:
goimports -local baas -w **/*.go
Expand All @@ -16,11 +16,10 @@ lint:

management_os: management_initramfs management_kernel

management_initramfs: control_server/static/initramfs
management_initramfs:
@$(mkfile_dir)/management_os/build/build_management_initramfs.sh

management_kernel: control_server/static/vmlinuz
@$(mkfile_dir)/management_os/build/build_management_kernel.sh
management_initramfs: control_server/static/initramfs

control_server_docker:
@docker-compose -f $(mkfile_dir)/docker-compose.yml up --build
Expand Down
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@

# BAAS

Baremetal as a service, or abbreviated to BAAS is a project done for the TU Delft to facilitate operating systems
Baremetal As A Service, or abbreviated to BAAS is a project done for the TU Delft to facilitate operating systems
research on high-powered machines, by scheduling the access researches have to these machines. This system makes sure
each researcher can have full access to the machines in their timeslot, being able to load their own (custom) kernel and have
access to all hardware. BAAS makes sure the system is reset a well-known state after every job, to make sure these custom kernels
have not messed up the system enough to make further research on them impossible.

Disclaimer: this system is custom-built for the needs of the TU Delft. It is open source, and written to be extensible,
but it is unlikely that it will completely fit your needs without changes. We are open to pull requests,
but it is unlikely that it will completely fit your needs without changes. We are open to pull requests,
but we might not implement suggestions ourselves which are outside the scope of the requirements for the TU Delft.

# Documentation

Some documentation about the systems, and building these systems is provided [here](https://baas-project.github.io/baas/)

# Install

## Required software
- Go
- cpio
- goimports
- libvirt
- virt-manager/virt-viewer

## Installation of the virtual machine
This software works on a client a server-model, where there is a
central control server which offers the management OS to one or multiple
clients. These are two entirely different systems and hence both
testing as well as developing must be done on two separate machines.

### Client machine
Normally, you would use a virtual machine to create a client machine
and run the server on your hardware. It is recommended to use libvirt
for this, which is also what was used for initial development. You can
set it up as follows:

First start virt-manager, go to Edit->Connection Details and create a
new network, select NAT, set the name as BAASNetwork and set "Forward
To" as the network card you typically use (in my case wlan0). Press on
finish.

> :warning: If you have problems with connecting to the server,
> double check if there is not a firewall running in the background.
Run the following command, after running it, you should be able to
boot the virtual machine with the proper network settings.

```sh
virt-install --pxe --prompt --memory 2048 --name baas --disk size=30
--boot uefi,network,hd --network network=BAASNetwork --os-variant generic
```

Finally generate the management operating system which is run on the
client machine.

```sh
make management_initramfs
```

### Control server
In `virt-manager` go to view and select Details, press on the light
bulb and find the menu item called NIC. From there copy the MAC
address and change the value in control_server/main.go to this IP
address. You can then run `make control_server` to run the control
server and reboot the virtual machine. If all is well, it should now
boot into the management operating system.

# License

// TODO
// TODO
1 change: 1 addition & 0 deletions control_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disks/
4 changes: 2 additions & 2 deletions control_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ RUN mkdir /static

# Build project
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o control_server_bin ./control_server
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o control_server_bin ./control_server

# Run stage
FROM scratch
FROM gcr.io/distroless/base
WORKDIR /app

COPY --from=build /build/control_server_bin /app/control_server_bin
Expand Down
24 changes: 24 additions & 0 deletions control_server/api/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Package api provides functions for handling http requests on the control server.
// This is used to respond to requests from pixiecore, to serve files (kernel, initramfs, disk images)
// and to communicate with machines running the management os.
package api

import (
"github.com/baas-project/baas/pkg/database"
)

// API is a struct on which functions are defined that respond to requests
// from either the management OS, or the end user (through some kind of interface).
// This struct holds state necessary for the request handlers.
type API struct {
store database.Store
diskpath string
}

// NewAPI creates a new API struct.
func NewAPI(store database.Store, diskpath string) *API {
return &API{
store: store,
diskpath: diskpath,
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package httpserver
package api

import (
"encoding/json"
"net"
"net/http"

"github.com/baas-project/baas/pkg/model"

log "github.com/sirupsen/logrus"

"github.com/gorilla/mux"

"github.com/baas-project/baas/control_server/machines"
)

type bootConfigResponse struct {
Expand All @@ -26,9 +26,10 @@ type bootConfigResponse struct {
Cmdline string `json:"cmdline"`
}

func getBootConfig(arch machines.SystemArchitecture) *bootConfigResponse {
func getBootConfig(arch model.SystemArchitecture) *bootConfigResponse {
switch arch {
case machines.X86_64:
case model.X86_64:
// TODO: refactor
return &bootConfigResponse{
Kernel: "http://localhost:4848/static/vmlinuz",
Initramfs: []string{
Expand All @@ -37,17 +38,18 @@ func getBootConfig(arch machines.SystemArchitecture) *bootConfigResponse {
Message: "Booting into X86 management kernel.",
Cmdline: "root=sr0",
}
case machines.Arm64:
case model.Arm64:
log.Warn("Received request to boot an ARM64 machine, which has not been implemented yet.")
fallthrough
case machines.Unknown:
case model.Unknown:
fallthrough
default:
return nil
}
}

// ServeBootConfigurations actually responds to requests from pixiecore.
func (routes *Routes) ServeBootConfigurations(w http.ResponseWriter, r *http.Request) {
func (api *API) ServeBootConfigurations(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
mac := vars["mac"]

Expand All @@ -60,7 +62,7 @@ func (routes *Routes) ServeBootConfigurations(w http.ResponseWriter, r *http.Req

log.Infof("Serving boot config for %v at ip: %v", mac, addr)

m, err := routes.machineStore.GetMachine(mac)
m, err := api.store.GetMachineByMac(mac)
if err != nil {
log.Errorf("Couldn't find machine in store: %v", err)
w.WriteHeader(http.StatusNotFound)
Expand Down
Loading