Giter Club home page Giter Club logo

nxosncrpc's Introduction

Python - nxosNCRPC Library 0.1

Author:       David Gee, copyright (C) 2014, ipengineer.net
Date:         17th of November 2014
Version:      0.1
Site:         http://ipengineer.net
Notes:		  Absolutely no error handling exists. Wrap usage with try:/except: to catch problems!

This class generates Cisco Nexus hello, close and RPC NETCONF messages for wrapping CLI commands.

Use this code to test:

from nxosNCRPC install *

# Create a call1 object with message-id of '42'
call1 = nxosNCRPC("42")
call1.add_command("conf t")
call1.add_command("int eth2/1")
call1.add_command("shut")
# Some built in helper functions to provide the NETCONF hello, the actual RPC message and the NETCONF close messages
print call1.hello()
print call1.message()
print call1.close()

The output this code generates can be copy and pasted in to an SSH session to test. From the bash, to connect to a Cisco Nexus NETCONF subsystem try the below.

ssh [email protected] -s netconf

Once you're logged in, copy and paste output generated like below. Once you're happy the code is functioning, you can then use something like Paramiko to programmatically send/receive data to and from NETCONF server.

<?xml version="1.0" encoding="ISO-8859-1"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
  </capabilities>
</hello>
]]>]]>

<?xml version='1.0' encoding='ISO-8859-1'?>
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nxos="http://www.cisco.com/nxos:1.0" message-id="42">
  <nxos:exec-command>
    <nxos:cmd>conf t</nxos:cmd>
    <nxos:cmd>int eth2/1</nxos:cmd>
    <nxos:cmd>shut</nxos:cmd>
  </nxos:exec-command>
</nc:rpc>
]]>]]>

<?xml version="1.0"?>
<nc:rpc message-id="101" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="http://www.cisco.com/nxos:1.0">
  <nc:close-session/>
</nc:rpc>
]]>]]>

nxosncrpc's People

Contributors

automationspace avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.