-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michio Honda
committed
Nov 3, 2020
1 parent
33e6e55
commit 076d41c
Showing
8 changed files
with
289 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: python | ||
python: | ||
- "3.8" | ||
install: | ||
- pip install -r requirements.txt | ||
- mkdir -p test_tftpboot/pxelinux.cfg | ||
- mkdir -p test_tftpboot/loaders/base | ||
- touch test_tftpboot/loaders/base/n01 | ||
- touch test_tftpboot/loaders/base/n02 | ||
- touch test_tftpboot/loaders/base/n03 | ||
- mkdir test_tftpboot/loaders/`whoami` | ||
- touch test_tftpboot/loaders/`whoami`/n01 | ||
- touch test_tftpboot/loaders/`whoami`/n02 | ||
- touch test_tftpboot/loaders/`whoami`/n03 | ||
- touch test_tmdb.json | ||
script: | ||
- pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# tm - testbed manager | ||
[](https://travis-ci.org/micchie/tm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
python-ipmi | ||
pandas | ||
tinydb | ||
pathlib |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from tm import Tm | ||
import shlex | ||
from re import search | ||
from datetime import datetime, timedelta | ||
|
||
n01 = 'tm inventory add --mac 00:00:00:00:12:36 --ip=192.168.0.14 --ipmiaddr 192.168.0.114 --ipmipass root,root --cpu "E3-1220v2" --ram 16 --nic "x520-DA2" n01' | ||
n02 = 'tm inventory add --mac 00:00:00:00:12:37 --ip=192.168.0.15 --ipmiaddr 192.168.0.115 --ipmipass root,root --cpu "E3-1220v2" --ram 8 --nic "x520-DA2" n02' | ||
n03 = 'tm inventory add --mac 00:00:00:00:12:38 --ip=192.168.0.16 --ipmiaddr 192.168.0.116 --ipmipass root,root --cpu "E3-1220v2" --ram 4 --nic "N/A" n03' | ||
addnodes = [n01, n02, n03] | ||
|
||
dbf = './test_tmdb.json' | ||
tfb = './test_tftpboot' | ||
|
||
ret_rsv_date_past = 'date must be on or later than today' | ||
ret_rsv_in_use = 'node in use' | ||
ret_rsv_success = 'reserve successful' | ||
ret_rsv_update_success = 'update successful' | ||
ret_rsv_release_success = 'release successful' | ||
|
||
def test_all(): | ||
out = Tm(shlex.split('tm inventory show'), dbfile=dbf, tftpboot=tfb).output | ||
assert search('no db entry', out) | ||
|
||
for a in addnodes: | ||
out = Tm(shlex.split(a), dbfile=dbf, tftpboot=tfb).output | ||
assert search('success', out) | ||
out = Tm(shlex.split('tm inventory show --addr --devices'), dbfile=dbf, tftpboot=tfb).output | ||
for n in ['n01', 'n02', 'n03']: | ||
assert n in out['node'].values | ||
for i in ['mac', 'ip', 'ipmiaddr', 'ipmipass', 'cpu', 'ram']: | ||
assert len(out[i].values) == 3 | ||
|
||
now = datetime.now().date() | ||
nowm1 = now + timedelta(days=-1) | ||
nowm1_s = datetime.strftime(nowm1, '%d/%m/%y') | ||
nowp1 = now + timedelta(days=1) | ||
nowp1_s = datetime.strftime(nowp1, '%d/%m/%y') | ||
nowp10 = now + timedelta(days=10) | ||
nowp10_s = datetime.strftime(nowp10, '%d/%m/%y') | ||
|
||
out = Tm(shlex.split('tm reservation reserve n01 {}'.format(nowm1_s)), | ||
dbfile=dbf, tftpboot=tfb).output | ||
assert search(ret_rsv_date_past, out) | ||
|
||
out = Tm(shlex.split('tm reservation reserve n01 {}'.format(nowp1_s)), | ||
dbfile=dbf, tftpboot=tfb).output | ||
assert search(ret_rsv_success, out) | ||
|
||
out = Tm(shlex.split('tm reservation reserve n01 {}'.format(nowm1_s)), | ||
dbfile=dbf, tftpboot=tfb).output | ||
assert search(ret_rsv_in_use, out) | ||
|
||
out = Tm(shlex.split('tm reservation update n01 {}'.format(nowp10_s)), | ||
dbfile=dbf, tftpboot=tfb).output | ||
assert search(ret_rsv_update_success, out) | ||
|
||
out = Tm(shlex.split('tm reservation release n01'), | ||
dbfile=dbf, tftpboot=tfb).output | ||
assert search(ret_rsv_release_success, out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[Unit] | ||
Description=Clean up tm reservations expired | ||
ConditionACPower=true | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/local/bin/tm reservation clean | ||
User=root | ||
ProtectSystem=strict | ||
ReadWritePaths=/usr/local/tm | ||
Nice=19 | ||
IOSchedulingClass=best-effort | ||
IOSchedulingPriority=7 | ||
ProtectControlGroups=true | ||
ProtectKernelModules=true | ||
RestrictRealtime=true | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Daily tm cleanup of expired reservations | ||
|
||
[Timer] | ||
OnCalendar=daily | ||
AccuracySec=1h | ||
Persistent=true | ||
|
||
[Install] | ||
WantedBy=timers.target |
Oops, something went wrong.