porting most of keypairs
This commit is contained in:
parent
69880b6d60
commit
59a5143fdd
@ -5,6 +5,7 @@ from django.conf import settings
|
||||
|
||||
INSTANCES = r'^(?P<tenant_id>[^/]+)/instances/(?P<instance_id>[^/]+)/%s$'
|
||||
IMAGES = r'^(?P<tenant_id>[^/]+)/images/(?P<image_id>[^/]+)/%s$'
|
||||
KEYPAIRS = r'^(?P<tenant_id>[^/]+)/keypairs/(?P<keypair_id>[^/]+)/%s$'
|
||||
|
||||
urlpatterns = patterns('django_openstack.dash.views.instances',
|
||||
url(r'^(?P<tenant_id>[^/]+)/$', 'usage', name='dash_usage'),
|
||||
@ -17,3 +18,8 @@ urlpatterns += patterns('django_openstack.dash.views.images',
|
||||
url(r'^(?P<tenant_id>[^/]+)/images/$', 'index', name='dash_images'),
|
||||
url(IMAGES % 'launch', 'launch', name='dash_images_launch'),
|
||||
)
|
||||
|
||||
urlpatterns += patterns('django_openstack.dash.views.keypairs',
|
||||
url(r'^(?P<tenant_id>[^/]+)/keypairs/$', 'index', name='dash_keypairs'),
|
||||
url(KEYPAIRS % 'launch', 'launch', name='dash_keypairs_launch'),
|
||||
)
|
||||
|
55
django-openstack/src/django_openstack/dash/views/keypairs.py
Normal file
55
django-openstack/src/django_openstack/dash/views/keypairs.py
Normal file
@ -0,0 +1,55 @@
|
||||
class DeleteKeypair(forms.SelfHandlingForm):
|
||||
keypair_id = forms.CharField(widget=forms.HiddenInput())
|
||||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
keypair = extras_api(request).keypairs.delete(data['keypair_id'])
|
||||
except api_exceptions.ApiException, e:
|
||||
messages.error(request, 'Error deleting keypair: %s' % e.message)
|
||||
return redirect('dash_keypairs')
|
||||
|
||||
class CreateKeypair(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="20", label="Keypair Name")
|
||||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
keypair = extras_api(request).keypairs.create(data['name'])
|
||||
response = http.HttpResponse(mimetype='application/binary')
|
||||
response['Content-Disposition'] = \
|
||||
'attachment; filename=%s.pem' % \
|
||||
keypair.key_name
|
||||
response.write(keypair.private_key)
|
||||
return response
|
||||
except api_exceptions.ApiException, e:
|
||||
messages.error(request, 'Error Creating Keypair: %s' % e.message)
|
||||
return redirect('dash_keypairs')
|
||||
|
||||
@login_required
|
||||
def index(request):
|
||||
for f in (DeleteKeypair):
|
||||
_, handled = f.maybe_handle(request)
|
||||
if handled:
|
||||
return handled
|
||||
|
||||
delete_form = DeleteKeypair()
|
||||
|
||||
try:
|
||||
keypairs = extras_api(request).keypairs.list()
|
||||
except api_exceptions.ApiException, e:
|
||||
keypairs = []
|
||||
messages.error(request, 'Error featching keypairs: %s' % e.message)
|
||||
|
||||
return render_to_response('dash_keypairs.html', {
|
||||
'keypairs': keypairs,
|
||||
'delete_form': delete_form,
|
||||
}, context_instance=template.RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def keypair_create(request):
|
||||
form, handled = CreateKeypair.maybe_handle(request)
|
||||
if handled:
|
||||
return handled
|
||||
|
||||
return render_to_response('keypair_create.html', {
|
||||
'create_form': form,
|
||||
}, context_instance=template.RequestContext(request))
|
@ -0,0 +1,8 @@
|
||||
<form id="form_delete_{{keypair.id}}" class="form-delete" method="post">
|
||||
{% csrf_token %}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{hidden}}
|
||||
{% endfor %}
|
||||
<input name="keypair_id" type="hidden" value="{{keypair.id}}" />
|
||||
<input id="delete_{{keypair.id}}" class="delete" type="submit" value="Delete" />
|
||||
</form>
|
20
openstack-dashboard/dashboard/templates/_keypair_list.html
Normal file
20
openstack-dashboard/dashboard/templates/_keypair_list.html
Normal file
@ -0,0 +1,20 @@
|
||||
<table id="images" style="width: 100%">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Created</th>
|
||||
<th>Updated</th>
|
||||
<th colspan="2">Status</th>
|
||||
</tr>
|
||||
{% for image in images %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td>{{ keypair.name }}</td>
|
||||
<td>{{ keypair.fingerprint }}</td>
|
||||
<td id="actions">
|
||||
<ul>
|
||||
<li>{% include "_delete_keypair.html" with form=delete_form %}</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
@ -0,0 +1,34 @@
|
||||
{% extends 'dash_base.html' %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% with current_sidebar="keypairs" %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div id='page_header'>
|
||||
<h2><span>System Panel:</span> keypairs</h2>
|
||||
<p class='desc'><span>—</span> Create a keypair.</p>
|
||||
</div>
|
||||
`
|
||||
{% include "_messages.html" %}
|
||||
|
||||
<div class="main_content">
|
||||
<div class="dash_block wide form">
|
||||
<div class='title_block'>
|
||||
<h3>Create Keypair</h3>
|
||||
</div>
|
||||
|
||||
{% include "_create_keypair.html" %}
|
||||
|
||||
<div class="right">
|
||||
<h3>Description:</h3>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vitae est urna. Phasellus sagittis, sem posuere hendrerit mattis, velit risus viverra enim, tempus dapibus sem turpis ac erat.</p>
|
||||
<p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis ligula nec lacus mollis eu laoreet lectus porta. </p>
|
||||
<p>Sed iaculis mauris et est consectetur egestas. Praesent dolor libero, semper sed aliquet</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
103
openstack-dashboard/dashboard/templates/dash_keypairs.html
Normal file
103
openstack-dashboard/dashboard/templates/dash_keypairs.html
Normal file
@ -0,0 +1,103 @@
|
||||
{% extends 'dash_base.html' %}
|
||||
{# list of user's images #}
|
||||
{# standard nav, sidebar, list of images in main #}
|
||||
|
||||
{% block sidebar %}
|
||||
{% with current_sidebar="images" %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div id='page_header'>
|
||||
<h2><span>Compute:</span> Keypairs</h2>
|
||||
<p class='desc'><span>—</span> Keypairs blah blah.</p>
|
||||
</div>
|
||||
{% include "_messages.html" %}
|
||||
|
||||
<div class='main_content'>
|
||||
{% if keypairs %}
|
||||
<div class='table_title wide'>
|
||||
<h3>Keypairs</h3>
|
||||
<div class='search'>
|
||||
<form action='' method='post'>
|
||||
<fieldset>
|
||||
<label for='table_search'>Search</label>
|
||||
<input id='table_search' name='search' type='text' value='' />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include '_kepair_list.html' %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
{% extends 'base.html' %}
|
||||
{% load sidebar_tags %}
|
||||
|
||||
{% block nav_pages %}
|
||||
{% sidebar_select keypairs %}
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block main_content %}
|
||||
<div id='page_header'>
|
||||
<h2><span>Compute:</span> Keypairs</h2>
|
||||
<p class='desc'><span>—</span> Keypairs blah blah.</p>
|
||||
</div>
|
||||
{% include "_messages.html" %}
|
||||
{% if keypairs %}
|
||||
<div class='main_content'>
|
||||
<div class='table_title wide'>
|
||||
<h3>Keypairs</h3>
|
||||
<div class='search'>
|
||||
<form action='' method='post'>
|
||||
<fieldset>
|
||||
<label for='table_search'>Search</label>
|
||||
<input id='table_search' name='search' type='text' value='' />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<table id='keypairs' class='wide'>
|
||||
<tr id='headings'>
|
||||
<th>Name</th>
|
||||
<th>Fingerprint</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
<tbody class='main'>
|
||||
{% for keypair in keypairs %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td>{{ keypair.name }}</td>
|
||||
<td>{{ keypair.fingerprint }}</td>
|
||||
<td id="actions">
|
||||
<ul>
|
||||
<li>
|
||||
<form id="form_keypair_{{ keypair.name }}" class="form-keypair-delete" method="post" action="{% url novaO_keypair_delete keypair.name %}" >
|
||||
{% csrf_token %}
|
||||
<input name="name" type="hidden" value="{{ keypair.name }}" />
|
||||
<input id="delete_{{keypair.name}}" title="keypair: {{keypair.name}}" class="terminate delete_link" type="submit" value="Delete" />
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="status_box info">
|
||||
<h2>Info</h2>
|
||||
<p>There are currently no keypairs.<br/><br/>You can create a keypair here <a href='{% url novaO_images %}'>Images Page.</a></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a id="keypair_create_link" href="{% url novaO_keypair_create %}">Create New Keypair>></a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock main_content %}
|
||||
|
@ -33,4 +33,39 @@ EXTERNAL_MONITORING = [
|
||||
# If you do not have external monitoring links
|
||||
# EXTERNAL_MONITORING = []
|
||||
|
||||
# Uncomment the following segment to silence most logging
|
||||
# django.db and boto DEBUG logging is extremely verbose.
|
||||
#LOGGING = {
|
||||
# 'version': 1,
|
||||
# # set to True will disable all logging except that specified, unless
|
||||
# # nothing is specified except that django.db.backends will still log,
|
||||
# # even when set to True, so disable explicitly
|
||||
# 'disable_existing_loggers': False,
|
||||
# 'handlers': {
|
||||
# 'null': {
|
||||
# 'level': 'DEBUG',
|
||||
# 'class': 'django.utils.log.NullHandler',
|
||||
# },
|
||||
# 'console': {
|
||||
# 'level': 'DEBUG',
|
||||
# 'class': 'logging.StreamHandler',
|
||||
# },
|
||||
# },
|
||||
# 'loggers': {
|
||||
# # Comment or Uncomment these to turn on/off logging output
|
||||
# 'django.db.backends': {
|
||||
# 'handlers': ['null'],
|
||||
# 'propagate': False,
|
||||
# },
|
||||
# 'boto': {
|
||||
# 'handlers': ['null'],
|
||||
# 'propagate': False,
|
||||
# },
|
||||
# 'django_openstack': {
|
||||
# 'handlers': ['null'],
|
||||
# 'propagate': False,
|
||||
# },
|
||||
# }
|
||||
#}
|
||||
|
||||
TOTAL_CLOUD_RAM_GB = 10
|
||||
|
Loading…
x
Reference in New Issue
Block a user