datacenter / nexus9000 Goto Github PK
View Code? Open in Web Editor NEWNexus 9000
Nexus 9000
Below is the list of ‘getters’ in the NXAPI() class:
Test code will 'Succeed' with this Bug in place, as 'username' and 'password' are identical. The 'get_password()' method returns 'self.username' where 'self.password' is expected.
class NXAPI:
'''A better NX-API utility'''
def init(self):
self.target_url = 'http://localhost/ins'
self.username = 'admin'
self.password = ‘admin’
self.timeout = 10
…
…
def get_target_url(self):
return self.target_url
def get_username(self):
return self.username
**def get_password(self):**
**return self. username**
def get_timeout(self):
return self.timeout
def get_cmd(self):
return self.cmd
def get_out_format(self):
return self.out_format
def get_do_chunk(self):
return self.do_chunk
def get_sid(self):
return self.sid
def get_cookie(self):
return self.cookie
Wondering if there's any work going on or planned for making this library into an installable Python module. If not I'd be happy to take this on in my fork.
I have a few projects going on that I'd like to build in NXAPI functionality and it would make it easier for me to build this in there if this functionality was built.
last poap.py version Jun 9 11:21
Target node: NX-OSv 9k 7.0.3.I6.1
Following the official guidelines, I made the following modifications to the script:
options = {
"username": "tftp",
"password": "tftp",
"hostname": "172.21.0.1",
"transfer_protocol": "tftp",
"mode": "raw",
"config_path": "NX-OSv-9k/7.0.3.16.1"
"target_image_path": "NX-OSv-9k/7.0.3.16.1"
"target_system_image": "nxos.7.0.3.I6.1.bin",
"user_app_path": "NX-OSv-9k/7.0.3.16.1"
"source_config_file": "poap.cfg"
}
To make sure they are not dismissed, I also performed the following modifications:
I also recomputed the checksum.
During the POAP phase, the NX-OSv 9k is able to get all its DHCP parameters, downloads the poap.py and says that an error occurred during execution without further explanation.
Some details would be very helpful.
Dear all,
I am trying to deploy the nexusdash application but i am getting an error when I run the manage.py file
below is a copy from my terminal, you can see that all the requirements are satisfied:
(nexusdash)user1:~/Desktop/nexus9000-master/nexusdash $ pip install -r requirements.txt Requirement already satisfied: Django==1.6.5 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 1)) Requirement already satisfied: django-bootstrap3==4.8.2 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 2)) Requirement already satisfied: django-debug-toolbar==1.2.1 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 3)) Requirement already satisfied: python-nvd3==0.12.2 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 4)) Requirement already satisfied: lxml==3.3.5 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 5)) Requirement already satisfied: xmltodict==0.9.0 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 6)) Requirement already satisfied: South==1.0 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 7)) Requirement already satisfied: django-celery==3.1.10 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 8)) Requirement already satisfied: pycrypto==2.6.1 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from -r requirements.txt (line 9)) Requirement already satisfied: sqlparse in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from django-debug-toolbar==1.2.1->-r requirements.txt (line 3)) Requirement already satisfied: setuptools in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg (from python-nvd3==0.12.2->-r requirements.txt (line 4)) Requirement already satisfied: Jinja2>=2.7.2 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from python-nvd3==0.12.2->-r requirements.txt (line 4)) Requirement already satisfied: awesome-slugify in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from python-nvd3==0.12.2->-r requirements.txt (line 4)) Requirement already satisfied: celery>=3.1.10 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from django-celery==3.1.10->-r requirements.txt (line 8)) Requirement already satisfied: MarkupSafe>=0.23 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from Jinja2>=2.7.2->python-nvd3==0.12.2->-r requirements.txt (line 4)) Requirement already satisfied: regex in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from awesome-slugify->python-nvd3==0.12.2->-r requirements.txt (line 4)) Requirement already satisfied: Unidecode<0.05,>=0.04.14 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from awesome-slugify->python-nvd3==0.12.2->-r requirements.txt (line 4)) Requirement already satisfied: kombu<3.1,>=3.0.37 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from celery>=3.1.10->django-celery==3.1.10->-r requirements.txt (line 8)) Requirement already satisfied: pytz>dev in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from celery>=3.1.10->django-celery==3.1.10->-r requirements.txt (line 8)) Requirement already satisfied: billiard<3.4,>=3.3.0.23 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from celery>=3.1.10->django-celery==3.1.10->-r requirements.txt (line 8)) Requirement already satisfied: amqp<2.0,>=1.4.9 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from kombu<3.1,>=3.0.37->celery>=3.1.10->django-celery==3.1.10->-r requirements.txt (line 8)) Requirement already satisfied: anyjson>=0.3.3 in /home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages (from kombu<3.1,>=3.0.37->celery>=3.1.10->django-celery==3.1.10->-r requirements.txt (line 8))
required exports:
(nexusdash)user1:~/Desktop/nexus9000-master/nexusdash $ export SECRET_KEY=123456789 (nexusdash)user1:~/Desktop/nexus9000-master/nexusdash $ export DJANGO_SETTINGS_MODULE=nexusdash.settings.local
trying to run manage.py:
(nexusdash)user1:~/Desktop/nexus9000-master/nexusdash $ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command klass = load_command_class(app_name, subcommand) File "/home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module __import__(name) File "/home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/south/management/commands/__init__.py", line 10, in <module> import django.template.loaders.app_directories File "/home/user1/miniconda/envs/nexusdash/lib/python2.7/site-packages/django/template/loaders/app_directories.py", line 25, in <module> raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0])) django.core.exceptions.ImproperlyConfigured: ImportError django_nvd3: No module named django_nvd3
Please advise
and thank you for your time
I am confused about if the poap.py.md5 file is necessary for the POAP process? And if it's necessary, what's the content should be? Should it be only one line like this below?
######################################################
the MD5 value calculated with command md5sum poap.py poap.py
######################################################
And I know the second line which contains the MD5 value in the poap.py file need to be updated once the file is changed, so the value in the poap.py file second line must be not same with the output of md5sum poap.py command. According to Cisco docs, the nexus switch need to check the MD5 hash value of the poap.py file, and every file in the POAP process need a corresponding .md5 extension file, so which one the nexus switch will choose to use for the mMD5value compare?
And I know the second line which contains the MD5 value in the poap.py file need to be updated once the file is changed, so the value in the poap.py file second line must be not same with the output of md5sum poap.py command. According to Cisco docs, the nexus switch need to check the MD5 hash value of the poap.py file, and every file in the POAP process need a corresponding .md5 extension file, so which one the nexus switch will choose to use for the mMD5value compare?
I'm curious about the proper way to iterate through the dictionary object generated by xmltodict.py utilities. I've successfully connected to a Nexus 9508 XML API and fed the XML into the parser to get a dictionary object.
I don't have a ton of experience with python dictionaries, and what I do have, wasn't hierarchical like this is. Here's what I have thus far:
from nxapi_utils import *
thisNXAPI = NXAPI()
thisNXAPI.set_target_url('http://1.1.1.1/ins')
thisNXAPI.set_username('admin')
thisNXAPI.set_password('password')
thisNXAPI.set_msg_type('cli_show')
thisNXAPI.set_cmd('show ip route')
returnData = thisNXAPI.send_req()
#print returnData[1]
doc = xmltodict.parse(returnData[1])
for k ,v in doc['ins_api']['outputs']['output']['body']['TABLE_vrf']['ROW_vrf']['TABLE_addrf']['ROW_addrf']['TABLE_prefix'].iteritems():
print k, v
This results in:
ROW_prefix [OrderedDict([(u'ipprefix', u'9.0.0.0/8'), (u'ucast-nhops', u'1'), (u'mcast-nhops', u'0'), (u'attached', u'FALSE'), (u'TABLE_path', OrderedDict([(u'ROW_path', OrderedDict([(u'uptime', u'PT10H1M21S'), (u'pref', u'1'), (u'metric', u'0'), (u'clientname', u'static'), (u'ubest', u'TRUE')]))]))]), OrderedDict([(u'ipprefix', u'172.16.1.0/30'), (u'ucast-nhops', u'1'), (u'mcast-nhops', u'0'), (u'attached', u'TRUE'), (u'TABLE_path', OrderedDict([(u'ROW_path', OrderedDict([(u'ipnexthop', u'172.16.1.2'), (u'ifname', u'Po1'), (u'uptime', u'PT21H59M20S'), (u'pref', u'0'), (u'metric', u'0'), (u'clientname', u'direct'), (u'ubest', u'TRUE')]))]))]), OrderedDict([(u'ipprefix', u'172.16.1.2/32'), (u'ucast-nhops', u'1'), (u'mcast-nhops', u'0'), (u'attached', u'TRUE'), (u'TABLE_path', OrderedDict([(u'ROW_path', OrderedDict([(u'ipnexthop', u'172.16.1.2'), (u'ifname', u'Po1'), (u'uptime', u'PT21H59M20S'), (u'pref', u'0'), (u'metric', u'0'), (u'clientname', u'local'), (u'ubest', u'TRUE')]))]))]), OrderedDict([(u'ipprefix', u'172.16.3.1/32'), (u'ucast-nhops', u'1'), (u'mcast-nhops', u'0'), (u'attached', u'FALSE'), (u'TABLE_path', OrderedDict([(u'ROW_path', OrderedDict([(u'ipnexthop', u'172.16.1.1'), (u'ifname', u'Po1'), (u'uptime', u'PT21H57M59S'), (u'pref', u'110'), (u'metric', u'2'), (u'clientname', u'ospf-1'), (u'type', u'intra'), (u'ubest', u'TRUE')]))]))]), OrderedDict([(u'ipprefix', u'172.16.33.1/32'), (u'ucast-nhops', u'1'), (u'mcast-nhops', u'0'), (u'attached', u'FALSE'), (u'TABLE_path', OrderedDict([(u'ROW_path', OrderedDict([(u'ipnexthop', u'172.16.1.1'), (u'ifname', u'Po1'), (u'uptime', u'PT21H57M59S'), (u'pref', u'110'), (u'metric', u'2'), (u'clientname', u'ospf-1'), (u'type', u'inter'), (u'ubest', u'TRUE')]))]))]), OrderedDict([(u'ipprefix', u'172.16.41.1/32'), (u'ucast-nhops', u'1'), (u'mcast-nhops', u'0'), (u'attached', u'FALSE'), (u'TABLE_path', OrderedDict([(u'ROW_path', OrderedDict([(u'ipnexthop', u'172.16.1.1'), (u'ifname', u'Po1'), (u'uptime', u'PT21H57M59S'), (u'pref', u'110'), (u'metric', u'2'), (u'clientname', u'ospf-1'), (u'type', u'inter'), (u'ubest', u'TRUE')]))]))])]
I was hoping to get to the point where I could create a few classes of my own (for instance a "route" class or similar to represent an entry in the routing table, but I'm at a loss as to how to iterate with what's here. I basically want to iterate through each item under TABLE_prefix, and for each ROW_prefix, add all of the properties within to a class object I can create later. It's the iterating part where I'm stuck.
Any help? Thanks in advance!
i want to test poap.py only push configuration not to download target image, what is the possible options?
tks
I ran this on a switch running 7.0(3)I2(2a) assuming it would upgrade to 7.0(3)I4(7) and the check for bios upgrade didn't flag that the bios was newer so it resulted in the loader prompt
Is there any place in the current script that it gets the bios version in the to-install .bin? If so it'd be easy enough to fix, otherwise I'll have to figure out how to get the bios version string from the new image
The command to recalculate the md5 is wrong. The result needs to be in double quotes. Command in question.
f=poap.py ; cat $f | sed '/^#md5sum/d' > $f.md5 ; sed -i "s/^#md5sum=./#md5sum=$(md5sum $f.md5 | sed 's/ .//')/" $f
Correct command
f=poap.py ; cat $f | sed '/^#md5sum/d' > $f.md5 ; sed -i "s/^#md5sum=./#md5sum="$(md5sum $f.md5 | sed 's/ .//')"/" $f
Hey guys! This may not be poap.py script related issue, but my switch is able to attempt tftp to download poap.py script and it fails. I have been able to ping the switch from my dhcp/tftp server while its IP is assigned.
Any ideas on what the problem may be? My dhcp/tftp server is running Window 10.
datacenter/nexus9000/nx-os/poap/poap.py
In some cases the cdp_interface may be None. This can lead to the clid call for cdp_interface causing an error.
Fix is on it's way.
Hello,
I'm working on pushing nxos.9.2.1.bin to our switching infrastructure.
Looking through poap.py it doesn't look like it currently supports 9.2.
Is this planned for the future? If so, is there a available timeline.
Thanks,
Bill
Can you clarify what the license of the code here is? Is it MIT, Apache2, something else?
Also the README link is broke (has been for quite a while).
https://opennxos.cisco.com/public/api - seems down.
Can we have this fixed or update readme with the working URL please?
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.