Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BrinKe-dev committed Mar 21, 2024
1 parent 4afc962 commit b29a4a0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cloudinit/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"AliYun",
"Vultr",
"Ec2",
"CloudCIX",
"CloudSigma",
"CloudStack",
"SmartOS",
Expand All @@ -51,6 +50,7 @@
"NWCS",
"Akamai",
"WSL",
"CloudCIX",
# At the end to act as a 'catch' when none of the above work...
"None",
],
Expand Down
22 changes: 7 additions & 15 deletions cloudinit/sources/DataSourceCloudCIX.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# This file is part of cloud-init. See LICENSE file for license information.

import base64
import json
import logging
from typing import Optional
from requests.exceptions import ConnectionError
from cloudinit import atomic_helper, dmi, helpers
from cloudinit import net, sources, url_helper, util
from cloudinit.sources.helpers import ec2

from cloudinit import dmi, net, sources, url_helper, util
from cloudinit.net.dhcp import NoDHCPLeaseError
from cloudinit.net.ephemeral import EphemeralDHCPv4, EphemeralIPNetwork
from cloudinit.net.ephemeral import EphemeralIPNetwork

LOG = logging.getLogger(__name__)

Expand All @@ -30,8 +27,6 @@ class DataSourceCloudCIX(sources.DataSource):

dsname = "CloudCIX"

_metadata_url: str

def __init__(self, sys_cfg, distro, paths):
super(DataSourceCloudCIX, self).__init__(sys_cfg, distro, paths)
self.distro = distro
Expand Down Expand Up @@ -63,7 +58,7 @@ def _get_data(self):
):
crawled_data = util.log_time(
logfunc=LOG.debug,
msg=f"Crawl of metadata service",
msg="Crawl of metadata service",
func=self.crawl_metadata_service,
)
except NoDHCPLeaseError as e:
Expand All @@ -84,7 +79,7 @@ def crawl_metadata_service(self) -> dict:
md_url = self.determine_md_url()
if md_url is None:
raise sources.InvalidMetaDataException(
f"Could not reach determine MetaData url"
"Could not reach determine MetaData url"
)

data = read_metadata(md_url, self.get_url_params())
Expand Down Expand Up @@ -129,7 +124,7 @@ def determine_md_url(self) -> Optional[str]:

@staticmethod
def ds_detect():
product_name = dmi.read_dmi_data("system-product")
product_name = dmi.read_dmi_data("system-product-name")
return product_name == CLOUDCIX_DMI_NAME

@property
Expand All @@ -153,9 +148,6 @@ def _generate_net_cfg(self, metadata):
"Metadata mac address %s not found.", iface["mac_address"]
)
continue
interfaces["name"] = iface

for name, iface in interfaces.items():
netcfg["ethernets"][name] = {
"set-name": name,
"match": {
Expand All @@ -171,7 +163,7 @@ def read_metadata(base_url, url_params):
md = {}
leaf_key_format_callback = (
("metadata", "meta-data", util.load_json),
("userdata", "user-data", util.maybe_64decode),
("userdata", "user-data", util.maybe_b64decode),
)

for url_leaf, new_key, format_callback in leaf_key_format_callback:
Expand Down
9 changes: 4 additions & 5 deletions tests/unittests/sources/test_cloudcix.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# This file is part of cloud-init. See LICENSE file for license information.
import json

from cloudinit import distros, helpers, sources, url_helper as uh
from cloudinit.sources import (
DataSourceCloudCIX as ds_mod,
InvalidMetaDataException,
)
from cloudinit import distros, helpers, sources
from cloudinit import url_helper as uh
from cloudinit.sources import DataSourceCloudCIX as ds_mod
from cloudinit.sources import InvalidMetaDataException
from tests.unittests.helpers import CiTestCase, mock

METADATA = {
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/sources/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@
VMware.DataSourceVMware,
NWCS.DataSourceNWCS,
Akamai.DataSourceAkamaiLocal,
CloudCIX.DataSourceCloudCIX,
WSL.DataSourceWSL,
]

DEFAULT_NETWORK = [
AliYun.DataSourceAliYun,
AltCloud.DataSourceAltCloud,
Bigstep.DataSourceBigstep,
CloudCIX.DataSourceCloudCIX,
CloudStack.DataSourceCloudStack,
DSNone.DataSourceNone,
Ec2.DataSourceEc2,
Expand Down

0 comments on commit b29a4a0

Please sign in to comment.