Skip to content
Snippets Groups Projects
Commit 0e14a4d4 authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

regnerated the PartnerTable migration again

parent bcea3135
Branches
Tags
1 merge request!176added partner model
Pipeline #85930 failed
name,email,as_number,as_set,route_set,black_listed_as_sets,additional_routers,additional_bgp_speakers,partner_type,created_at
Partner A,partnera@example.com,AS1234,,,"AS100,AS200",,"Router1,Router2",NREN,2024-03-14
Partner B,partnerb@example.com,AS5678,,,"AS300,AS400",,"Router3,Router4",RE_PEER,2024-03-15
Partner C,partnerc@example.com,AS91011,,,"AS500,AS600",,"Router5,Router6",PUBLIC_PEER,2024-03-16
...@@ -212,7 +212,7 @@ def import_partners_from_csv(file_path: Path) -> list[dict]: ...@@ -212,7 +212,7 @@ def import_partners_from_csv(file_path: Path) -> list[dict]:
@app.command() @app.command()
def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV file containing partners")): def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV file containing partners")) -> None:
"""Import partners from a CSV file into the database.""" """Import partners from a CSV file into the database."""
typer.echo(f"Importing partners from {file_path} ...") typer.echo(f"Importing partners from {file_path} ...")
...@@ -221,9 +221,7 @@ def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV f ...@@ -221,9 +221,7 @@ def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV f
try: try:
for partner in partners: for partner in partners:
if partner.get("created_at"): if partner.get("created_at"):
partner["created_at"] = datetime.strptime(partner["created_at"], "%Y-%m-%d").replace( partner["created_at"] = datetime.strptime(partner["created_at"], "%Y-%m-%d").replace(tzinfo=UTC)
tzinfo=UTC
)
new_partner = PartnerTable(**partner) new_partner = PartnerTable(**partner)
db.session.add(new_partner) db.session.add(new_partner)
......
...@@ -49,8 +49,6 @@ def create_partner( ...@@ -49,8 +49,6 @@ def create_partner(
raise raise
finally: finally:
db.session.close() db.session.close()
finally:
db.session.close()
def delete_partner_by_name(name: str) -> None: def delete_partner_by_name(name: str) -> None:
...@@ -67,5 +65,3 @@ def delete_partner_by_name(name: str) -> None: ...@@ -67,5 +65,3 @@ def delete_partner_by_name(name: str) -> None:
raise raise
finally: finally:
db.session.close() db.session.close()
finally:
db.session.close()
...@@ -258,7 +258,8 @@ def iptrunk_subscription_factory(iptrunk_side_subscription_factory, faker, geant ...@@ -258,7 +258,8 @@ def iptrunk_subscription_factory(iptrunk_side_subscription_factory, faker, geant
iptrunk_sides = iptrunk_sides or [iptrunk_side_a, iptrunk_side_b] iptrunk_sides = iptrunk_sides or [iptrunk_side_a, iptrunk_side_b]
iptrunk_subscription = IptrunkInactive.from_product_id( iptrunk_subscription = IptrunkInactive.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True) product_id, customer_id=partner["partner_id"], insync=True
)
iptrunk_subscription.iptrunk.geant_s_sid = geant_s_sid iptrunk_subscription.iptrunk.geant_s_sid = geant_s_sid
iptrunk_subscription.iptrunk.iptrunk_description = iptrunk_description iptrunk_subscription.iptrunk.iptrunk_description = iptrunk_description
iptrunk_subscription.iptrunk.iptrunk_type = iptrunk_type iptrunk_subscription.iptrunk.iptrunk_type = iptrunk_type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment