Reserving a Sandbox Lab
The Open NX-OS sandbox is a testing environment that enables developers to experiment from the production environment or repository of CISCO lab. A developer can use this sandbox to program the switch through various configuration management tools and scripts like bash, python, puppet, chef and ansible.
- Go to the DevNet Sandbox data center labs
- Click on the Open NX-OS box to read more about the lab or click on "Reserve" to reserve the lab.
- Upon successful reservation you will receive an email from the DevNet Sandbox team that describes further instructions to access the sandbox.
TACACS
Terminal Access Controller Access Control System (TACACS) is an authentication protocol that allows a remote access server to forward a user's logon password to an authentication server to determine whether access can be allowed to a given system. On Nexus 9000 switch TACACS provide a centralized validation of users who are attempting to gain access to a router or network access server. This section describe how you can manage and program TACACS on a CISCO Nexus 9000 switch using different configuration management code snippet.
Using Python in the Sandbox
Follow following steps to execute the python scripts on Nexus switch.
- Login to switch using provided credentials. Example username is 'admin' and password 'cisco123'.
- If bash is not enabled, Goto 'config t' and enable it by running 'feature bash-shell'
- Run 'run bash' to go to bash shell.
- Run sudo su
- Copy the required script to /isan/python/scripts/cisco directory. For example, if you want to manage TACACS
configuration using python, create test_tacacs.py using vi editor like this:
vi test_tacacs.py
- Now copy the script to this file. Save and exit.
- Execute following command to run the script '/isan/bin/python –m cisco.test_tacacs
- The format of the command to be executed is, '/isan/bin/python -m'
Using Puppet in the Sandbox
Following steps would execute the manifest files on nx9000 switch.
SSH to toolserver host using provided credentials. (If credentials are not provided Default username is cisco
and password cisco123
Copy the respective manifest script to /etc/puppetlabs/code/environments/production/manifests directory. For example, if you want to configure interface then create manifest file configure_interface.pp using vi editor and paste the respective script in this file.
Note: All the manifest scripts are available "/etc/puppetlabs/code/environments/production/modules/ciscolib_nxos/manifests" for reference.
Save and exit.
Run sudo su
Start the puppetserver service. Run service puppetserver start
or /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/bin/puppet master
Run export PATH=$PATH:/opt/puppetlabs/bin:/opt/puppetlabs/lib
on toolserver
Run puppet cert list -a
Note: If agent hostname is not listed in the certificates in step 7 then we need to add the certificate first. Follow the steps mentioned in "Steps to add the certificates" section.
Note: Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver
Example: toolserver IP: 10.10.10.114
hostname: toolserver-devnet.insieme.local
Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet"
- Login to Switch sandbox.
- On the switch console run
run bash
- Run
sudo ip netns exec management bash
- Run
export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/puppet/lib
- export http and https proxy by executing these commands.
Run
export http_proxy=https://proxy.esl.cisco.com:8080
Run export https_proxy=https://proxy.esl.cisco.com:8080
- Install "install cisco_node_utils" package by executing following command,
Run
gem install cisco_node_utils
- Run
puppet agent -t
. The configuration would be updated automatically on the switch.
- Go to switch prompt and run
copy r s
Steps to add the certificates:
- Login to Switch sandbox.
- On the switch console run
run bash
- Run
sudo ip netns exec management bash
- Run
export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/puppet/lib
- Run
rm -rf /etc/puppetlabs/puppet/ssl
to clean all the old certificates.
- Run
puppet agent -t
on bash shell. This will create a new certificate.
- Now login to toolserver.
- Run
sudo su
- Start the puppetserver service. Run
service puppetserver start
or /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/bin/puppet master
- Run
export PATH=$PATH:/opt/puppetlabs/bin:/opt/puppetlabs/lib
on toolserver
- Run
puppet cert list -a
. It should list the certificate sent by agent #agent hostname should be present.
- Run
puppet cert sign <certificate name>
. For example, puppet cert sign "n9kvswitchfcs.cisco.com" ## agent hostname
AAA
Access control is the way you control who is allowed access to the network server and what services they are allowed to use once they have access. Authentication, authorization, and accounting (AAA) network security services provide the primary framework through which you set up access control on your router or access server. Following example shows how to enable authentication login ascii-authentication and error-enable.
Configure aaa authentication to show or display of error message on login failures and ascii authentication:
Using NX-API REST in the Sandbox
Follow below steps to execute NX-API REST code snippet on nx9000 switch.
On the nx9000 switch perform following operation.
- SSH to switch using provided credentials. (If credentials are not provided Default username is 'admin' and password 'cisco123'
- Run 'config t' on the switch prompt.
- Enable nxapi by running 'feature nxapi'.
- Exit to switch prompt by running 'exit'.
- Run 'copy r s' to save the configuration.
Setup postman Code snippet:
In order to execute NXAPI from postman, login needs to be performed. The cookie would get generated and stored for subsequent execution.
Executing NXAPI using postman for first time:
- Copy POST URL, mentioned in 'setup postman' section above, after replacing SWITCH-IP with IP address of Nexus switch .
- Select method as POST
- Open raw JSON section.
- Copy POST-BODY JSON to raw JSON body section of postman.
- Replace SWITCH_USERNAME with switch user.
- Replace SWITCH_PASSWORD with switch password.
- Click send button
Note: If the cookie gets expired, you might have to perform the above steps again.
For subsequent NXAPI call:
- Copy POST URL, after replacing SWITCH-IP with IP address of Nexus switch.
- Select method as POST
- Open raw JSON section.
- Copy POST-BODY JSON to raw JSON body section of postman.
- Click send button
How to connect to sandbox lab:
- Go to the sandbox homepage: https://developer.cisco.com/site/devnet/sandbox/
- Login. Hit the yellow button "Get Started!" button
- In the upper-right corner click on "DEVNET".
- Now you are in Cisco's Devnet domain and it would list the labs hosted under the domain.
- You can find the 8 tiles for the NX-OS labs. The tiles are named as "Open NX-OS Lab -1(through 8)"
- Click on 'Reserve' a lab. Upon successful reservation you would receive a mail from "devnetsandbox@cisco.com" that describes further instructions to access the sandbox.
Using Python in the Sandbox
Follow following steps to execute the python scripts on Nexus switch.
- Login to switch using provided credentials. Example username is 'admin' and password 'cisco123'.
- If bash is not enabled, Goto 'config t' and enable it by running 'feature bash-shell'
- Run 'run bash' to go to bash shell.
- Run sudo su
- Copy the required script to /isan/python/scripts/cisco directory. For example, if you want to manage AAA
configuration using python, create test_aaa.py using vi editor like this:
vi test_aaa.py
- Now copy the script to this file. Save and exit.
- Execute following command to run the script '/isan/bin/python “m cisco.test_aaa
- The format of the command to be executed is, '/isan/bin/python -m'
SNMP
The Simple Network Management Protocol (SNMP) is an application-layer protocol that provides a message format for communication between SNMP managers and agents. SNMP provides a standardized framework and a common language used for the monitoring and management of devices in a network. Following example shows snmp community configuration.
Using Python in the Sandbox
Follow the following steps to execute the python scripts on Nexus switch.
- Login to switch using provided credentials. Example username is 'admin' and password 'cisco123'.
- If bash is not enabled, Goto 'config t' and enable it by running 'feature bash-shell'
- Run 'run bash' to go to bash shell.
- Run sudo su
- Copy the required script to /isan/python/scripts/cisco directory. For example, if you want to manage snmp
configuration using python, create test_snmp.py using vi editor like this:
vi test_snmp.py
- Now copy the script to this file. Save and exit.
- Execute following command to run the script '/isan/bin/python –m cisco.test_aaa
- The format of the command to be executed is, '/isan/bin/python -m'
Using Puppet in the Sandbox
Following steps would execute the manifest files on nx9000 switch.
- SSH to toolserver host using provided credentials. (If credentials are not provided Default username is
cisco
and password cisco123
- Copy the respective manifest script to /etc/puppetlabs/code/environments/production/manifests directory. For example, if you want to configure interface then create manifest file configure_interface.pp using vi editor and paste the respective script in this file.
- Save and exit.
- Run
sudo su
- Start the puppetserver service. Run
service puppetserver start
or /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/bin/puppet master
- Run
export PATH=$PATH:/opt/puppetlabs/bin:/opt/puppetlabs/lib
on toolserver
- Run
puppet cert list -a
Note: If agent hostname is not listed in the certificates in step 7 then we need to add the certificate first. Follow the steps mentioned in "Steps to add the certificates" section.
Note: Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver
Example: toolserver IP: 10.10.10.114
hostname: toolserver-devnet.insieme.local
Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet"
- Login to Switch sandbox.
- On the switch console run
run bash
- Run
sudo ip netns exec management bash
- Run
export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/puppet/lib
- export http and https proxy by executing these commands.
Run
export http_proxy=https://proxy.esl.cisco.com:8080
Run export https_proxy=https://proxy.esl.cisco.com:8080
- Install "install cisco_node_utils" package by executing following command,
Run
gem install cisco_node_utils
- Run
puppet agent -t
. The configuration would be updated automatically on the switch.
- Go to switch prompt and run
copy r s
Steps to add the certificates :
- Login to Switch sandbox.
- On the switch console run
run bash
- Run
sudo ip netns exec management bash
- Run
export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/puppet/lib
- Run
rm -rf /etc/puppetlabs/puppet/ssl
to clean all the old certificates.
- Run
puppet agent -t
on bash shell. This will create a new certificate.
- Now login to toolserver.
- Run
sudo su
- Start the puppetserver service. Run
service puppetserver start
or /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/bin/puppet master
- Run
export PATH=$PATH:/opt/puppetlabs/bin:/opt/puppetlabs/lib
on toolserver
- Run
puppet cert list -a
. It should list the certificate sent by agent #agent hostname should be present.
- Run
puppet cert sign <certificate name>
. For example, puppet cert sign "n9kvswitchfcs.cisco.com"? ## agent hostname