summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Wise <phil@advancedtelematic.com>2018-03-19 16:31:31 +0100
committerPhil Wise <phil@advancedtelematic.com>2018-03-19 16:31:31 +0100
commitfc8f9b4b1721a029a30bf41e6086cfbff085089d (patch)
tree1251f3656efe0504f1cefec590fe2a6280a1e5ac
parentc3c8d56af6daac3c1eb38118f683db430af48d63 (diff)
downloadmeta-updater-fc8f9b4b1721a029a30bf41e6086cfbff085089d.tar.gz
Add a --secondary-network option to run-qemu-ota
This sets up a simulated 'in vehicle' network. Add support for a Primary node with a DHCP server and a secondary node with a DHCP client.
-rw-r--r--recipes-test/demo-network-config/files/25-dhcp-server.network12
-rw-r--r--recipes-test/demo-network-config/files/26-dhcp-client.network6
-rw-r--r--recipes-test/demo-network-config/primary-network-config.bb16
-rw-r--r--recipes-test/demo-network-config/secondary-network-config.bb16
-rw-r--r--recipes-test/images/primary-image.bb12
-rw-r--r--recipes-test/images/secondary-image.bb5
-rw-r--r--scripts/qemucommand.py6
-rwxr-xr-xscripts/run-qemu-ota3
8 files changed, 75 insertions, 1 deletions
diff --git a/recipes-test/demo-network-config/files/25-dhcp-server.network b/recipes-test/demo-network-config/files/25-dhcp-server.network
new file mode 100644
index 0000000..4766f9a
--- /dev/null
+++ b/recipes-test/demo-network-config/files/25-dhcp-server.network
@@ -0,0 +1,12 @@
1[Match]
2Name=enp0s4
3
4[Network]
5Description=Private internal network between aktualizr Primary and Secondary nodes
6DHCPServer=yes
7Address=10.0.3.1/24
8IPForward=yes
9IPMasquerade=yes
10
11[DHCPServer]
12PoolOffset=10 \ No newline at end of file
diff --git a/recipes-test/demo-network-config/files/26-dhcp-client.network b/recipes-test/demo-network-config/files/26-dhcp-client.network
new file mode 100644
index 0000000..319664f
--- /dev/null
+++ b/recipes-test/demo-network-config/files/26-dhcp-client.network
@@ -0,0 +1,6 @@
1[Match]
2Name=enp0s4
3
4[Network]
5Description=Private internal network between aktualizr Primary and Secondary nodes
6DHCP=yes
diff --git a/recipes-test/demo-network-config/primary-network-config.bb b/recipes-test/demo-network-config/primary-network-config.bb
new file mode 100644
index 0000000..78678a2
--- /dev/null
+++ b/recipes-test/demo-network-config/primary-network-config.bb
@@ -0,0 +1,16 @@
1DESCRIPTION = "Sample network configuration for an Uptane Primary"
2LICENSE = "CLOSED"
3
4inherit allarch
5
6SRC_URI = "file://25-dhcp-server.network"
7
8
9FILES_${PN} = "/usr/lib/systemd/network"
10
11PR = "1"
12
13do_install() {
14 install -d ${D}/usr/lib/systemd/network
15 install -m 0644 ${WORKDIR}/25-dhcp-server.network ${D}/usr/lib/systemd/network/
16}
diff --git a/recipes-test/demo-network-config/secondary-network-config.bb b/recipes-test/demo-network-config/secondary-network-config.bb
new file mode 100644
index 0000000..492d3ca
--- /dev/null
+++ b/recipes-test/demo-network-config/secondary-network-config.bb
@@ -0,0 +1,16 @@
1DESCRIPTION = "Sample network configuration for an Uptane Secondary"
2LICENSE = "CLOSED"
3
4inherit allarch
5
6SRC_URI = "file://26-dhcp-client.network"
7
8
9FILES_${PN} = "/usr/lib/systemd/network"
10
11PR = "1"
12
13do_install() {
14 install -d ${D}/usr/lib/systemd/network
15 install -m 0644 ${WORKDIR}/26-dhcp-client.network ${D}/usr/lib/systemd/network/
16}
diff --git a/recipes-test/images/primary-image.bb b/recipes-test/images/primary-image.bb
new file mode 100644
index 0000000..6c06527
--- /dev/null
+++ b/recipes-test/images/primary-image.bb
@@ -0,0 +1,12 @@
1include recipes-core/images/core-image-minimal.bb
2
3SUMMARY = "A minimal Uptane Primary image running aktualizr, for testing with a Linux secondary"
4
5LICENSE = "MIT"
6
7IMAGE_INSTALL_remove = " \
8 "
9
10IMAGE_INSTALL_append = " \
11 primary-network-config \
12 "
diff --git a/recipes-test/images/secondary-image.bb b/recipes-test/images/secondary-image.bb
index c7a91db..c1ce57a 100644
--- a/recipes-test/images/secondary-image.bb
+++ b/recipes-test/images/secondary-image.bb
@@ -15,4 +15,7 @@ IMAGE_INSTALL_remove = " \
15 aktualizr-implicit-prov \ 15 aktualizr-implicit-prov \
16 " 16 "
17 17
18IMAGE_INSTALL_append = " aktualizr-secondary " \ No newline at end of file 18IMAGE_INSTALL_append = " \
19 aktualizr-secondary \
20 secondary-network-config \
21 "
diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py
index 6b1106d..e209a07 100644
--- a/scripts/qemucommand.py
+++ b/scripts/qemucommand.py
@@ -81,6 +81,7 @@ class QemuCommand(object):
81 self.gdb = args.gdb 81 self.gdb = args.gdb
82 self.pcap = args.pcap 82 self.pcap = args.pcap
83 self.overlay = args.overlay 83 self.overlay = args.overlay
84 self.secondary_network = args.secondary_network
84 85
85 def command_line(self): 86 def command_line(self):
86 netuser = 'user,hostfwd=tcp:0.0.0.0:%d-:22,restrict=off' % self.ssh_port 87 netuser = 'user,hostfwd=tcp:0.0.0.0:%d-:22,restrict=off' % self.ssh_port
@@ -104,6 +105,11 @@ class QemuCommand(object):
104 ] 105 ]
105 if self.pcap: 106 if self.pcap:
106 cmdline += ['-net', 'dump,file=' + self.pcap] 107 cmdline += ['-net', 'dump,file=' + self.pcap]
108 if self.secondary_network:
109 cmdline += [
110 '-net', 'nic,vlan=1,macaddr='+random_mac(),
111 '-net', 'socket,vlan=1,mcast=230.0.0.1:1234',
112 ]
107 if self.gui: 113 if self.gui:
108 cmdline += ["-serial", "stdio"] 114 cmdline += ["-serial", "stdio"]
109 else: 115 else:
diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota
index 56e4fbc..b2f55e9 100755
--- a/scripts/run-qemu-ota
+++ b/scripts/run-qemu-ota
@@ -33,6 +33,9 @@ def main():
33 help='Use an overlay storage image file. Will be created if it does not exist. ' + 33 help='Use an overlay storage image file. Will be created if it does not exist. ' +
34 'This option lets you have a persistent image without modifying the underlying image ' + 34 'This option lets you have a persistent image without modifying the underlying image ' +
35 'file, permitting multiple different persistent machines.') 35 'file, permitting multiple different persistent machines.')
36 parser.add_argument('--secondary-network', action='store_true', dest='secondary_network',
37 help='Give the image a second network card connected to a virtual network. ' +
38 'This can be used to test Uptane Primary/Secondary communication.')
36 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true') 39 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true')
37 args = parser.parse_args() 40 args = parser.parse_args()
38 try: 41 try: