Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bird-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
labs
bird-tools
Commits
ae07c9e8
Commit
ae07c9e8
authored
Dec 02, 2015
by
Maria Matejka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Random control IPs and MACs
parent
7640a123
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
74 additions
and
54 deletions
+74
-54
.gitignore
.gitignore
+5
-0
bin/omapi
bin/omapi
+23
-0
bin/prepare
bin/prepare
+2
-0
bin/reload
bin/reload
+0
-2
bin/start
bin/start
+2
-0
bin/status
bin/status
+7
-1
bin/stop
bin/stop
+1
-1
bin/virt-lib
bin/virt-lib
+9
-2
etc/dhcpd-hosts.conf
etc/dhcpd-hosts.conf
+0
-8
etc/dhcpd.conf
etc/dhcpd.conf
+10
-1
etc/virtlist
etc/virtlist
+15
-39
No files found.
.gitignore
0 → 100644
View file @
ae07c9e8
img/*
iso/*
run/*
nfs/*
bin/socat
bin/omapi
0 → 100755
View file @
ae07c9e8
#!/usr/bin/env python
import
pypureomapi
import
sys
keyname
=
"dhcp_key"
#secret = "6Qsf2UG4cvSli+Fup3bHI/4lCGO4i3SO6hl6WWBr042vUHktQ/1KiQwI 3MQrNrGs7c7EMDr/fho2Fzr3y1EP/Q=="
secret
=
"3MQrNrGs7c7EMDr/fho2Fzr3y1EP/Q=="
server
=
"127.0.0.1"
port
=
7911
try
:
oma
=
pypureomapi
.
Omapi
(
server
,
port
,
keyname
,
secret
,
debug
=
False
)
except
pypureomapi
.
OmapiError
,
err
:
print
"OMAPI error: %s"
%
(
err
,)
sys
.
exit
(
1
)
if
sys
.
argv
[
1
]
==
"add"
:
oma
.
add_host
(
sys
.
argv
[
3
],
sys
.
argv
[
2
])
elif
sys
.
argv
[
1
]
==
"del"
:
oma
.
del_host
(
sys
.
argv
[
2
])
else
:
print
(
"Usage: omapi (add MAC IP|del MAC)"
)
bin/prepare
View file @
ae07c9e8
...
...
@@ -18,3 +18,5 @@ iptables -A FORWARD -i eth0 -o $VIRTCTRL -m state --state RELATED,ESTABLISHED -j
iptables
-A
FORWARD
-i
eth0
-o
$VIRTCTRL
-j
ACCEPT
iptables
-A
FORWARD
-i
$VIRTCTRL
-o
eth0
-j
ACCEPT
iptables
-A
FORWARD
-o
eth0
-j
REJECT
dhcpd
-cf
$ROOT
/etc/dhcpd.conf
-pf
$ROOT
/run/dhcpd.pid
$VIRTCTRL
bin/reload
View file @
ae07c9e8
#!/bin/bash
.
$(
dirname
$(
readlink
-f
$0
))
/virt-lib
egrep
-i
'^\s*Network'
<
$VIRTUALS
|
sed
-r
's/.*[Nn][Ee][Tt][Ww][Oo][Rr][Kk]\s+(.*)\s+(.*)\s+(.*)$/host \1 { hardware ethernet \2; fixed-address \3; }/'
>
$ROOT
/etc/dhcpd-hosts.conf
[
-f
$ROOT
/run/dhcpd.pid
]
&&
kill
$(
cat
$ROOT
/run/dhcpd.pid
)
dhcpd
-cf
$ROOT
/etc/dhcpd.conf
-pf
$ROOT
/run/dhcpd.pid
$VIRTCTRL
bin/start
View file @
ae07c9e8
...
...
@@ -35,6 +35,8 @@ fi
#echo -e "IP4:\t\t$HOSTIP4"
#echo -e "TAP:\t\t$HOSTTAP"
$ROOT
/bin/omapi add
$HOSTMAC
$HOSTIP4
qemu-system-
$HOSTARCH
-enable-kvm
-m
$HOSTMEMORY
${
HOSTCDROM
:+-cdrom
$ROOT
/iso/
$HOSTCDROM
-boot d
}
-hda
$ROOT
/img/
$HOSTIMAGE
$HOSTCOW
-display
none
${
HOSTVNCID
:+-vnc
10.0.0.11
:
$HOSTVNCID
}
-netdev
tap,id
=
ctl,ifname
=
$HOSTTAP
,script
=
no
-device
e1000,netdev
=
ctl,mac
=
$HOSTMAC
-pidfile
$ROOT
/run/
$NAME
.pid
-monitor
unix:
$ROOT
/run/
$NAME
.sock,server,nowait
-daemonize
"
$@
"
#-runas $VIRTUSER
...
...
bin/status
View file @
ae07c9e8
...
...
@@ -7,7 +7,13 @@ seen[dhcpd]=1
for
S
in
`
find
$ROOT
/run
-name
'*.sock'
`
;
do
S
=
$(
basename
$S
)
gethost
${
S
%%.sock
}
echo
"
${
S
%%.sock
}
running, IPv4
$HOSTIP4
, monitor
$S
"
if
ping
-nc1
$HOSTIP4
>
/dev/null
;
then
PING
=
"(ping ok)"
else
PING
=
"(ping FAIL)"
fi
echo
"
${
S
%%.sock
}
running, IPv4
$HOSTIP4
$PING
, monitor
$S
"
seen[
"
${
S
%%.sock
}
"
]=
1
done
...
...
bin/stop
View file @
ae07c9e8
...
...
@@ -13,7 +13,7 @@ function ok() {
echo
rm
-f
$ROOT
/run/
$NAME
.sock
$ROOT
/run/
$NAME
.pid
if
gethost
$NAME
;
then
vsctl del-port
$VIRTBR
$HOSTTAP
$ROOT
/bin/omapi del
$HOSTMAC
else
echo
"Warning: Config not found for this host"
fi
...
...
bin/virt-lib
View file @
ae07c9e8
...
...
@@ -84,7 +84,6 @@ function gethost() {
function
hostdefaults
()
{
if
[
-z
"
$HOSTIMAGE
"
]
;
then
echo
"Error: Image not set"
;
return
1
;
fi
if
[
-z
"
$HOSTNETWORK
"
]
;
then
echo
"Error: No control network set"
;
return
1
;
fi
if
[
-z
"
$HOSTARCH
"
]
;
then
HOSTARCH
=
x86_64
;
fi
if
[
-z
"
$HOSTMEMORY
"
]
;
then
HOSTMEMORY
=
64M
;
fi
if
[
"
${
HOSTCOW
^^
}
"
=
"YES"
]
;
then
HOSTCOW
=
-snapshot
;
else
HOSTCOW
=
;
fi
...
...
@@ -94,7 +93,15 @@ function hostdefaults() {
NICMAC
=
${
NIC
##*
}
done
read
HOSTTAP HOSTMAC HOSTIP4
<<<
"
$HOSTNETWORK
"
if
[
-z
"
$HOSTNETWORK
"
]
;
then
local
SHA
=
$(
sha1sum
<<<
"
$HOSTNAME
"
|
head
-c
12
)
HOSTTAP
=
vc-
$SHA
HOSTMAC
=
02:
$(
sed
-r
's/^.*(..)(..)(..)(..)(..)$/\1:\2:\3:\4:\5/'
<<<
"
$SHA
"
)
HOSTIP4
=
192.168.
$((
193
+((
0
x
$SHA
/
254
)
%
63
))
)
.
$((
0
x
$SHA
%
254
))
else
read
HOSTTAP HOSTMAC HOSTIP4
<<<
"
$HOSTNETWORK
"
fi
return
0
}
...
...
etc/dhcpd-hosts.conf
deleted
100644 → 0
View file @
7640a123
host
tci
-
freebsd10
{
hardware
ethernet
00
:
11
:
22
:
00
:
05
:
01
;
fixed
-
address
192
.
168
.
197
.
1
; }
host
tci
-
debian8
{
hardware
ethernet
00
:
11
:
22
:
00
:
01
:
01
;
fixed
-
address
192
.
168
.
193
.
1
; }
host
tci
-
debian5
{
hardware
ethernet
00
:
11
:
22
:
00
:
01
:
02
;
fixed
-
address
192
.
168
.
193
.
2
; }
host
tci
-
fb10
-
1
{
hardware
ethernet
00
:
11
:
22
:
00
:
15
:
01
;
fixed
-
address
192
.
168
.
200
.
1
; }
host
tci
-
fb10
-
2
{
hardware
ethernet
00
:
11
:
22
:
00
:
15
:
02
;
fixed
-
address
192
.
168
.
200
.
2
; }
host
tcd8
-
1
{
hardware
ethernet
00
:
11
:
22
:
00
:
11
:
01
;
fixed
-
address
192
.
168
.
210
.
1
; }
host
tcd8
-
2
{
hardware
ethernet
00
:
11
:
22
:
00
:
11
:
11
;
fixed
-
address
192
.
168
.
210
.
2
; }
host
tcd8
-
3
{
hardware
ethernet
00
:
11
:
22
:
00
:
11
:
21
;
fixed
-
address
192
.
168
.
210
.
3
; }
etc/dhcpd.conf
View file @
ae07c9e8
...
...
@@ -14,4 +14,13 @@ subnet 192.168.192.0 netmask 255.255.192.0 {
default
-
lease
-
time
15555555
;
}
include
"/var/lib/virt/etc/dhcpd-hosts.conf"
;
key
dhcp_key
{
algorithm
HMAC
-
MD5
;
secret
"3MQrNrGs7c7EMDr/fho2Fzr3y1EP/Q=="
;
}
#6Qsf2UG4cvSli+Fup3bHI/4lCGO4i3SO6hl6WWBr042vUHktQ/1KiQwI
omapi
-
port
7911
;
omapi
-
key
dhcp_key
;
#include "/var/lib/virt/etc/dhcpd-hosts.conf";
etc/virtlist
View file @
ae07c9e8
Host freebsd10-install
Image freebsd10
Network tci-freebsd10 00:11:22:00:05:01 192.168.197.1
Memory 512M
# Cdrom freebsd10.iso
VNC 51
Type freebsd
Host freebsd10
Image freebsd10
Memory 512M
Type freebsd
Cow yes
Host debian8-install
Image debian8
Network tci-debian8 00:11:22:00:01:01 192.168.193.1
Memory 512M
# Cdrom debian8.iso
VNC 11
Type linux
Host debian5-install
Image debian5
Network tci-debian5 00:11:22:00:01:02 192.168.193.2
Memory 512M
# Cdrom debian5.iso
VNC 12
Type linux
Host fb10-1
Image freebsd10
Network tci-fb10-1 00:11:22:00:15:01 192.168.200.1
Memory 128M
VNC 101
Cow yes
Type freebsd
Host fb10-2
Image freebsd10
Network tci-fb10-2 00:11:22:00:15:02 192.168.200.2
Memory 2G
Cow yes
Type freebsd
Host d8-1
Host debian8
Image debian8
Network tcd8-1 00:11:22:00:11:01 192.168.210.1
Memory 128M
Memory 512M
Type linux
Cow yes
Host d
8-2
Image debian
8
Network tcd8-2 00:11:22:00:11:11 192.168.210.2
Memory 128M
Host d
ebian5-install
Image debian
5
Memory 512M
VNC 12
Type linux
Cow yes
Host d8-3
Image debian8
Network tcd8-3 00:11:22:00:11:21 192.168.210.3
Memory 128M
Host debian5
Image debian5
Memory 512M
Type linux
Cow yes
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment