Skip to content
Snippets Groups Projects

Migrate iptrunks ansible integration

Merged Simone Spinelli requested to merge migrate_iptrunks_ansible_integration into develop
Files
4
+ 27
12
@@ -19,6 +19,10 @@ class IPTrunkParams(BaseModel):
callback: HttpUrl
#: A dictionary representation of the IP trunk subscription that is to be provisioned.
subscription: dict
#: Trouble Ticket number that is associated with the deployment.
tt_number: str
#: The process ID generated by workflow orchestrator, used for the commit comment in the routers.
process_id: str
class IPTrunkProvisioningParams(IPTrunkParams):
@@ -52,6 +56,8 @@ class IPTrunkMigrationParams(IPTrunkParams):
new_side: dict
#: An Ansible playbook verb that is passed along for indicating the phase of the migration that is performed.
verb: str
#: The type of object that is migrated.
config_object: str
class IPTrunkCheckParams(IPTrunkParams):
@@ -86,8 +92,9 @@ def provision_ip_trunk(params: IPTrunkProvisioningParams) -> PlaybookLaunchRespo
"dry_run": str(params.dry_run),
"verb": "deploy",
"config_object": params.object,
"commit_comment": f"IPtrunk {params.subscription['iptrunk']['geant_s_sid']} "
f"({params.subscription['subscription_id']}) - deployment of {params.object}",
"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(
@@ -117,9 +124,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"IPtrunk "
f"{params.subscription['iptrunk']['geant_s_sid']} "
f"({params.subscription['subscription_id']})",
"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(
@@ -150,10 +157,9 @@ def delete_ip_trunk(params: IPTrunkDeleteParams) -> PlaybookLaunchResponse:
"dry_run": str(params.dry_run),
"verb": "terminate",
"config_object": "trunk_deprovision",
"commit_comment": f"IPtrunk "
f"{params.subscription['iptrunk']['geant_s_sid']} "
f"({params.subscription['subscription_id']}) "
f"- termination",
"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(
@@ -204,18 +210,27 @@ def migrate_ip_trunk(params: IPTrunkMigrationParams) -> PlaybookLaunchResponse:
"""
extra_vars = {
"wfo_trunk_json": params.subscription,
"new_side": params.new_side,
"dry_run": str(params.dry_run),
"new_node": params.new_side["new_node"],
"new_lag_interface": params.new_side["new_lag_interface"],
"new_lag_member_interfaces": params.new_side["new_lag_member_interfaces"],
"replace_index": params.new_side["replace_index"],
"verb": params.verb,
"config_object": params.config_object,
"dry_run": str(params.dry_run),
"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(
playbook_path=path.join(config_params.ansible_playbooks_root_dir, "iptrunks.yaml"),
playbook_path=path.join(config_params.ansible_playbooks_root_dir, "iptrunks_migration.yaml"),
inventory=str(
params.subscription["iptrunk"]["iptrunk_sides"][0]["iptrunk_side_node"]["router_fqdn"]
+ "\n"
+ params.subscription["iptrunk"]["iptrunk_sides"][1]["iptrunk_side_node"]["router_fqdn"]
+ "\n"
+ params.new_side["new_node"]["router"]["router_fqdn"]
+ "\n"
),
extra_vars=extra_vars,
callback=params.callback,
Loading