second commit, merged the plugin files in the repository
Change-Id: If032706c159d8dab48d81c8befecc9f2cd8afcd9
This commit is contained in:
parent
ac6fbb1a51
commit
25de0ba200
12
MANIFEST.in
12
MANIFEST.in
|
@ -1,6 +1,8 @@
|
|||
include AUTHORS
|
||||
include ChangeLog
|
||||
exclude .gitignore
|
||||
exclude .gitreview
|
||||
include setup.py
|
||||
|
||||
global-exclude *.pyc
|
||||
recursive-include mellanox_dashboard/templates *
|
||||
recursive-include mellanox_dashboard/static *
|
||||
recursive-include mellanox_dashboard/neopanel/templates *
|
||||
recursive-include mellanox_dashboard/aboutpanel/templates *
|
||||
recursive-include mellanox_dashboard/ufmpanel/templates *
|
||||
recursive-include mellanox_dashboard/settingspanel/templates *
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
===============================
|
||||
horizon-mellanox
|
||||
Horizon mellanox
|
||||
===============================
|
||||
|
||||
OpenStack Boilerplate contains all the boilerplate you need to create an OpenStack package.
|
||||
|
||||
Please feel here a long description which must be at least 3 lines wrapped on
|
||||
80 cols, so that distribution package maintainers can use it in their packages.
|
||||
Note that this is a hard requirement.
|
||||
Plugin that view Mellanox products UIs.
|
||||
|
||||
* Free software: Apache license
|
||||
* Documentation: http://docs.openstack.org/developer/horizon-mellanox
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
# The slug of the dashboard to be added to HORIZON['dashboards']. Required.
|
||||
DASHBOARD = 'mellanox_dashboard'
|
||||
# If set to True, this dashboard will be set as the default dashboard.
|
||||
DEFAULT = False
|
||||
# A dictionary of exception classes to be added to HORIZON['exceptions'].
|
||||
ADD_EXCEPTIONS = {}
|
||||
# A list of applications to be added to INSTALLED_APPS.
|
||||
ADD_INSTALLED_APPS = ['mellanox_dashboard']
|
||||
|
||||
ADD_ANGULAR_MODULES = [
|
||||
'horizon.dashboard.mellanox_dashboard',
|
||||
]
|
||||
|
||||
AUTO_DISCOVER_STATIC_FILES = True
|
|
@ -1,19 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
import pbr.version
|
||||
|
||||
|
||||
__version__ = pbr.version.VersionInfo(
|
||||
'horizon-mellanox').version_string()
|
|
@ -1,23 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2010-2011 OpenStack Foundation
|
||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslotest import base
|
||||
|
||||
|
||||
class TestCase(base.BaseTestCase):
|
||||
|
||||
"""Test case base class for all unit tests."""
|
|
@ -1,28 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
test_horizon-mellanox
|
||||
----------------------------------
|
||||
|
||||
Tests for `horizon-mellanox` module.
|
||||
"""
|
||||
|
||||
from horizon-mellanox.tests import base
|
||||
|
||||
|
||||
class TestHorizon-mellanox(base.TestCase):
|
||||
|
||||
def test_something(self):
|
||||
pass
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from mellanox_dashboard import dashboard
|
||||
|
||||
class Aboutpanel(horizon.Panel):
|
||||
name = _("About")
|
||||
slug = "aboutpanel"
|
||||
|
||||
|
||||
dashboard.MLXDashboard.register(Aboutpanel)
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from openstack_dashboard.dashboards.mydashboard import dashboard
|
||||
|
||||
class Mypanel(horizon.Panel):
|
||||
name = _("My Fruits")
|
||||
slug = "mypanel"
|
||||
|
||||
|
||||
dashboard.Mydashboard.register(Mypanel)
|
|
@ -0,0 +1,40 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "NEO" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<style>
|
||||
|
||||
#content_body .container-fluid{
|
||||
height: 100% !important;
|
||||
margin-left: -15px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row{
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12{
|
||||
height: 100% !important;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12 .page-header{
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
iframe#about_iframe{
|
||||
width: 100%;
|
||||
height: 99%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<iframe id="about_iframe" src="https://wiki.openstack.org/wiki/Mellanox-Neutron">
|
||||
<p>Your browser does not support iframes.</p>
|
||||
</iframe>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from horizon.test import helpers as test
|
||||
|
||||
|
||||
class AboutpanelTests(test.TestCase):
|
||||
# Unit tests for mypanel.
|
||||
def test_me(self):
|
||||
self.assertTrue(1 + 1 == 2)
|
|
@ -0,0 +1,11 @@
|
|||
from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
|
||||
from mellanox_dashboard.aboutpanel.views \
|
||||
import IndexView
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
)
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
|
||||
from mydashboard.mypanel.views \
|
||||
import IndexView
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
)
|
|
@ -0,0 +1,10 @@
|
|||
from horizon import views
|
||||
|
||||
|
||||
class IndexView(views.APIView):
|
||||
# A very simple class-based view...
|
||||
template_name = 'mellanox_dashboard/aboutpanel/index.html'
|
||||
|
||||
def get_data(self, request, context, *args, **kwargs):
|
||||
# Add data to the context here...
|
||||
return context
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
from . import mellanox_rest_api
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
from django.views import generic
|
||||
from openstack_dashboard.api.rest import utils as rest_utils
|
||||
from openstack_dashboard.api.rest import urls
|
||||
import requests
|
||||
import httplib, urllib, urllib2
|
||||
|
||||
@urls.register
|
||||
class NEOLoginService(generic.View):
|
||||
"""API for Murano packages.
|
||||
"""
|
||||
url_regex = r'mlnx/neo_login/$'
|
||||
|
||||
@rest_utils.ajax()
|
||||
def get(self, request):
|
||||
#postdata = {"username" : "admin", "password" : "123456"}
|
||||
#headers = {'content-type': 'application/x-www-form-urlencoded'}
|
||||
#r = requests.post("http://10.224.15.50/neo/login", data=postdata)
|
||||
|
||||
|
||||
params = urllib.urlencode({'username' : "admin", "password" : "123456"})
|
||||
headers = {"Content-type": "application/x-www-form-urlencoded"}
|
||||
conn = httplib.HTTPConnection("10.224.15.50")
|
||||
conn.request("POST", "/neo/login", params, headers)
|
||||
response = conn.getresponse()
|
||||
data = response.read()
|
||||
conn.close()
|
||||
return {
|
||||
'status': response.status,
|
||||
'text' : data
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
import horizon
|
||||
|
||||
import mellanox_dashboard.api.rest
|
||||
|
||||
class MLXDashboard(horizon.Dashboard):
|
||||
name = _("Mellanox Technologies")
|
||||
slug = "mellanox_dashboard"
|
||||
panels = ('settingspanel', 'neopanel', 'ufmpanel', 'aboutpanel') # Add your panels here.
|
||||
default_panel = 'settingspanel' # Specify the slug of the dashboard's default panel.
|
||||
|
||||
horizon.register(MLXDashboard)
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
"""
|
||||
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
|
||||
"""
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from mellanox_dashboard import dashboard
|
||||
|
||||
class Neopanel(horizon.Panel):
|
||||
name = _("NEO")
|
||||
slug = "neopanel"
|
||||
|
||||
|
||||
dashboard.MLXDashboard.register(Neopanel)
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from openstack_dashboard.dashboards.mydashboard import dashboard
|
||||
|
||||
class Mypanel(horizon.Panel):
|
||||
name = _("My Fruits")
|
||||
slug = "mypanel"
|
||||
|
||||
|
||||
dashboard.Mydashboard.register(Mypanel)
|
|
@ -0,0 +1,47 @@
|
|||
shit{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "NEO" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<style>
|
||||
|
||||
#content_body .container-fluid{
|
||||
height: 100% !important;
|
||||
margin-left: -15px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row{
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12{
|
||||
height: 100% !important;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12 .page-header{
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
iframe#neo_iframe{
|
||||
width: 100%;
|
||||
height: 99%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<ng-include src="'{{ STATIC_URL }}mellanox_dashboard/js/mellanox_dashboard.js'"></ng-include>
|
||||
|
||||
<script>
|
||||
alert(getCookie("mellanox_neo_host"));
|
||||
</script>
|
||||
|
||||
<iframe id="neo_iframe" src="http://10.224.15.51/neo">
|
||||
<p>Your browser does not support iframes.</p>
|
||||
</iframe>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "NEO" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<style>
|
||||
|
||||
#content_body .container-fluid{
|
||||
height: 100% !important;
|
||||
margin-left: -15px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row{
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12{
|
||||
height: 100% !important;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12 .page-header{
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
iframe#neo_iframe{
|
||||
width: 100%;
|
||||
height: 99%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
horizon.mellanox_dashboard.prepareNEOPanel();
|
||||
});
|
||||
</script>
|
||||
|
||||
<iframe id="neo_iframe" src="">
|
||||
<p>Your browser does not support iframes.</p>
|
||||
</iframe>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from horizon.test import helpers as test
|
||||
|
||||
|
||||
class NeopanelTests(test.TestCase):
|
||||
# Unit tests for mypanel.
|
||||
def test_me(self):
|
||||
self.assertTrue(1 + 1 == 2)
|
|
@ -0,0 +1,11 @@
|
|||
from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
|
||||
from mellanox_dashboard.neopanel.views \
|
||||
import IndexView
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
)
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
|
||||
from mydashboard.mypanel.views \
|
||||
import IndexView
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
)
|
|
@ -0,0 +1,10 @@
|
|||
from horizon import views
|
||||
|
||||
|
||||
class IndexView(views.APIView):
|
||||
# A very simple class-based view...
|
||||
template_name = 'mellanox_dashboard/neopanel/index.html'
|
||||
|
||||
def get_data(self, request, context, *args, **kwargs):
|
||||
# Add data to the context here...
|
||||
return context
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,65 @@
|
|||
# Copyright 2013 Centrin Data Systems Ltd.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.forms import ValidationError # noqa
|
||||
from django import http
|
||||
from django import shortcuts
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.decorators.debug import sensitive_variables # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
from horizon.utils import functions as utils
|
||||
from horizon.utils import validators
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
|
||||
def _one_year():
|
||||
now = datetime.utcnow()
|
||||
return now + timedelta(days=365)
|
||||
|
||||
|
||||
class SettingsForm(forms.SelfHandlingForm):
|
||||
neo_host = forms.CharField(label=_('NEO Server'), required=False)
|
||||
ufm_host = forms.CharField(label=_('UFM Server'), required=False)
|
||||
neo_host_user = forms.CharField(label=_('NEO Username'), required=False)
|
||||
n_a_ = forms.CharField(label=_('a'), required=False)
|
||||
neo_host_password = forms.CharField(label=_('NEO Password'), required=False, widget=forms.PasswordInput(render_value=False))
|
||||
no_autocomplete = False
|
||||
|
||||
def handle(self, request, data):
|
||||
response = shortcuts.redirect(request.build_absolute_uri())
|
||||
request.session['mellanox_neo_host'] = data['neo_host']
|
||||
response.set_cookie('mellanox_neo_host', data['neo_host'],
|
||||
expires=_one_year())
|
||||
|
||||
request.session['mellanox_neo_host_user'] = data['neo_host_user']
|
||||
response.set_cookie('mellanox_neo_host_user', data['neo_host_user'],
|
||||
expires=_one_year())
|
||||
|
||||
request.session['mellanox_neo_host_password'] = data['neo_host_password']
|
||||
response.set_cookie('mellanox_neo_host_password', data['neo_host_password'],
|
||||
expires=_one_year())
|
||||
|
||||
request.session['mellanox_ufm_host'] = data['ufm_host']
|
||||
response.set_cookie('mellanox_ufm_host', data['ufm_host'],
|
||||
expires=_one_year())
|
||||
|
||||
return response
|
Binary file not shown.
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2013 Centrin Data Systems Ltd.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
from mellanox_dashboard import dashboard
|
||||
|
||||
class SettingsPanel(horizon.Panel):
|
||||
name = _("Settings")
|
||||
slug = 'settingspanel'
|
||||
#policy_rules = (("identity", "identity:change_password"),)
|
||||
|
||||
dashboard.MLXDashboard.register(SettingsPanel)
|
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
{% block title %}{% trans "Mellanox Settings" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
#content_body .container-fluid .row .col-xs-12 .page-header{
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.modal-header{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.static_page{
|
||||
float: none;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.form-group{
|
||||
float: left;
|
||||
width: 220px;
|
||||
margin-right: 60px;
|
||||
}
|
||||
|
||||
label[for^="id_n_a_"]{
|
||||
visibility: hidden;
|
||||
|
||||
}
|
||||
|
||||
#id_n_a_{
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.col-sm-6{
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
.product_header_neo{
|
||||
background-color:#428BCA;
|
||||
width:250px;
|
||||
padding:7px;
|
||||
margin-top:30px;
|
||||
float: left;
|
||||
height: 50px;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.product_header_ufm{
|
||||
background-color:#428BCA;
|
||||
width:250px;
|
||||
margin-top:30px;
|
||||
float: left;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.ufm_lable{
|
||||
color: #fff;
|
||||
font-size: 27px;
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
margin: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<div class="product_header_neo">
|
||||
<img height=32 src="{% static 'mellanox_dashboard/images/neo_logo_trans.png' %}">
|
||||
</div>
|
||||
<div class="product_header_ufm">
|
||||
<label class="ufm_lable">UFM</label>
|
||||
</div>
|
||||
<div style="clear:both;height:0px;"></div>
|
||||
|
||||
|
||||
|
||||
|
||||
{% include "mellanox_dashboard/settingspanel/_change.html" %}
|
||||
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
horizon.mellanox_dashboard.prepareSettingsPanel();
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
Binary file not shown.
After Width: | Height: | Size: 138 KiB |
|
@ -0,0 +1,74 @@
|
|||
# Copyright 2013 Centrin Data Systems Ltd.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django import http
|
||||
from django.utils.six.moves.urllib.parse import urlsplit # noqa
|
||||
|
||||
from mox3.mox import IsA # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
|
||||
INDEX_URL = reverse('horizon:settings:password:index')
|
||||
|
||||
|
||||
class ChangePasswordTests(test.TestCase):
|
||||
|
||||
@test.create_stubs({api.keystone: ('user_update_own_password', )})
|
||||
def test_change_password(self):
|
||||
api.keystone.user_update_own_password(IsA(http.HttpRequest),
|
||||
'oldpwd',
|
||||
'normalpwd',).AndReturn(None)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
formData = {'method': 'PasswordForm',
|
||||
'current_password': 'oldpwd',
|
||||
'new_password': 'normalpwd',
|
||||
'confirm_password': 'normalpwd'}
|
||||
res = self.client.post(INDEX_URL, formData)
|
||||
|
||||
self.assertNoFormErrors(res)
|
||||
|
||||
def test_change_validation_passwords_not_matching(self):
|
||||
formData = {'method': 'PasswordForm',
|
||||
'current_password': 'currpasswd',
|
||||
'new_password': 'testpassword',
|
||||
'confirm_password': 'doesnotmatch'}
|
||||
res = self.client.post(INDEX_URL, formData)
|
||||
|
||||
self.assertFormError(res, "form", None, ['Passwords do not match.'])
|
||||
|
||||
@test.create_stubs({api.keystone: ('user_update_own_password', )})
|
||||
def test_change_password_sets_logout_reason(self):
|
||||
api.keystone.user_update_own_password(IsA(http.HttpRequest),
|
||||
'oldpwd',
|
||||
'normalpwd').AndReturn(None)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
formData = {'method': 'PasswordForm',
|
||||
'current_password': 'oldpwd',
|
||||
'new_password': 'normalpwd',
|
||||
'confirm_password': 'normalpwd'}
|
||||
res = self.client.post(INDEX_URL, formData, follow=False)
|
||||
|
||||
self.assertRedirectsNoFollow(res, settings.LOGOUT_URL)
|
||||
self.assertIn('logout_reason', res.cookies)
|
||||
self.assertEqual(res.cookies['logout_reason'].value,
|
||||
"Password changed. Please log in again to continue.")
|
||||
scheme, netloc, path, query, fragment = urlsplit(res.url)
|
||||
redirect_response = res.client.get(path, http.QueryDict(query))
|
||||
self.assertRedirectsNoFollow(redirect_response, settings.LOGIN_URL)
|
|
@ -0,0 +1,24 @@
|
|||
# Copyright 2013 Centrin Data Systems Ltd.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
|
||||
|
||||
from mellanox_dashboard.settingspanel import views
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', views.SettingsView.as_view(), name='index'))
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
# Copyright 2013 Centrin Data Systems Ltd.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import forms
|
||||
|
||||
from mellanox_dashboard.settingspanel \
|
||||
import forms as settings_forms
|
||||
|
||||
class SettingsView(forms.ModalFormView):
|
||||
form_class = settings_forms.SettingsForm
|
||||
form_id = "change_settings_modal_form"
|
||||
modal_header = _("")
|
||||
modal_id = "change_settings_modal"
|
||||
page_title = _("Settings")
|
||||
submit_label = _("Save")
|
||||
submit_url = reverse_lazy("horizon:mellanox_dashboard:settingspanel:index")
|
||||
template_name = 'mellanox_dashboard/settingspanel/change.html'
|
||||
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 138 KiB |
Binary file not shown.
|
@ -0,0 +1,55 @@
|
|||
|
||||
horizon.mellanox_dashboard = {
|
||||
_getCookie: function(cname) {
|
||||
var name = cname + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0; i<ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1);
|
||||
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
|
||||
}
|
||||
return "";
|
||||
},
|
||||
prepareNEOPanel: function(){
|
||||
var val = this._getCookie("mellanox_neo_host");
|
||||
if(val != ""){/*
|
||||
// neo authentication
|
||||
var xhttp = new XMLHttpRequest();
|
||||
var url = "http://" + val + "/neo/login";
|
||||
var user = this._getCookie("mellanox_neo_host_user");
|
||||
var password = this._getCookie("mellanox_neo_host_password");
|
||||
var data = "username=" + user + "&password=" + password;
|
||||
xhttp.open("POST", url, true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
alert("on");
|
||||
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||
alert("ready state");
|
||||
//document.getElementById("neo_iframe").src = "http://" + val + "/neo";
|
||||
}
|
||||
};
|
||||
xhttp.send(data);*/
|
||||
document.getElementById("neo_iframe").src = "http://" + val + "/neo";
|
||||
}else{
|
||||
var msg = "<h5 style='margin:20px;'>NEO hostname/ip is not set, you can set it in Configurations panel</h5>";
|
||||
document.getElementsByClassName("col-xs-12")[0].innerHTML = msg;
|
||||
}
|
||||
},
|
||||
prepareUFMPanel: function(){
|
||||
var val = this._getCookie("mellanox_ufm_host");
|
||||
if(val != "")
|
||||
document.getElementById("ufm_iframe").src = "http://" + val + "/ufmui";
|
||||
else{
|
||||
var msg = "<h5 style='margin:20px;'>UFM hostname/ip is not set, you can set it in Configurations panel</h5>";
|
||||
document.getElementsByClassName("col-xs-12")[0].innerHTML = msg;
|
||||
}
|
||||
},
|
||||
prepareSettingsPanel: function(){
|
||||
document.getElementById("id_neo_host").value = this._getCookie("mellanox_neo_host");
|
||||
document.getElementById("id_neo_host_user").value = this._getCookie("mellanox_neo_host_user");
|
||||
document.getElementById("id_neo_host_password").value = this._getCookie("mellanox_neo_host_password");
|
||||
document.getElementById("id_ufm_host").value = this._getCookie("mellanox_ufm_host");
|
||||
|
||||
}
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'horizon/common/_sidebar.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include "horizon/_messages.html" %}
|
||||
{% block neo_dashboard_main %}{% endblock %}
|
||||
{% endblock %}
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from mellanox_dashboard import dashboard
|
||||
|
||||
class UFMpanel(horizon.Panel):
|
||||
name = _("UFM")
|
||||
slug = "ufmpanel"
|
||||
|
||||
|
||||
dashboard.MLXDashboard.register(UFMpanel)
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from openstack_dashboard.dashboards.mydashboard import dashboard
|
||||
|
||||
class Mypanel(horizon.Panel):
|
||||
name = _("My Fruits")
|
||||
slug = "mypanel"
|
||||
|
||||
|
||||
dashboard.Mydashboard.register(Mypanel)
|
|
@ -0,0 +1,48 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "NEO" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<style>
|
||||
|
||||
#content_body .container-fluid{
|
||||
height: 100% !important;
|
||||
omargin-left: -15px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row{
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12{
|
||||
height: 100% !important;
|
||||
opadding-right: 0px;
|
||||
}
|
||||
|
||||
#content_body .container-fluid .row .col-xs-12 .page-header{
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
iframe#ufm_iframe{
|
||||
width: 100%;
|
||||
height: 99%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<iframe id="ufm_iframe" src="">
|
||||
<p>Your browser does not support iframes.</p>
|
||||
</iframe>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
horizon.mellanox_dashboard.prepareUFMPanel();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from horizon.test import helpers as test
|
||||
|
||||
|
||||
class UFMpanelTests(test.TestCase):
|
||||
# Unit tests for mypanel.
|
||||
def test_me(self):
|
||||
self.assertTrue(1 + 1 == 2)
|
|
@ -0,0 +1,11 @@
|
|||
from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
|
||||
from mellanox_dashboard.ufmpanel.views \
|
||||
import IndexView
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
)
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
|
||||
from mydashboard.mypanel.views \
|
||||
import IndexView
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
)
|
|
@ -0,0 +1,10 @@
|
|||
from horizon import views
|
||||
|
||||
|
||||
class IndexView(views.APIView):
|
||||
# A very simple class-based view...
|
||||
template_name = 'mellanox_dashboard/ufmpanel/index.html'
|
||||
|
||||
def get_data(self, request, context, *args, **kwargs):
|
||||
# Add data to the context here...
|
||||
return context
|
Binary file not shown.
38
setup.cfg
38
setup.cfg
|
@ -1,13 +1,17 @@
|
|||
[metadata]
|
||||
name = horizon-mellanox
|
||||
summary = OpenStack Boilerplate contains all the boilerplate you need to create an OpenStack package.
|
||||
name = mellanox_dashboard
|
||||
summary = plugin that view Mellanox products UIs.
|
||||
description-file =
|
||||
README.rst
|
||||
author = OpenStack
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = http://www.openstack.org/
|
||||
author = Murad Awawdeh
|
||||
author-email = murada@mellanox.com
|
||||
home-page = https://launchpad.net/horizon-mellanox
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Framework :: Django
|
||||
Intended Audience :: Developers
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Intended Audience :: Information Technology
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
|
@ -21,26 +25,4 @@ classifier =
|
|||
|
||||
[files]
|
||||
packages =
|
||||
horizon-mellanox
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
all_files = 1
|
||||
|
||||
[upload_sphinx]
|
||||
upload-dir = doc/build/html
|
||||
|
||||
[compile_catalog]
|
||||
directory = horizon-mellanox/locale
|
||||
domain = horizon-mellanox
|
||||
|
||||
[update_catalog]
|
||||
domain = horizon-mellanox
|
||||
output_dir = horizon-mellanox/locale
|
||||
input_file = horizon-mellanox/locale/horizon-mellanox.pot
|
||||
|
||||
[extract_messages]
|
||||
keywords = _ gettext ngettext l_ lazy_gettext
|
||||
mapping_file = babel.cfg
|
||||
output_file = horizon-mellanox/locale/horizon-mellanox.pot
|
||||
mellanox_dashboard
|
||||
|
|
23
setup.py
23
setup.py
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||
#! /usr/bin/env python
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -13,17 +13,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
|
||||
import setuptools
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name = 'mellanox_dashboard',
|
||||
version = '0.0.1',
|
||||
packages=find_packages(),
|
||||
include_package_data = True,
|
||||
)
|
||||
|
||||
|
||||
# In python < 2.7.4, a lazy loading of package `pbr` will break
|
||||
# setuptools if some other modules registered functions in `atexit`.
|
||||
# solution from: http://bugs.python.org/issue15881#msg170215
|
||||
try:
|
||||
import multiprocessing # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr'],
|
||||
pbr=True)
|
||||
|
|
Loading…
Reference in New Issue