From 3bb80bd89af0cb657cf0cd0fbe85097b15db06eabf9f6db0919474374b5e6909 Mon Sep 17 00:00:00 2001
From: Robert Schweikert <rjschwei@suse.com>
Date: Wed, 12 Feb 2020 19:33:31 +0000
Subject: [PATCH] - Update cloud-init-write-routes.patch (bsc#1163178)   +
 Entries in the routes definition have changed causing a traceback     during
 rout config file writing. This patch update addresses the     issue by
 extracting the new entries properly.

OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=161
---
 cloud-init-write-routes.patch | 14 ++++++++++----
 cloud-init.changes            |  8 ++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/cloud-init-write-routes.patch b/cloud-init-write-routes.patch
index 348d606..92573e8 100644
--- a/cloud-init-write-routes.patch
+++ b/cloud-init-write-routes.patch
@@ -8,7 +8,7 @@
  
  from cloudinit import helpers
  from cloudinit import log as logging
-@@ -172,7 +173,47 @@ class Distro(distros.Distro):
+@@ -172,7 +173,53 @@ class Distro(distros.Distro):
              util.write_file(out_fn, str(conf), 0o644)
  
      def _write_network_config(self, netconfig):
@@ -34,12 +34,18 @@
 +            for subnet in subnets:
 +                routes = subnet.get('routes', [])
 +                for route in routes:
-+                    dest = route.get('network')
++                    dest = route.get('destination')
 +                    if dest in default_nets:
 +                        dest = 'default'
 +                    if dest != 'default':
-+                        prefix = mask_to_net_prefix(route.get('netmask'))
-+                        dest += '/' + str(prefix)
++                        netmask = route.get('genmask')
++                        if netmask:
++                            prefix = mask_to_net_prefix(netmask)
++                            dest += '/' + str(prefix)
++                        if '/' not in dest:
++                            LOG.warning(
++                                'Route destination has no prefix "%s"', dest
++                            )
 +                    gateway = route.get('gateway')
 +                    config_routes += ' '.join(
 +                        [dest, gateway, '-', '-\n']
diff --git a/cloud-init.changes b/cloud-init.changes
index 30d104a..dfbf5f0 100644
--- a/cloud-init.changes
+++ b/cloud-init.changes
@@ -1,3 +1,11 @@
+-------------------------------------------------------------------
+Wed Feb 12 19:30:42 UTC 2020 - Robert Schweikert <rjschwei@suse.com>
+
+- Update cloud-init-write-routes.patch (bsc#1163178)
+  + Entries in the routes definition have changed causing a traceback
+    during rout config file writing. This patch update addresses the
+    issue by extracting the new entries properly.
+
 -------------------------------------------------------------------
 Fri Jan 17 18:55:41 UTC 2020 - Robert Schweikert <rjschwei@suse.com>