[elbe-devel] [PATCH 1/3] config: allow to configure initvm sshport and obey soapport on initvm create

Torben Hohn torben.hohn at linutronix.de
Tue Sep 3 12:07:37 CEST 2019


ELBE_SOAPPORT is not honoured in "elbe initvm create"

remove the portforwards for both ssh and soap ports from default-init.xml
and generate the ports from ELBE_SOAPPORT and ELBE_SSHPORT now.

also allow empty forwards section in dbsfed.xsd.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/config.py             |  4 ++++
 elbepack/init/default-init.xml | 10 ----------
 elbepack/init/libvirt.xml.mako |  4 ++++
 schema/dbsfed.xsd              |  2 +-
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/elbepack/config.py b/elbepack/config.py
index 4c485822f..7ef2910f9 100644
--- a/elbepack/config.py
+++ b/elbepack/config.py
@@ -13,6 +13,7 @@ class Config(dict):
         dict.__init__(self)
         self['soaphost'] = "localhost"
         self['soapport'] = "7587"
+        self['sshport'] = "5022"
         self['elbeuser'] = "root"
         self['elbepass'] = "foo"
         self['pbuilder_jobs'] = "auto"
@@ -21,6 +22,9 @@ class Config(dict):
         if 'ELBE_SOAPPORT' in os.environ:
             self['soapport'] = os.environ['ELBE_SOAPPORT']
 
+        if 'ELBE_SSHPORT' in os.environ:
+            self['sshport'] = os.environ['ELBE_SSHPORT']
+
         if 'ELBE_SOAPHOST' in os.environ:
             self['soaphost'] = os.environ['ELBE_SOAPHOST']
 
diff --git a/elbepack/init/default-init.xml b/elbepack/init/default-init.xml
index ebca55bea..f6b306dbe 100644
--- a/elbepack/init/default-init.xml
+++ b/elbepack/init/default-init.xml
@@ -51,16 +51,6 @@
 		<swap-size>10GiB</swap-size>
 		<img>qcow2</img>
 		<portforwarding>
-			<forward>
-				<proto>tcp</proto>
-				<buildenv>22</buildenv>
-				<host>5022</host>
-			</forward>
-			<forward>
-				<proto>tcp</proto>
-				<buildenv>7588</buildenv>
-				<host>7587</host>
-			</forward>
 		</portforwarding>
 	</initvm>
 </ns0:RootFileSystem>
diff --git a/elbepack/init/libvirt.xml.mako b/elbepack/init/libvirt.xml.mako
index c33609e73..a0e1f2ef9 100644
--- a/elbepack/init/libvirt.xml.mako
+++ b/elbepack/init/libvirt.xml.mako
@@ -33,6 +33,10 @@ for f in prj.node("portforwarding"):
     forward += ',hostfwd=%s::%s-:%s' % (
         f.text("proto"), f.text("host"), f.text("buildenv"))
 
+forward += ',hostfwd=%s::%s-:%s' % ("tcp", cfg['soapport'], "7588")
+if cfg['sshport'] != '-1':
+    forward += ',hostfwd=%s::%s-:%s' % ("tcp", cfg['sshport'], "22")
+
 %><domain type='kvm'
 xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
 <name>${name}</name>
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index 14789d4e7..930ba8b69 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -744,7 +744,7 @@
       </documentation>
     </annotation>
     <sequence>
-      <element name="forward" type="rfs:forward" minOccurs="1" maxOccurs="unbounded">
+      <element name="forward" type="rfs:forward" minOccurs="0" maxOccurs="unbounded">
         <annotation>
           <documentation>
             describes a single port forward
-- 
2.11.0




More information about the elbe-devel mailing list