Skip to content

Add new cli to add a interface ip as secondary address#3016

Merged
qiluo-msft merged 11 commits intosonic-net:masterfrom
shbalaku-microsoft:add-cli-command-for-specifying-secondary
May 15, 2024
Merged

Add new cli to add a interface ip as secondary address#3016
qiluo-msft merged 11 commits intosonic-net:masterfrom
shbalaku-microsoft:add-cli-command-for-specifying-secondary

Conversation

@shbalaku-microsoft
Copy link
Copy Markdown
Contributor

What I did

Added a new CLI command to add secondary subnet value.

How I did it

In the config class, added a snippet of code where the code to validate the secondary field and set the appropriate flag.

How to verify it

Added a test to validate the added flag

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)


if secondary:
# We update the secondary flag only in case of VLAN Interface.
if table_name == "VLAN_INTERFACE":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For other interface types, do we need to throw an error?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a validation to make sure not all IPs are marked as secondary?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a validation to make sure no more than one primary IP for a given VLAN interface?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a validation to make sure not all IPs are marked as secondary?

Ack, this is a good check.

Do we need a validation to make sure no more than one primary IP for a given VLAN interface?

This we cannot do for two reasons: a) impact to potential existing devices with more than one interface b) interchanging primary with secondary would need more than one primary intermittently.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been addressed. Only vlans with atleast one primary can be added with secondaries.

result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Vlan100", "10.11.20.1/24", "--secondary"], obj=obj)
assert result.exit_code == 0
assert ('Vlan100', '10.11.20.1/24') in db.cfgdb.get_table('VLAN_INTERFACE')
assert db.cfgdb.get_table('VLAN_INTERFACE')[('Vlan100', '10.11.20.1/24')]['secondary'] == "true"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a test where 'secondary' is false for non-secondary cli call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the test case for this scenario.

@shbalaku-microsoft
Copy link
Copy Markdown
Contributor Author

@venkatmahalingam can you review the PR?

@zhangyanzhao
Copy link
Copy Markdown
Collaborator

prsunny
prsunny previously approved these changes Feb 6, 2024
@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Feb 6, 2024

@venkatmahalingam , can you signoff?

@irene-pan1202
Copy link
Copy Markdown

@shbalaku-microsoft
The design of the secondary IP seems to have an issue that hasn't been considered?

  1. If a VLAN interface has only an IPv6 address, it is also considered as the primary IP, and an IPv4 secondary IP can still be successfully configured.
  2. Deleting the primary IP seems to not check if the secondary IP exists?

@zhangyanzhao
Copy link
Copy Markdown
Collaborator

@qiluo-msft can we merge this PR? Thanks.

@qiluo-msft
Copy link
Copy Markdown
Contributor

Please merge latest master branch. The semgrep checker is added after this PR raised, so it will always block.

@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Apr 29, 2024

@shbalaku-microsoft , can you please rebase the code?

@zhangyanzhao
Copy link
Copy Markdown
Collaborator

@shbalaku-microsoft kind reminder to rebase the code, so that we can merge this feature before 202405 fork date on 5/30

@qiluo-msft qiluo-msft merged commit e054b45 into sonic-net:master May 15, 2024
arfeigin pushed a commit to arfeigin/sonic-utilities that referenced this pull request Jun 16, 2024
#### What I did

Added a new CLI command to add secondary subnet value. 

#### How I did it

In the config class, added a snippet of code where the code to validate the secondary field and set the appropriate flag.

#### How to verify it

Added a test to validate the added flag
nmoray pushed a commit to nmoray/sonic-utilities that referenced this pull request Jun 25, 2025
#### What I did

Added a new CLI command to add secondary subnet value. 

#### How I did it

In the config class, added a snippet of code where the code to validate the secondary field and set the appropriate flag.

#### How to verify it

Added a test to validate the added flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants