Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions models/yang/annotations/openconfig-interfaces-annot.yang
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,32 @@ module openconfig-interfaces-annot {
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:config {
deviate add {
sonic-ext:table-name "NONE";
sonic-ext:subtree-transformer "intf_ip_addr_xfmr";
}
}
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:state {
deviate add {
sonic-ext:table-name "NONE";
sonic-ext:subtree-transformer "intf_ip_addr_xfmr";
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:config {
deviate add {
sonic-ext:table-name "NONE";
sonic-ext:subtree-transformer "intf_ip_addr_xfmr";
}
}
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:state {
deviate add {
sonic-ext:table-name "NONE";
sonic-ext:subtree-transformer "intf_ip_addr_xfmr";
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:state/oc-intf:counters {
deviate add {
sonic-ext:subtree-transformer "intf_get_counters_xfmr";
Expand Down
15 changes: 11 additions & 4 deletions models/yang/annotations/sonic-mgmt-interface-annot.yang
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ module sonic-mgmt-interface-annot {

yang-version "1.1";

namespace "http://openconfig.net/yang/annotation/smgmtintf-annot";
prefix "smgmtintf-annot";
namespace "http://openconfig.net/yang/annotation/smgmt-intf-annot";
prefix "smgmt-intf-annot";

import sonic-extensions { prefix sonic-ext; }
import sonic-mgmt-interface { prefix smgmt-intf; }
import sonic-interface { prefix sintf; }
import sonic-mgmt-interface { prefix smgmt; }

deviation /smgmt:sonic-mgmt-interface/smgmt:MGMT_INTF_TABLE {
deviation /smgmt-intf:renew_dhcp_lease {
deviate add {
sonic-ext:rpc-callback "rpc_renew_dhcp_lease";
}
}


deviation /smgmt-intf:sonic-mgmt-interface/smgmt-intf:MGMT_INTF_TABLE {
deviate add {
sonic-ext:db-name "APPL_DB";
}
Expand Down
36 changes: 26 additions & 10 deletions models/yang/extensions/openconfig-interfaces-ext.yang
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ module openconfig-interfaces-ext {
}
}

augment "/oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:config" {
leaf default-gwaddr {
type oc-inet:ipv4-address;
description "IPv4 Default Gateway address";
}
}
augment "/oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:state" {
leaf default-gwaddr {
type oc-inet:ipv4-address;
description "IPv4 Default Gateway address";
}
}
augment "/oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:config" {
leaf default-gwaddr {
type oc-inet:ipv6-address;
description "IPv6 Default Gateway address";
}
}
augment "/oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:state" {
leaf default-gwaddr {
type oc-inet:ipv6-address;
description "IPv6 Default Gateway address";
}
}

augment "/oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:addresses/oc-ip:address/oc-ip:config" {
leaf gw-addr {
type oc-inet:ipv4-address;
Expand Down Expand Up @@ -182,10 +207,7 @@ module openconfig-interfaces-ext {
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:proxy-arp {
deviate not-supported;
}
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:config {
deviate not-supported;
}
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:state {
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:unnumbered {
deviate not-supported;
}

Expand All @@ -198,12 +220,6 @@ module openconfig-interfaces-ext {
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:unnumbered {
deviate not-supported;
}
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:config {
deviate not-supported;
}
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:state {
deviate not-supported;
}
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip-ext:autoconf {
deviate not-supported;
}
Expand Down
44 changes: 44 additions & 0 deletions models/yang/sonic/sonic-mgmt-interface.yang
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ module sonic-mgmt-interface {
"Initial revision.";
}

/*
* RPC's
*/
rpc renew_dhcp_lease {
description "RPC for renew DHCP lease of an interface.";
input {
leaf portname{
type leafref {
path "/mgmtprt:sonic-mgmt-port/mgmtprt:MGMT_PORT/mgmtprt:MGMT_PORT_LIST/mgmtprt:ifname";
}
}
}
output {
leaf status {
type int32;
description
"The status of the operation execution request.";
}
leaf status-detail {
type string;
description
"The detailed status of the operation execution request.";
}
}
}

container sonic-mgmt-interface {

container MGMT_INTERFACE {
Expand All @@ -45,6 +71,24 @@ module sonic-mgmt-interface {
}
}

leaf ipv4_default_gwaddr {
type inet:ipv4-address;
}

leaf ipv6_default_gwaddr {
type inet:ipv6-address;
}

leaf ipv4_dhcp_client {
type boolean;
default false;
}

leaf ipv6_dhcp_client {
type boolean;
default false;
}

leaf vrf-name {
type leafref {
path "/mvrf:sonic-mgmt-vrf/mvrf:MGMT_VRF_CONFIG/mvrf:MGMT_VRF_CONFIG_LIST/mvrf:vrf_global_name";
Expand Down
63 changes: 63 additions & 0 deletions scripts/host_modules/renew_dhcp_lease.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
""" Renew DHCP lease handler"""
import host_service
import subprocess

MOD_NAME= 'renew_dhcp_lease'

class RENEW_DHCP_LEASE(host_service.HostModule):
"""DBus endpoint that executes RENEW_DHCP_LEASE related commands """

@staticmethod
def _run_command(options):
""" Run renew dhcp lease command """
if len(options) < 2:
print("RENEW_DHCP_LEASE Invalid options, {}".format(options))
return 1, "Invalid options"

ifName = options[0]
version = ""
file_ext = ""
cmd_opt = ""
output = ""
rc = 0

for x in options[1:]:
if x == "ipv6":
version = "-6"
file_ext = "6"
cmd_opt = "-D LL"

try:
cmd = "/sbin/dhclient {} -r {}".format(version, ifName)
output = subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError as err:
print("Exception when calling get_sonic_error -> %s\n" %(err))
pass

try:
cmd = "[ -f /var/run/dhclient{}.{}.pid ] && kill `cat /var/run/dhclient{}.{}.pid` && rm -f /var/run/dhclient{}.{}.pid".format(file_ext, ifName, file_ext, ifName, file_ext, ifName)
output = subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError as err:
print("Exception when calling get_sonic_error -> %s\n" %(err))
pass

try:
cmd = "/sbin/dhclient {} -pf /run/dhclient{}.{}.pid -lf /var/lib/dhcp/dhclient{}.{}.leases {} -nw {} ".format(version, file_ext, ifName, file_ext, ifName, ifName, cmd_opt)
output = subprocess.check_call(cmd, shell=True)

output = "SUCCESS"
except subprocess.CalledProcessError as err:
print("Exception when calling get_sonic_error -> %s\n" %(err))
rc = err.returncode
output = err.output

return rc,output


@host_service.method(host_service.bus_name(MOD_NAME), in_signature='as', out_signature='is')
def action(self, options):
return RENEW_DHCP_LEASE._run_command(options)

def register():
"""Return class name"""
return RENEW_DHCP_LEASE, MOD_NAME
53 changes: 53 additions & 0 deletions src/CLI/actioner/sonic-cli-mgmt-dhcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/python
###########################################################################
#
# Copyright 2019 Dell, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################

import sys
import time
import json
import ast
import cli_client as cc
from rpipe_utils import pipestr
from scripts.render_cli import show_cli_output

def invoke(func, args):
body = None
aa = cc.ApiClient()
if func == 'rpc_sonic_mgmt_interface_renew_dhcp_lease':
keypath = cc.Path('/restconf/operations/sonic-mgmt-interface:renew_dhcp_lease')
body = {"sonic-mgmt-interface:input":{"portname":args[0]}}
return aa.post(keypath, body)
else:
return

def run(func, args):
try:
api_response = invoke(func,args)
status = api_response.content["sonic-mgmt-interface:output"]
if status["status"] != 0:
print status["status-detail"]
except:
print "%Error: Transaction Failure"
return


if __name__ == '__main__':
pipestr().write(sys.argv)
run(sys.argv[1], sys.argv[2:])


46 changes: 44 additions & 2 deletions src/CLI/actioner/sonic_cli_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,50 @@ def invoke_api(func, args=[]):
body = { "openconfig-if-ip:config": {"ip" : sp[0], "prefix-length" : int(sp[1]), "openconfig-interfaces-ext:gw-addr": args[2]} }
else:
body = { "openconfig-if-ip:config": {"ip" : sp[0], "prefix-length" : int(sp[1])} }
return api.patch(path, body)

return api.patch(path, body)

elif func == 'patch_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv4_config_default_gwaddr':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv4/config', name=args[0], index="0")
body = { "openconfig-if-ip:config": {"openconfig-interfaces-ext:default-gwaddr": args[1]}}
return api.patch(path, body)

elif func == 'delete_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv4_config_default_gwaddr':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv4/config/openconfig-interfaces-ext:default-gwaddr', name=args[0], index="0")
return api.delete(path)

elif func == 'patch_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv4_config_dhcp_client':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv4/config', name=args[0], index="0")
if args[1] == "true":
body = { "openconfig-if-ip:config": {"openconfig-interfaces-ext:dhcp-client": True }}
else :
body = { "openconfig-if-ip:config": {"openconfig-interfaces-ext:dhcp-client": False }}
return api.patch(path, body)

elif func == 'delete_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv4_config_dhcp_client':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv4/config/dhcp-client', name=args[0], index="0")
return api.delete(path)

elif func == 'patch_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv6_config_dhcp_client':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv6/config', name=args[0], index="0")
if args[1] == "true":
body = { "openconfig-if-ip:config": {"openconfig-interfaces-ext:dhcp-client": True }}
else :
body = { "openconfig-if-ip:config": {"openconfig-interfaces-ext:dhcp-client": False }}
return api.patch(path, body)

elif func == 'delete_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv6_config_dhcp_client':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv6/config/dhcp-client', name=args[0], index="0")
return api.delete(path)

elif func == 'patch_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv6_config_default_gwaddr':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv6/config', name=args[0], index="0")
body = { "openconfig-if-ip:config": {"openconfig-interfaces-ext:default-gwaddr": args[1]}}
return api.patch(path, body)

elif func == 'delete_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv6_config_default_gwaddr':
path = cc.Path('/restconf/data/openconfig-interfaces:interfaces/interface={name}/subinterfaces/subinterface={index}/openconfig-if-ip:ipv6/config/openconfig-interfaces-ext:default-gwaddr', name=args[0], index="0")
return api.delete(path)

elif func == 'patch_openconfig_if_ip_interfaces_interface_subinterfaces_subinterface_ipv6_addresses_address_config':
sp = args[1].split('/')

Expand Down
4 changes: 4 additions & 0 deletions src/CLI/clitree/cli-xml/enable_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ limitations under the License.
<COMMAND
name="clear"
help="Clear commands" />
<!-- renew commands -->
<COMMAND
name="renew"
help="Renew commands" />
<!-- Debug commands -->
<COMMAND
name="debug"
Expand Down
Loading