diff --git a/.zuul.yaml b/.zuul.yaml index cb466fe4..62716583 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -61,16 +61,19 @@ - hadolint - container-image-python-osism-build - mypy + - python-black gate: jobs: - flake8 - hadolint + - python-black periodic-daily: jobs: - flake8 - hadolint - container-image-python-osism-push - mypy + - python-black post: jobs: - container-image-python-osism-push: diff --git a/files/import/main.py b/files/import/main.py index a483f1e6..9fa6f8cd 100644 --- a/files/import/main.py +++ b/files/import/main.py @@ -423,7 +423,6 @@ def createDeviceTypes(deviceTypes, nb): def main(): - cwd = os.getcwd() startTime = datetime.now() diff --git a/osism/actions/check_configuration.py b/osism/actions/check_configuration.py index 0f5df9e2..6cb1d969 100644 --- a/osism/actions/check_configuration.py +++ b/osism/actions/check_configuration.py @@ -7,7 +7,6 @@ def for_device(name, parameters={}): - device = utils.nb.dcim.devices.get(name=name) if ( diff --git a/osism/actions/deploy_configuration.py b/osism/actions/deploy_configuration.py index fc70a021..fb05523e 100644 --- a/osism/actions/deploy_configuration.py +++ b/osism/actions/deploy_configuration.py @@ -9,7 +9,6 @@ def for_device(name, parameters={}, mode="deploy"): - device = utils.nb.dcim.devices.get(name=name) if ( @@ -53,7 +52,6 @@ def for_device(name, parameters={}, mode="deploy"): if not first and last_commit == current_commit and mode == "deploy": logger.info(f"No deployment for device {device.name} required") else: - if not first: try: last_configuration = repo.git.show( @@ -76,7 +74,6 @@ def for_device(name, parameters={}, mode="deploy"): f"There is now prepared configuration for device {device.name}" ) else: - t = jinja2.Environment(loader=jinja2.BaseLoader()).from_string( current_configuration ) diff --git a/osism/actions/diff_configuration.py b/osism/actions/diff_configuration.py index 8a7f69dc..1397f265 100644 --- a/osism/actions/diff_configuration.py +++ b/osism/actions/diff_configuration.py @@ -8,7 +8,6 @@ def for_device(name, parameters={}): - device = utils.nb.dcim.devices.get(name=name) if ( diff --git a/osism/actions/manage_device.py b/osism/actions/manage_device.py index 0f9ea848..517ee171 100644 --- a/osism/actions/manage_device.py +++ b/osism/actions/manage_device.py @@ -124,7 +124,6 @@ def manage_interfaces(device, data): lag_interfaces = get_lag_interfaces(data) for interface in data[device]: - if data[device][interface]["type"] in ["virtual", "port-channel", "mlag"]: continue @@ -311,7 +310,6 @@ def manage_interfaces(device, data): # ensure that all interfaces are enabled that should be enabled if not interface_a.enabled: - if "enabled" in data[device][interface]["data"]: interface_a.enabled = bool(data[device][interface]["data"]["enabled"]) else: diff --git a/osism/commands/reconciler.py b/osism/commands/reconciler.py index e4923152..9b6b4814 100644 --- a/osism/commands/reconciler.py +++ b/osism/commands/reconciler.py @@ -77,6 +77,4 @@ def take_action(self, parsed_args): redis.close() return rc else: - logger.info( - f"Task {t.task_id} is running in background. No more output." - ) + logger.info(f"Task {t.task_id} is running in background. No more output.") diff --git a/osism/commands/vault.py b/osism/commands/vault.py index 5b46195a..fc3f99bb 100644 --- a/osism/commands/vault.py +++ b/osism/commands/vault.py @@ -13,7 +13,6 @@ class SetPassword(Command): - keyfile = "/share/ansible_vault_password.key" def get_parser(self, prog_name): diff --git a/osism/commands/wait.py b/osism/commands/wait.py index 735d4217..108b42ce 100644 --- a/osism/commands/wait.py +++ b/osism/commands/wait.py @@ -63,7 +63,6 @@ def take_action(self, parsed_args): result = AsyncResult(f"{task_id}", app=app) if result.state == "PENDING": - q = i.query_task(f"{task_id}") if not len([x for x in q.values() if len(x)]): if format == "log": @@ -79,7 +78,6 @@ def take_action(self, parsed_args): task_ids.insert(0, task_id) elif result.state == "SUCCESS": - if format == "log": logger.info(f"Task {task_id} is in state SUCCESS") elif format == "script": @@ -89,7 +87,6 @@ def take_action(self, parsed_args): print(result.get()) elif result.state == "STARTED": - if format == "log": logger.info(f"Task {task_id} is in state STARTED") elif format == "script": diff --git a/osism/services/listener.py b/osism/services/listener.py index 206eca25..375bbfc9 100644 --- a/osism/services/listener.py +++ b/osism/services/listener.py @@ -96,7 +96,6 @@ def on_message(self, body, message): netbox.set_state.delay(name, object_data["provision_state"], "provision") if object_data["provision_state"] == "manageable": - # system should be in state c netbox.connect.delay(name, "c") @@ -120,7 +119,6 @@ def on_message(self, body, message): object_data["previous_provision_state"] == "cleaning" and object_data["provision_state"] == "available" ): # noqa - # system should be in state c netbox.connect.delay(name, "c") diff --git a/osism/settings.py b/osism/settings.py index 9cae6960..5c87fc13 100644 --- a/osism/settings.py +++ b/osism/settings.py @@ -32,4 +32,6 @@ def read_secret(secret_name): # 43200 seconds = 12 hours GATHER_FACTS_SCHEDULE = float(os.getenv("GATHER_FACTS_SCHEDULE", "43200.0")) -INVENTORY_RECONCILER_SCHEDULE = float(os.getenv("INVENTORY_RECONCILER_SCHEDULE", "600.0")) +INVENTORY_RECONCILER_SCHEDULE = float( + os.getenv("INVENTORY_RECONCILER_SCHEDULE", "600.0") +) diff --git a/osism/tasks/conductor.py b/osism/tasks/conductor.py index 4558804f..1f8efb2c 100644 --- a/osism/tasks/conductor.py +++ b/osism/tasks/conductor.py @@ -45,7 +45,6 @@ def celery_init_worker(**kwargs): # Resolve all IDs in the conductor.yml if Config.enable_ironic in ["True", "true", "Yes", "yes"]: - if "ironic_parameters" not in configuration: logger.error( "ironic_parameters not found in the conductor configuration" diff --git a/osism/tasks/netbox.py b/osism/tasks/netbox.py index 27ffd2f3..4cbdfbbc 100644 --- a/osism/tasks/netbox.py +++ b/osism/tasks/netbox.py @@ -51,7 +51,6 @@ def celery_init_worker(**kwargs): @app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): - if Config.enable_bifrost in ["True", "true", "Yes", "yes"]: # Synchronize the status of Bifrost with Netbox every 5 minutes sender.add_periodic_task(300.0, periodic_synchronize_bifrost.s(), expires=10)