Skip to content

Commit c870629

Browse files
committed
Update to Python Prism REST API Lab v1.2
1 parent 21d9653 commit c870629

File tree

17 files changed

+88
-49
lines changed

17 files changed

+88
-49
lines changed

.disclaimer

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This code is intended as a standalone example. Subject to licensing restrictions defined on nutanix.dev, this can be downloaded, copied and/or modified in any way you see fit. Please be aware that all public code samples provided by Nutanix are unofficial in nature, are provided as examples only, are unsupported and will need to be heavily scrutinized and potentially modified before they can be used in a production environment. All such code samples are provided on an as-is basis, and Nutanix expressly disclaims all warranties, express or implied. All code samples are © Nutanix, Inc., and are provided as-is under the MIT license (https://opensource.org/licenses/MIT).

.flaskenv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FLASK_ENV=development
2+
FLASK_APP=lab

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
nutanix/
2+
3+
*.pyc
4+
__pycache__/
5+
6+
instance/
7+
8+
.pytest_cache/
9+
.coverage
10+
htmlcov/
11+
12+
dist/
13+
build/
14+
*.egg-info/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Nutanix
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Nutanix Python API Lab v1.2 - Complete Demo
2+
3+
This Python Flask demo app is designed as a complete working version of the dashboard created in the [Nutanix Python Flask and Prism REST API lab](https://www.nutanix.dev/labs/).
4+
5+
Rather than download this complete app and run it standalone, new users are recommended to follow the lab so that all components and concepts are appropriately communicated.
6+
7+
Those with Python Flask experience are welcome to download this demo and use as they see fit, of course.
8+
9+
## License
10+
11+
Please see the accompanying `LICENSE` file that is distributed with this repository.
12+
13+
## Disclaimer
14+
15+
Please see the `.disclaimer` file that is distributed with this repository.
16+

config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
22

33
class Config(object):
4-
SECRET_KEY = os.environ.get('SECRET_KEY') or 'some strong secret string'
5-
4+
SECRET_KEY = os.environ.get('SECRET_KEY') or 'some strong secret string'

lab/__init__.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@ def create_app(test_config=None):
2020
'css/lib/jq.jqplot.css',
2121
'css/ntnx.css'
2222
)
23-
2423
home_js = Bundle(
25-
'js/lib/jquery-2.1.3.min.js',
26-
'js/lib/classie.min.js',
27-
'js/lib/ntnx-bootstrap.min.js',
28-
'js/lib/modernizr.custom.min.js',
29-
'js/lib/jquery.jqplot.min.js',
30-
'js/lib/jqplot.logAxisRenderer.js',
31-
'js/lib/jqplot.categoryAxisRenderer.js',
32-
'js/lib/jqplot.canvasAxisLabelRenderer.js',
33-
'js/lib/jqplot.canvasTextRenderer.js',
34-
'js/lib/jquery.gridster.min.js',
35-
'js/ntnx.js'
24+
'js/lib/jquery-2.1.3.min.js',
25+
'js/lib/classie.min.js',
26+
'js/lib/ntnx-bootstrap.min.js',
27+
'js/lib/modernizr.custom.min.js',
28+
'js/lib/jquery.jqplot.min.js',
29+
'js/lib/jqplot.logAxisRenderer.js',
30+
'js/lib/jqplot.categoryAxisRenderer.js',
31+
'js/lib/jqplot.canvasAxisLabelRenderer.js',
32+
'js/lib/jqplot.canvasTextRenderer.js',
33+
'js/lib/jquery.gridster.min.js',
34+
'js/ntnx.js'
3635
)
3736

3837
assets.register('home_css',home_css)
@@ -59,5 +58,4 @@ def create_app(test_config=None):
5958
from . import ajax
6059
app.register_blueprint(ajax.bp)
6160

62-
return app
63-
61+
return app

lab/ajax.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from datetime import datetime
66
from datetime import timedelta
77
import time
8+
import urllib3
89

910
from flask import (
1011
Blueprint, flash, g, redirect, render_template, request, session, url_for, jsonify
@@ -15,6 +16,13 @@
1516

1617
bp = Blueprint('ajax', __name__, url_prefix='/ajax')
1718

19+
"""
20+
disable insecure connection warnings
21+
please be advised and aware of the implications of doing this
22+
in a production environment!
23+
"""
24+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
25+
1826
"""
1927
get the form POST data provided by the user
2028
"""
@@ -102,5 +110,4 @@ def containers():
102110
get_form()
103111
client = apiclient.ApiClient('get',cvmAddress,f'storage_containers','',username,password,'v2.0')
104112
results = client.get_info()
105-
return jsonify(results)
106-
113+
return jsonify(results)

lab/forms.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ class clusterForm(FlaskForm):
1010
username = StringField('username', validators=[DataRequired()])
1111
password = PasswordField('password', validators=[DataRequired()])
1212
submit = SubmitField('Go!', id="goButton")
13-

lab/index.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ def index():
1212
# make sure we are using the form that's been generated in forms.py
1313
form = clusterForm()
1414
return render_template('index.html', form=form)
15-

0 commit comments

Comments
 (0)