forked from sonic-net/sonic-mgmt-framework
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sFlow CLI template * Add XML skeleton for the sFlow CLI * Add actioner script * Add renderer template Signed-off-by: Garrick He <garrick_he@dell.com>
- Loading branch information
Showing
5 changed files
with
167 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?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> | ||
<xi:include href="include/pipe.xml"/> | ||
</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> | ||
<xi:include href="include/pipe.xml"/> | ||
</COMMAND> | ||
</VIEW> | ||
<VIEW name="configure-view"> | ||
<COMMAND name="sflow" help="sFlow Configurations"/> | ||
<COMMAND name="sflow collector" help="Collector name" ptype="SUBCOMMAND" mode="subcommand"> | ||
<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"/> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
<COMMAND name="sflow enable" help="Enable sFlow" ptype="SUBCOMMAND" mode="subcommand"> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
<COMMAND name="sflow agent-id" help="Collector agent interface" ptype="SUBCOMMAND" mode="subcommand"> | ||
<PARAM name="interface" help="Interface name" ptype="STRING"/> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
<COMMAND name="sflow polling-interval" help="Collector polling interval" ptype="SUBCOMMAND" mode="subcommand"> | ||
<PARAM name="interval" help="Interval" ptype="UINT"/> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
|
||
<COMMAND name="no sflow" help="Negate sFlow configurations"/> | ||
<COMMAND name="no sflow collector" help="Remove a collector" ptype="SUBCOMMAND" mode="subcommand"> | ||
<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"/> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
<COMMAND name="no sflow enable" help="Disable sFlow" ptype="SUBCOMMAND" mode="subcommand"> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
<COMMAND name="no sflow agent-id" help="Set default agent-id" ptype="SUBCOMMAND" mode="subcommand"> | ||
<PARAM name="interface" help="Interface name" ptype="STRING"/> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
<COMMAND name="no sflow polling-interval" help="Set default polling interval" ptype="SUBCOMMAND" mode="subcommand"> | ||
<PARAM name="interval" help="Interval" ptype="UINT"/> | ||
<ACTION builtin="clish_nop"/> | ||
</COMMAND> | ||
</VIEW> | ||
</CLISH_MODULE> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} | ||
|