Alright friends, let's now use Netconv to begin sending some remote procedure
calls to our target
device. Now in order to get things up and running what I'm going to do is
suggest we use the
Cisco DevNet always on sandbox and inside of here we're going to use the Cisco
iOS XE device which
should be configured for Netconv. So first things first let's go to our browser
and check this out.
Okay so all I will do is log in to DevNet sandbox and if I choose to launch the
sandbox,
all that we'll do is go to the top and I'll search for XE. Now we can see here WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
all that we'll do is go to the top and I'll search for XE. Now we can see here
we have the cat 8KV
always on sandbox, let's go with that so we don't have to reserve anything. Now
what I should say
as always is that these particular credentials may actually change so always
check this before
you actually go and do something. So we can see here this is the domain we use
to connect to the
device we have our user name of admin, the password of C1SEO12345 and crucially
the Netconv port is
enabled on port 830. Okay so remember those details, take a note of it. What we WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
enabled on port 830. Okay so remember those details, take a note of it. What we
now want to do is
we want to use a particular utility that can effectively send these Netconv RPC
s. So the command
or rather the command, the utility that I'm going to recommend we use is
something known as NC
Client. This is the Netconv client. Essentially this is just a Python library
that allows us to send
these RPCs and then we can manipulate the data utilizing Python as expected. So
with that said,
let's go and check it out. So as we can see I have my virtual environment
activated as we've seen
before in previous skills all I will do now is say pit3 install NC Client and WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
before in previous skills all I will do now is say pit3 install NC Client and
hit Enter. Now as it
stands I already have this installed in my virtual environment but if you just
follow along you will
have it available. With this now done I will create a little folder let's just
call this
Netconv, I don't know I just say Netconv stuff and I'll just change into this
directory okay so I've
got a nice clean directory from which to work. So what I will do is let me just
create a little script
called script1.py and all I will do is open this up. Okay so first thing is
first we're going to send WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
first we're going to send
a getconfig RPC okay. So what this should do is it should return all of the
information about the
configuration of our device. Now one thing to note here very very important
this can be a little bit
confusing when you first see it. Remember we have these different types of Yang
models we can have
the native models which are going to be Cisco specific. We're also going to
have our vendor
neutral model such as OpenConfig as well as IETF. Now when we happen to just
retrieve the
configuration of our device using a getconfig RPC we're going to see the same WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
configuration of our device using a getconfig RPC we're going to see the same
data modeled in
multiple different ways we'll get to see the same information IE all the
running configuration
of the device modeled in the native style we'll also get to see the same
information modeled in
the OpenConfig style and the same information modeled in the IETF style. So
obviously this can actually
present a ton of information it can be really quite difficult to sift through
visually. Tons and tons
of XML tags this is just something that we have to get around. What I will say WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
of XML tags this is just something that we have to get around. What I will say
though is that as we
progress throughout this particular skill we'll get to see how we can filter
this information to be
a little bit more specific but the first time we see this just be warned this
might be a bit of a
headache okay it's a lot of information to consume. So the first thing we want
to do like you say is to
use a particular utility NC clients to actually send this RPCs. So first things
first what I will
say at the top is from NC clients what I'm going to do is import manager now
our manager object that
we are importing will allow us to connect to a device and then we're going to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we are importing will allow us to connect to a device and then we're going to
have particular
methods associated to the type of RPCs we want to send does that seem confusing
well trying
it to whatever it will get to see an action it should become a little bit
clearer. So what I will do
is I will create a little dictionary here called my device. So I will have my
currently braces here
and all I will do is I'll populate some values so the first key is going to be
the host key
and then I'll specify the address that I'm going to be connecting to and
remember this may change
when you happen to do this yourself so just double check it but for right now WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
when you happen to do this yourself so just double check it but for right now
this is the address
for the XE box. So I'll do is paste in this information add my little comma and
now add my next key.
So I'll say the port key is going to be port 830 remember that is the netcon's
default and as we
can see as per the actual documentation that is the port the netcon's
configured here we also have
the admin username and the Cisco password of C1s012345 so let's go and add
these two so I'll have my
username key corresponding value as admin and the password key corresponding WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
username key corresponding value as admin and the password key corresponding
value like I say
let's just add in C1s012345. Now lastly all I will say is host key underscore
verify and I'm
going to set that to the billion value of false basically we don't care about
verifying the host keys
now remember in python that is a particular way we can automatically close our
connection after
it's been opened and that is to use a context manager which is using the with
statement as so
so all I will do is I will take my manager object and I'm going to use the
connect method and all
I will do is I'll pass in all of the values within my dictionary here so I can WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I will do is I'll pass in all of the values within my dictionary here so I can
do this recall we can
unpack our dictionary with special syntax with two asterix and then we just use
the name of the
dictionary so pretty much all this information here is going to be passed into
the connect method
and this is what we're going to connect to utilizing the manager object so what
I want to do is
I want to store it as a variable called m and then indent it within what I will
do is I'll create a
variable just called let's maybe say results and I'll take the m object just WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
variable just called let's maybe say results and I'll take the m object just
created here and I'm
going to send a get_config rpc now remember with respect to our netconv we also
have different
data stores we can target we have the startup data store the running data store
and the candidate
data store in my case I'm just going to keep things really quite simple and
just focus in the running
data store okay so I'm going to have to specify this so I will say the source
that I'm targeting
is going to be the running data store now for the moment all I will do here is WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is going to be the running data store now for the moment all I will do here is
I will print out
the results so if I just save this for the moment and I just clear the screen
and I say Python 3
and type in the name of the script and to enter give a moment and bam this is
all the information
I've been talking about look at this try to read this with human eyes this is
why it's such a
nightmare working with XML especially when you're working with multiple
different yang models so
what I'm going to do here just to try to make this a little bit more readable
is I'm going to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is I'm going to
ultimately format the response so what I'm going to do here is I'm going to say
from xml.dom I'm going
to import manydom now to be clear all I'm doing here is nothing to do with the
actual netconv itself
all I'm trying to do here is to help you read the output a little bit easier so
it's just about
XML formatting okay so don't get too confused about it or don't get too hung up
about it so what I'm
going to do here is I'm going to print and I'm going to say manydom and I'm
going to pass string
and I'm going to pass in the result that I just got there and then I'm going to
say give me
it in pretty XML okay so let's try this again clear this green to know if I rer WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
it in pretty XML okay so let's try this again clear this green to know if I rer
un this we now get
a response byte now whilst this is still really quite hard to look at we have
some ugly lane wrapping
at least we have some form of indentation and structure in fact let me just
zoom out a little bit
so you can help you see it a little bit better see this right here this is all
the information now
we have a lot of indentation we have a ton of information so like you say if
you happen to look
at the output here we're seeing information related to in this case here this
is a Cisco native
Yang model and there's a whole bunch of that information model below okay and WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Yang model and there's a whole bunch of that information model below okay and
within the same
output we can also see Yang models which are utilizing the ietf models as well
as information
modeled via open config as we see right here so right now all we've done is
send a get config rpc
without any filter ultimately getting back every possible way that the running
configuration
can be models so we're getting a lot of info what we now want to do is to be a
little bit more
precise and begin filtering that information now the first way we want to
filter is utilizing
something known as sub tree filtering so let's talk about that in the very next WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
something known as sub tree filtering so let's talk about that in the very next
video