|
18 | 18 | import logging
|
19 | 19 | import os
|
20 | 20 | import subprocess
|
21 |
| -import re |
22 | 21 |
|
23 | 22 | from .utils import systemctl_is_active, systemctl_is_installed
|
24 | 23 |
|
@@ -52,21 +51,22 @@ def _del_col(type, iface, column, value):
|
52 | 51 | default = DEFAULTS.get(column)
|
53 | 52 | if default is None:
|
54 | 53 | # removes the exact value only if it was set by netplan
|
55 |
| - subprocess.check_call([OPENVSWITCH_OVS_VSCTL, 'remove', type, iface, column, value]) |
| 54 | + cmd = [OPENVSWITCH_OVS_VSCTL, 'remove', type, iface, column, value] |
| 55 | + logging.debug('Running: %s' % ' '.join(cmd)) |
| 56 | + subprocess.check_call(cmd) |
56 | 57 | elif default and default != value:
|
57 | 58 | # reset to default, if its not the default already
|
58 |
| - subprocess.check_call([OPENVSWITCH_OVS_VSCTL, 'set', type, iface, '%s=%s' % (column, default)]) |
| 59 | + cmd = [OPENVSWITCH_OVS_VSCTL, 'set', type, iface, '%s=%s' % (column, default)] |
| 60 | + logging.debug('Running: %s' % ' '.join(cmd)) |
| 61 | + subprocess.check_call(cmd) |
59 | 62 |
|
60 | 63 |
|
61 | 64 | def _del_dict(type, iface, column, key, value):
|
62 | 65 | """Cleanup values from a dictionary (i.e. "column:key=value")"""
|
63 | 66 | # removes the exact value only if it was set by netplan
|
64 |
| - subprocess.check_call([OPENVSWITCH_OVS_VSCTL, 'remove', type, iface, column, key, _escape_colon(value)]) |
65 |
| - |
66 |
| - |
67 |
| -# for ovsdb remove: column key's value can not contain bare ':', need to escape with '\' |
68 |
| -def _escape_colon(literal): |
69 |
| - return re.sub(r'([^\\]):', r'\g<1>\:', literal) |
| 67 | + cmd = [OPENVSWITCH_OVS_VSCTL, 'remove', type, iface, column, '%s=\"%s\"' % (key, value)] |
| 68 | + logging.debug('Running: %s' % ' '.join(cmd)) |
| 69 | + subprocess.check_call(cmd) |
70 | 70 |
|
71 | 71 |
|
72 | 72 | def _del_global(type, iface, key, value):
|
|
0 commit comments