From ee23fa2bcae2fd793d62a531cb5ae0c9272d8a97 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Thu, 16 May 2019 22:47:12 +0300 Subject: OTA-2541: Static IP address on Primary's and Secondary's internal NIC Signed-off-by: Mike Sul --- .../files/26-static-client.network | 7 +++++++ .../demo-network-config/primary-network-config.bb | 13 ++++++++++--- .../demo-network-config/secondary-network-config.bb | 13 ++++++++++--- .../demo-network-config/static-network-config.inc | 16 ++++++++++++++++ .../demo-secondary-config/files/30-fake_pacman.toml | 2 ++ .../demo-secondary-config/secondary-config.bb | 20 ++++++++++++++++++++ recipes-test/images/primary-image.bb | 1 + recipes-test/images/secondary-image.bb | 1 + scripts/qemucommand.py | 4 ++-- 9 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 recipes-test/demo-network-config/files/26-static-client.network create mode 100644 recipes-test/demo-network-config/static-network-config.inc create mode 100644 recipes-test/demo-secondary-config/files/30-fake_pacman.toml create mode 100644 recipes-test/demo-secondary-config/secondary-config.bb diff --git a/recipes-test/demo-network-config/files/26-static-client.network b/recipes-test/demo-network-config/files/26-static-client.network new file mode 100644 index 0000000..19a6b83 --- /dev/null +++ b/recipes-test/demo-network-config/files/26-static-client.network @@ -0,0 +1,7 @@ +[Match] +Name=@IFNAME@ + +[Network] +Description=Private internal network between aktualizr Primary and Secondary nodes +Address=@ADDR@ +DHCP=no diff --git a/recipes-test/demo-network-config/primary-network-config.bb b/recipes-test/demo-network-config/primary-network-config.bb index 78678a2..ce19f07 100644 --- a/recipes-test/demo-network-config/primary-network-config.bb +++ b/recipes-test/demo-network-config/primary-network-config.bb @@ -3,8 +3,9 @@ LICENSE = "CLOSED" inherit allarch -SRC_URI = "file://25-dhcp-server.network" - +SRC_URI = "\ + file://27-dhcp-client-external.network \ + " FILES_${PN} = "/usr/lib/systemd/network" @@ -12,5 +13,11 @@ PR = "1" do_install() { install -d ${D}/usr/lib/systemd/network - install -m 0644 ${WORKDIR}/25-dhcp-server.network ${D}/usr/lib/systemd/network/ + install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/ } + +SECONDARY_NETWORK_IP_ADDR ?= "10.0.3.1" + +require static-network-config.inc + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/recipes-test/demo-network-config/secondary-network-config.bb b/recipes-test/demo-network-config/secondary-network-config.bb index 9091c65..6473e05 100644 --- a/recipes-test/demo-network-config/secondary-network-config.bb +++ b/recipes-test/demo-network-config/secondary-network-config.bb @@ -3,18 +3,25 @@ LICENSE = "CLOSED" inherit allarch +# TODO: It configures the 'user' interface in NAT mode and provides an access to public Inet via it +# which is not desired for Secondary. It cannot be just removed since we get SSH access to Secondary +# VM via this interface. So, the task is to configure the interface in such way that it does provide access +# via SSH from a host machine and forbids an access to Inet SRC_URI = "\ - file://26-dhcp-client.network \ file://27-dhcp-client-external.network \ " - FILES_${PN} = "/usr/lib/systemd/network" PR = "1" do_install() { install -d ${D}/usr/lib/systemd/network - install -m 0644 ${WORKDIR}/26-dhcp-client.network ${D}/usr/lib/systemd/network/ install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/ } + +SECONDARY_NETWORK_IP_ADDR ?= "10.0.3.2" + +require static-network-config.inc + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/recipes-test/demo-network-config/static-network-config.inc b/recipes-test/demo-network-config/static-network-config.inc new file mode 100644 index 0000000..27d2a20 --- /dev/null +++ b/recipes-test/demo-network-config/static-network-config.inc @@ -0,0 +1,16 @@ +SRC_URI_append = "\ + file://26-static-client.network \ + " + +SECONDARY_NETWORK_INTERFACE_NAME ?= "enp0s5" + +do_install_append() { + install -d ${D}/usr/lib/systemd/network + install -m 0644 ${WORKDIR}/26-static-client.network ${D}/usr/lib/systemd/network/ + sed -i -e 's|@ADDR@|${SECONDARY_NETWORK_IP_ADDR}|g' \ + -e 's|@IFNAME@|${SECONDARY_NETWORK_INTERFACE_NAME}|g' \ + ${D}/usr/lib/systemd/network/26-static-client.network + +} + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/recipes-test/demo-secondary-config/files/30-fake_pacman.toml b/recipes-test/demo-secondary-config/files/30-fake_pacman.toml new file mode 100644 index 0000000..3fb5cf2 --- /dev/null +++ b/recipes-test/demo-secondary-config/files/30-fake_pacman.toml @@ -0,0 +1,2 @@ +[pacman] +type = "fake" diff --git a/recipes-test/demo-secondary-config/secondary-config.bb b/recipes-test/demo-secondary-config/secondary-config.bb new file mode 100644 index 0000000..3187ff0 --- /dev/null +++ b/recipes-test/demo-secondary-config/secondary-config.bb @@ -0,0 +1,20 @@ +DESCRIPTION = "Sample configuration for an Uptane Secondary" +LICENSE = "CLOSED" + +inherit allarch + +SRC_URI = "\ + file://30-fake_pacman.toml \ + " + +do_install () { + install -m 0700 -d ${D}${libdir}/sota/conf.d + install -m 0644 ${WORKDIR}/30-fake_pacman.toml ${D}/${libdir}/sota/conf.d/30-fake_pacman.toml +} + +FILES_${PN} = " \ + ${libdir}/sota/conf.d \ + ${libdir}/sota/conf.d/30-fake_pacman.toml \ + " + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/recipes-test/images/primary-image.bb b/recipes-test/images/primary-image.bb index 6d2df94..ac14233 100644 --- a/recipes-test/images/primary-image.bb +++ b/recipes-test/images/primary-image.bb @@ -5,6 +5,7 @@ SUMMARY = "A minimal Uptane Primary image running aktualizr, for testing with a LICENSE = "MIT" IMAGE_INSTALL_remove = " \ + virtual/network-configuration \ " IMAGE_INSTALL_append = " \ diff --git a/recipes-test/images/secondary-image.bb b/recipes-test/images/secondary-image.bb index 61df85b..46be3d1 100644 --- a/recipes-test/images/secondary-image.bb +++ b/recipes-test/images/secondary-image.bb @@ -21,6 +21,7 @@ IMAGE_INSTALL_remove = " \ IMAGE_INSTALL_append = " \ aktualizr-secondary \ secondary-network-config \ + secondary-config \ " # vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py index cafab6d..1049d7c 100644 --- a/scripts/qemucommand.py +++ b/scripts/qemucommand.py @@ -109,8 +109,8 @@ class QemuCommand(object): cmdline += ['-net', 'dump,file=' + self.pcap] if self.secondary_network: cmdline += [ - '-net', 'nic,vlan=1,macaddr='+random_mac(), - '-net', 'socket,vlan=1,mcast=230.0.0.1:1234,localaddr=127.0.0.1', + '-netdev', 'socket,id=vlan1,mcast=230.0.0.1:1234,localaddr=127.0.0.1', + '-device', 'e1000,netdev=vlan1,mac='+random_mac(), ] if self.gui: cmdline += ["-serial", "stdio"] -- cgit v1.2.3-54-g00ecf