Skip to content

Commit 760f21c

Browse files
committed
updates due to sandbox changes
1 parent 1f9a8c7 commit 760f21c

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed
Loading

labs/coding-102-rest-python-ga/4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ To run this code sample:
104104
* Write a new function called getHosts(theTicket) to get and display the network hosts. See step 3 for the URL to use for retrieving host data.
105105

106106

107-
In the next section, we will learn how to manage APIC-EM Users.
107+
In the next section, we will learn how to build a network topology.

labs/coding-102-rest-python-ga/5.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Step 5. Manage APIC-EM Users
1+
# Step 5. Build Network Topology
22

3-
In this step we're going to get the topology then parse the data to determine how devices link to one another and their status.
3+
In this step we're going to get the topology then parse the data to determine and display how devices link to one another and their link status.
44

55

6-
#### manage-users.py
6+
#### build-topology.py
77
This sample code uses the application REST function call to retrieve a list of devices called nodes and links which are the interfaces that connect them. Our goal is to find the devices and display information about them and how they connect to other devices.
88

99

@@ -108,6 +108,11 @@ getTopology(theTicket)
108108
Let's look at what the code is doing. We'll focus on the key code changes.
109109
* *def getTopology(theTicket):*
110110
* We define the function named getTopology. This function reads in the topology data. It parses the nodes which are devices on the network and displays some information about them. It also parses the link data which are interfaces that connect the nodes and displays information about how they connect the devices and their status. The passed in parameter 'theTicket' is used for authorization purposes.
111+
* *for n in r_json["response"]["nodes"]:*
112+
* We read the dictionary data for each node into n from which we will parse the data.
113+
* *if "platformId" in n:*
114+
* Checking that the node in n contains a 'platformId' key. Some records don't have this key which is the reason for the check.
115+
111116

112117
To run this code sample:
113118
1. Go to directory **coding102-REST-python-ga**. In the terminal type:
@@ -128,6 +133,7 @@ To run this code sample:
128133

129134

130135
## Things to Try
131-
* After running the script, review the node data printed. Replace the label attribute that is printed with another attribute such as role or nodeType.
132-
* You may have noticed that no host devices are printed. Review the data and the source code, and determine why this is so along with how you would print this data.
136+
* After running the script, review the node data printed. Replace the label attribute that is printed with another attribute such as role or nodeType.
137+
* You may have noticed that no host devices are printed. Review the data and the source code, and determine why this is so along with how you would print this data. Hint: you can easily identify the host by its attribute nodeType or role.
133138
* Modify the source code so that host devices are printed as well.
139+
* Modify the source code so that interface connections to the hosts are printed as is currently done with the other network devices.

labs/coding-205-writing-file-ga/5.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Often, when you are working with REST APIs (see [Coding 101: Rest Basics Learnin
33

44
We can combine the techniques for writing to a file that we just learned with the techniques for calling REST APIs that we learned in [Coding 101 Calling REST APIs from Python](/#/labs/coding-101-rest-python/step/1)
55

6-
Let's take a look at an example that retrieves some JSON from the [APIC-EM APIs](https://anypoint.mulesoft.com/apiplatform/cisco-dev/#/portals/organizations/de91ddd1-9fb8-4731-8bce-03f47c3ba41a/apis/56056/versions/58124/pages/75870).
6+
Let's take a look at an example that retrieves some JSON from the [APIC-EM APIs](http://devnetapic.cisco.com).
77

88
```python
99
# import the requests library so we can use it to make REST calls (http://docs.python-requests.org/en/latest/index.html)
@@ -15,10 +15,10 @@ import json
1515

1616
# All of our REST calls will use the url for the APIC EM Controller as the base URL
1717
# So lets define a variable for the controller IP or DNS so we don't have to keep typing it
18-
controller_url = "https://sandboxapic.cisco.com:9443"
18+
controller_url = "https://sandboxapic.cisco.com"
1919

2020
#the username and password to access the APIC-EM Controller
21-
payload = {"username":"admin","password":"C!sc0123"}
21+
payload = {"username":"devnetuser","password":"Cisco123!"}
2222

2323
ticket_url = controller_url + "/api/v1/ticket"
2424

@@ -77,8 +77,8 @@ To run this code sample:
7777
**cd \DevNetCode\<your-name>\coding-skills-sample-code\coding-205-writing-file-ga**
7878
2. Assign the APIC-EM Controller IP address or DNS to the **controller_url** variable.
7979
* Open the file **write-json-to-file.py**. For example, in Windows type: **notepad write-json-to-file.py**
80-
* *If you are not using your own APIC-EM Controller*, use the [DevNet Sandbox](https://developer.cisco.com/site/devnet/sandbox/) Always-On APIC-EM Lab: [sandboxapic.cisco.com:9443](https://sandboxapic.cisco.com:9443)
81-
* controller_url='https://sandboxapic.cisco.com:9443'
80+
* *If you are not using your own APIC-EM Controller*, use the [DevNet Sandbox](https://developer.cisco.com/site/devnet/sandbox/) Always-On APIC-EM Lab: [sandboxapic.cisco.com](https://sandboxapic.cisco.com)
81+
* controller_url='https://sandboxapic.cisco.com'
8282
3. Save the file. If encoding type is an option select **UTF-8**.
8383
4. Type the python command and then the filename at the command prompt, and press the return key.
8484
* *On Windows type*: **py -3 write-json-to-file.py**. Or type: **python write-json-to-file.py**

labs/coding-207-putting-it-together-ga/3.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ The following part of the code accomplishes these steps of the application:
99
# Get Count of Devices
1010
# All of our REST calls will use the url for the APIC EM Controller as the base URL
1111
# So lets define a variable for the controller IP or DNS so we don't have to keep typing it
12-
controller_url = "https://sandboxapic.cisco.com:9443"
12+
controller_url = "https://sandboxapic.cisco.com"
1313

1414
# put the ip address or dns of your apic-em controller in this url
1515
ticket_url = controller_url + '/api/v1/ticket'
1616

1717
#the username and password to access the APIC-EM Controller
18-
payload = {"username":"admin","password":"C!sc0123"}
18+
payload = {"username":"devnetuser","password":"Cisco123!"}
1919

2020
#Content type must be included in the header
2121
header = {"content-type": "application/json"}
@@ -63,7 +63,7 @@ logging.debug("API response: " + json.dumps(get_devices_json, indent=4, separato
6363
```
6464
Let's look at what is going on in the code.
6565

66-
* Using the [APIC-EM API Reference](https://anypoint.mulesoft.com/apiplatform/cisco-dev/#/portals/organizations/de91ddd1-9fb8-4731-8bce-03f47c3ba41a/apis/56056/versions/58124/pages/75870), we can see that the url **api/v1/ticket** will return the service ticket that's used to authorize calls to the APIC-EM APIs. Like the other 'post' and 'get' calls it uses the Requests library to make a call to the APIC-EM Controller to retrieve the response data.
66+
* Using the [APIC-EM API Reference](http://devnetapic.cisco.com), we can see that the url **api/v1/ticket** will return the service ticket that's used to authorize calls to the APIC-EM APIs. Like the other 'post' and 'get' calls it uses the Requests library to make a call to the APIC-EM Controller to retrieve the response data.
6767
* The url **api/v1/network-device/count** will return the total count of devices
6868
* This statement **devices_count_response = requests.get(devices_count_url, headers=header, verify=False)** makes the 'get' call to retrieve the device count.
6969
* **devices_count_response** will contain the response returned from the API
@@ -78,5 +78,5 @@ Let's look at what is going on in the code.
7878

7979

8080
### Things to think about
81-
* What other APIC-EM APIs in the [APIC-EM API Reference](https://anypoint.mulesoft.com/apiplatform/cisco-dev/#/portals/organizations/de91ddd1-9fb8-4731-8bce-03f47c3ba41a/apis/56056/versions/58124/pages/75870) would you like to try?
81+
* What other APIC-EM APIs in the [APIC-EM API Reference](http://devnetapic.cisco.com) would you like to try?
8282
* Check out the [Coding 102: Calling REST APIs from Python Learning Lab](/#/labs/coding-102-rest-python/step/1) for more information on using the Requests library to make API calls.

labs/coding-207-putting-it-together-ga/4.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ requests.packages.urllib3.disable_warnings()
5353

5454

5555
# All of our REST calls will use the url for the APIC EM Controller as the base URL
56-
controller_url = "https://sandboxapic.cisco.com:9443"
56+
controller_url = "https://sandboxapic.cisco.com"
5757

5858
#asks the user for the device type and logging file name
5959
def getUserInput():
@@ -86,7 +86,7 @@ def getTicket():
8686
url = controller_url + "/api/v1/ticket"
8787

8888
#the username and password to access the APIC-EM Controller
89-
payload = {"username":"admin","password":"C!sc0123"}
89+
payload = {"username":"devnetuser","password":"Cisco123!"}
9090

9191
#Content type must be included in the header
9292
header = {"content-type": "application/json"}
@@ -179,8 +179,8 @@ To run this code sample:
179179
**cd \DevNetCode\<your-name>\coding-skills-sample-code\coding207-putting-it-together-ga**
180180
2. Assign the APIC-EM Controller IP address or DNS to the **controller_url** variable.
181181
* Open the file **create-device-list.py**. For example, in Windows type: **notepad create_device-list.py**
182-
* *If you are not using your own APIC-EM Controller*, use the [DevNet Sandbox](https://developer.cisco.com/site/devnet/sandbox/) Always-On APIC-EM Lab: [sandboxapic.cisco.com:9443](https://sandboxapic.cisco.com:9443)
183-
* controller_url='https://sandboxapic.cisco.com:9443'
182+
* *If you are not using your own APIC-EM Controller*, use the [DevNet Sandbox](https://developer.cisco.com/site/devnet/sandbox/) Always-On APIC-EM Lab: [sandboxapic.cisco.com](https://sandboxapic.cisco.com)
183+
* controller_url='https://sandboxapic.cisco.com'
184184
3. Save the file. If encoding type is an option select **UTF-8**.
185185
4. Type the python command and then the filename at the command prompt, and press the return key.
186186
* *On Windows type*: **py -3 create-device-list.py**. Or type: **python create-device-list.py**
Loading

0 commit comments

Comments
 (0)