Ubuntu Pastebin

Paste from smoser at Mon, 20 Mar 2017 19:30:41 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py
index 8048226d..7b3a6e87 100644
--- a/cloudinit/net/netplan.py
+++ b/cloudinit/net/netplan.py
@@ -2,7 +2,6 @@
 
 import copy
 import os
-from textwrap import indent
 
 from . import renderer
 from .network_state import subnet_is_ipv6
@@ -12,30 +11,37 @@ from cloudinit.net import SYS_CLASS_NET, get_devicelist
 
 
 NET_CONFIG_TO_V2 = {
- 'bond': {'bond-ad-select': 'ad-select',
-          'bond-arp-interval': 'arp-interval',
-          'bond-arp-ip-target': 'arp-ip-target',
-          'bond-arp-validate': 'arp-validate',
-          'bond-downdelay': 'down-delay',
-          'bond-fail-over-mac': 'fail-over-mac-policy',
-          'bond-lacp-rate': 'lacp-rate',
-          'bond-miimon': 'mii-monitor-interval',
-          'bond-min-links': 'min-links',
-          'bond-mode': 'mode',
-          'bond-num-grat-arp': 'gratuitious-arp',
-          'bond-primary-reselect': 'primary-reselect-policy',
-          'bond-updelay': 'up-delay',
-          'bond-xmit_hash_policy': 'transmit_hash_policy'},
- 'bridge': {'bridge_ageing': 'ageing-time',
-            'bridge_bridgeprio': 'priority',
-            'bridge_fd': 'forward-delay',
-            'bridge_gcint': None,
-            'bridge_hello': 'hello-time',
-            'bridge_maxage': 'max-age',
-            'bridge_maxwait': None,
-            'bridge_pathcost': 'path-cost',
-            'bridge_portprio': None,
-            'bridge_waitport': None}}
+    'bond': {'bond-ad-select': 'ad-select',
+             'bond-arp-interval': 'arp-interval',
+             'bond-arp-ip-target': 'arp-ip-target',
+             'bond-arp-validate': 'arp-validate',
+             'bond-downdelay': 'down-delay',
+             'bond-fail-over-mac': 'fail-over-mac-policy',
+             'bond-lacp-rate': 'lacp-rate',
+             'bond-miimon': 'mii-monitor-interval',
+             'bond-min-links': 'min-links',
+             'bond-mode': 'mode',
+             'bond-num-grat-arp': 'gratuitious-arp',
+             'bond-primary-reselect': 'primary-reselect-policy',
+             'bond-updelay': 'up-delay',
+             'bond-xmit_hash_policy': 'transmit_hash_policy'},
+    'bridge': {'bridge_ageing': 'ageing-time',
+               'bridge_bridgeprio': 'priority',
+               'bridge_fd': 'forward-delay',
+               'bridge_gcint': None,
+               'bridge_hello': 'hello-time',
+               'bridge_maxage': 'max-age',
+               'bridge_maxwait': None,
+               'bridge_pathcost': 'path-cost',
+               'bridge_portprio': None,
+               'bridge_waitport': None}}
+
+
+def indent(text, prefix):
+    lines = []
+    for line in text.splitlines(True):
+        lines.append(prefix + line)
+    return ''.join(lines)
 
 
 def _get_params_dict_by_match(config, match):
@@ -44,9 +50,9 @@ def _get_params_dict_by_match(config, match):
 
 
 def _extract_addresses(config, entry):
-    """ This method parse a cloudinit.net.network_state dictionary (config) and
-        maps netstate keys/values into a dictionary (entry) to represent
-        netplan yaml.
+    """This method parse a cloudinit.net.network_state dictionary (config) and
+       maps netstate keys/values into a dictionary (entry) to represent
+       netplan yaml.
 
     An example config dictionary might look like:
 
@@ -80,8 +86,7 @@ def _extract_addresses(config, entry):
     """
 
     def _listify(obj, token=' '):
-        """ Helper to convert strings to list of strings, handle single
-            string"""
+        "Helper to convert strings to list of strings, handle single string"
         if not obj or type(obj) not in [str]:
             return obj
         if token in obj:
@@ -193,9 +198,9 @@ class Renderer(renderer.Renderer):
         util.subp(self.NETPLAN_GENERATE, capture=True)
 
     def _net_setup_link(self, run=False):
-        """ To ensure device link properties are applied, we poke
-            udev to re-evaluate networkd .link files and call
-            the setup_link udev builtin command
+        """To ensure device link properties are applied, we poke
+           udev to re-evaluate networkd .link files and call
+           the setup_link udev builtin command
         """
         if not run:
             print("netsetup postcmd disabled")
Download as text