parser = parsers.add_parser("dump", description="Get and write all mdsal models")
parser.add_argument("path",
help="the directory that the parsed data is written into")
+ parser.add_argument("-s", "--https", action="store_true",
+ help="use https for secure connection")
parser.add_argument("-i", "--ip", default="localhost",
help="OpenDaylight ip address")
- parser.add_argument("-p", "--pretty_print", action="store_true",
- help="json dump with pretty_print")
parser.add_argument("-t", "--port", default="8181",
help="OpenDaylight restconf port, defaul: 8181")
parser.add_argument("-u", "--user", default="admin",
help="OpenDaylight restconf username, default: admin")
parser.add_argument("-w", "--pw", default="admin",
help="OpenDaylight restconf password, default: admin")
+ parser.add_argument("-p", "--pretty_print", action="store_true",
+ help="json dump with pretty_print")
parser.set_defaults(func=cmd.run_dump)
model_path = res[DSM_PATH]
path_split = split_model_path(model_path)
filename = make_filename(args.path, store, path_split.name, path_split.container)
- url = make_url(args.ip, args.port, store, path_split.name, path_split.container)
+ url = make_url(args.https, args.ip, args.port, store, path_split.name, path_split.container)
get_model_data(filename, url, args.user, args.pw, args.pretty_print)
return "{}/{}_{}:{}.json".format(path, store, name, container.replace("/", "_"))
-def make_url(ip, port, store, name, container):
- return "http://{}:{}/restconf/{}/{}:{}".format(ip, port, store,
- name, container)
+def make_url(https, ip, port, store, name, container):
+ http = 'https' if https else 'http'
+ return "{}://{}:{}/restconf/{}/{}:{}".format(http, ip, port, store,
+ name, container)
def get_from_odl(url, user, pw):
self.name = name
self.container = container
self.store = store
+ self.http = 'https' if args.https else 'http'
self.ip = args.ip
self.port = args.port
self.url = self.make_url()
return "{}/{}___{}__{}___topology___{}.json".format(self.path, self.store, self.name, self.container, fmid)
def make_url(self):
- return "http://{}:{}/restconf/{}/{}:{}".format(self.ip, self.port, self.store,
- self.name, self.container)
+ return "{}://{}:{}/restconf/{}/{}:{}".format(self.http, self.ip, self.port,
+ self.store, self.name,
+ self.container)
def make_url_type(self, mid):
- return "http://{}:{}/restconf/{}/{}:{}/topology/{}".format(self.ip, self.port, self.store,
- self.name, self.container, mid)
+ return "{}://{}:{}/restconf/{}/{}:{}/topology/{}".format(self.http, self.ip, self.port,
+ self.store, self.name,
+ self.container, mid)
def get_from_odl(self):
return odltools.mdsal.request.get(self.url, self.USER, self.PW)
import config
import flow_parser
import flows
+import tables
+
from odltools.mdsal.models import constants
from odltools.mdsal.models import ietf_interfaces
from odltools.mdsal.models import itm_state
if flow.get('vlanid') and flow.get('vlanid') != vlanid:
flow_status = 'VlanId mismatch for SubPort:{} and Flow:{}'.format(subport, flow.get('flow'))
if subport:
- print 'SubPort:{},Table:{},FlowStatus:{}'.format(
- subport.get('port-id'), flow.get('table'), flow_status)
+ print 'SubPort:{},Table:{}/{},FlowStatus:{}'.format(
+ subport.get('port-id'), flow.get('table'),
+ tables.get_table_name(flow.get('table')),
+ flow_status)
def analyze_neutron_port(port, iface, ifstate):
if ((flow.get('ifname') == port['uuid']) or
(flow.get('lport') and ifstate and flow['lport'] == ifstate.get('if-index')) or
(iface['name'] == flow.get('ifname'))):
- result = 'Table:{},FlowId:{}{}'.format(
- flow['table'], flow['id'],
- utils.show_optionals(flow))
+ result = 'Table:{}/{},FlowId:{}{}'.format(
+ flow['table'], tables.get_table_name(flow['table']),
+ flow['id'], utils.show_optionals(flow))
print result
print 'Flow:', utils.format_json(None, flow_parser.parse_flow(flow.get('flow')))
flow_list.append(flow_dict)
flows = sorted(flow_list, key=lambda x: x['table'])
for flow in flows:
- print 'Table:', flow['table']
+ print 'Table:{}/{}'.format(flow['table'],
+ tables.get_table_name(flow['table']))
print 'FlowId:', flow['id'], 'FlowName:', flow.get('name')
def add_common_args(parser):
parser.add_argument("--path",
help="the directory that the parsed data is written into")
+ parser.add_argument("-s", "--https", action="store_true",
+ help="use https for secure connection")
parser.add_argument("-i", "--ip", default="localhost",
help="OpenDaylight ip address")
- parser.add_argument("-p", "--pretty_print", action="store_true",
- help="json dump with pretty_print")
parser.add_argument("-t", "--port", default="8181",
help="OpenDaylight restconf port, default: 8181")
parser.add_argument("-u", "--user", default="admin",
help="OpenDaylight restconf username, default: admin")
parser.add_argument("-w", "--pw", default="admin",
help="OpenDaylight restconf password, default: admin")
+ parser.add_argument("-p", "--pretty_print", action="store_true",
+ help="json dump with pretty_print")
def add_interface_parser(parsers):
parser.add_argument("--modules",
help="service module owning the flow")
parser.add_argument("flowtype", choices=["all", "duplicate", "elan", "learned", "stale"])
+ parser.add_argument("--metaOnly", action="store_true",
+ help="display flow meta info only")
+ parser.add_argument("--urls", action="store_true",
+ help="show flow urls")
parser.set_defaults(func=show.show_flows)
parser = parsers.add_parser("id-pools")
from odltools.netvirt import utils
import config
import flow_parser
+import tables
logger = logging.getLogger("netvirt.flows")
def get_eltag_for_iface(eifaces, einsts, iface):
- print eifaces
ifname = iface.get('name') if iface else None
eiface = eifaces.get(ifname) if ifname else None
einst_name = eiface.get('elan-instance-name') if eiface else None
print 'Flow without binding: ', flow['ifname']
+def get_flow_url(args, flow):
+ base_url = 'http://{}:{}/restconf/config'.format(args.ip, args.port)
+ flow_path = 'opendaylight-inventory:nodes/node/openflow:{}/' \
+ 'flow-node-inventory:table/{}/flow/{}'.format(
+ flow['dpnid'], flow['table'], flow['id'])
+ return '{}/{}'.format(base_url, flow_path)
+
+
def show_stale_flows(args, sort_by='table'):
config.get_models(args, {
"elan_elan_instances",
ip_list = get_ips_for_iface(nports, flow.get('ifname'))
if ip_list:
flow['iface-ips'] = ip_list
- result = 'Table:{}, Host:{}, FlowId:{}{}'.format(
- flow['table'], host, flow['id'],
+ result = 'Table:{}/{}, Host:{}, FlowId:{}{}'.format(
+ flow['table'], tables.get_table_name(flow.get('table')),
+ host, flow['id'],
utils.show_optionals(flow))
print result
- ##path = get_data_path('flows', flow)
- #print('http://192.168.2.32:8383/restconf/config/{}'.format(path))
- #print 'Flow:', utils.format_json(args, flow_parser.parse_flow(flow['flow']))
+ if args.urls:
+ print('http://{}'.format(get_flow_url(args, flow)))
+ if not args.metaOnly:
+ print 'Flow:{}'.format(utils.format_json(args, flow_parser.parse_flow(flow['flow'])))
def show_elan_flows(args):
compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()
for flow in utils.sort(get_all_flows(args, modules=['elan']), 'id'):
host = compute_map.get(flow.get('dpnid'), flow.get('dpnid'))
- result = 'MacHost:{}{}, Table:{}, FlowId:{}, {}, Flow:{}'.format(
- flow['id'][-17:], host, flow['table'], flow['id'], utils.show_optionals(flow),
+ result = 'MacHost:{}{}, Table:{}/{}, FlowId:{}, {}, Flow:{}'.format(
+ flow['id'][-17:], host, flow['table'],
+ tables.get_table_name(flow['table']),
+ flow['id'], utils.show_optionals(flow),
utils.format_json(args, flow_parser.parse_flow(flow['flow'])))
print result
- #print 'Flow:', utils.format_json(args, flow_parser.parse_flow(flow['flow']))
+ if not args.metaOnly:
+ print 'Flow:{}'.format(utils.format_json(args, flow_parser.parse_flow(flow['flow'])))
def get_matchstr(args, flow):
nports.get(flow_info.get('src-mac'))) or
(flow_info.get('table') == 51 and
not nports.get(flow_info.get('dst-mac')))):
- result = 'Table:{}, Host:{}, FlowId:{}{}'.format(
- flow_info.get('table'), host, flow.get('id'),
- utils.show_optionals(flow_info))
+ result = 'Table:{}/{}, Host:{}, FlowId:{}{}'.format(
+ flow_info.get('table'),
+ tables.get_table_name(flow['table']),
+ host, flow.get('id'), utils.show_optionals(flow_info))
print result
- print 'Flow:{}'.format(utils.format_json(args, flow_parser.parse_flow(flow)))
+ if not args.metaOnly:
+ print 'Flow:{}'.format(utils.format_json(args,flow_parser.parse_flow(flow)))
def get_stale_bindings(args):
ip_list = get_ips_for_iface(nports, flow.get('ifname'))
if ip_list:
flow['iface-ips'] = ip_list
- result = 'Table:{}, Host:{}, FlowId:{}{}'.format(
- flow['table'], host, flow['id'],
+ result = 'Table:{}/{}, Host:{}, FlowId:{}{}'.format(
+ flow['table'], tables.get_table_name(flow['table']),
+ host, flow['id'],
utils.show_optionals(flow))
print result
- print 'Flow:', utils.format_json(args, flow_parser.parse_flow(flow['flow']))
+ if not args.metaOnly:
+ print 'Flow:', utils.format_json(args, flow_parser.parse_flow(flow['flow']))
def show_all_flows(args):