Skip to content

Validations checks while creating and deleting a Portchannel#1326

Merged
prsunny merged 3 commits intosonic-net:masterfrom
AkhileshSamineni:po_add_rem_validations
Jan 20, 2021
Merged

Validations checks while creating and deleting a Portchannel#1326
prsunny merged 3 commits intosonic-net:masterfrom
AkhileshSamineni:po_add_rem_validations

Conversation

@AkhileshSamineni
Copy link
Contributor

Added below validation checks when a portchannel is created by the user:
1 if a given portchannel name is valid or not
2 if a given portchannel name is already created by user (exists in CONFIG_DB)

Added below validation checks when a portchannel is attempted for deletion by the user:
1 if a given portchannel name is valid or not
2 if a given portchannel name exists in exists in CONFIG_DB or not (throw an error if it does not exist)

More details :
Issue 1 : Creating a invalid Portchannel name

If we create a portchannel with invalid name, it gets added to CONFIG_DB, like below
root@sonic:/home/admin# config portchannel add PortChan001
root@sonic:/home/admin#
root@sonic:/home/admin# sonic-db-cli CONFIG_DB keys *PORTCHANNEL*
PORTCHANNEL|PortChan001
root@sonic:/home/admin#

Fix: Added a PortChannel name validation check, like below

root@sonic:/home/admin# config portchannel add PortChan001
Usage: config portchannel add [OPTIONS] <portchannel_name>

Error: PortChan001 is invalid!, name should have prefix 'PortChannel' and suffix '<0-9999>'
root@sonic:/home/admin#

Issue 2 : Creating a same PortChannel again and deleting the portchannel which is not exists

If we create a same portchannel again, it is allowing, like below
root@sonic:/home/admin# config portchannel add PortChannel0001
root@sonic:/home/admin#
root@sonic:/home/admin# sonic-db-cli CONFIG_DB keys *PORTCHANNEL*
PORTCHANNEL|PortChannel0001
root@sonic:/home/admin#
root@sonic:/home/admin# config portchannel add PortChannel0001
root@sonic:/home/admin#
root@sonic:/home/admin# sonic-db-cli CONFIG_DB keys *PORTCHANNEL*
PORTCHANNEL|PortChannel0001
root@sonic:/home/admin#

If we delete a portchannel which is not exists, it is allowing
root@sonic:/home/admin# sonic-db-cli CONFIG_DB keys *PORTCHANNEL*
PORTCHANNEL|PortChannel0001
root@sonic:/home/admin#
root@sonic:/home/admin# config portchannel del PortChannel0002
root@sonic:/home/admin#

Fix : Added a validation check like given portchannel exists in CONFIG_DB or not

While creating a portchannel
root@sonic:/home/admin# config portchannel add PortChannel0001
root@sonic:/home/admin#
root@sonic:/home/admin# sonic-db-cli CONFIG_DB keys *PORTCHANNEL*
PORTCHANNEL|PortChannel0001
root@sonic:/home/admin#
root@sonic:/home/admin# config portchannel add PortChannel0001
Usage: config portchannel add [OPTIONS] <portchannel_name>

Error: PortChannel0001 already exists!
root@sonic:/home/admin#

While deleting a portchannel
root@sonic:/home/admin# sonic-db-cli CONFIG_DB keys *PORTCHANNEL*
PORTCHANNEL|PortChannel0001
root@sonic:/home/admin#
root@sonic:/home/admin# config portchannel del PortChannel0002
Usage: config portchannel del [OPTIONS] <portchannel_name>

Error: PortChannel0002 is not present.
root@sonic:/home/admin#

Signed-off-by: Akhilesh Samineni akhilesh.samineni@broadcom.com

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

7 similar comments
@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

@lguohan Please review the changes.

@prsunny
Copy link
Contributor

prsunny commented Jan 12, 2021

Does #1328 supersedes this PR?

@AkhileshSamineni
Copy link
Contributor Author

Does #1328 supersedes this PR?

@prsunny Yes, I have resolved the merge conflicts. Please review the changes now.

@AkhileshSamineni
Copy link
Contributor Author

@prsunny @lguohan Please review and merge the PR.

@prsunny prsunny merged commit 8119ba2 into sonic-net:master Jan 20, 2021
anand-kumar-subramanian pushed a commit to anand-kumar-subramanian/sonic-utilities that referenced this pull request Mar 2, 2021
…et#1326)

Added below validation checks when a portchannel is created by the user:
1 if a given portchannel name is valid or not
2 if a given portchannel name is already created by user (exists in CONFIG_DB)

Added below validation checks when a portchannel is attempted for deletion by the user:
1 if a given portchannel name is valid or not
2 if a given portchannel name exists in exists in CONFIG_DB or not (throw an error if it does not exist)

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants