Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cloudinit/cmd/devel/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def handle_args(name, args):
paths.run_dir, INSTANCE_JSON_SENSITIVE_FILE)
if not os.path.exists(instance_data_fn):
LOG.warning(
'Missing root-readable %s. Using redacted %s instead.',
instance_data_fn, redacted_data_fn)
'Missing root-readable %s. Using redacted %s instead.',
instance_data_fn, redacted_data_fn
)
instance_data_fn = redacted_data_fn
else:
instance_data_fn = redacted_data_fn
Expand Down
5 changes: 3 additions & 2 deletions cloudinit/cmd/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ def handle_args(name, args):
instance_data_fn = sensitive_data_fn
else:
LOG.warning(
'Missing root-readable %s. Using redacted %s instead.',
sensitive_data_fn, redacted_data_fn)
'Missing root-readable %s. Using redacted %s instead.',
sensitive_data_fn, redacted_data_fn
)
instance_data_fn = redacted_data_fn
else:
instance_data_fn = redacted_data_fn
Expand Down
10 changes: 6 additions & 4 deletions cloudinit/distros/netbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ def set_passwd(self, user, passwd, hashed=False):
else:
method = crypt.METHOD_BLOWFISH # pylint: disable=E1101
hashed_pw = crypt.crypt(
passwd,
crypt.mksalt(method))
passwd,
crypt.mksalt(method)
)

try:
subp.subp(['usermod', '-p', hashed_pw, user])
Expand Down Expand Up @@ -143,8 +144,9 @@ def _get_pkg_cmd_environ(self):
os_arch = platform.machine()
e = os.environ.copy()
e['PKG_PATH'] = (
'http://cdn.netbsd.org/pub/pkgsrc/'
'packages/NetBSD/%s/%s/All') % (os_arch, os_release)
'http://cdn.netbsd.org/pub/pkgsrc/'
'packages/NetBSD/%s/%s/All'
) % (os_arch, os_release)
return e

def update_package_sources(self):
Expand Down
7 changes: 4 additions & 3 deletions cloudinit/distros/openbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ def _get_pkg_cmd_environ(self):
os_arch = platform.machine()
e = os.environ.copy()
e['PKG_PATH'] = (
'ftp://ftp.openbsd.org/pub/OpenBSD/{os_release}/'
'packages/{os_arch}/').format(
os_arch=os_arch, os_release=os_release)
'ftp://ftp.openbsd.org/pub/OpenBSD/{os_release}/'
'packages/{os_arch}/').format(
os_arch=os_arch, os_release=os_release
)
return e


Expand Down
5 changes: 3 additions & 2 deletions cloudinit/net/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,9 @@ def find_mac(flat_list):
def get_interfaces_by_mac_on_netbsd():
ret = {}
re_field_match = (
r"(?P<ifname>\w+).*address:\s"
r"(?P<mac>([\da-f]{2}[:-]){5}([\da-f]{2})).*")
r"(?P<ifname>\w+).*address:\s"
r"(?P<mac>([\da-f]{2}[:-]){5}([\da-f]{2})).*"
)
(out, _) = subp.subp(['ifconfig', '-a'])
if_lines = re.sub(r'\n\s+', ' ', out).splitlines()
for line in if_lines:
Expand Down
5 changes: 3 additions & 2 deletions cloudinit/net/bsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ def _ifconfig_entries(self, settings, target=None):
if subnet.get('type') == 'static':
if not subnet.get('netmask'):
LOG.debug(
'Skipping IP %s, because there is no netmask',
subnet.get('address'))
'Skipping IP %s, because there is no netmask',
subnet.get('address')
)
continue
LOG.debug('Configuring dev %s with %s / %s', device_name,
subnet.get('address'), subnet.get('netmask'))
Expand Down
5 changes: 3 additions & 2 deletions cloudinit/net/netbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def write_config(self):
if self.dhcp_interfaces():
self.set_rc_config_value('dhcpcd', 'YES')
self.set_rc_config_value(
'dhcpcd_flags',
' '.join(self.dhcp_interfaces()))
'dhcpcd_flags',
' '.join(self.dhcp_interfaces())
)
for device_name, v in self.interface_configurations.items():
if isinstance(v, dict):
self.set_rc_config_value(
Expand Down
5 changes: 3 additions & 2 deletions cloudinit/net/openbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def write_config(self):
elif isinstance(v, dict):
try:
content = "inet {address} {netmask}\n".format(
address=v['address'],
netmask=v['netmask'])
address=v['address'],
netmask=v['netmask']
)
except KeyError:
LOG.error(
"Invalid static configuration for %s",
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/net/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def _render_subnets(cls, iface_cfg, subnets, has_default_route, flavor):
iface_cfg['IPADDR6_%d' % ipv6_index] = ipv6_cidr
else:
iface_cfg['IPV6ADDR_SECONDARIES'] += \
" " + ipv6_cidr
" " + ipv6_cidr
else:
ipv4_index = ipv4_index + 1
suff = "" if ipv4_index == 0 else str(ipv4_index)
Expand Down
14 changes: 10 additions & 4 deletions cloudinit/reporting/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def __init__(self,
self.event_key_prefix = u"{0}|{1}".format(self.EVENT_PREFIX,
self.incarnation_no)
self.publish_thread = threading.Thread(
target=self._publish_event_routine)
target=self._publish_event_routine
)
self.publish_thread.daemon = True
self.publish_thread.start()

Expand Down Expand Up @@ -202,10 +203,15 @@ def _event_key(self, event):
uuid.uuid4())

def _encode_kvp_item(self, key, value):
data = (struct.pack("%ds%ds" % (
data = struct.pack(
"%ds%ds"
% (
self.HV_KVP_EXCHANGE_MAX_KEY_SIZE,
self.HV_KVP_EXCHANGE_MAX_VALUE_SIZE),
key.encode('utf-8'), value.encode('utf-8')))
self.HV_KVP_EXCHANGE_MAX_VALUE_SIZE,
),
key.encode("utf-8"),
value.encode("utf-8"),
)
return data

def _decode_kvp_item(self, record_data):
Expand Down
33 changes: 19 additions & 14 deletions cloudinit/sources/DataSourceAzure.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,9 @@ def _get_data(self):

try:
crawled_data = util.log_time(
logfunc=LOG.debug, msg='Crawl of metadata service',
func=self.crawl_metadata)
logfunc=LOG.debug, msg='Crawl of metadata service',
func=self.crawl_metadata
)
except sources.InvalidMetaDataException as e:
LOG.warning('Could not crawl Azure metadata: %s', e)
return False
Expand Down Expand Up @@ -893,9 +894,10 @@ def count_files(mp):
(cand_part, cand_path, devpath))

with events.ReportEventStack(
name="mount-ntfs-and-count",
description="mount-ntfs-and-count",
parent=azure_ds_reporter) as evt:
name="mount-ntfs-and-count",
description="mount-ntfs-and-count",
parent=azure_ds_reporter
) as evt:
try:
file_count = util.mount_cb(cand_path, count_files, mtype="ntfs",
update_env_for_mount={'LANG': 'C'})
Expand Down Expand Up @@ -924,9 +926,10 @@ def address_ephemeral_resize(devpath=RESOURCE_DISK_PATH, maxwait=120,
# wait for ephemeral disk to come up
naplen = .2
with events.ReportEventStack(
name="wait-for-ephemeral-disk",
description="wait for ephemeral disk",
parent=azure_ds_reporter):
name="wait-for-ephemeral-disk",
description="wait for ephemeral disk",
parent=azure_ds_reporter
):
missing = util.wait_for_files([devpath],
maxwait=maxwait,
naplen=naplen,
Expand Down Expand Up @@ -1334,9 +1337,10 @@ def parse_network_config(imds_metadata):
@return: Dictionary containing network version 2 standard configuration.
"""
with events.ReportEventStack(
name="parse_network_config",
description="",
parent=azure_ds_reporter) as evt:
name="parse_network_config",
description="",
parent=azure_ds_reporter
) as evt:
if imds_metadata != sources.UNSET and imds_metadata:
netconfig = {'version': 2, 'ethernets': {}}
LOG.debug('Azure: generating network configuration from IMDS')
Expand Down Expand Up @@ -1480,9 +1484,10 @@ def maybe_remove_ubuntu_network_config_scripts(paths=None):

def _is_platform_viable(seed_dir):
with events.ReportEventStack(
name="check-platform-viability",
description="found azure asset tag",
parent=azure_ds_reporter) as evt:
name="check-platform-viability",
description="found azure asset tag",
parent=azure_ds_reporter
) as evt:

"""Check platform environment to report if this datasource may run."""
asset_tag = util.read_dmi_data('chassis-asset-tag')
Expand Down
Loading