Alright friends, let's try and demystify these URLs. So like I said, the URL is
directly tied
to the Yang model and we know that we have different types of Yang models
available, we have ITF,
we have Cisco or other native models which include Cisco, Juniper, so on, so
forth, as well as
the Open Config models. So what I propose we do is we go to a website called
GetUp, whereby all of
these models are actually uploaded and we can download a copy of all of the
available models and
then we can begin inspecting them and from that point we can derive what our WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
then we can begin inspecting them and from that point we can derive what our
URL should actually be.
So let me go and go to my browser here, so if you happen to search for Yang
models GetUp,
let's click this link here. Now what I'm going to do is I'm going to download a
copy of everything
that is in all of these folders, okay. So because I'm downloading from GetUp, I
'm going to use
a utility called GetSaults. They get clone and then paste in the address that I
just saw there and
if I enter we're going to begin downloading all of these files, okay. Now just
whilst that
downloads, if I go back to my browser, what we can actually see here is we have WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
downloads, if I go back to my browser, what we can actually see here is we have
a whole bunch of
different folders, okay. So if I just go into say, for example, the standard
folder, I can get down
and go into IETF for the IETF models, if I go into RFC for the request for
comments, what we actually
see here are tons and tons and tons of these models. So we have IETF models for
things like IPv4,
Unicast routing, so if you've got some type of routing configuration, the
information you would
find would be in this model, whereas if you want to get, say for example, some
interface information,
if we scroll on up, what we can see here is the IETF interfaces yang model. Now WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
if we scroll on up, what we can see here is the IETF interfaces yang model. Now
one thing you'll
notice is if we happen to just look at this right here and if you scroll
through all of this,
you are beginning to see that this looks kind of confusing, it's pretty complex
and it really is
very, very long. I can just keep scrolling and scrolling and scrolling. This is
really, really hard
to just look at this way and because of that, what I'm going to suggest we do
is we use
the utility that is going to transform this data into something that is at
least a little bit more
readable. So the utility that I'm going to use right now is something called pi WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
readable. So the utility that I'm going to use right now is something called pi
yang. It's basically
a Python program that is going to, well, ingest these models. So I'll say pip3
installed pi yang
and to enter and then we begin installation. So now we're that done because I
have downloaded the
yang models, it's been downloaded into a directory called yang, which we can
see right here. So if I
just go into this folder and I do a listing, we actually see all of the same
information that we
saw on the website right there. We can go into the standard folder, we can go
into vendor models,
so on, so forth. So if I just go into the standard folder like we just saw WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
so on, so forth. So if I just go into the standard folder like we just saw
before and I do a listing
and I go into the ITF folder and do a listing and again, our FC, we can see
this is the exact same
structure. So inside this folder, do a listing, we're going to see all of these
models. So again,
scrolling on up, we can see models for SNMP, segment routing, tons and tons and
tons of stuff.
But for now, let's go and grab the ITF interfaces model, okay? So if I just
copy this right here,
and grab you, what I will do is use my tool and say, pi yang dash f for the
format, say I want to see
this in a tree like format and then just paste in the model that we want to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
this in a tree like format and then just paste in the model that we want to
inspect. If I hit enter,
we now see this tree like structure. So let's go up to the very top, okay? So
at the very top,
we actually see the name of the module, okay? And then inside that, we have all
of the model data,
okay? So again, I know this is pretty confusing to look at. But honestly, we
don't have to get too
deep in the way to this, okay? So don't be discouraged. Try to follow along. So
basically we have this top
level container here called interfaces. And we can see it's actually out-dented
here a little bit.
And then everything within, this is all within that particular container, see WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And then everything within, this is all within that particular container, see
that? Now I will say it
gets more detailed than this. But for a good starting point, what we're going
to do is to make a note
of the module here, okay? And then we're going to make a note of the top level
container. Okay,
so just take those two pieces of information that we see right now, okay? And I
'm going to basically
combine them now, pause for a moment. These two values might actually be
familiar. If you go back
to our script, look at what we actually see here. This is the way we build our
URL. We have the target WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
URL. We have the target
we're trying to reach and the port and then we say forward slash, rest corn
forward slash data.
That's a standard. After that, we now specify the information that we want to
receive from the
browser rather than the browser from the router. So the first portion here,
this is me telling what
yang model I want to be retrieving. Okay? And remember that's just what you saw
right there. Okay?
See it. This is the module name right here for all of this information. And
then immediately after,
what I have is a little colon separator, which we can see. And then right after WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
what I have is a little colon separator, which we can see. And then right after
we have that top
level container. So think about it like this. If I wanted to get a different
piece of information,
how would I do that? But I would go through another yang model. I could then
use pie yang. And from
that point, I would quickly look at the module and then get the top level
container. So here's the
thing. If you go back into our yang folder here, and this time we go into the
vendor folder. And now
I go in and look for Cisco. And then I'm on a Cisco iOS XE device. So I'll go
into this particular
folder and all I have here are all of these revision numbers. So let's grab the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
folder and all I have here are all of these revision numbers. So let's grab the
latest revision.
So this one right here, going here. If I do a listing, we see all of these
models. Okay?
If I just grab the model that says native, this is essentially going to give me
all of my running
configuration. So let's just copy this here. And I'll say pie yang f dream. And
I'll paste in the
model once again, if I enter. So because this can model the entire
configuration, this is an
absolutely massive file. But if I go to the very top, what can we see here? I
can see the name of
the module, which is this right here. And then the top level container is this WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the module, which is this right here. And then the top level container is this
one right here.
Okay? So let's try to follow the same principles and return this data. So let
me just
copy this right here. Okay? And all I will do is I will copy it over the
previous script. And I'll
create one called script free dot py. So if I open this up, go in here and what
I'm going to do here,
if I just remove all of this. And I'll go and modify the actual path. Okay? So
let's just take the URL,
delete this, paste in the name of the module. Then we'll have a colon and then
we'll use the top WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we'll use the top
level container, which is native. Open in fact, before I do this, let me put my
parentheses back in
right here. And now I will say, Python 3 script 3 dot py and to enter. And now
look at this, we get a
whole bunch of different information we're seeing effectively. The running
configuration, your show
runs of the speak in this Yang model type data. So scrolling all the way up to
the very top,
we can actually see the information that we have here is the outer key and
instead of that,
we have our version, which returns the version number. If you want to scroll on
down,
we have a host name key, which tells me the name of the host. We also have a WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we have a host name key, which tells me the name of the host. We also have a
router key. And instead
of here, we can see that happens to be OSPF configured on this particular
device. So there's two ways
to actually approach this. We can just get this data very generally and get all
this information back
and then we can begin parsing it directly with Python. So say, for example,
what I could do is
copy the key right here. And then when I retrieve the data, I can paste in the
key. So if I save this,
clear the screen, read around the script, if I scroll all the way up to the
very top once again.
Now we can see we have removed that outer key. So I can now grab more WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now we can see we have removed that outer key. So I can now grab more
information. Let's try the
version key right here. Okay. So again, paste your in. If I run it one more
time, now we're just receiving
back the version key. Here's what's happening here. I've got my Linux machine
and I've got my
REST CONF configured catalyst switch here. So right now, I'm sending an 80DP
request to ultimately get
back all of the native configuration. Okay. And this is actually sending back a
ton of information
back to my machine right here over the network. And at this point on my machine
, I'm just effectively WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
, I'm just effectively
filtering all of that data locally right here to return this particular piece
of information.
As opposed to me sending a request just to target the native data and pull back
tons and tons
of that information being sent over the wire and filter it here. What I can
actually do is I can just
send a more specific URL to the actual server itself. And this will just send
me over the very specific
data that I want. So pretty much the filtering is happening over here, meaning
that we're not having
to send tons and tons of data over the network unnecessarily just to filter it WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to send tons and tons of data over the network unnecessarily just to filter it
out locally.
So as opposed to filtering it out with Python, let's actually filter it out
directly from the server
by specifying a more specific URL. So here's what I will do. I will delete the
part of the time filtering
just so I can see all the data one more time, run the script. And if I scroll
on up to the very top,
what if I just try to add the version directly within the URL itself? Okay. So
check this out. What
we'll do here is go back in this time. I will just say forward slash version
and save you if I
clear the screen and run the script. Look at this. The formatting might look a WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
clear the screen and run the script. Look at this. The formatting might look a
little bit different,
but we're actually getting back the correct value in this time. We've only had
the server send over
a very tiny amount of data, just the specific details that we want. So
similarly, why could do
is go back again? Let's just remove this to get the more general information.
Save you.
Arrow up try again. Say for example, I wanted to get this banner information.
Okay. Well, you'll
notice that this banner is actually indented within this key. And this key is
also indented within.
This key. Okay. So this has been a beginning to get a little bit confusing. So WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
This key. Okay. So this has been a beginning to get a little bit confusing. So
we'll reference this key
first. The most outer key. So if I just say forward slash banner, save you.
Clear the screen,
try again. Now we're getting the more banner specific information. So again,
let's get the MOTD key.
So I'll just say forward slash MOTD, save you. Run it again. Now we have the
banner key right here.
So if I just say forward slash banner one more time and run the script, here we
can now see we're
parsing at the actual banner within the device itself. And again, if I just log
in and say SSH and
just give the sandbox address. If I log in, indeed we can see here, this WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
just give the sandbox address. If I log in, indeed we can see here, this
actually is the banner that
we're seeing. See that. So no doubt if this is the first time you're seeing
this in action,
risk on and Yang can be pretty confusing due to these URLs. But really as a
recap, all we have to do
is to download the models. We then choose the model that we want to use, say
for example, an interface
model. And then we can make a note of the module name and also specify the top
level container.
We then take this information, put it into a URL and then make a request to the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
We then take this information, put it into a URL and then make a request to the
device. And this
will return the information about that particular model. And from that point on
, we can either work with
the data programmatically via Python, which is going to include us sending,
perhaps maybe a lot more
information over the network. Or if we wish we can request that the server
itself filters the
information being sent back. But ultimately, walking through the data and just
specifying more specific URLs.