diff --git a/lso/routes/ip_trunk.py b/lso/routes/ip_trunk.py index b1b4c3b3144bcab3a3a87a561f45f837260e5885..e1efb9f68ddae630b7dff3000bb35a05b63b076a 100644 --- a/lso/routes/ip_trunk.py +++ b/lso/routes/ip_trunk.py @@ -56,6 +56,7 @@ class IPTrunkMigrationParams(IPTrunkParams): verb: str config_object: str + class IPTrunkCheckParams(IPTrunkParams): """Additional parameters for checking an IPtrunk.""" @@ -88,7 +89,9 @@ def provision_ip_trunk(params: IPTrunkProvisioningParams) -> PlaybookLaunchRespo "dry_run": str(params.dry_run), "verb": "deploy", "config_object": params.object, - "commit_comment": f"GSO_PROCESS_ID: {params.process_id} - TT_NUMBER: {params.tt_number} - Deploy config for {params.subscription['iptrunk']['geant_s_sid']} ", + "commit_comment": f"GSO_PROCESS_ID: {params.process_id} " + f"- TT_NUMBER: {params.tt_number}" + f"- Deploy config for {params.subscription['iptrunk']['geant_s_sid']} ", } return run_playbook( @@ -118,7 +121,9 @@ def modify_ip_trunk(params: IPTrunkModifyParams) -> PlaybookLaunchResponse: "old_wfo_trunk_json": params.old_subscription, "dry_run": str(params.dry_run), "verb": "modify", - "commit_comment": f"GSO_PROCESS_ID: {params.process_id} - TT_NUMBER: {params.tt_number} - Modify config for {params.subscription['iptrunk']['geant_s_sid']} ", + "commit_comment": f"GSO_PROCESS_ID: {params.process_id} " + f"- TT_NUMBER: {params.tt_number}" + f"- Modify config for {params.subscription['iptrunk']['geant_s_sid']} ", } return run_playbook( @@ -149,7 +154,9 @@ def delete_ip_trunk(params: IPTrunkDeleteParams) -> PlaybookLaunchResponse: "dry_run": str(params.dry_run), "verb": "terminate", "config_object": "trunk_deprovision", - "commit_comment": f"GSO_PROCESS_ID: {params.process_id} - TT_NUMBER: {params.tt_number} - Remove config for {params.subscription['iptrunk']['geant_s_sid']} ", + "commit_comment": f"GSO_PROCESS_ID: {params.process_id} " + f"- TT_NUMBER: {params.tt_number}" + f"- Remove config for {params.subscription['iptrunk']['geant_s_sid']} ", } return run_playbook( @@ -207,7 +214,9 @@ def migrate_ip_trunk(params: IPTrunkMigrationParams) -> PlaybookLaunchResponse: "verb": params.verb, "config_object": params.config_object, "dry_run": str(params.dry_run), - "commit_comment": f"GSO_PROCESS_ID: {params.process_id} - TT_NUMBER: {params.tt_number} - Migrating - {params.verb} - {params.subscription['iptrunk']['geant_s_sid']} ", + "commit_comment": f"GSO_PROCESS_ID: {params.process_id} " + f"- TT_NUMBER: {params.tt_number}" + f"- Deploy config for {params.subscription['iptrunk']['geant_s_sid']} ", } return run_playbook( diff --git a/test/routes/test_ip_trunk.py b/test/routes/test_ip_trunk.py index 3f999aa9503a09177aad3e28f135c2b25974b56e..c9a5af2f1fe0071dc431cb0e6a574ae7e8c4d498 100644 --- a/test/routes/test_ip_trunk.py +++ b/test/routes/test_ip_trunk.py @@ -109,38 +109,35 @@ _SUBSCRIPTION_OBJECT = { _MIGRATION_OBJECT = { "new_node": { - "name": "RouterBlock", - "label": None, - "router_fqdn": "rt2.city.country.geant.net", - "router_role": "p", - "router_site": { - "name": "SiteBlock", - "label": None, - "site_city": "City", - "site_name": "city", - "site_tier": "1", - "site_country": "Country", - "site_latitude": 1, - "site_longitude": 1, - "site_ts_address": "0.0.0.0", - "site_internal_id": 2, - "site_country_code": "country", - "owner_subscription_id": "93cba8dc-7424-44c0-8872-13159df93042", - "site_bgp_community_id": 2, - "subscription_instance_id": "6bf4f274-6496-438d-9dba-9c3984d0ec07", + "description": "Router rt1.luc.it.geant.net", + "router": { + "router_access_via_ts": "true", + "router_fqdn": "rt1.luc.it.geant.net", + "router_role": "pe", + "router_is_ias_connected": "false", + "router_lo_ipv4_address": "62.40.96.7", + "router_lo_ipv6_address": "2001:798:aa:1::49", + "router_lo_iso_address": "49.51e5.0001.0620.4009.6007.00", + "router_site": { + "name": "SiteBlock", + "label": "null", + "site_city": "Lucca", + "site_name": "luc", + "site_tier": "1", + "site_country": "Italy", + "site_latitude": "10.0", + "site_longitude": "43.0", + "site_ts_address": "172.16.100.151", + "site_internal_id": 133, + "site_country_code": "IT", + "owner_subscription_id": "f4bacf38-39bb-4553-8e74-190699bd9b4e", + "site_bgp_community_id": 33, + "subscription_instance_id": "2cf443a2-4039-4402-ab75-73ff1a1096f5", + }, + "router_ts_port": 22111, + "router_vendor": "juniper", }, - "router_vendor": "juniper", - "router_ts_port": 11111, - "router_access_via_ts": True, - "owner_subscription_id": "9cb1fc7d-9608-42ce-aacc-2a97f9620a91", - "router_lo_iso_address": "49.51e5.0001.0620.4009.6066.00", - "router_lo_ipv4_address": "0.0.0.0", - "router_lo_ipv6_address": "::", - "router_si_ipv4_network": "0.0.0.0/31", - "router_is_ias_connected": True, - "subscription_instance_id": "6d09394e-658b-4e55-8b1f-8b812d59f5a1", - "router_ias_lt_ipv4_network": "0.0.0.0/31", - "router_ias_lt_ipv6_network": "::/126", + "status": "provisioning", }, "new_lag_interface": "ae1", "new_lag_member_interfaces": ["ge-0/0/0", "ge-0/0/1"], @@ -154,6 +151,8 @@ def test_ip_trunk_provisioning(client: TestClient) -> None: params = { "callback": TEST_CALLBACK_URL, + "process_id": "cb5f6c71-63d7-4857-9124-4fc6e7ef3f41", + "tt_number": "TT123456789", "dry_run": True, "object": "trunk_interface", "verb": "deploy", @@ -179,6 +178,8 @@ def test_ip_trunk_modification(client: TestClient) -> None: params = { "callback": TEST_CALLBACK_URL, + "process_id": "cb5f6c71-63d7-4857-9124-4fc6e7ef3f41", + "tt_number": "TT123456789", "dry_run": True, "verb": "modify", "subscription": _SUBSCRIPTION_OBJECT, @@ -202,7 +203,14 @@ def test_ip_trunk_modification(client: TestClient) -> None: def test_ip_trunk_deletion(client: TestClient) -> None: responses.put(url=TEST_CALLBACK_URL, status=204) - params = {"callback": TEST_CALLBACK_URL, "dry_run": True, "verb": "terminate", "subscription": _SUBSCRIPTION_OBJECT} + params = { + "callback": TEST_CALLBACK_URL, + "process_id": "cb5f6c71-63d7-4857-9124-4fc6e7ef3f41", + "tt_number": "TT123456789", + "dry_run": True, + "verb": "terminate", + "subscription": _SUBSCRIPTION_OBJECT, + } with patch("lso.playbook.ansible_runner.run", new=test_ansible_runner_run) as _: rv = client.request(url="/api/ip_trunk/", method=responses.DELETE, json=params) @@ -224,7 +232,10 @@ def test_ip_trunk_migration(client: TestClient) -> None: params = { "callback": TEST_CALLBACK_URL, "dry_run": True, + "process_id": "cb5f6c71-63d7-4857-9124-4fc6e7ef3f41", + "tt_number": "TT123456789", "verb": "migrate", + "config_object": "trunk_interface", "subscription": _SUBSCRIPTION_OBJECT, "new_side": _MIGRATION_OBJECT, } diff --git a/test/routes/test_router.py b/test/routes/test_router.py index 167af9d51ace6b5021ad5f37aca6f1793a9b92d8..3f7c5aa912302e97a99e6e3c3ebd223fe7167124 100644 --- a/test/routes/test_router.py +++ b/test/routes/test_router.py @@ -16,6 +16,8 @@ def test_router_provisioning(client: TestClient) -> None: params = { "callback": TEST_CALLBACK_URL, "dry_run": True, + "process_id": "cb5f6c71-63d7-4857-9124-4fc6e7ef3f41", + "tt_number": "TT123456789", "verb": "deploy", "subscription": { "router": {