diff --git a/gso/cli/imports.py b/gso/cli/imports.py index 7bfcbd2afccdd9c13623a4817fc3567c2bfdfe03..fad9d1e14328b4319d60ed066cbc79b188c7b584 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -53,6 +53,7 @@ from gso.utils.types.ip_address import ( from gso.utils.types.virtual_identifiers import VC_ID, VLAN_ID app: typer.Typer = typer.Typer() +IMPORT_WAIT_MESSAGE = "Waiting for the dust to settle before importing new products..." class CreatePartner(BaseModel): @@ -451,7 +452,7 @@ def _generic_import_product( except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before moving on the importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) # Migrate new products from imported to "full" counterpart. @@ -539,7 +540,7 @@ def import_edge_port(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before moving on the importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) edge_port_ids = get_subscriptions( @@ -610,7 +611,7 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before moving on the importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) trunk_ids = get_subscriptions( @@ -670,7 +671,7 @@ def import_l3_core_service(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) # Migrate new products from imported to "full" counterpart. @@ -728,7 +729,7 @@ def import_layer_2_circuit_service(filepath: str = common_filepath_option) -> No ) except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) # Migrate new products from imported to "full" counterpart. diff --git a/gso/services/lso_client.py b/gso/services/lso_client.py index 9280cbc4dbcbb6d1bb4d111c1f341b22fb0114b7..6f5d8599822c7bf1a94b5274db55ab09e102ac92 100644 --- a/gso/services/lso_client.py +++ b/gso/services/lso_client.py @@ -22,6 +22,7 @@ from unidecode import unidecode from gso import settings logger = logging.getLogger(__name__) +RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME = "Running Ansible playbook" class _LSOState(TypedDict): # noqa: PYI049 @@ -211,7 +212,7 @@ def lso_interaction(provisioning_step: Step) -> StepList: >> _inventory_is_not_empty( begin >> callback_step( - name="Running Ansible playbook", action_step=_execute_playbook, validate_step=_evaluate_results + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=_evaluate_results ) >> step("Inject result title")(lambda: {"lso_result_title": provisioning_step.name}) >> _show_results @@ -243,7 +244,7 @@ def indifferent_lso_interaction(provisioning_step: Step) -> StepList: >> _inventory_is_not_empty( begin >> callback_step( - name="Running Ansible playbook", action_step=_execute_playbook, validate_step=_ignore_results + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=_ignore_results ) >> step("Inject result title")(lambda: {"lso_result_title": provisioning_step.name}) >> _show_results @@ -268,7 +269,9 @@ def anonymous_lso_interaction(provisioning_step: Step, validation_step: Step = _ begin >> provisioning_step >> _inventory_is_not_empty( - callback_step(name="Running Ansible playbook", action_step=_execute_playbook, validate_step=validation_step) + callback_step( + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=validation_step + ) ) >> _clean_state ) @@ -287,7 +290,7 @@ def anonymous_indifferent_lso_interaction(provisioning_step: Step) -> StepList: >> provisioning_step >> _inventory_is_not_empty( callback_step( - name="Running Ansible playbook", + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=_ignore_results, ) diff --git a/gso/utils/types/interfaces.py b/gso/utils/types/interfaces.py index 80ac4a5f84a804ed1ea97f8d8fade083ce5743a7..f76cd8de373ac4eb916d67d3370193de0210db51 100644 --- a/gso/utils/types/interfaces.py +++ b/gso/utils/types/interfaces.py @@ -54,10 +54,10 @@ def validate_juniper_phy_interface_name(interface_name: str) -> str: Returns: The interface name if match was successful, otherwise it will throw a ValueError exception. """ - pattern = re.compile(r"^(ge|et|xe)-1?[0-9]/[0-9]{1,2}/[0-9]{1,2}$") + pattern = re.compile(r"^(ge|et|xe)-1?\d/\d{1,2}/\d{1,2}$") if not bool(pattern.match(interface_name)): error_msg = ( - f"Invalid interface name. The interface name should be of format: xe-1/0/0. " f"Got: {interface_name}" + f"Invalid interface name. The interface name should be of format: xe-1/0/0, received: {interface_name}" ) raise ValueError(error_msg) return interface_name @@ -113,7 +113,7 @@ def bandwidth_string_is_valid(bandwidth_string: str) -> str: if len(bandwidth_string) < 2: # noqa: PLR2004 not a magic value raise ValueError(msg) - if bandwidth_string[-1:] not in "K" "M" "G" "T": + if bandwidth_string[-1:] not in set("K" "M" "G" "T"): raise ValueError(msg) try: diff --git a/gso/utils/types/site_name.py b/gso/utils/types/site_name.py index 903b3468abbe744280a77c27bb2cf7861e8a389e..48d91dba779722c3caede4205c707cc210c3ce77 100644 --- a/gso/utils/types/site_name.py +++ b/gso/utils/types/site_name.py @@ -11,7 +11,7 @@ def validate_site_name(site_name: str) -> str: The site name must consist of three uppercase letters, optionally followed by a single digit. """ - pattern = re.compile(r"^[A-Z]{3}[0-9]?$") + pattern = re.compile(r"^[A-Z]{3}\d?$") if not pattern.match(site_name): msg = ( "Enter a valid site name. It must consist of three uppercase letters (A-Z), followed by an optional single " diff --git a/gso/workflows/edge_port/create_edge_port.py b/gso/workflows/edge_port/create_edge_port.py index a62c7147531299f8fdad5c822fe9077278cd2397..f715e10470ede68c7993f7af58c1344c20ffe3b4 100644 --- a/gso/workflows/edge_port/create_edge_port.py +++ b/gso/workflows/edge_port/create_edge_port.py @@ -154,7 +154,7 @@ def initialize_subscription( subscription.edge_port.ga_id = ga_id subscription.edge_port.mac_address = mac_address partner_name = get_partner_by_id(partner).name - subscription.description = f"Edge Port {name} on {router.router_fqdn}, " f"{partner_name}, {ga_id or ""}" + subscription.description = f"Edge Port {name} on {router.router_fqdn}, {partner_name}, {ga_id or ""}" subscription.edge_port.edge_port_description = description for member in ae_members: subscription.edge_port.edge_port_ae_members.append( diff --git a/gso/workflows/iptrunk/migrate_iptrunk.py b/gso/workflows/iptrunk/migrate_iptrunk.py index 1282f6365b65b6edaf3c9d7c42977b57cd9b51af..83e7000c5c3376bd12934ce5d64b8ab52661fd94 100644 --- a/gso/workflows/iptrunk/migrate_iptrunk.py +++ b/gso/workflows/iptrunk/migrate_iptrunk.py @@ -445,7 +445,7 @@ def update_remaining_side_bfd_dry( "verb": "update", "config_object": "bfd_update", "dry_run": True, - "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} " f"- Update BFD config.", + "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Update BFD config.", } return { @@ -473,7 +473,7 @@ def update_remaining_side_bfd_real( "verb": "update", "config_object": "bfd_update", "dry_run": False, - "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} " f"- Update BFD config.", + "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Update BFD config.", } return { diff --git a/sonar.properties b/sonar.properties index 4933ccded6da45048827c9c5c748ce232806cd70..cea633fcce5f5f68771bed8d097568fd195ac865 100644 --- a/sonar.properties +++ b/sonar.properties @@ -1,6 +1,7 @@ sonar.projectKey=gso sonar.projectName=GSO -sonar.projectVersion=0.x +sonar.projectVersion=2.28 sonar.sources=gso sonar.python.coverage.reportPaths=coverage.xml -sonar.host.url=https://sonarqube.software.geant.org/ \ No newline at end of file +sonar.host.url=https://sonarqube.software.geant.org/ +sonar.exclusions=gso/migrations/**, test/**, docs/** diff --git a/test/fixtures/layer_2_circuit_fixtures.py b/test/fixtures/layer_2_circuit_fixtures.py index 2b93a37025a3ae728f68d0b869305b20b7474ff8..b8772cf44c08c58ed2fdc77a1ec5d21504b668bc 100644 --- a/test/fixtures/layer_2_circuit_fixtures.py +++ b/test/fixtures/layer_2_circuit_fixtures.py @@ -107,7 +107,7 @@ def layer_2_circuit_subscription_factory(faker, geant_partner, edge_port_subscri subscription.layer_2_circuit.bandwidth = None subscription.layer_2_circuit.policer_burst_rate = None subscription.description = description or ( - f"{subscription.product.name} - " f"{subscription.layer_2_circuit.virtual_circuit_id}" + f"{subscription.product.name} - {subscription.layer_2_circuit.virtual_circuit_id}" ) subscription = SubscriptionModel.from_other_lifecycle(subscription, SubscriptionLifecycle.ACTIVE)