-
Notifications
You must be signed in to change notification settings - Fork 15
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
sFlow CLI Template #147
sFlow CLI Template #147
Changes from 4 commits
31f1ffa
23546dd
e412d8a
fa370fa
6d39063
476b008
3701f81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/python | ||
import sys | ||
import time | ||
import json | ||
import ast | ||
from collections import OrderedDict | ||
from scripts.render_cli import show_cli_output | ||
|
||
|
||
import urllib3 | ||
urllib3.disable_warnings() | ||
plugins = dict() | ||
|
||
|
||
def register(func): | ||
"""Register sdk client method as a plug-in""" | ||
plugins[func.__name__] = func | ||
return func | ||
|
||
def call_method(name, args): | ||
method = plugins[name] | ||
return method(args) | ||
|
||
def get_sflow(): | ||
pass | ||
|
||
def get_sflow_interface(): | ||
pass | ||
|
||
def run(func, args): | ||
|
||
# create a body block | ||
if (func.__name__ == 'get_sflow'): | ||
sflow_info = {'sflow' : {'admin_state' : 'enabled', 'polling-interval' : 20, 'agent-id' : 'default'}} | ||
else: | ||
sflow_info = {} | ||
sflow_info['sflow'] = OrderedDict() | ||
for i in range(30): | ||
sflow_info['sflow']['Ethernet'+str(i)] = {'admin_state' : 'enabled', 'sampling_rate' : 4000} | ||
show_cli_output(sys.argv[2], sflow_info) | ||
return | ||
|
||
if __name__ == '__main__': | ||
func = eval(sys.argv[1], globals(), {}) | ||
run(func, sys.argv[2:]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2019 Dell, Inc. | ||
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. | ||
|
@@ -13,7 +13,7 @@ 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. | ||
--> | ||
--> | ||
|
||
<CLISH_MODULE | ||
xmlns="http://www.dellemc.com/sonic/XMLSchema" | ||
|
@@ -181,7 +181,7 @@ limitations under the License. | |
name="no" | ||
help="Negate a command or set its defaults" | ||
/> | ||
<COMMAND | ||
<COMMAND | ||
name="description" | ||
help="Textual description"> | ||
<PARAM | ||
|
@@ -209,12 +209,12 @@ limitations under the License. | |
help="Remove MTU"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_mtu ${iface} 9100 </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
<COMMAND | ||
name="shutdown" | ||
help="Disable the interface"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_enabled ${iface} False </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
<COMMAND | ||
name="no shutdown" | ||
help="Enable the interface"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_enabled ${iface} True </ACTION> | ||
|
@@ -281,8 +281,19 @@ limitations under the License. | |
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
<COMMAND name="sflow" help="enable sflow"> | ||
<PARAM name="sampling-rate" help="sFlow sampling rate" ptype="SUBCOMMAND" mode="subcommand" optional="true"> | ||
<PARAM name="rate" help="sampling rate" ptype="UINT"/> | ||
</PARAM> | ||
<PARAM name="admin-status" help="sFlow status for interface" ptype="SUBCOMMAND" mode="subcommand" optional="true"> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
<COMMAND name="no sflow" help="disable sflow"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will change. |
||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
|
||
<COMMAND | ||
<COMMAND | ||
name="no switchport" | ||
help="Remove switchport parameters" | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
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. | ||
--> | ||
|
||
<CLISH_MODULE | ||
xmlns="http://www.dellemc.com/sonic/XMLSchema" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:xi="http://www.w3.org/2001/XInclude" | ||
xsi:schemaLocation="http://www.dellemc.com/sonic/XMLSchema | ||
http://www.dellemc.com/sonic/XMLSchema/clish.xsd" | ||
> | ||
|
||
<VIEW name="enable-view"> | ||
<COMMAND name="show sflow" help="Show sFlow information"> | ||
<ACTION> python $SONIC_CLI_ROOT/sonic-cli-sflow.py get_sflow show_sflow.j2 </ACTION> | ||
</COMMAND> | ||
<COMMAND name="show sflow interface" help="Show sFlow interface information"> | ||
<ACTION> python $SONIC_CLI_ROOT/sonic-cli-sflow.py get_sflow_interface show_sflow_intf.j2 </ACTION> | ||
</COMMAND> | ||
</VIEW> | ||
<VIEW name="configure-view"> | ||
<COMMAND name="sflow" help="enable sflow"> | ||
<PARAM name="collector" help="Collector name" ptype="SUBCOMMAND" mode="subcommand" optional="true"> | ||
<PARAM name="collector-name" help="Collector name" ptype="STRING"/> | ||
<PARAM name="collector-ip" help="Collector IP address" ptype="STRING"/> | ||
<PARAM name="collector-port" help="Collector port number" ptype="UINT" optional="true"/> | ||
</PARAM> | ||
<PARAM name="agent-id" help="Collector agent interface" ptype="SUBCOMMAND" mode="subcommand" optional="true"> | ||
<PARAM name="interface" help="Interface name" ptype="STRING"/> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"/> | ||
<PARAM name="polling-interval" help="Collector polling interval" ptype="SUBCOMMAND" mode="subcommand" optional="true"> | ||
<PARAM name="interval" help="Interval" ptype="UINT"/> | ||
</PARAM> | ||
</COMMAND> | ||
<COMMAND name="no sflow" help="disable sflow"> | ||
<PARAM name="collector" help="Collector name" ptype="SUBCOMMAND" mode="subcommand" optional="true"> | ||
<PARAM name="collector-name" help="Collector name" ptype="STRING"/> | ||
</PARAM> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will add these. |
||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
</VIEW> | ||
</CLISH_MODULE> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{'---------------------------------------------------------'}} | ||
{{'Global sFlow Information'.ljust(20)}} | ||
{{'---------------------------------------------------------'}} | ||
{% if json_output and 'sflow' in json_output -%} | ||
{% set sflow_info = json_output['sflow'] %} | ||
{{' admin state: '}}{{sflow_info['admin_state']}} | ||
{{' polling-interval: '}}{{sflow_info['polling-interval']}} | ||
{{' agent-id: '}} {{sflow_info['agent-id']}} | ||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{{'-----------------------------------------------------------'}} | ||
{{'sFlow interface configurations'.ljust(20)}} | ||
{{'%40s'|format('Interface Admin State Sampling Rate')}} | ||
{% if json_output and 'sflow' in json_output -%} | ||
{% set sflow_info = json_output['sflow'] %} | ||
{% for intf, values in sflow_info.items() %} | ||
{{'%13s'|format(intf.ljust(10))}} {{sflow_info[intf]['admin_state']}} {{sflow_info[intf]['sampling_rate']}} | ||
{% endfor %} | ||
{% endif %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your HLD, this parameter was called
enable
rather thanadmin-status
.If both of the PARAMs under here are
optional="true"
then will this result in a user being able to configure justsflow
by itself? I don't think we should allow that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I think
enable
is a better keyword thanadmin-status
, since "admin status" is typically used to describe the enable/disable of an interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change.