facebookincubator / fcr Goto Github PK
View Code? Open in Web Editor NEWFBNet-Command-Runner: A thrift service to run commands on heterogeneous Network devices with configurable parameters.
FBNet-Command-Runner: A thrift service to run commands on heterogeneous Network devices with configurable parameters.
This may be a question and not necessary an issue.
I see this error message in the server output:
future: <Task finished coro=<SSHConnection._run_task() done, defined at /Users/bthornto/github/FCR2/venv/lib/python3.6/site-packages/asyncssh/connection.py:366> exception=CancelledError()>
concurrent.futures._base.CancelledError
It doesn't seem to correlate directly to a device failure so I'm not sure what to think of it.
Any clue what it may indicate?
The most time consuming part of adopting a new command-runner is defining the interaction between different vendors. This seems quite flexible with FCR except other than test-case examples, there's nothing provided there.
While similar products (trigger or netmiko) may be lacking comparatively in features like client-neutral API, scalability, and configuration, have bundled vendor drivers. I like FCR but feel it will simply be an underused framework until there are community distributed vendor configs to avoid Network Engineers at each company repeating the same wonky regex work. :)
First of all thank you for FCR, it looks great.
A couple comments just testing it out:
I need to change device_info.py, def get_ip from
if self.check_ip(ip):
return ip.addr
to
if self.check_ip(ip):
return ip
otherwise I would get an error:
message='run failed: AttributeError("\'str\' object has no attribute \'addr\'",)')
Additionally, the json example has a few errors, I was able to get this working:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
#
from fbnet.command_runner.service import FcrServiceBase
from fbnet.command_runner.command_server import CommandServer
from fbnet.command_runner.device_db import BaseDeviceDB
from fbnet.command_runner.device_vendor import DeviceVendors
from fbnet.command_runner.device_info import DeviceInfo, DeviceIP
from fbnet.command_runner.device_db import BaseDeviceDB
from fbnet.command_runner.options import Option
# You will likely get this data from your backend systems.
# But for illustration we will assume this is available in JSON
# format
import json
json_devdata = '''
[
{"host": "device.company.net", "chassis": "N7000", "ip": ["10.250.255.15"], "role": "switch", "vendor": "cisco_nxos"}
]
'''
class DeviceDB(BaseDeviceDB):
async def _fetch_device_data(self, name_filter=None, hostname=None):
'''
Fetch data from your backend database.
This sample implementation assumes you have the data in a json format
'''
devinfos = json.loads(json_devdata)
return {self._make_dev(devinfo) for devinfo in devinfos }
def _make_dev(self, devinfo):
return DeviceInfo(
self.service,
hostname=devinfo['host'],
username='default', # typically a user with a bare minimum RO priviledges
password='passwd',
pref_ips=devinfo['ip'], # a list of IP addresses in order of preferences
ip=devinfo['ip'][0], # the default fallback IP (after exhausting the pref_ips
vendor_data=self.service.vendors.get(devinfo['vendor']),
# vendor_data=self.app.vendors.get(devinfo['vendor']),
role=devinfo['role'],
ch_model=devinfo['chassis'])
class Vendors(DeviceVendors):
pass
class FCRService(FcrServiceBase):
def __init__(self):
super().__init__("FCR")
self.vendors = Vendors(self)
self.device_db = DeviceDB(self)
self.service = CommandServer(self)
def main():
service = FCRService()
service.start()
if __name__ == "__main__":
main()
thanks again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.