Archive
, Super Contributor
Archive
Python for Non-Programmers (Part 1)
Nov 11, 2013

PYTHON AS A POWER TOOL

 

When I talk with Network Engineers and Operations teams about automation, often times the response is: "I am not a programmer, so I can't do this".  Worse yet are folks in the blog-o-sphere saying that if networking folks don't become a programmers, they will become obsolete.  This is all rubbish. 

 

Have you ever used Linux, and hacked out a shell "for" or "while" loop to do a quick repetitive task?  I'm sure you have, but would you call that programming?  No, of course not.  I have friends that are in different fields, like science and finance.  They use programming languages, like Python, to do numerical analysis, as a power-tool for their job.  If you ask my friend the scientist if they are a "Programmer", they would say "NO!  I am a Scientist!" 

 

So there seems to be a (self inflicted) distinction between using a programming language as a power-tool and being a programmer as a profession.  And yes, I do believe there is a distinct difference, and no, it does not mean you have a Computer Science degree.

 

So perhaps we can all agree that using a programming language does not make you a programmer.  It's just a power-tool to help you do you job. So now you can get over it, and start to have some fun and be more productive.

 

AUTOMATION IS ABOUT CONSUMPTION

 

My basic thesis is that automation is defined by the nature of the consumer, that is, the person using the automation technology.  The technology could be a purpose built tool/product, an IT framework, a set of language libraries, SDKs, or a combination of the above.  I've even tried to make this concept consumable by creating an analogy to "ice cream" - as described in this blog

 

If we treat automation as consumption, then we must consider the "digestion factor", or "how easy" can we make automation consumable by the user, you, the non-programmer.  If you are presented with an automation task that is "too hard" then it is not consumable, and thus creates "indigestion".   For example, let's say that in order to do some automation task you had to develop in Java and write over 500 lines of code. #fail.

 

My rule of thumb:  Do something useful in less than 50 lines of code, or just do it interactively.

 

THE "JUNOS EZ" LIBRARY FOR PYTHON

 

The "Junos EZ" library is a way for non-programmers to start benefiting from using automation without requiring them to be hardcore programmers.  It is not a set of APIs - APIs are for application programmers - which we've already agreed we are not.  Can Junos EZ be used by "programmers" to build tools? -- of course.  This library could also be the basis of integration with other higher-order IT frameworks (like Ansible or Salt).

 

This series of blogs "Python for Non-Programmers" will introduce the major concepts of Junos EZ.  These include:

 

  • Remote Connectivity and "Fact" Gathering
  • Configuration Management - Structured abstractions
  • Configuration Management - Unstructured snippets and templating
  • Gathering Operational (Run-State) information
  • Multipurpose Utilities (like filesystem, software-upgrade, file-copy)

 

SETUP PYTHON FOR JUNOS AUTOMATION

 

(updated: 2014-Mar-27)

 

The updated installation steps are now posted on the Juniper TechWiki here:

https://techwiki.juniper.net/Automation_Scripting/Junos_OS_PyEZ/Installation

 

TESTING "HELLO, WORLD"

 

Once everything is installed, you can do a quick check by connecting to a Junos device, and displaying the "facts" like software-version and serial-number.  I've documented this example, and others, on a previous blog here.

 

AUTOMATION IS A JOURNEY, AND SO IT BEGINS ...

 

You now have an environment and the consumable tools to begin automation efforts.  I would suggest by starting with "read-only" automation, like gathering statistical information or correlating information like the SRX example.

 

 

FURTHER READING

 

 

Nov 25, 2013
MrTugs

I'm trying to test this with the hello world script from here (http://forums.juniper.net/t5/Network-Automaniac/Junos-NETCONF-and-SSH-tunneling-Part-2/ba-p/215307). When I do, it can't find the module 'eznc', referenced in:

 

from jnpr.eznc import Netconf

 

I went to Github and tried another 'test' script which uses:

 

from jnpr.junos import Device

 

...and that worked ok. Any ideas where I screwed up? Thank you!

Nov 25, 2013

@MrTugs,

 

My apologies, I need to update that blog post.  The most recent version of "Junos EZ" has been migrated to a new namespace per feedback.

 

It was: "from jnpr.eznc import Netconf", and it is now "from jnpr.junos import Device".  The docs for the library have been updated on github, and I've scrubbed the "Python for Non-Programmers" series.  I'll scrub my other posts as well.  Thank you again for bringing this to my attention.

 

 

Nov 25, 2013
MrTugs

Thanks so much for the super-fast correction! I am all set now Yeah, baby:

john@dns1:~/jnpr$ python testhw
{'2RE': False,
'RE0': {'last_reboot_reason': '0x2:watchdog ',
'mastership_state': 'master',
'model': 'EX3200-24T, 8 POE',
'status': 'OK',
'up_time': '46 days, 8 hours, 36 minutes, 48 seconds'},
'fqdn': 'noisy',
'hostname': 'noisy',
'ifd_style': 'SWITCH',
'master': 'RE0',
'model': 'EX3200-24T',
'personality': 'SWITCH',
'serialnumber': '--',
'switch_style': 'VLAN',
'vc_capable': False,
'version': '12.3R3.4',
'version_info': junos.versino_info(major=(12, 3), type=R, minor=3, build=4)}

 

Now to start playing with it more!

Nov 25, 2013

@MrTugs,


Excellent.  Check out the Tables and Vies under the "jnpr/junos/op" directory.  It abstracts getting operational/run-state data.  It's the topic of my next (and final) blog in this series.  You can jump directly to the docs from here.

Dec 17, 2013
Maurizio Ipsale

Hi,

when I try installing the NETCONF 'ncclient library' I get a lot of errors:


src/lxml/lxml.etree.c:175069: error: ‘findChildBackwards’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175070: error: ‘nextElement’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175071: error: ‘previousElement’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175073: error: ‘pyunicode’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175077: error: ‘namespacedName’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175078: error: ‘namespacedNameFromNsName’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175081: error: ‘findOrBuildNodeNsPrefix’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175087: error: expected declaration specifiers or ‘...’ before ‘xmlParserCtxt’

src/lxml/lxml.etree.c:175088: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseParser’ has no member named ‘_newParserCtxt’

src/lxml/lxml.etree.c:175088: error: ‘xmlParserCtxt’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175088: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175088: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_11_BaseParser__newParserCtxt’

src/lxml/lxml.etree.c:175089: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseParser’ has no member named ‘_newPushParserCtxt’

src/lxml/lxml.etree.c:175089: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175089: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_11_BaseParser__newPushParserCtxt’

src/lxml/lxml.etree.c:175090: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseParser’ has no member named ‘_copy’

src/lxml/lxml.etree.c:175091: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseParser’ has no member named ‘_parseUnicodeDoc’

src/lxml/lxml.etree.c:175091: error: ‘xmlDoc’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175091: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175091: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_11_BaseParser__parseUnicodeDoc’

src/lxml/lxml.etree.c:175092: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseParser’ has no member named ‘_parseDoc’

src/lxml/lxml.etree.c:175092: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175092: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_11_BaseParser__parseDoc’

src/lxml/lxml.etree.c:175093: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseParser’ has no member named ‘_parseDocFromFile’

src/lxml/lxml.etree.c:175093: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175093: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFile’

src/lxml/lxml.etree.c:175094: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseParser’ has no member named ‘_parseDocFromFilelike’

src/lxml/lxml.etree.c:175094: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175094: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFilelike’

src/lxml/lxml.etree.c:175271: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext’ has no member named ‘_createParserInputBuffer’

src/lxml/lxml.etree.c:175271: error: ‘xmlParserInputBuffer’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175271: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175271: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_18_FileReaderContext__createParserInputBuffer’

src/lxml/lxml.etree.c:175272: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext’ has no member named ‘_createParserInput’

src/lxml/lxml.etree.c:175272: error: ‘xmlParserInput’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175272: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175272: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_18_FileReaderContext__createParserInput’

src/lxml/lxml.etree.c:175273: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext’ has no member named ‘_readDtd’

src/lxml/lxml.etree.c:175273: error: ‘xmlDtd’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175273: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175273: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_18_FileReaderContext__readDtd’

src/lxml/lxml.etree.c:175274: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext’ has no member named ‘_readDoc’

src/lxml/lxml.etree.c:175274: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175274: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_18_FileReaderContext__readDoc’

src/lxml/lxml.etree.c:175275: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext’ has no member named ‘copyToBuffer’

src/lxml/lxml.etree.c:175282: error: expected declaration specifiers or ‘...’ before ‘xmlError’

src/lxml/lxml.etree.c:175297: error: ‘struct __pyx_vtabstruct_4lxml_5etree_XSLT’ has no member named ‘_run_transform’

src/lxml/lxml.etree.c:175297: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175297: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_4XSLT__run_transform’

src/lxml/lxml.etree.c:175313: error: ‘struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator’ has no member named ‘_nextNodeAnyTag’

src/lxml/lxml.etree.c:175313: error: ‘xmlNode’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175313: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175313: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_25ElementDepthFirstIterator__nextNodeAnyTag’

src/lxml/lxml.etree.c:175314: error: ‘struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator’ has no member named ‘_nextNodeMatchTag’

src/lxml/lxml.etree.c:175314: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175314: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_25ElementDepthFirstIterator__nextNodeMatchTag’

src/lxml/lxml.etree.c:175352: error: expected declaration specifiers or ‘...’ before ‘xmlXPathContext’

src/lxml/lxml.etree.c:175358: error: expected declaration specifiers or ‘...’ before ‘xmlXPathObject’

src/lxml/lxml.etree.c:175414: error: expected declaration specifiers or ‘...’ before ‘xmlNode’

src/lxml/lxml.etree.c:175415: error: expected declaration specifiers or ‘...’ before ‘xmlAttr’

src/lxml/lxml.etree.c:175518: error: expected declaration specifiers or ‘...’ before ‘xmlXPathContext’

src/lxml/lxml.etree.c:175533: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseContext’ has no member named ‘_find_cached_function’

src/lxml/lxml.etree.c:175533: warning: type defaults to ‘int’ in declaration of ‘xmlChar’

src/lxml/lxml.etree.c:175533: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token

src/lxml/lxml.etree.c:175533: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_12_BaseContext__find_cached_function’

src/lxml/lxml.etree.c:175534: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseContext’ has no member named ‘_release_temp_refs’

src/lxml/lxml.etree.c:175535: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseContext’ has no member named ‘_hold’

src/lxml/lxml.etree.c:175536: error: ‘struct __pyx_vtabstruct_4lxml_5etree__BaseContext’ has no member named ‘_findDocumentForNode’

src/lxml/lxml.etree.c:175536: error: expected declaration specifiers or ‘...’ before ‘xmlNode’

src/lxml/lxml.etree.c:175543: error: expected declaration specifiers or ‘...’ before ‘xsltTransformContext’

src/lxml/lxml.etree.c:175552: error: expected declaration specifiers or ‘...’ before ‘xmlNode’

src/lxml/lxml.etree.c:175576: error: expected declaration specifiers or ‘...’ before ‘xmlParserCtxt’

src/lxml/lxml.etree.c:175580: error: expected declaration specifiers or ‘...’ before ‘xmlDoc’

src/lxml/lxml.etree.c:175581: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserContext’ has no member named ‘_handleParseResultDoc’

src/lxml/lxml.etree.c:175581: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175581: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_14_ParserContext__handleParseResultDoc’

src/lxml/lxml.etree.c:175588: error: expected declaration specifiers or ‘...’ before ‘xmlParserCtxt’

src/lxml/lxml.etree.c:175590: error: expected declaration specifiers or ‘...’ before ‘xmlParserCtxt’

src/lxml/lxml.etree.c:175598: error: expected declaration specifiers or ‘...’ before ‘xmlDoc’

src/lxml/lxml.etree.c:175599: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserContext’ has no member named ‘_handleParseResultDoc’

src/lxml/lxml.etree.c:175599: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175599: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_20_TargetParserContext__handleParseResultDoc’

src/lxml/lxml.etree.c:175601: error: expected declaration specifiers or ‘...’ before ‘xmlDoc’

src/lxml/lxml.etree.c:175611: error: expected declaration specifiers or ‘...’ before ‘xmlXPathContext’

src/lxml/lxml.etree.c:175656: error: ‘struct __pyx_vtabstruct_4lxml_5etree__Document’ has no member named ‘_findOrBuildNodeNs’

src/lxml/lxml.etree.c:175656: error: ‘xmlNs’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175656: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175656: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_9_Document__findOrBuildNodeNs’

src/lxml/lxml.etree.c:175657: error: ‘struct __pyx_vtabstruct_4lxml_5etree__Document’ has no member named ‘_setNodeNs’

src/lxml/lxml.etree.c:175657: error: expected declaration specifiers or ‘...’ before ‘xmlNode’

src/lxml/lxml.etree.c:175657: warning: type defaults to ‘int’ in declaration of ‘xmlChar’

src/lxml/lxml.etree.c:175657: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token

src/lxml/lxml.etree.c:175657: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_9_Document__setNodeNs’

src/lxml/lxml.etree.c:175708: error: expected declaration specifiers or ‘...’ before ‘xmlError’

src/lxml/lxml.etree.c:175736: error: expected declaration specifiers or ‘...’ before ‘xmlParserCtxt’

src/lxml/lxml.etree.c:175738: error: expected declaration specifiers or ‘...’ before ‘xmlDoc’

src/lxml/lxml.etree.c:175739: error: expected declaration specifiers or ‘...’ before ‘xmlNode’

src/lxml/lxml.etree.c:175740: error: expected declaration specifiers or ‘...’ before ‘xmlNode’

src/lxml/lxml.etree.c:175741: error: expected declaration specifiers or ‘...’ before ‘xmlNode’

src/lxml/lxml.etree.c:175776: error: expected declaration specifiers or ‘...’ before ‘xmlChar’

src/lxml/lxml.etree.c:175857: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘_getThreadDict’

src/lxml/lxml.etree.c:175857: error: ‘xmlDict’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175857: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175857: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_24_ParserDictionaryContext__getThreadDict’

src/lxml/lxml.etree.c:175858: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘initThreadDictRef’

src/lxml/lxml.etree.c:175858: error: expected declaration specifiers or ‘...’ before ‘xmlDict’

src/lxml/lxml.etree.c:175859: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘initParserDict’

src/lxml/lxml.etree.c:175859: error: expected declaration specifiers or ‘...’ before ‘xmlParserCtxt’

src/lxml/lxml.etree.c:175860: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘initXPathParserDict’

src/lxml/lxml.etree.c:175860: error: expected declaration specifiers or ‘...’ before ‘xmlXPathContext’

src/lxml/lxml.etree.c:175861: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘initDocDict’

src/lxml/lxml.etree.c:175861: error: expected declaration specifiers or ‘...’ before ‘xmlDoc’

src/lxml/lxml.etree.c:175862: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘findImpliedContext’

src/lxml/lxml.etree.c:175863: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘pushImpliedContextFromParser’

src/lxml/lxml.etree.c:175864: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘pushImpliedContext’

src/lxml/lxml.etree.c:175865: error: ‘struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext’ has no member named ‘popImpliedContext’

src/lxml/lxml.etree.c:175997: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter’ has no member named ‘_createOutputBuffer’

src/lxml/lxml.etree.c:175997: error: ‘xmlOutputBuffer’ undeclared (first use in this function)

src/lxml/lxml.etree.c:175997: error: expected expression before ‘)’ token

src/lxml/lxml.etree.c:175997: error: expected ‘;’ before ‘__pyx_f_4lxml_5etree_15_FilelikeWriter__createOutputBuffer’

src/lxml/lxml.etree.c:175998: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter’ has no member named ‘write’

src/lxml/lxml.etree.c:175999: error: ‘struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter’ has no member named ‘close’

src/lxml/lxml.etree.c:176030: error: expected declaration specifiers or ‘...’ before ‘xsltSecurityOption’

src/lxml/lxml.etree.c:176031: error: expected declaration specifiers or ‘...’ before ‘xsltTransformContext’

src/lxml/lxml.etree.c:176032: error: expected declaration specifiers or ‘...’ before ‘xsltSecurityOption’

src/lxml/lxml.etree.c:176065: error: expected declaration specifiers or ‘...’ before ‘xmlDoc’

src/lxml/lxml.etree.c:176066: error: expected declaration specifiers or ‘...’ before ‘xmlParserCtxt’

src/lxml/lxml.etree.c:176884: warning: implicit declaration of function ‘xmlThrDefIndentTreeOutput’

src/lxml/lxml.etree.c:176893: warning: implicit declaration of function ‘xmlThrDefLineNumbersDefaultValue’

src/lxml/lxml.etree.c:176911: warning: implicit declaration of function ‘xmlInitParser’

src/lxml/lxml.etree.c:177212: error: ‘xmlParserVersion’ undeclared (first use in this function)

src/lxml/lxml.etree.c:177334: error: ‘LIBXML_VERSION’ undeclared (first use in this function)

src/lxml/lxml.etree.c:178335: error: ‘__pyx_v_4lxml_5etree___DEFAULT_ENTITY_LOADER’ undeclared (first use in this function)

src/lxml/lxml.etree.c:178335: warning: implicit declaration of function ‘xmlGetExternalEntityLoader’

src/lxml/lxml.etree.c:178344: warning: implicit declaration of function ‘xmlSetExternalEntityLoader’

src/lxml/lxml.etree.c:178344: error: ‘xmlExternalEntityLoader’ undeclared (first use in this function)

src/lxml/lxml.etree.c:178344: error: expected ‘)’ before ‘__pyx_f_4lxml_5etree__local_resolver’

src/lxml/lxml.etree.c:178353: error: ‘XML_PARSE_NOENT’ undeclared (first use in this function)

src/lxml/lxml.etree.c:178353: error: ‘XML_PARSE_NOCDATA’ undeclared (first use in this function)

src/lxml/lxml.etree.c:178353: error: ‘XML_PARSE_NONET’ undeclared (first use in this function)

src/lxml/lxml.etree.c:178647: error: ‘XML_PARSE_RECOVER’ undeclared (first use in this function)

src/lxml/lxml.etree.c:178647: error: ‘HTML_PARSE_NONET’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179321: error: ‘XML_XPATH_NUMBER_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179331: error: ‘XML_XPATH_UNFINISHED_LITERAL_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179341: error: ‘XML_XPATH_VARIABLE_REF_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179351: error: ‘XML_XPATH_INVALID_PREDICATE_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179361: error: ‘XML_XPATH_UNCLOSED_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179371: error: ‘XML_XPATH_INVALID_CHAR_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179405: error: ‘XML_XPATH_UNDEF_VARIABLE_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179415: error: ‘XML_XPATH_UNDEF_PREFIX_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179425: error: ‘XML_XPATH_UNKNOWN_FUNC_ERROR’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179435: error: ‘XML_XPATH_INVALID_OPERAND’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179445: error: ‘XML_XPATH_INVALID_TYPE’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179455: error: ‘XML_XPATH_INVALID_ARITY’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179465: error: ‘XML_XPATH_INVALID_CTXT_SIZE’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179475: error: ‘XML_XPATH_INVALID_CTXT_POSITION’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179818: error: ‘LIBXSLT_VERSION’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179830: error: ‘xsltLibxsltVersion’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179842: error: ‘__pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179842: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179851: warning: implicit declaration of function ‘xsltSetLoaderFunc’

src/lxml/lxml.etree.c:179851: error: ‘xsltDocLoaderFunc’ undeclared (first use in this function)

src/lxml/lxml.etree.c:179851: error: expected ‘)’ before ‘__pyx_f_4lxml_5etree__xslt_doc_loader’

src/lxml/lxml.etree.c:180101: warning: implicit declaration of function ‘xsltRegisterAllExtras’

src/lxml/lxml.etree.c:180110: warning: implicit declaration of function ‘exsltRegisterAll’

error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/local/bin/python2.7 -c "import setuptools;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FuoZyY-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip_build_root/lxml
Traceback (most recent call last):
File "/usr/local/bin/pip-2.7", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip-2.7')()
File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 148, in main
return command.main(args[1:], options)
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 169, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 81: ordinal not in range(128)

Dec 17, 2013

@Maurizio,

 

What Linux distro/version are you using?  Did you download ncclient from the Juniper github?  It appears that you might not have the right libraries installed.  You many need to manually install the "libxslt" and "libxml2" libraries.  There is a good post here on how that's done:

 

http://lamejournal.com/2013/12/02/installing-junos-ez-library-easy-sdn-part-1/

Mar 6, 2014
musa

I'm getting the same error above,

i'm using Centos and tried to get the libraires manully but didn't succeed even;

 

Cleaning up...
Command /usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-08NOEd-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/lxml
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
  File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 81: ordinal not in range(128)

Mar 9, 2014
aeroplane

Hi Jeremy

 

Could you please refer me any good book for network automation/scripting using python on amazon store?

 

Thanks

Mar 16, 2014

@aeroplane - I would suggest "The Quick Python Book" as a good start.

Apr 14, 2014
kalsoup

Hello Jeremy,

 

I am running Python 2.7.5 on Ubuntu 13.10.

I installed: python-pip, python-dev, libxml2-dev and libxslt-dev prior to installing ncclient 0.4.1 (https://pypi.python.org/pypi/ncclient) using  "sudo python setup.py install" from the ncclient directory.

 

After this, I attempt install junos-eznc using "pip install junos-eznc" , but get the following error:

 

"ser@wt-ubuntu:~$ sudo pip install junos-eznc
Downloading/unpacking junos-eznc
  Downloading junos-eznc-0.0.5.tar.gz (81kB): 81kB downloaded
  Running setup.py egg_info for package junos-eznc
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'namespace_packages'
      warnings.warn(msg)
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
      warnings.warn(msg)
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help
    
    error: invalid command 'egg_info'
    Complete output from command python setup.py egg_info:
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'namespace_packages'

  warnings.warn(msg)

/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'

  warnings.warn(msg)

usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: invalid command 'egg_info'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/junos-eznc"

 

Could you please tell me if I'm missing/doing something wrong?

I'm no expert at Linux/Ubuntu and would greatly appreciate your help!

 

Best Regards