From d3af8344c8f075452cd3fa8dcbe1fc28c2dd9661 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Thu, 29 Aug 2024 11:41:44 +0200 Subject: [PATCH] Update switch domain model --- ...bd9be532b3f9_update_switch_domain_model.py | 29 +++++++++++++++++++ gso/products/product_blocks/switch.py | 12 ++++---- 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 gso/migrations/versions/2024-08-29_bd9be532b3f9_update_switch_domain_model.py diff --git a/gso/migrations/versions/2024-08-29_bd9be532b3f9_update_switch_domain_model.py b/gso/migrations/versions/2024-08-29_bd9be532b3f9_update_switch_domain_model.py new file mode 100644 index 00000000..2abecc09 --- /dev/null +++ b/gso/migrations/versions/2024-08-29_bd9be532b3f9_update_switch_domain_model.py @@ -0,0 +1,29 @@ +"""Update switch domain model. + +Revision ID: bd9be532b3f9 +Revises: 87a05eddee3e +Create Date: 2024-08-29 11:41:06.936423 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = 'bd9be532b3f9' +down_revision = '87a05eddee3e' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + conn = op.get_bind() + conn.execute(sa.text(""" +UPDATE resource_types SET resource_type='switch_fqdn' WHERE resource_types.resource_type = 'switch_hostname' + """)) + + +def downgrade() -> None: + conn = op.get_bind() + conn.execute(sa.text(""" +UPDATE resource_types SET resource_type='switch_hostname' WHERE resource_types.resource_type = 'switch_fqdn' + """)) diff --git a/gso/products/product_blocks/switch.py b/gso/products/product_blocks/switch.py index bdf2b465..43be0169 100644 --- a/gso/products/product_blocks/switch.py +++ b/gso/products/product_blocks/switch.py @@ -26,7 +26,7 @@ class SwitchBlockInactive( ): """A switch that's being currently inactive. See :class:`SwitchBlock`.""" - switch_hostname: str | None = None + switch_fqdn: str | None = None switch_ts_port: PortNumber | None = None switch_site: SiteBlockInactive | None = None switch_vendor: Vendor | None = None @@ -36,18 +36,18 @@ class SwitchBlockInactive( class SwitchBlockProvisioning(SwitchBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]): """A switch that's being provisioned. See :class:`SwitchBlock`.""" - switch_hostname: str + switch_fqdn: str switch_ts_port: PortNumber switch_site: SiteBlockProvisioning switch_vendor: Vendor - switch_model: SwitchModel | None = None + switch_model: SwitchModel class SwitchBlock(SwitchBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): """A switch that's currently deployed in the network.""" - #: The hostname of the switch. - switch_hostname: str + #: The :term:`FQDN` of the switch. + switch_fqdn: str #: The port of the terminal server that this switch is connected to. Used to offer out of band access. switch_ts_port: PortNumber #: The :class:`Site` that this switch resides in. Both physically and computationally. @@ -55,4 +55,4 @@ class SwitchBlock(SwitchBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTI #: The vendor of the switch. switch_vendor: Vendor #: The model of the switch. - switch_model: SwitchModel | None = None + switch_model: SwitchModel -- GitLab