From 4ff242bbedffc93ff927cbfed48edc8758b945a3 Mon Sep 17 00:00:00 2001 From: Juliana Cardozo Date: Mon, 17 Aug 2026 10:52:03 -0300 Subject: [PATCH 1/2] feat: add undeploying and deploying status for portchannel --- ...103000_expand_status_deploy_port_channel.migration | 11 +++++++++++ networkapi/api_interface/facade.py | 2 ++ networkapi/interface/models.py | 6 ++++-- .../interface/resource/InterfaceChannelResource.py | 4 ++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration diff --git a/dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration b/dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration new file mode 100644 index 00000000..a702237d --- /dev/null +++ b/dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration @@ -0,0 +1,11 @@ +#-*- coding:utf-8 -*- +SQL_UP = u""" +-- Expands status_deploy size to support in-progress values (deploying/undeploying) +ALTER TABLE `port_channel` +MODIFY COLUMN `status_deploy` VARCHAR(15) NOT NULL DEFAULT 'pending'; +""" + +SQL_DOWN = u""" +ALTER TABLE `port_channel` +MODIFY COLUMN `status_deploy` VARCHAR(10) NOT NULL DEFAULT 'pending'; +""" diff --git a/networkapi/api_interface/facade.py b/networkapi/api_interface/facade.py index 17bfe2b3..2690b49d 100644 --- a/networkapi/api_interface/facade.py +++ b/networkapi/api_interface/facade.py @@ -489,6 +489,8 @@ def generate_and_deploy_channel_config_sync(user, id_channel): raise exceptions.InvalidIdInterfaceException() channel = PortChannel.get_by_pk(id_channel) + channel.status_deploy = StatusDeploy.deploying[0] + channel.save(user) interfaces = channel.list_interfaces() diff --git a/networkapi/interface/models.py b/networkapi/interface/models.py index 67862dfc..25dc8e70 100644 --- a/networkapi/interface/models.py +++ b/networkapi/interface/models.py @@ -148,9 +148,11 @@ def get_by_name(cls, name): class StatusDeploy: pending = ('pending', 'pending') + deploying = ('deploying', 'deploying') + undeploying = ('undeploying', 'undeploying') deployed = ('deployed', 'deployed') error = ('error', 'error') - list_type = (pending, deployed, error) + list_type = (pending, deploying, undeploying, deployed, error) class PortChannel(BaseModel): @@ -161,7 +163,7 @@ class PortChannel(BaseModel): nome = models.CharField(max_length=10, unique=True) lacp = models.BooleanField(default=1) status_deploy = models.CharField( - max_length=10, + max_length=15, choices=StatusDeploy.list_type, default=StatusDeploy.pending[0] ) diff --git a/networkapi/interface/resource/InterfaceChannelResource.py b/networkapi/interface/resource/InterfaceChannelResource.py index bba6f1fd..2635df65 100644 --- a/networkapi/interface/resource/InterfaceChannelResource.py +++ b/networkapi/interface/resource/InterfaceChannelResource.py @@ -338,6 +338,10 @@ def handle_delete(self, request, user, *args, **kwargs): # For each equipment (leaf), undeploy port channel config try: + if keep_db: + channel.status_deploy = StatusDeploy.undeploying[0] + channel.save(user, commit=True) + for e in equip_dict: if not keep_db: for i in equip_dict.get(e): From 4800a8e16164c36b8596083f57d47b299896b0de Mon Sep 17 00:00:00 2001 From: Juliana Cardozo Date: Tue, 18 Aug 2026 11:02:43 -0300 Subject: [PATCH 2/2] feat: add 'processing' status for portchannel deploy --- ...103000_expand_status_deploy_port_channel.migration | 11 ----------- networkapi/api_interface/facade.py | 2 +- networkapi/interface/models.py | 7 +++---- .../interface/resource/InterfaceChannelResource.py | 2 +- 4 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration diff --git a/dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration b/dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration deleted file mode 100644 index a702237d..00000000 --- a/dbmigrate/migrations/20260810103000_expand_status_deploy_port_channel.migration +++ /dev/null @@ -1,11 +0,0 @@ -#-*- coding:utf-8 -*- -SQL_UP = u""" --- Expands status_deploy size to support in-progress values (deploying/undeploying) -ALTER TABLE `port_channel` -MODIFY COLUMN `status_deploy` VARCHAR(15) NOT NULL DEFAULT 'pending'; -""" - -SQL_DOWN = u""" -ALTER TABLE `port_channel` -MODIFY COLUMN `status_deploy` VARCHAR(10) NOT NULL DEFAULT 'pending'; -""" diff --git a/networkapi/api_interface/facade.py b/networkapi/api_interface/facade.py index 2690b49d..e96c685f 100644 --- a/networkapi/api_interface/facade.py +++ b/networkapi/api_interface/facade.py @@ -489,7 +489,7 @@ def generate_and_deploy_channel_config_sync(user, id_channel): raise exceptions.InvalidIdInterfaceException() channel = PortChannel.get_by_pk(id_channel) - channel.status_deploy = StatusDeploy.deploying[0] + channel.status_deploy = StatusDeploy.processing[0] channel.save(user) interfaces = channel.list_interfaces() diff --git a/networkapi/interface/models.py b/networkapi/interface/models.py index 25dc8e70..4d902fe1 100644 --- a/networkapi/interface/models.py +++ b/networkapi/interface/models.py @@ -148,11 +148,10 @@ def get_by_name(cls, name): class StatusDeploy: pending = ('pending', 'pending') - deploying = ('deploying', 'deploying') - undeploying = ('undeploying', 'undeploying') + processing = ('processing', 'processing') deployed = ('deployed', 'deployed') error = ('error', 'error') - list_type = (pending, deploying, undeploying, deployed, error) + list_type = (pending, processing, deployed, error) class PortChannel(BaseModel): @@ -163,7 +162,7 @@ class PortChannel(BaseModel): nome = models.CharField(max_length=10, unique=True) lacp = models.BooleanField(default=1) status_deploy = models.CharField( - max_length=15, + max_length=10, choices=StatusDeploy.list_type, default=StatusDeploy.pending[0] ) diff --git a/networkapi/interface/resource/InterfaceChannelResource.py b/networkapi/interface/resource/InterfaceChannelResource.py index 2635df65..e8710998 100644 --- a/networkapi/interface/resource/InterfaceChannelResource.py +++ b/networkapi/interface/resource/InterfaceChannelResource.py @@ -339,7 +339,7 @@ def handle_delete(self, request, user, *args, **kwargs): # For each equipment (leaf), undeploy port channel config try: if keep_db: - channel.status_deploy = StatusDeploy.undeploying[0] + channel.status_deploy = StatusDeploy.processing[0] channel.save(user, commit=True) for e in equip_dict: