From 3348a7ce348de9cae9a49742b5edce4606059178 Mon Sep 17 00:00:00 2001
From: Alain Takoudjou <talino@tiolive.com>
Date: Wed, 4 Mar 2015 10:28:09 +0100
Subject: [PATCH] publish guest vm network information, if exists

---
 software/kvm/common.cfg              | 2 +-
 software/kvm/instance-kvm.cfg.jinja2 | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/software/kvm/common.cfg b/software/kvm/common.cfg
index 18001c3c3..fc270e82f 100644
--- a/software/kvm/common.cfg
+++ b/software/kvm/common.cfg
@@ -93,7 +93,7 @@ mode = 0644
 recipe = hexagonit.recipe.download
 url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
 mode = 644
-md5sum = 681cd5a4dddceba1e756e9aa409477a6
+md5sum = 1f21759827c136a65baf597952c71e9a
 download-only = true
 on-update = true
 
diff --git a/software/kvm/instance-kvm.cfg.jinja2 b/software/kvm/instance-kvm.cfg.jinja2
index ee85b14cf..75fe338f8 100644
--- a/software/kvm/instance-kvm.cfg.jinja2
+++ b/software/kvm/instance-kvm.cfg.jinja2
@@ -230,7 +230,9 @@ recipe = slapos.cookbook:publish
 ipv6 = ${slap-network-information:global-ipv6}
 backend-url = https://[${novnc-instance:ip}]:${novnc-instance:port}/vnc_auto.html?host=[${novnc-instance:ip}]&port=${novnc-instance:port}&encrypt=1&password=${kvm-instance:vnc-passwd}
 url = ${request-slave-frontend:connection-url}/vnc_auto.html?host=${request-slave-frontend:connection-domainname}&port=${request-slave-frontend:connection-port}&encrypt=1&path=${request-slave-frontend:connection-resource}&password=${kvm-instance:vnc-passwd}
+{% set iface = 'eth0' -%}
 {% if slapparameter_dict.get('use-nat', 'True') == 'True' -%}
+{%   set iface = 'eth1' -%}
 # Publish NAT port mapping status
 # XXX: hardcoded value from [slap-parameter]
 {%   set nat_rule_list = slapparameter_dict.get('nat-rules', '22 80 443') %}
@@ -242,6 +244,12 @@ nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:{{external_por
 {%     endif -%}
 {%   endfor -%}
 {% endif -%}
+{% if slapparameter_dict.get('use-tap', 'False') == 'True' -%}
+1_info = If IPv4 address is provided for your VM, use this sample configuration to configure your VM interface.
+2_info = ifconfig {{ iface }} ${slap-network-information:tap-ipv4} netmask ${slap-network-information:tap-netmask}
+3_info = route add -host ${slap-network-information:tap-gateway} dev {{ iface }}
+4_info = route add -net ${slap-network-information:tap-network} netmask ${slap-network-information:tap-netmask} gw ${slap-network-information:tap-gateway}
+{% endif -%}
 
 
 [slap-parameter]
-- 
2.30.9