We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
cloud-init generates a traceback if a default route already exists during ephemeral network setup
This bug was originally filed in Launchpad as [LP: #1860164](https://bugs.launchpad.net/cloud-init/+bug/1860164)
<details>
<summary>Launchpad details</summary>
<pre>
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2020-01-17T18:37:30.886100+00:00
date_fix_committed = None
date_fix_released = None
id = 1860164
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1860164
milestone = None
owner = rjschwei
owner_name = Robert Schweikert
private = False
status = triaged
submitter = rjschwei
submitter_name = Robert Schweikert
tags = []
duplicates = []
</pre>
</details>

_Launchpad user **Robert Schweikert(rjschwei)** wrote on 2020-01-17T18:37:30.886100+00:00_

If a route already exists when the ephemeral network exists cloud-init will generate the following traceback:

2020-01-16 21:14:22,584 - util.py[DEBUG]: Getting data from <class 'cloudinit.sources.DataSourceOracle.DataSourceOracle'> failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 760, in find_source
    if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 649, in update_metadata
    result = self.get_data()
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 273, in get_data
    return_value = self._get_data()
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOracle.py", line 195, in _get_data
    with dhcp.EphemeralDHCPv4(net.find_fallback_nic()):
  File "/usr/lib/python2.7/site-packages/cloudinit/net/dhcp.py", line 57, in __enter__
    return self.obtain_lease()
  File "/usr/lib/python2.7/site-packages/cloudinit/net/dhcp.py", line 109, in obtain_lease
    ephipv4.__enter__()
  File "/usr/lib/python2.7/site-packages/cloudinit/net/__init__.py", line 920, in __enter__
    self._bringup_static_routes()
  File "/usr/lib/python2.7/site-packages/cloudinit/net/__init__.py", line 974, in _bringup_static_routes
    ['dev', self.interface], capture=True)
  File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 2083, in subp
    cmd=args)
ProcessExecutionError: Unexpected error while running command.

This is a regression from 19.1 on SUSE where exiting routes were simply skipped.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cloudinit/net/netops/iproute2.py`
Content:
```
1 from typing import Optional
2 
3 from cloudinit import subp
4 from cloudinit.net.netops import NetOps
5 
6 
7 class Iproute2(NetOps):
8     @staticmethod
9     def link_up(
10         interface: str, family: Optional[str] = None
11     ) -> subp.SubpResult:
12         family_args = []
13         if family:
14             family_args = ["-family", family]
15         return subp.subp(
16             ["ip", *family_args, "link", "set", "dev", interface, "up"]
17         )
18 
19     @staticmethod
20     def link_down(
21         interface: str, family: Optional[str] = None
22     ) -> subp.SubpResult:
23         family_args = []
24         if family:
25             family_args = ["-family", family]
26         return subp.subp(
27             ["ip", *family_args, "link", "set", "dev", interface, "down"]
28         )
29 
30     @staticmethod
31     def link_rename(current_name: str, new_name: str):
32         subp.subp(["ip", "link", "set", current_name, "name", new_name])
33 
34     @staticmethod
35     def add_route(
36         interface: str,
37         route: str,
38         *,
39         gateway: Optional[str] = None,
40         source_address: Optional[str] = None,
41     ):
42         gateway_args = []
43         source_args = []
44         if gateway and gateway != "0.0.0.0":
45             gateway_args = ["via", gateway]
46         if source_address:
47             source_args = ["src", source_address]
48         subp.subp(
49             [
50                 "ip",
51                 "-4",
52                 "route",
53                 "add",
54                 route,
55                 *gateway_args,
56                 "dev",
57                 interface,
58                 *source_args,
59             ]
60         )
61 
62     @staticmethod
63     def append_route(interface: str, address: str, gateway: str):
64         gateway_args = []
65         if gateway and gateway != "0.0.0.0":
66             gateway_args = ["via", gateway]
67         subp.subp(
68             [
69                 "ip",
70                 "-4",
71                 "route",
72                 "append",
73                 address,
74                 *gateway_args,
75                 "dev",
76                 interface,
77             ]
78         )
79 
80     @staticmethod
81     def del_route(
82         interface: str,
83         address: str,
84         *,
85         gateway: Optional[str] = None,
86         source_address: Optional[str] = None,
87     ):
88         gateway_args = []
89         source_args = []
90         if gateway and gateway != "0.0.0.0":
91             gateway_args = ["via", gateway]
92         if source_address:
93             source_args = ["src", source_address]
94         subp.subp(
95             [
96                 "ip",
97                 "-4",
98                 "route",
99                 "del",
100                 address,
101                 *gateway_args,
102                 "dev",
103                 interface,
104                 *source_args,
105             ]
106         )
107 
108     @staticmethod
109     def get_default_route() -> str:
110         return subp.subp(
111             ["ip", "route", "show", "0.0.0.0/0"],
112         ).stdout
113 
114     @staticmethod
115     def add_addr(
116         interface: str, address: str, broadcast: Optional[str] = None
117     ):
118         broadcast_args = []
119         if broadcast:
120             broadcast_args = ["broadcast", broadcast]
121         subp.subp(
122             [
123                 "ip",
124                 "-family",
125                 "inet",
126                 "addr",
127                 "add",
128                 address,
129                 *broadcast_args,
130                 "dev",
131                 interface,
132             ],
133             update_env={"LANG": "C"},
134         )
135 
136     @staticmethod
137     def del_addr(interface: str, address: str):
138         subp.subp(
139             ["ip", "-family", "inet", "addr", "del", address, "dev", interface]
140         )
141 
142     @staticmethod
143     def flush_addr(interface: str):
144         subp.subp(["ip", "flush", "dev", interface])
145
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/cloudinit/net/netops/iproute2.py b/cloudinit/net/netops/iproute2.py
--- a/cloudinit/net/netops/iproute2.py
+++ b/cloudinit/net/netops/iproute2.py
@@ -50,7 +50,7 @@
                 "ip",
                 "-4",
                 "route",
-                "add",
+                "replace",
                 route,
                 *gateway_args,
                 "dev",

{"golden_diff": "diff --git a/cloudinit/net/netops/iproute2.py b/cloudinit/net/netops/iproute2.py\n--- a/cloudinit/net/netops/iproute2.py\n+++ b/cloudinit/net/netops/iproute2.py\n@@ -50,7 +50,7 @@\n                 \"ip\",\n                 \"-4\",\n                 \"route\",\n-                \"add\",\n+                \"replace\",\n                 route,\n                 *gateway_args,\n                 \"dev\",\n", "issue": "cloud-init generates a traceback if a default route already exists during ephemeral network setup\nThis bug was originally filed in Launchpad as [LP: #1860164](https://bugs.launchpad.net/cloud-init/+bug/1860164)\n<details>\n<summary>Launchpad details</summary>\n<pre>\naffected_projects = []\nassignee = None\nassignee_name = None\ndate_closed = None\ndate_created = 2020-01-17T18:37:30.886100+00:00\ndate_fix_committed = None\ndate_fix_released = None\nid = 1860164\nimportance = medium\nis_complete = False\nlp_url = https://bugs.launchpad.net/cloud-init/+bug/1860164\nmilestone = None\nowner = rjschwei\nowner_name = Robert Schweikert\nprivate = False\nstatus = triaged\nsubmitter = rjschwei\nsubmitter_name = Robert Schweikert\ntags = []\nduplicates = []\n</pre>\n</details>\n\n_Launchpad user **Robert Schweikert(rjschwei)** wrote on 2020-01-17T18:37:30.886100+00:00_\n\nIf a route already exists when the ephemeral network exists cloud-init will generate the following traceback:\n\n2020-01-16 21:14:22,584 - util.py[DEBUG]: Getting data from <class 'cloudinit.sources.DataSourceOracle.DataSourceOracle'> failed\nTraceback (most recent call last):\n  File \"/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py\", line 760, in find_source\n    if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):\n  File \"/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py\", line 649, in update_metadata\n    result = self.get_data()\n  File \"/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py\", line 273, in get_data\n    return_value = self._get_data()\n  File \"/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOracle.py\", line 195, in _get_data\n    with dhcp.EphemeralDHCPv4(net.find_fallback_nic()):\n  File \"/usr/lib/python2.7/site-packages/cloudinit/net/dhcp.py\", line 57, in __enter__\n    return self.obtain_lease()\n  File \"/usr/lib/python2.7/site-packages/cloudinit/net/dhcp.py\", line 109, in obtain_lease\n    ephipv4.__enter__()\n  File \"/usr/lib/python2.7/site-packages/cloudinit/net/__init__.py\", line 920, in __enter__\n    self._bringup_static_routes()\n  File \"/usr/lib/python2.7/site-packages/cloudinit/net/__init__.py\", line 974, in _bringup_static_routes\n    ['dev', self.interface], capture=True)\n  File \"/usr/lib/python2.7/site-packages/cloudinit/util.py\", line 2083, in subp\n    cmd=args)\nProcessExecutionError: Unexpected error while running command.\n\nThis is a regression from 19.1 on SUSE where exiting routes were simply skipped.\n", "before_files": [{"content": "from typing import Optional\n\nfrom cloudinit import subp\nfrom cloudinit.net.netops import NetOps\n\n\nclass Iproute2(NetOps):\n    @staticmethod\n    def link_up(\n        interface: str, family: Optional[str] = None\n    ) -> subp.SubpResult:\n        family_args = []\n        if family:\n            family_args = [\"-family\", family]\n        return subp.subp(\n            [\"ip\", *family_args, \"link\", \"set\", \"dev\", interface, \"up\"]\n        )\n\n    @staticmethod\n    def link_down(\n        interface: str, family: Optional[str] = None\n    ) -> subp.SubpResult:\n        family_args = []\n        if family:\n            family_args = [\"-family\", family]\n        return subp.subp(\n            [\"ip\", *family_args, \"link\", \"set\", \"dev\", interface, \"down\"]\n        )\n\n    @staticmethod\n    def link_rename(current_name: str, new_name: str):\n        subp.subp([\"ip\", \"link\", \"set\", current_name, \"name\", new_name])\n\n    @staticmethod\n    def add_route(\n        interface: str,\n        route: str,\n        *,\n        gateway: Optional[str] = None,\n        source_address: Optional[str] = None,\n    ):\n        gateway_args = []\n        source_args = []\n        if gateway and gateway != \"0.0.0.0\":\n            gateway_args = [\"via\", gateway]\n        if source_address:\n            source_args = [\"src\", source_address]\n        subp.subp(\n            [\n                \"ip\",\n                \"-4\",\n                \"route\",\n                \"add\",\n                route,\n                *gateway_args,\n                \"dev\",\n                interface,\n                *source_args,\n            ]\n        )\n\n    @staticmethod\n    def append_route(interface: str, address: str, gateway: str):\n        gateway_args = []\n        if gateway and gateway != \"0.0.0.0\":\n            gateway_args = [\"via\", gateway]\n        subp.subp(\n            [\n                \"ip\",\n                \"-4\",\n                \"route\",\n                \"append\",\n                address,\n                *gateway_args,\n                \"dev\",\n                interface,\n            ]\n        )\n\n    @staticmethod\n    def del_route(\n        interface: str,\n        address: str,\n        *,\n        gateway: Optional[str] = None,\n        source_address: Optional[str] = None,\n    ):\n        gateway_args = []\n        source_args = []\n        if gateway and gateway != \"0.0.0.0\":\n            gateway_args = [\"via\", gateway]\n        if source_address:\n            source_args = [\"src\", source_address]\n        subp.subp(\n            [\n                \"ip\",\n                \"-4\",\n                \"route\",\n                \"del\",\n                address,\n                *gateway_args,\n                \"dev\",\n                interface,\n                *source_args,\n            ]\n        )\n\n    @staticmethod\n    def get_default_route() -> str:\n        return subp.subp(\n            [\"ip\", \"route\", \"show\", \"0.0.0.0/0\"],\n        ).stdout\n\n    @staticmethod\n    def add_addr(\n        interface: str, address: str, broadcast: Optional[str] = None\n    ):\n        broadcast_args = []\n        if broadcast:\n            broadcast_args = [\"broadcast\", broadcast]\n        subp.subp(\n            [\n                \"ip\",\n                \"-family\",\n                \"inet\",\n                \"addr\",\n                \"add\",\n                address,\n                *broadcast_args,\n                \"dev\",\n                interface,\n            ],\n            update_env={\"LANG\": \"C\"},\n        )\n\n    @staticmethod\n    def del_addr(interface: str, address: str):\n        subp.subp(\n            [\"ip\", \"-family\", \"inet\", \"addr\", \"del\", address, \"dev\", interface]\n        )\n\n    @staticmethod\n    def flush_addr(interface: str):\n        subp.subp([\"ip\", \"flush\", \"dev\", interface])\n", "path": "cloudinit/net/netops/iproute2.py"}], "after_files": [{"content": "from typing import Optional\n\nfrom cloudinit import subp\nfrom cloudinit.net.netops import NetOps\n\n\nclass Iproute2(NetOps):\n    @staticmethod\n    def link_up(\n        interface: str, family: Optional[str] = None\n    ) -> subp.SubpResult:\n        family_args = []\n        if family:\n            family_args = [\"-family\", family]\n        return subp.subp(\n            [\"ip\", *family_args, \"link\", \"set\", \"dev\", interface, \"up\"]\n        )\n\n    @staticmethod\n    def link_down(\n        interface: str, family: Optional[str] = None\n    ) -> subp.SubpResult:\n        family_args = []\n        if family:\n            family_args = [\"-family\", family]\n        return subp.subp(\n            [\"ip\", *family_args, \"link\", \"set\", \"dev\", interface, \"down\"]\n        )\n\n    @staticmethod\n    def link_rename(current_name: str, new_name: str):\n        subp.subp([\"ip\", \"link\", \"set\", current_name, \"name\", new_name])\n\n    @staticmethod\n    def add_route(\n        interface: str,\n        route: str,\n        *,\n        gateway: Optional[str] = None,\n        source_address: Optional[str] = None,\n    ):\n        gateway_args = []\n        source_args = []\n        if gateway and gateway != \"0.0.0.0\":\n            gateway_args = [\"via\", gateway]\n        if source_address:\n            source_args = [\"src\", source_address]\n        subp.subp(\n            [\n                \"ip\",\n                \"-4\",\n                \"route\",\n                \"replace\",\n                route,\n                *gateway_args,\n                \"dev\",\n                interface,\n                *source_args,\n            ]\n        )\n\n    @staticmethod\n    def append_route(interface: str, address: str, gateway: str):\n        gateway_args = []\n        if gateway and gateway != \"0.0.0.0\":\n            gateway_args = [\"via\", gateway]\n        subp.subp(\n            [\n                \"ip\",\n                \"-4\",\n                \"route\",\n                \"append\",\n                address,\n                *gateway_args,\n                \"dev\",\n                interface,\n            ]\n        )\n\n    @staticmethod\n    def del_route(\n        interface: str,\n        address: str,\n        *,\n        gateway: Optional[str] = None,\n        source_address: Optional[str] = None,\n    ):\n        gateway_args = []\n        source_args = []\n        if gateway and gateway != \"0.0.0.0\":\n            gateway_args = [\"via\", gateway]\n        if source_address:\n            source_args = [\"src\", source_address]\n        subp.subp(\n            [\n                \"ip\",\n                \"-4\",\n                \"route\",\n                \"del\",\n                address,\n                *gateway_args,\n                \"dev\",\n                interface,\n                *source_args,\n            ]\n        )\n\n    @staticmethod\n    def get_default_route() -> str:\n        return subp.subp(\n            [\"ip\", \"route\", \"show\", \"0.0.0.0/0\"],\n        ).stdout\n\n    @staticmethod\n    def add_addr(\n        interface: str, address: str, broadcast: Optional[str] = None\n    ):\n        broadcast_args = []\n        if broadcast:\n            broadcast_args = [\"broadcast\", broadcast]\n        subp.subp(\n            [\n                \"ip\",\n                \"-family\",\n                \"inet\",\n                \"addr\",\n                \"add\",\n                address,\n                *broadcast_args,\n                \"dev\",\n                interface,\n            ],\n            update_env={\"LANG\": \"C\"},\n        )\n\n    @staticmethod\n    def del_addr(interface: str, address: str):\n        subp.subp(\n            [\"ip\", \"-family\", \"inet\", \"addr\", \"del\", address, \"dev\", interface]\n        )\n\n    @staticmethod\n    def flush_addr(interface: str):\n        subp.subp([\"ip\", \"flush\", \"dev\", interface])\n", "path": "cloudinit/net/netops/iproute2.py"}]}