Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #230 from nre-learning/config-presentation
Browse files Browse the repository at this point in the history
Converting existing lessons to match new endpoint format
  • Loading branch information
Mierdin authored Jun 23, 2019
2 parents c772dbd + 5f6e45f commit 764a182
Show file tree
Hide file tree
Showing 63 changed files with 1,582 additions and 106 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Rename syringe.yaml to lesson.meta.yaml, and move lessons into descriptive subdirs [#222](https://github.com/nre-learning/nrelabs-curriculum/pull/222)
- Prepare curriculum for collections [#224](https://github.com/nre-learning/nrelabs-curriculum/pull/224)
- Update all paths with new lesson directory mount point [#227](https://github.com/nre-learning/nrelabs-curriculum/pull/227)
- Converting existing lessons to match new endpoint format [#230](https://github.com/nre-learning/nrelabs-curriculum/pull/230)

## v0.3.2 - April 19, 2019

Expand Down
2 changes: 2 additions & 0 deletions images/configurator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM python

RUN apt-get update && apt-get install sshpass

COPY requirements.txt /
RUN pip install -r /requirements.txt

Expand Down
9 changes: 7 additions & 2 deletions images/configurator/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
with driver(hostname=host, username=user, password=password, optional_args={'port': port}) as device:

# Retrieve management IP address
# TODO(mierdin): this is junos-specific. Will need to maintain a list of management interfaces per vendor,
# or expose this as a field in the endpoint.
#
# TODO(mierdin): while this script works for any vendor, the IP address replacement functionality using Jinja
# below is specific to Junos. So, any other vendor device must use NAT for now. This should be easy to fix, though.
# The best approach will be to provide interface_ip_details to the template, rather than a specific interface. Then,
# the underlying config can specify the interface they want. The change here will be simple - the tedious work will
# be updating all existing configs to use the new dictionary.

interface_ip_details = device.get_interfaces_ip()['em0.0']
for addr, prefix in interface_ip_details['ipv4'].items():
address_cidr = "%s/%s" % (addr, prefix['prefix_length'])
Expand Down
1 change: 1 addition & 0 deletions images/configurator/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
napalm
ansible
4 changes: 2 additions & 2 deletions images/notebook/push.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
docker build -t antidotelabs/jupyter .
docker push antidotelabs/jupyter
docker build -t antidotelabs/jupyter:newpath .
docker push antidotelabs/jupyter:newpath
8 changes: 4 additions & 4 deletions images/selfservice-flask-app/flask_bootstrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,19 @@ def lwrap(cdn, primary=static):
return ConditionalCDN('BOOTSTRAP_SERVE_LOCAL', primary, cdn)

bootstrap = lwrap(
WebCDN('//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/%s/' %
WebCDN('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/%s/' %
BOOTSTRAP_VERSION), local)

jquery = lwrap(
WebCDN('//cdnjs.cloudflare.com/ajax/libs/jquery/%s/' %
WebCDN('https://cdnjs.cloudflare.com/ajax/libs/jquery/%s/' %
JQUERY_VERSION), local)

html5shiv = lwrap(
WebCDN('//cdnjs.cloudflare.com/ajax/libs/html5shiv/%s/' %
WebCDN('https://cdnjs.cloudflare.com/ajax/libs/html5shiv/%s/' %
HTML5SHIV_VERSION))

respondjs = lwrap(
WebCDN('//cdnjs.cloudflare.com/ajax/libs/respond.js/%s/' %
WebCDN('https://cdnjs.cloudflare.com/ajax/libs/respond.js/%s/' %
RESPONDJS_VERSION))

app.extensions['bootstrap'] = {
Expand Down
77 changes: 77 additions & 0 deletions lessons/fundamentals/lesson-1-demo/lesson.meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
lessonName: Antidote Test Lesson
lessonId: 1
category: fundamentals
tier: ptr #NEVER promote to prod. Not a real lesson
lessonDiagram: https://raw.githubusercontent.com/nre-learning/nrelabs-curriculum/v0.3.2/lessons/lesson-15/lessondiagram.png
description: |
Example lesson used to test the various features of the Antidote platform
slug: selfservice
tags:
- foo
- bar

endpoints:

- name: influxdb
image: influxdb
additionalPorts: [8086]

- name: selfservice
image: antidotelabs/selfservice-flask-app
presentations:
- name: web
port: 5000
type: http

- name: vqfx1
image: antidotelabs/vqfx:snap1
configurationType: python
presentations:
- name: cli
port: 22
type: ssh

- name: vqfx2
image: antidotelabs/vqfx:snap2
configurationType: napalm-junos
presentations:
- name: cli
port: 22
type: ssh

- name: vqfx3
image: antidotelabs/vqfx:snap3
configurationType: napalm-junos
presentations:
- name: cli
port: 22
type: ssh

- name: linux
image: antidotelabs/utility
configurationType: ansible
presentations:
- name: cli1
port: 22
type: ssh
- name: cli2
port: 22
type: ssh

connections:
- a: vqfx1
b: vqfx2
- a: vqfx2
b: vqfx3
- a: vqfx3
b: vqfx1

stages:

- id: 1
description: Stage 1
- id: 2
description: Stage 2
jupyterLabGuide: true
15 changes: 15 additions & 0 deletions lessons/fundamentals/lesson-1-demo/stage1/configs/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: test playbook
hosts: all
gather_facts: no
vars:
ansible_user: antidote
ansible_password: antidotepassword
tasks:

- name: Debug date
shell: date
register: date_output

- debug:
msg: "{{ date_output }}"
32 changes: 32 additions & 0 deletions lessons/fundamentals/lesson-1-demo/stage1/configs/vqfx1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python

import sys, os
import napalm
from jinja2 import FileSystemLoader, Environment

user = "antidote"
password = "antidotepassword"
vendor = "junos"
port = "22"
host = os.getenv("SYRINGE_TARGET_HOST")
template_file = "vqfx1.txt"

driver = napalm.get_network_driver(vendor)
with driver(hostname=host, username=user, password=password, optional_args={'port': port}) as device:

# Retrieve management IP address
# TODO(mierdin): this is junos-specific. Will need to maintain a list of management interfaces per vendor,
# or expose this as a field in the endpoint.
interface_ip_details = device.get_interfaces_ip()['em0.0']
for addr, prefix in interface_ip_details['ipv4'].items():
address_cidr = "%s/%s" % (addr, prefix['prefix_length'])

# Create template configuration with this address
loader = FileSystemLoader([os.path.dirname(os.path.realpath(__file__))]) # Use current directory
env = Environment(loader=loader, trim_blocks=True, lstrip_blocks=True)
template_object = env.get_template(template_file)
rendered_config = template_object.render(mgmt_addr=address_cidr)

# Push rendered config to device
device.load_replace_candidate(config=rendered_config)
device.commit_config()
165 changes: 165 additions & 0 deletions lessons/fundamentals/lesson-1-demo/stage1/configs/vqfx1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<configuration>
<version>15.1X53-D60.4</version>
<system>
<host-name>vqfx1</host-name>
<root-authentication>
<encrypted-password>$1$mlo32jo6$BOMVhmtORai2Kr24wRCCv1</encrypted-password>
<ssh-rsa>
<name>ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key</name>
</ssh-rsa>
</root-authentication>
<login>
<user>
<name>antidote</name>
<class>super-user</class>
<authentication>
<encrypted-password>$1$iH4TNedH$3RKJbtDRO.N4Ua8B6LL/v/</encrypted-password>
</authentication>
</user>
<password>
<change-type>set-transitions</change-type>
<minimum-changes>0</minimum-changes>
</password>
</login>
<services>
<ssh>
<root-login>allow</root-login>
</ssh>
<netconf>
<ssh>
</ssh>
<rfc-compliant/>
</netconf>
<rest>
<http>
<port>8080</port>
</http>
<enable-explorer/>
</rest>
</services>
<syslog>
<user>
<name>*</name>
<contents>
<name>any</name>
<emergency/>
</contents>
</user>
<file>
<name>messages</name>
<contents>
<name>any</name>
<notice/>
</contents>
<contents>
<name>authorization</name>
<info/>
</contents>
</file>
<file>
<name>interactive-commands</name>
<contents>
<name>interactive-commands</name>
<any/>
</contents>
</file>
</syslog>
<extensions>
<providers>
<name>juniper</name>
<license-type>
<name>juniper</name>
<deployment-scope>commercial</deployment-scope>
</license-type>
</providers>
<providers>
<name>chef</name>
<license-type>
<name>juniper</name>
<deployment-scope>commercial</deployment-scope>
</license-type>
</providers>
</extensions>
</system>
<interfaces>
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interface>
<name>em3</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>10.12.0.11/24</name>
</address>
</inet>
</family>
</unit>
</interface>
<interface>
<name>em4</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>10.31.0.11/24</name>
</address>
</inet>
</family>
</unit>
</interface>
</interfaces>
<forwarding-options>
<storm-control-profiles>
<name>default</name>
<all>
</all>
</storm-control-profiles>
</forwarding-options>
<routing-options>
<autonomous-system>
<as-number>64001</as-number>
</autonomous-system>
</routing-options>
<protocols>
<bgp operation="replace">
<group>
<name>PEERS</name>
<type>external</type>
<neighbor>
<name>10.31.0.13</name>
<peer-as>64003</peer-as>
</neighbor>
<neighbor>
<name>10.12.0.12</name>
<peer-as>64002</peer-as>
</neighbor>
</group>
</bgp>
<igmp-snooping>
<vlan>
<name>default</name>
</vlan>
</igmp-snooping>

</protocols>
<vlans>
<vlan>
<name>default</name>
<vlan-id>1</vlan-id>
</vlan>
</vlans>
</configuration>
Loading

0 comments on commit 764a182

Please sign in to comment.