Skip to content

Commit

Permalink
Merge pull request #49 from michsmit99/master
Browse files Browse the repository at this point in the history
Snapback: Configuration Snapshot and Rollback
  • Loading branch information
michsmit99 committed Mar 29, 2015
2 parents 4afe6e1 + 078f965 commit 4cbeb39
Show file tree
Hide file tree
Showing 28 changed files with 2,093 additions and 3 deletions.
1 change: 1 addition & 0 deletions acitoolkit/acisession.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import logging
import json
import requests
from requests import Timeout, ConnectionError
import threading
import time
from websocket import create_connection, WebSocketException
Expand Down
769 changes: 769 additions & 0 deletions applications/snapback/aciconfigdb.py

Large diffs are not rendered by default.

464 changes: 464 additions & 0 deletions applications/snapback/snapback.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions applications/snapback/static/data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Version,Deletions,Additions
50 changes: 50 additions & 0 deletions applications/snapback/static/layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
body {
background: #EEE;
}

#content {
background: white;
border: 1px solid #CCC;
padding: 12px;
overflow: scroll;
}

#brand {
float: left;
font-weight: 300;
margin: 0;
}

.search-form {
margin: 0 5px;
}

.search-form form {
margin: 0;
}

.btn-menu {
margin: 4px 5px 0 0;
float: right;
}

.btn-menu a, .btn-menu input {
padding: 7px 16px !important;
border-radius: 0 !important;
}

.btn, textarea, input[type], button, .model-list {
border-radius: 0;
}

.model-list {
border-radius: 0;
}

.nav-pills li > a {
border-radius: 0;
}

.select2-container .select2-choice {
border-radius: 0;

30 changes: 30 additions & 0 deletions applications/snapback/templates/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends 'admin/master.html' %}
{% block body %}
<br>
<h3>Snapback</h3>
<h4><i>Beta</i> Version 0.1</h4>
<p>Snapback is a Configuration Snapshot and Rollback tool for use with
Cisco ACI fabrics.</p>

<p>Full documentation for Snapback can be found at the following
<a href="http://datacenter.github.io/acitoolkit">link</a>.</p>

<h4>License</h4>
<p>Copyright 2015 Cisco Systems, Inc.</p>

<p>Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at</p>

<pre><code>http://www.apache.org/licenses/LICENSE-2.0
</code></pre>

<p>Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</p>

<h4>Authors</h4>
<p>Michael Smith <a href="mailto:michsmit@cisco.com">michsmit@cisco.com</a></p>
{% endblock %}
11 changes: 11 additions & 0 deletions applications/snapback/templates/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends 'admin/master.html' %}
{% block body %}
{{ super() }}
<div class="row-fluid">
<h2>Snapback</h2>
<p class="lead">
Configuration Snapshot and Rollback for ACI fabrics
</p>
<p><i>Beta</i> v0.1</p>
</div>
{% endblock body %}
15 changes: 15 additions & 0 deletions applications/snapback/templates/credentials.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends 'admin/master.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% block body %}
<p>Enter the Credentials used to communicate with the APIC.</p>
<br>
{{ wtf.quick_form(form, form_type='horizontal',
horizontal_columns=('lg', 2, 2)) }}
{% if ipaddr %}
<br>
<p><u>Current Settings</u>
<br>APIC Username: <b>{{ username }}</b>
<br>APIC IP address: <b>{{ ipaddr }}</b></p>
{{ wtf.quick_form(reset_form) }}
{% endif %}
{% endblock %}
21 changes: 21 additions & 0 deletions applications/snapback/templates/diffview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends 'admin/master.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% block body %}

<style type="text/css">
#content {
resize: both;
overflow: auto;
}
table.diff {font-size:85%; line-height: 110%; width:99%;padding:0.5%; border:medium;}
.diff_header {background-color:#e0e0e0}
td.diff_header {text-align:right}
.diff_next {background-color:#c0c0c0}
.diff_add {background-color:#aaffaa}
.diff_chg {background-color:#ffff77}
.diff_sub {background-color:#ffaaaa}
</style>

{{ table|safe }}

{% endblock %}
12 changes: 12 additions & 0 deletions applications/snapback/templates/feedback.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'admin/master.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% block body %}
<p>We welcome comments and suggestions on how we can make this tool
better.<br> Please feel free to provide any constructive feedback below.</p>
<form class="form" action="MAILTO:acitoolkit@external.cisco.com" enctype="text/plain" method="post" role="form">
{{ wtf.form_field(form.category) }}
{{ wtf.form_field(form.comment) }}
{{ wtf.form_field(form.submit) }}
</form>

{% endblock %}
35 changes: 35 additions & 0 deletions applications/snapback/templates/fileview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends 'admin/master.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% block body %}
<style>
pre{
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
margin-bottom: 10px;
overflow: auto;
width: auto;
padding: 5px;
background-color: #eee;
width: 650px!ie7;
padding-bottom: 20px!ie7;
max-height: 600px;
line-height: 15px;
}
pre {
overflow-x: auto;
}
pre code {
overflow-wrap: normal;
white-space: pre;
}
</style>

{% for file in files %}
<p>Filename:<b>{{ file[1] }}</b> Version:<b>{{ file[2] }}</b></p>
<pre>
<code>
{{ file[0] }}
</code>
</pre>
{% endfor %}

{% endblock %}
30 changes: 30 additions & 0 deletions applications/snapback/templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% import 'admin/layout.html' as layout with context -%}
{% extends 'admin/base.html' %}

{% block head_tail %}
{{ super() }}
<link href="{{ url_for('static', filename='layout.css') }}" rel="stylesheet">
{% endblock %}

{% block page_body %}
<div class="container">
<div class="row">
<div class="span2">
<ul class="nav nav-pills nav-stacked">
{{ layout.menu() }}
{{ layout.menu_links() }}
</ul>
</div>
<div class="span10">
<div id="content">
{% block brand %}
<h2 id="brand">{{ admin_view.name|capitalize }}</h2>
<div class="clearfix"></div>
{% endblock %}
{{ layout.messages() }}
{% block body %}{% endblock %}
</div>
</div>
</div>
</div>
{% endblock %}
39 changes: 39 additions & 0 deletions applications/snapback/templates/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends 'admin/model/list.html' %}
{% import 'admin/model/layout.html' as model_layout with context %}

{% block brand %}
<h2 id="brand">Snapshots</h2>
{% if admin_view.can_create %}
<div class="btn-menu">
<a href="{{ url_for('.create_view', url=return_url) }}" class="btn btn-primary pull-right">{{ _gettext('Create') }}</a>
</div>
{% endif %}

{% if filter_groups %}
<div class="btn-group btn-menu">
{{ model_layout.filter_options(btn_class='btn dropdown-toggle btn-title') }}
</div>
{% endif %}

{% if actions %}
<div class="btn-group btn-menu">
{{ actionlib.dropdown(actions, btn_class='btn dropdown-toggle btn-title') }}
</div>
{% endif %}

{% if search_supported %}
<div class="search-form btn-menu">
{{ model_layout.search_form(input_class='span2 btn-title') }}
</div>
{% endif %}
<div class="clearfix"></div>
<hr>
{% endblock %}

{% block model_menu_bar %}
{% endblock %}

{% macro render_changes(model, column) %}
{{ '<font color="green">'|safe + model.changes.split('/')[0] +
'</font>'|safe + '/' + '<font color="red">'|safe + model.changes.split('/')[1] + '</font>'|safe}}
{% endmacro %}
30 changes: 30 additions & 0 deletions applications/snapback/templates/snapshot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends 'admin/master.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% block body %}
<p>Schedule an ongoing automated snapshot of the APIC configuration or
schedule a one time snapshot.</p>
<form class="form" method="post" role="form">
{{ wtf.form_field(form.frequency) }}
{{ wtf.form_field(form.number, style="float:left") }}
{{ wtf.form_field(form.interval) }}
{{ wtf.form_field(form.date) }}
{{ wtf.form_field(form.time) }}
{{ form.csrf_token }}
{{ wtf.form_field(form.submit) }}
</form>

{% if lastsnapshot %}
<p>Last snapshot taken at {{ lastsnapshot }}</p>
{% endif %}
{% if nextsnapshot %}
{% if schedule['interval'] %}
<p>Next snapshot scheduled for {{ nextsnapshot }} and every {{ schedule['interval'] }} {{ schedule['granularity'] }} beyond that.</p>
{% else %}
<p>Next snapshot scheduled for {{ nextsnapshot }}</p>
{% endif %}
{{ wtf.quick_form(cancel_form) }}
{% else %}
<p>No recurring snapshot currently scheduled</p>
{% endif %}
{% endblock %}

0 comments on commit 4cbeb39

Please sign in to comment.