summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_install_hotplug.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/config/cc_install_hotplug.py')
-rw-r--r--cloudinit/config/cc_install_hotplug.py48
1 files changed, 26 insertions, 22 deletions
diff --git a/cloudinit/config/cc_install_hotplug.py b/cloudinit/config/cc_install_hotplug.py
index 9b4075cc..952d9f13 100644
--- a/cloudinit/config/cc_install_hotplug.py
+++ b/cloudinit/config/cc_install_hotplug.py
@@ -3,15 +3,12 @@
import os
from textwrap import dedent
-from cloudinit import util
-from cloudinit import subp
-from cloudinit import stages
+from cloudinit import stages, subp, util
from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema
from cloudinit.distros import ALL_DISTROS
-from cloudinit.event import EventType, EventScope
+from cloudinit.event import EventScope, EventType
from cloudinit.settings import PER_INSTANCE
-
frequency = PER_INSTANCE
distros = [ALL_DISTROS]
@@ -19,7 +16,8 @@ meta = {
"id": "cc_install_hotplug",
"name": "Install Hotplug",
"title": "Install hotplug if supported and enabled",
- "description": dedent("""\
+ "description": dedent(
+ """\
This module will install the udev rules to enable hotplug if
supported by the datasource and enabled in the userdata. The udev
rules will be installed as
@@ -32,21 +30,26 @@ meta = {
network configuration.
Currently supported datasources: Openstack, EC2
- """),
+ """
+ ),
"distros": distros,
"examples": [
- dedent("""\
+ dedent(
+ """\
# Enable hotplug of network devices
updates:
network:
when: ["hotplug"]
- """),
- dedent("""\
+ """
+ ),
+ dedent(
+ """\
# Enable network hotplug alongside boot event
updates:
network:
when: ["boot", "hotplug"]
- """),
+ """
+ ),
],
"frequency": frequency,
}
@@ -74,14 +77,14 @@ schema = {
"boot-legacy",
"boot",
"hotplug",
- ]
- }
+ ],
+ },
}
- }
+ },
}
- }
+ },
}
- }
+ },
}
__doc__ = get_meta_doc(meta, schema)
@@ -100,14 +103,15 @@ LABEL="cloudinit_end"
def handle(_name, cfg, cloud, log, _args):
validate_cloudconfig_schema(cfg, schema)
network_hotplug_enabled = (
- 'updates' in cfg and
- 'network' in cfg['updates'] and
- 'when' in cfg['updates']['network'] and
- 'hotplug' in cfg['updates']['network']['when']
+ "updates" in cfg
+ and "network" in cfg["updates"]
+ and "when" in cfg["updates"]["network"]
+ and "hotplug" in cfg["updates"]["network"]["when"]
)
hotplug_supported = EventType.HOTPLUG in (
- cloud.datasource.get_supported_events(
- [EventType.HOTPLUG]).get(EventScope.NETWORK, set())
+ cloud.datasource.get_supported_events([EventType.HOTPLUG]).get(
+ EventScope.NETWORK, set()
+ )
)
hotplug_enabled = stages.update_event_enabled(
datasource=cloud.datasource,