Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgmt_vrf_namespace: management vrf using namespace solution #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

mgmt_vrf_namespace: management vrf using namespace solution #422

wants to merge 1 commit into from

Conversation

kannankvs
Copy link
Collaborator

- What I did
Added support for management VRF using namespace solution.
Requirements that are covered are explained in the design document.

- How I did it
Added config commands and show commands to enable/disable the management VRF. On enabling, it creates the management namespace, attached eth0 to management namespace, creates the required iptables rules and restarts the networking service.
Detailed design is explained in the design document.

- How to verify it
Use the following commands to enable/disable mgmt vrf and test the features.
config vrf add mgmt
config vrf del mgmt
config interface eth0 ip add ip/mask gatewayIP
Ex: config interface eth0 ip add 10.16.206.11/24 10.16.206.1

- Description for the changelog

def vrf_add_management_vrf():
"""Enable management vrf"""

cmd = 'sonic-cfggen -d --var-json "MGMT_VRF_CONFIG"'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to read this address from the config DB?
Why do you read using sonic-cfggen, but write directly to DB?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pavel-shirshov : Addressed your comment in #431. Instead of using cfggen to read, it now reads from config DB.


cmd = 'sonic-cfggen -d --var-json "MGMT_VRF_CONFIG"'
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
res = p.communicate()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd extract subprocess.Popen chunk as a function, otherwise you have a lot of duplicate code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pavel-shirshov : Addressed your comment in #431. Instead of using cfggen to read, it now reads from config DB and hence there is no duplicate usage of Popen chunk.

@click.pass_context
def vrf_add (ctx, vrfname):
"""VRF ADD"""
if vrfname == 'mgmt' or vrfname == 'management':
Copy link
Contributor

@pavel-shirshov pavel-shirshov Dec 31, 2018

Choose a reason for hiding this comment

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

why two VRF names? Do we need to choose one only? Like 'mgmt' you defined in the help?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pavel-shirshov : Replied to your comment in #431. Please check and followup in that PR.

if address in network:
return True
else:
return False
Copy link
Contributor

Choose a reason for hiding this comment

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

return address in network ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pavel-shirshov : Replied to your comment in #431. Please check and followup in that PR.

@@ -803,14 +932,42 @@ def ip(ctx):

@ip.command()
@click.argument("ip_addr", metavar="<ip_addr>", required=True)
@click.argument('gw1', metavar='<default gateway IP address>', required=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use gw here? Why gw1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pavel-shirshov : Addressed your comment in #431. Changed gw1 to gw.

"""Add an IP address towards the interface"""
config_db = ctx.obj["config_db"]
interface_name = ctx.obj["interface_name"]

if interface_name.startswith("Ethernet"):
config_db.set_entry("INTERFACE", (interface_name, ip_addr), {"NULL": "NULL"})
elif interface_name.startswith("eth0"):
Copy link
Contributor

Choose a reason for hiding this comment

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

It could match interface 'eth01'. I think it's better to compare to 'eth' here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pavel-shirshov : Addressed your comment in #431. Changed "startswith eth0" and checked for exact match with "eth0".

@@ -828,6 +985,8 @@ def remove(ctx, ip_addr):

if interface_name.startswith("Ethernet"):
config_db.set_entry("INTERFACE", (interface_name, ip_addr), None)
elif interface_name.startswith("eth0"):
Copy link
Contributor

Choose a reason for hiding this comment

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

interface_name ==

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pavel-shirshov : Addressed your comment in #431. Changed "startswith eth0" and checked for exact match with "eth0".

@lguohan
Copy link
Contributor

lguohan commented Jan 2, 2019

I am not sure we should use namespace problem to address management vrf in sonic.

@kannankvs
Copy link
Collaborator Author

kannankvs commented Jan 10, 2019

Since we faced some issues in raising pull requests on top of this pull request, we shall cancel this PR. New PR #431 is raised. Once if it is decided to use namespace solution for management VRF, all the comments given in this PR will be addressed as part of PR#431. This PR#422 is cancelled. Similarly the related sonic-buildimage PR 'sonic-net/sonic-buildimage#2405' is also cancelled.
The new PR on sonic-buildimage is at sonic-net/sonic-buildimage#2431.
PR#2431 together with PR#431 provides the complete support for namespace based management VRF solution.

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