Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint issues #403

Merged
merged 1 commit into from
Jan 10, 2025
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
2 changes: 1 addition & 1 deletion sunbeam-python/sunbeam/commands/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def launch(
instance_name = name if name else petname.Generate()
image = conn.compute.find_image(image_name)
flavor = conn.compute.find_flavor("m1.tiny")
network = conn.network.find_network(f'{tf_output["OS_USERNAME"]}-network')
network = conn.network.find_network(f"{tf_output['OS_USERNAME']}-network")
keypair = conn.compute.find_keypair(key)
server = conn.compute.create_server(
name=instance_name,
Expand Down
2 changes: 1 addition & 1 deletion sunbeam-python/sunbeam/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __init__(self, result_type: ResultType = ResultType.COMPLETED, **kwargs):
# attribute.
if hasattr(self, key):
raise ValueError(
f"{key} was specified but already exists on " f"this StepResult."
f"{key} was specified but already exists on this StepResult."
)
self.__setattr__(key, value)

Expand Down
14 changes: 7 additions & 7 deletions sunbeam-python/sunbeam/core/juju.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ async def wait_units_gone(
)
except asyncio.TimeoutError as e:
raise TimeoutException(
"Timed out while waiting for units " f"{', '.join(name_set)} to be gone"
f"Timed out while waiting for units {', '.join(name_set)} to be gone"
) from e

async def wait_units_ready(
Expand Down Expand Up @@ -1491,7 +1491,7 @@ def _juju_cmd(self, *args):
cmd.extend(args)
cmd.extend(["--format", "json"])

LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(f"Command finished. stdout={process.stdout}, stderr={process.stderr}")

Expand Down Expand Up @@ -1628,7 +1628,7 @@ def add_cloud(self, name: str, cloud: dict, controller: str | None) -> bool:
]
if controller:
cmd.extend(["--controller", controller, "--force"])
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand All @@ -1651,7 +1651,7 @@ def add_k8s_cloud_in_client(self, name: str, kubeconfig: dict):

env = os.environ.copy()
env.update({"KUBECONFIG": temp.name})
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd, capture_output=True, text=True, check=True, env=env
)
Expand Down Expand Up @@ -1679,7 +1679,7 @@ def add_credential(self, cloud: str, credential: dict, controller: str | None):
cmd.extend(["--controller", controller])
else:
cmd.extend(["--client"])
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand All @@ -1702,7 +1702,7 @@ def integrate(
requirer,
]
try:
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand All @@ -1722,7 +1722,7 @@ def remove_relation(self, model: str, provider: str, requirer: str):
provider,
requirer,
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(f"Command finished. stdout={process.stdout}, stderr={process.stderr}")

Expand Down
14 changes: 7 additions & 7 deletions sunbeam-python/sunbeam/core/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def init(self) -> None:
if backend_updated:
LOG.debug("Backend updated, running terraform init -reconfigure")
cmd.append("-reconfigure")
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd,
capture_output=True,
Expand Down Expand Up @@ -203,7 +203,7 @@ def apply(self, extra_args: list | None = None):
cmd.extend(["-auto-approve", "-no-color"])
if self.parallelism is not None:
cmd.append(f"-parallelism={self.parallelism}")
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd,
capture_output=True,
Expand Down Expand Up @@ -241,7 +241,7 @@ def destroy(self):
]
if self.parallelism is not None:
cmd.append(f"-parallelism={self.parallelism}")
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd,
capture_output=True,
Expand Down Expand Up @@ -270,7 +270,7 @@ def output(self, hide_output: bool = False) -> dict:

try:
cmd = [self.terraform, "output", "-json", "-no-color"]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd,
capture_output=True,
Expand Down Expand Up @@ -306,7 +306,7 @@ def pull_state(self) -> dict:

try:
cmd = [self.terraform, "state", "pull"]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd,
capture_output=True,
Expand Down Expand Up @@ -335,7 +335,7 @@ def state_list(self) -> list:

try:
cmd = [self.terraform, "state", "list"]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd,
capture_output=True,
Expand Down Expand Up @@ -365,7 +365,7 @@ def state_rm(self, resource: str) -> None:

try:
cmd = [self.terraform, "state", "rm", resource]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd,
capture_output=True,
Expand Down
5 changes: 1 addition & 4 deletions sunbeam-python/sunbeam/feature_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ def update_features(
p.upgrade_hook(deployment, upgrade_release=upgrade_release)
except TypeError:
LOG.debug(
(
f"Feature {p.name} does not support upgrades "
"between channels"
)
f"Feature {p.name} does not support upgrades between channels"
)
p.upgrade_hook(deployment)
2 changes: 1 addition & 1 deletion sunbeam-python/sunbeam/features/interface/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def validate_ca_chain(
chain_bytes = base64.b64decode(value)
chain_list = re.findall(
pattern=(
"(?=-----BEGIN CERTIFICATE-----)(.*?)" "(?<=-----END CERTIFICATE-----)"
"(?=-----BEGIN CERTIFICATE-----)(.*?)(?<=-----END CERTIFICATE-----)"
),
string=chain_bytes.decode(),
flags=re.DOTALL,
Expand Down
2 changes: 1 addition & 1 deletion sunbeam-python/sunbeam/features/validation/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Profile(pydantic.BaseModel):
DEFAULT_PROFILE = Profile(
name="refstack",
help=(
"Tests that are part of the RefStack project " "https://refstack.openstack.org/"
"Tests that are part of the RefStack project https://refstack.openstack.org/"
),
params={"test-list": "refstack-2022.11"},
)
Expand Down
8 changes: 4 additions & 4 deletions sunbeam-python/sunbeam/features/vault/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_vault_status(self, unit: str) -> dict:
"-tls-skip-verify",
"-format=json",
]
LOG.debug(f'Running vault command: {" ".join(cmd)}')
LOG.debug(f"Running vault command: {' '.join(cmd)}")
result = self._run_command_on_container(unit, cmd)
LOG.debug(f"Vault command result: {result}")
return json.loads(result.get("stdout"))
Expand All @@ -149,7 +149,7 @@ def initialize_vault(self, unit: str, key_shares: int, key_threshold: int) -> di
"-tls-skip-verify",
"-format=json",
]
LOG.debug(f'Running vault command: {" ".join(cmd)}')
LOG.debug(f"Running vault command: {' '.join(cmd)}")
result = self._run_command_on_container(unit, cmd)
# Do not log result since the result has secret keys
LOG.debug(f"Vault command result code: {result['return-code']}")
Expand All @@ -175,7 +175,7 @@ def unseal_vault(self, unit: str, key: str) -> dict:
"-format=json",
key,
]
LOG.debug(f'Running vault command: {" ".join(cmd[:-1])}')
LOG.debug(f"Running vault command: {' '.join(cmd[:-1])}")
result = self._run_command_on_container(unit, cmd)
LOG.debug(f"Vault command result: {result}")
if result["return-code"] != 0:
Expand All @@ -201,7 +201,7 @@ def create_token(self, unit: str, root_token: str) -> dict:
"-format=json",
]
env = {"VAULT_TOKEN": root_token}
LOG.debug(f'Running vault command: {" ".join(cmd)}')
LOG.debug(f"Running vault command: {' '.join(cmd)}")
result = self._run_command_on_container(unit, cmd, env)
# Do not log result since the result has root token
LOG.debug(f"Vault command result code: {result.get('return-code')}")
Expand Down
8 changes: 4 additions & 4 deletions sunbeam-python/sunbeam/provider/maas/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ def run(self) -> DiagnosticsResult:
diagnostics=textwrap.dedent(
f"""\
A machine needs to be in spaces to be a part of an openstack
deployment. Given machine has roles: {', '.join(assigned_roles)},
deployment. Given machine has roles: {", ".join(assigned_roles)},
and therefore needs to be a part of the following spaces:
{', '.join(required_spaces)}."""
{", ".join(required_spaces)}."""
),
machine=self.machine["hostname"],
)
Expand Down Expand Up @@ -551,7 +551,7 @@ def run(self) -> DiagnosticsResult:
{memory_min}MB RAM to be a part of an openstack deployment.
Either add more cores and memory to the machine or remove the
machine from the deployment.
{self.machine['hostname']}:
{self.machine["hostname"]}:
roles: {self.machine["roles"]}
cores: {self.machine["cores"]}
memory: {self.machine["memory"]}MB"""
Expand Down Expand Up @@ -690,7 +690,7 @@ def run(self) -> DiagnosticsResult:
diagnostics = textwrap.dedent(
f"""\
A deployment needs to have either 1 zone or more than 2 zones.
Current zones: {', '.join(self.zones)}
Current zones: {", ".join(self.zones)}
"""
)
if nb_zones == 0:
Expand Down
30 changes: 15 additions & 15 deletions sunbeam-python/sunbeam/steps/juju.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def run(self, status: Status | None = None) -> Result:
arg = "=".join((option, "********"))
hidden_cmd.append(arg)

LOG.debug(f'Running command {" ".join(hidden_cmd)}')
LOG.debug(f"Running command {' '.join(hidden_cmd)}")
env = os.environ.copy()
env.update(self.proxy_settings)

Expand Down Expand Up @@ -345,7 +345,7 @@ def run(self, status: Status | None = None) -> Result:
str(self.n),
*self.extra_args,
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(f"Command finished. stdout={process.stdout}, stderr={process.stderr}")
cmd = [
Expand All @@ -360,7 +360,7 @@ def run(self, status: Status | None = None) -> Result:
]
self.update_status(status, "scaling controller")
LOG.debug("Waiting for HA to be enabled")
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(f"Command finished. stdout={process.stdout}, stderr={process.stderr}")
return Result(ResultType.COMPLETED)
Expand Down Expand Up @@ -456,7 +456,7 @@ def run(self, status: Status | None = None) -> Result:
"""
try:
cmd = [self._get_juju_binary(), "add-user", self.username]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand All @@ -473,7 +473,7 @@ def run(self, status: Status | None = None) -> Result:

# Grant superuser access to user.
cmd = [self._get_juju_binary(), "grant", self.username, "superuser"]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand All @@ -488,7 +488,7 @@ def run(self, status: Status | None = None) -> Result:
"admin",
CONTROLLER_MODEL,
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand Down Expand Up @@ -536,7 +536,7 @@ def run(self, status: Status | None = None) -> Result:
"admin",
model_with_owner,
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand Down Expand Up @@ -594,7 +594,7 @@ def run(self, status: Status | None = None) -> Result:
"""
try:
cmd = [self._get_juju_binary(), "remove-user", self.username, "--yes"]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand Down Expand Up @@ -699,7 +699,7 @@ def run(self, status: Status | None = None) -> Result:
self.controller,
"--no-prompt",
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(
cmd, capture_output=True, text=True, check=True
)
Expand Down Expand Up @@ -901,7 +901,7 @@ def run(self, status: Status | None = None) -> Result:
self.controller,
"--no-prompt",
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand Down Expand Up @@ -1080,7 +1080,7 @@ def run(self, status: Status | None = None) -> Result:
str(self.machine_id),
"--no-prompt",
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand Down Expand Up @@ -1600,7 +1600,7 @@ def run(self, status: Status | None = None) -> Result:
"--base",
JUJU_BASE,
]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
env = os.environ.copy()
env.update(self.proxy_settings)
process = subprocess.run(
Expand Down Expand Up @@ -1928,7 +1928,7 @@ def run(self, status: Status | None = None) -> Result:
"""Switch to juju controller."""
try:
cmd = [self._get_juju_binary(), "switch", self.controller]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand Down Expand Up @@ -2156,7 +2156,7 @@ def __init__(

def _switch_controller(self, controller: str):
cmd = [self._get_juju_binary(), "switch", controller]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(f"Command finished. stdout={process.stdout}, stderr={process.stderr}")

Expand Down Expand Up @@ -2205,7 +2205,7 @@ def run(self, status: Status | None = None) -> Result:

try:
cmd = [self._get_juju_binary(), "migrate", self.model, self.to_controller]
LOG.debug(f'Running command {" ".join(cmd)}')
LOG.debug(f"Running command {' '.join(cmd)}")
process = subprocess.run(cmd, capture_output=True, text=True, check=True)
LOG.debug(
f"Command finished. stdout={process.stdout}, stderr={process.stderr}"
Expand Down
2 changes: 1 addition & 1 deletion sunbeam-python/sunbeam/steps/microceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def run(self, status: Status | None = None) -> Result:
LOG.debug(f"Failed to remove resource {resource}: {str(e)}")
return Result(
ResultType.FAILED,
f"Failed to remove resource {resource}" " from state",
f"Failed to remove resource {resource} from state",
)

return super().run(status)
Loading