Skip to content

Commit 753c616

Browse files
committed
Added a Qemu Packer builder, and adjusted Travis-CI to use it (though Travis-CI is still disabled, due to networking issues with Qemu that are to be solved).
1 parent 80e9b4e commit 753c616

File tree

6 files changed

+121
-74
lines changed

6 files changed

+121
-74
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
composer.phar
2-
vendor/
2+
vendor/
3+
/tests/vm/output-virtualbox-iso
4+
/tests/vm/output-qemu
5+
/tests/vm/packer_cache

.travis.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#
2-
# There's no way to use VirtualBox inside Travis-CI.
3-
# This file was an attempt in case Travis-CI did,
4-
# and it will be modified accordingly if a working way is found.
5-
# In the meantime, Travis-CI is disabled, and this file stands as more of a "how to"
6-
# for contributors wanting to make a testing environment.
2+
# Travis-CI is currently disabled due to difficulties with Qemu,
3+
# combined with the inability to use VirtualBox instead.
74
#
85
language: php
96
php:
@@ -21,37 +18,35 @@ env:
2118
addons:
2219
hosts:
2320
- 192.168.56.101 ros.example.com
24-
- 127.0.0.1 invalid.ros.example.com
25-
- 192.168.200.1 silent.ros.example.com
21+
- 192.168.56.2 invalid.ros.example.com
22+
- 192.168.56.98 silent.ros.example.com
2623
before_install:
2724
- sudo apt-get update
2825
- sudo apt-get install unzip
29-
- sudo apt-get install gdebi-core
30-
- wget -O ~/vbox.deb http://download.virtualbox.org/virtualbox/4.3.28/virtualbox-4.3_4.3.28-100309~Ubuntu~precise_i386.deb
3126
- wget -O ~/packer.zip https://dl.bintray.com/mitchellh/packer/packer_0.7.5_linux_amd64.zip
3227
install:
3328
# Install Packer
3429
- unzip ~/packer.zip -d ~/packer
3530
- export PATH=$PATH:~/packer
3631
# Install Apache
3732
- sudo apt-get install apache2
38-
# Install VirtualBox
39-
- sudo gdebi ~/vbox.deb
33+
# Install Qemu
34+
- sudo apt-get install qemu
4035
before_script:
4136
# Setup VM
4237
- cd tests/vm
43-
- packer build -var "v=${ROS_VERSION}" -var "h=${ROS_HASH}" RouterOS.packer.json
44-
- VBoxManage register output-virtualbox-iso/RouterOS-${ROS_VERSION}.ova
38+
- packer build -only=qemu -var "v=${ROS_VERSION}" -var "h=${ROS_HASH}" RouterOS.packer.json
4539
- cd ../..
4640
# Setup PHP dependencies
4741
- composer self-update
4842
- composer require pear2/net_transmitter:dev-develop
4943
- composer install
5044
# Configure Apache
51-
- echo "Listen 8728,8729" >> /etc/apache2/ports.conf
45+
- echo "Listen 8728" >> /etc/apache2/ports.conf
46+
- echo "Listen 8729" >> /etc/apache2/ports.conf
5247
script:
5348
- sudo service apache2 restart
54-
- VBoxManage startvm --type=headless "RouterOS-${ROS_VERSION}" &
55-
- sleep 15
5649
- cd tests
50+
- vm/RouterOS.qemu.sh &
51+
- sleep 20
5752
- ../vendor/bin/phpunit

docs/wiki

Submodule wiki updated from 282d4f9 to 1d60ee8

tests/vm/RouterOS.packer.json

Lines changed: 96 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,99 @@
11
{
2-
"variables": {
3-
"v": null,
4-
"h": null
5-
},
6-
"builders": [
7-
{
8-
"type": "virtualbox-iso",
9-
"headless": true,
10-
"vm_name": "RouterOS-{{user `v`}}",
11-
"guest_os_type": "Other",
12-
"disk_size": "1000",
13-
"vboxmanage": [
14-
["modifyvm", "{{.Name}}", "--memory", "128"],
15-
["modifyvm", "{{.Name}}", "--acpi", "on"],
16-
["modifyvm", "{{.Name}}", "--ioapic", "on"],
17-
["modifyvm", "{{.Name}}", "--hpet", "on"],
18-
["modifyvm", "{{.Name}}", "--rtcuseutc", "on"],
19-
["modifyvm", "{{.Name}}", "--pae", "on"],
20-
["modifyvm", "{{.Name}}", "--usb", "on"],
21-
["modifyvm", "{{.Name}}", "--usbehci", "off"],
22-
["modifyvm", "{{.Name}}", "--uart1", "0x3F8", "4"],
23-
24-
["modifyvm", "{{.Name}}", "--nic2", "nat"],
25-
["modifyvm", "{{.Name}}", "--cableconnected2", "on"],
26-
["modifyvm", "{{.Name}}", "--nic3", "null"],
27-
["modifyvm", "{{.Name}}", "--cableconnected3", "off"]
28-
],
29-
"iso_url": "http://download2.mikrotik.com/routeros/{{user `v`}}/mikrotik-{{user `v`}}.iso",
30-
"iso_checksum_type": "md5",
31-
"iso_checksum": "{{user `h`}}",
32-
"http_directory": ".",
33-
"boot_command": [
34-
"ainy<wait10><enter>",
35-
"<wait10><wait10><wait10><wait10>",
36-
"admin<enter><wait>",
37-
"<enter><wait>",
38-
"<enter><wait>",
39-
"/ip dhcp-client add disabled=no interface=ether1<enter>",
40-
"<wait5>",
2+
"variables": {
3+
"v": null,
4+
"h": null
5+
},
6+
"builders": [
7+
{
8+
"type": "virtualbox-iso",
9+
"headless": true,
10+
"vm_name": "RouterOS-{{user `v`}}",
11+
"disk_size": 512,
12+
"iso_url": "http://download2.mikrotik.com/routeros/{{user `v`}}/mikrotik-{{user `v`}}.iso",
13+
"iso_checksum_type": "md5",
14+
"iso_checksum": "{{user `h`}}",
15+
"http_directory": ".",
16+
"boot_command": [
17+
"ainy<wait10><enter>",
18+
"<wait10><wait10><wait10><wait10>",
19+
"admin<enter><wait>",
20+
"<enter><wait>",
21+
"<enter><wait5>",
22+
"/ip dhcp-client add disabled=no interface=ether1<enter>",
23+
"<wait5>",
24+
"/tool fetch url=\"http://{{ .HTTPIP }}:{{ .HTTPPort }}/RouterOS_SETTINGS.rsc\" keep-result=yes dst-path=\"RouterOS_SETTINGS.rsc\"<enter>",
25+
"<wait5>",
26+
"/import R<tab><enter>",
27+
"<wait5>"
28+
],
29+
"ssh_username": "admin",
30+
"ssh_password": "",
31+
"ssh_wait_timeout": "80s",
32+
"guest_os_type": "Other",
33+
"guest_additions_mode": "disable",
34+
"vboxmanage": [
35+
["modifyvm", "{{.Name}}", "--memory", "128"],
36+
["modifyvm", "{{.Name}}", "--acpi", "on"],
37+
["modifyvm", "{{.Name}}", "--ioapic", "on"],
38+
["modifyvm", "{{.Name}}", "--hpet", "on"],
39+
["modifyvm", "{{.Name}}", "--rtcuseutc", "on"],
40+
["modifyvm", "{{.Name}}", "--pae", "on"],
41+
["modifyvm", "{{.Name}}", "--usb", "on"],
42+
["modifyvm", "{{.Name}}", "--usbehci", "off"],
43+
["modifyvm", "{{.Name}}", "--uart1", "0x3F8", "4"],
4144

42-
"/tool fetch url=\"http://{{ .HTTPIP }}:{{ .HTTPPort }}/RouterOS_SETTINGS.rsc\" keep-result=yes dst-path=\"RouterOS_SETTINGS.rsc\"<enter>",
43-
"<wait5>",
44-
"/import R<tab><enter>",
45-
"<wait5>"
46-
],
47-
"guest_additions_mode": "disable",
48-
"ssh_username": "admin",
49-
"ssh_password": "",
50-
"ssh_wait_timeout": "80s",
51-
"vboxmanage_post": [
52-
["modifyvm", "{{.Name}}", "--nic1", "hostonly"],
53-
["modifyvm", "{{.Name}}", "--hostonlyadapter1", "VirtualBox Host-Only Ethernet Adapter"],
54-
["modifyvm", "{{.Name}}", "--cableconnected1", "on"]
55-
],
56-
"format": "ova"
57-
}
58-
]
45+
["modifyvm", "{{.Name}}", "--nic2", "nat"],
46+
["modifyvm", "{{.Name}}", "--cableconnected2", "on"],
47+
["modifyvm", "{{.Name}}", "--nic3", "null"],
48+
["modifyvm", "{{.Name}}", "--cableconnected3", "off"]
49+
],
50+
"vboxmanage_post": [
51+
["modifyvm", "{{.Name}}", "--nic1", "hostonly"],
52+
["modifyvm", "{{.Name}}", "--hostonlyadapter1", "VirtualBox Host-Only Ethernet Adapter"],
53+
["modifyvm", "{{.Name}}", "--cableconnected1", "on"]
54+
],
55+
"format": "ova"
56+
},
57+
{
58+
"type": "qemu",
59+
"headless": true,
60+
"vm_name": "RouterOS-{{user `v`}}",
61+
"disk_size": 512,
62+
"iso_url": "http://download2.mikrotik.com/routeros/{{user `v`}}/mikrotik-{{user `v`}}.iso",
63+
"iso_checksum_type": "md5",
64+
"iso_checksum": "{{user `h`}}",
65+
"http_directory": ".",
66+
"boot_command": [
67+
"ainy<wait10><enter>",
68+
"<wait10><wait10><wait10><wait10>",
69+
"<wait10><wait10><wait10><wait10>",
70+
"admin<enter><wait>",
71+
"<enter><wait>",
72+
"<enter><wait5>",
73+
"/ip dhcp-client add disabled=no interface=ether1<enter>",
74+
"<wait5>",
75+
"/tool fetch url=\"http://{{ .HTTPIP }}:{{ .HTTPPort }}/RouterOS_SETTINGS.rsc\" keep-result=yes dst-path=\"RouterOS_SETTINGS.rsc\"<enter>",
76+
"<wait5>",
77+
"/import R<tab><enter>",
78+
"<wait5>"
79+
],
80+
"ssh_username": "admin",
81+
"ssh_password": "",
82+
"ssh_wait_timeout": "80s",
83+
"ssh_host_port_min": 3213,
84+
"ssh_host_port_max": 3214,
85+
"accelerator": "tcg",
86+
"disk_interface": "ide",
87+
"qemuargs": [
88+
["-netdev", "user,id=user.0,hostfwd=tcp::3213-:22,hostfwd=tcp::3214-:22,net=10.0.2.0/24,host=10.0.2.2"],
89+
["-device", "virtio-net,netdev=user.0,mac=DE:AD:BE:EF:00:01"],
90+
["-netdev", "user,id=user.1"],
91+
["-device", "virtio-net,netdev=user.1,mac=DE:AD:BE:EF:00:02"],
92+
["-netdev", "user,id=user.2"],
93+
["-device", "virtio-net,netdev=user.2,mac=DE:AD:BE:EF:00:03"],
94+
["-m", "128M"]
95+
],
96+
"format": "raw"
97+
}
98+
]
5999
}

tests/vm/RouterOS.qemu.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:: TODO: Find a way to have the equivalent of VirtualBox's "host-only adapter",
2+
:: allowing separate IP addresses, so that the host could access the same ports,
3+
:: once on its own IP, and then those ports on the guest's IP.
4+
qemu-system-x86_64 "output-qemu\RouterOS-%ROS_VERSION%.raw" "-name" "RouterOS-%ROS_VERSION%" "-display" "sdl" "-machine" "type=pc,accel=tcg" "-netdev" "user,id=user.0,net=192.168.56.0/24,host=192.168.56.2,dhcpstart=192.168.56.101,hostfwd=tcp::38728-:8728" "-device" "virtio-net,netdev=user.0,mac=DE:AD:BE:EF:00:01" "-netdev" "user,id=user.1" "-device" "virtio-net,netdev=user.1,mac=DE:AD:BE:EF:00:02" "-netdev" "user,id=user.2" "-device" "virtio-net,netdev=user.2,mac=DE:AD:BE:EF:00:03" "-m" "128M"

tests/vm/RouterOS.qemu.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
# TODO: Find a way to have the equivalent of VirtualBox's "host-only adapter",
3+
# allowing separate IP addresses, so that the host could access the same ports,
4+
# once on its own IP, and then those ports on the guest's IP.
5+
qemu-system-x86_64 "output-qemu/RouterOS-${ROS_VERSION}.raw" "-name" "RouterOS-${ROS_VERSION}" "-display" "sdl" "-machine" "type=pc,accel=tcg" "-netdev" "user,id=user.0,net=192.168.56.0/24,host=192.168.56.2,dhcpstart=192.168.56.101,hostfwd=tcp::38728-:8728" "-device" "virtio-net,netdev=user.0,mac=DE:AD:BE:EF:00:01" "-netdev" "user,id=user.1" "-device" "virtio-net,netdev=user.1,mac=DE:AD:BE:EF:00:02" "-netdev" "user,id=user.2" "-device" "virtio-net,netdev=user.2,mac=DE:AD:BE:EF:00:03" "-m" "128M"

0 commit comments

Comments
 (0)