Skip to content

Commit 5d8914d

Browse files
authored
Merge pull request #120 from CiscoDevNet/f-rename-spark-to-webex
F rename spark to webex
2 parents 67fe70f + 7507d09 commit 5d8914d

17 files changed

Lines changed: 56 additions & 57 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Within this repository are several files and folders covering different topics a
1111
| File / Folder | Description |
1212
| --- | --- |
1313
| [`env_lab.py`](env_lab.py) | A Python file containing lab infrastructure details for routers, switches and appliances leveraged in the different labs. This file provides a centralized Python `import` that is used in other code samples to retrieve IPs, usernames, and passwords for connections |
14-
| [`env_user.template`](env_user.template) | Similar to `env_lab.py`, this is a template for end users to copy within their own code repo as `env_user.py` where they can provide unique details for their own accounts. For example, their Webex Teams (formerly Cisco Spark) authentication token. Not all labs require this file, if one does it will be specified in setup. |
14+
| [`env_user.template`](env_user.template) | Similar to `env_lab.py`, this is a template for end users to copy within their own code repo as `env_user.py` where they can provide unique details for their own accounts. For example, their Webex authentication token. Not all labs require this file, if one does it will be specified in setup. |
1515
| [`requirements.txt`](requirements.txt) | Global Python requirements file containing the requirements for **all** labs within this repository. Each folder also contains a local `requirements.txt` file. |
1616
| [`intro-python/`](intro-python/) | Sample code and exercises for the [Python Fundamentals Learning Labs](https://developer.cisco.com/learning/modules/programming-fundamentals/intro-python-part1/step/1) <br> |
1717
| [`rest-api/`](rest-api/) | Sample code and exercises for the [REST API Fundamentals Learning Labs](https://developer.cisco.com/learning/modules/rest-api-fundamentals/hands-on-postman/step/1) <br> |

dev/python/template.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import env_user # noqa
4747

4848

49-
spark = ciscosparkapi.CiscoSparkAPI(access_token=env_user.SPARK_ACCESS_TOKEN)
49+
spark = ciscosparkapi.CiscoSparkAPI(access_token=env_user.WEBEX_ACCESS_TOKEN)
5050

5151

5252
print(
@@ -63,8 +63,8 @@
6363
)
6464

6565

66-
print("Oh yeah... I'm also connected to Cisco Spark as:")
66+
print("Oh yeah... I'm also connected to Webex as:")
6767
print(spark.people.me())
6868

6969
print("...and I'm posting things to the following Spark Room:")
70-
print(spark.rooms.get(env_user.SPARK_ROOM_ID))
70+
print(spark.rooms.get(env_user.WEBEX_ROOM_ID))

env_user.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ SOFTWARE.
3434

3535
# User Input
3636

37-
SPARK_ACCESS_TOKEN = ""
38-
SPARK_ROOM_ID = ""
37+
WEBEX_ACCESS_TOKEN = ""
38+
WEBEX_ROOM_ID = ""
3939
MERAKI_API_KEY = "6bec40cf957de430a6f1f2baa056b99a4fac9ea0"
4040

4141
# End User Input

intro-ansible/group_vars/sandbox.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ ansible_user: 'developer'
22
ansible_ssh_pass: 'C1sco12345'
33
ansible_port: 22
44
netconf_port: 830
5-

intro-cmx/cmx-04-mission/cmxnotificationreceiver.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import datetime
3535
import os
3636
import re
37-
import ciscosparkapi
37+
import webexteamsapi
3838
from pprint import pprint
3939
from flask import Flask
4040
from flask import json
@@ -54,8 +54,8 @@
5454
import env_user # noqa
5555

5656

57-
# Create a Cisco Spark object
58-
spark = ciscosparkapi.CiscoSparkAPI(access_token=env_user.SPARK_ACCESS_TOKEN)
57+
# Create a Webex object
58+
spark = ciscosparkapi.CiscoSparkAPI(access_token=env_user.WEBEX_ACCESS_TOKEN)
5959

6060
requests.packages.urllib3.disable_warnings()
6161
app = Flask(__name__)
@@ -66,8 +66,7 @@ def create_notification(msg):
6666
global username
6767
global password
6868

69-
# MISSION TODO
70-
endpoint = "https://" + url + "CMX API ENDPOINT TO CREATE NOTIFICATIONS"
69+
endpoint = "https://" + url + "/api/config/v1/notification"
7170

7271
payload = \
7372
{
@@ -77,7 +76,7 @@ def create_notification(msg):
7776
{
7877
"conditions":[
7978
{
80-
"condition": "locationupdate.macAddressList == MAC ADDRESS TO BE FOUND;"
79+
"condition": "locationupdate.macAddressList == 00:00:2a:01:00:4e;"
8180
}
8281
]
8382
}
@@ -102,7 +101,7 @@ def create_notification(msg):
102101
"macScramblingSalt": "learning",
103102
"notificationType": "LocationUpdate"
104103
}
105-
# END MISSION TODO
104+
106105
headers = {"Content-Type": "application/json"}
107106

108107
print(json.dumps(payload))
@@ -120,7 +119,7 @@ def notification_handler():
120119
deviceId = r_json["notifications"][0]["deviceId"]
121120
location = r_json["notifications"][0]["locationMapHierarchy"]
122121
spark.messages.create(
123-
env_user.SPARK_ROOM_ID,
122+
env_user.WEBEX_ROOM_ID,
124123
text="CMX Mission Accomplished! Device " \
125124
+ deviceId + " found at location: " + location,
126125
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ciscosparkapi==0.9.2
1+
webexteamsapi
22
requests==2.18.4
33
requests-toolbelt==0.8.0
44
Flask==0.12.2

intro-guestshell/mission01/mission.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
"""Sends configuration difference to Webex Teams, formerly Spark.
2+
"""Sends configuration difference to Webex Teams.
33
44
Compares the current running configuration and the saved running
55
configuration, creates diff and sends it to a Webex Teams room.
@@ -31,7 +31,7 @@
3131
import re
3232

3333
from cli import cli, clip
34-
from ciscosparkapi import CiscoSparkAPI
34+
from webexteamssdk import WebexTeamsAPI
3535

3636

3737
BACKUP_CONFIG_IOS_PATH = 'flash:/running-config.bak'
@@ -127,15 +127,15 @@ def get_config_diff(backup_config_ios_path):
127127
return config_diff_lines
128128

129129

130-
def form_spark_message(config_diff_lines):
131-
"""Creates a Spark message formatted in markdown based on config diff
130+
def form_webex_message(config_diff_lines):
131+
"""Creates a Webex message formatted in markdown based on config diff
132132
133133
Args:
134134
config_diff_lines (list): list of lines containing config
135135
difference
136136
137137
Returns:
138-
str: markdown Spark message as a string
138+
str: markdown Webex message as a string
139139
"""
140140
message = (
141141
'Configuration differences between '
@@ -150,7 +150,7 @@ def form_spark_message(config_diff_lines):
150150

151151

152152
def main():
153-
spark_api = CiscoSparkAPI()
153+
api = WebexTeamsAPI()
154154

155155
# MISSION TODO 4: use the function that converts IOS path to
156156
# linux, which is defined in this file
@@ -177,12 +177,12 @@ def main():
177177
# END MISSION SECTION 6
178178
if config_diff_lines is not None:
179179
print('Changes have been found')
180-
message = form_spark_message(config_diff_lines)
181-
spark_api.messages.create(
182-
roomId=os.environ.get('SPARK_ROOM_ID'),
180+
message = form_webex_message(config_diff_lines)
181+
api.messages.create(
182+
roomId=os.environ.get('WEBEX_ROOM_ID'),
183183
markdown=message,
184184
)
185-
message = 'Spark message has been sent'
185+
message = 'Webex message has been sent'
186186
print(message)
187187
send_syslog(message)
188188
else:

intro-mdp/mission01/netconf_configure_ips.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import sys
2828
from netconf_functions import check_ip, set_ip
2929

30-
import ciscosparkapi
30+
from webexteamssdk import WebexTeamsAPI
3131

3232
# Get the absolute path for the directory where this file is located "here"
3333
here = os.path.abspath(os.path.dirname(__file__))
@@ -41,8 +41,8 @@
4141
import env_lab # noqa
4242
import env_user # noqa
4343

44-
# Create a Cisco Spark object
45-
spark = ciscosparkapi.CiscoSparkAPI(access_token=env_user.SPARK_ACCESS_TOKEN)
44+
# Create a Webex object
45+
webex = WebexTeamsAPI(access_token=env_user.WEBEX_ACCESS_TOKEN)
4646

4747
# Create message list
4848
messages = [
@@ -79,4 +79,4 @@
7979
messages.append("Device {} IP set to {}".format(result[0], result[1]))
8080

8181
# Post message to Spark
82-
spark.messages.create(roomId=env_user.SPARK_ROOM_ID, text="\n".join(messages))
82+
webex.messages.create(roomId=env_user.WEBEX_ROOM_ID, text="\n".join(messages))

intro-nfvis/mission01/mission.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
requests.packages.urllib3.disable_warnings()
5959

60-
spark = ciscosparkapi.CiscoSparkAPI(access_token=env_user.SPARK_ACCESS_TOKEN)
60+
spark = ciscosparkapi.CiscoSparkAPI(access_token=env_user.WEBEX_ACCESS_TOKEN)
6161

6262
def nvfis_getgcred():
6363
login = NFVIS_USERNAME
@@ -202,6 +202,6 @@ def nfv_delete_vm(s, url, data):
202202
print (json.dumps(r_vm_device_deployment, indent=4, sort_keys=True))
203203

204204
print ("STEP 6 - Send Spark message")
205-
message = spark.messages.create(env_user.SPARK_ROOM_ID,
205+
message = spark.messages.create(env_user.WEBEX_ROOM_ID,
206206
text='NFVIS mission completed')
207207
print (message)

intro-nfvis/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ciscosparkapi==0.9.2
22
requests==2.18.4
33
urllib3==1.22
4+
webexteamssdk

0 commit comments

Comments
 (0)