diff --git a/django-openstack/src/django_openstack/dash/urls.py b/django-openstack/src/django_openstack/dash/urls.py index 0e9cd2218..81c66dd68 100644 --- a/django-openstack/src/django_openstack/dash/urls.py +++ b/django-openstack/src/django_openstack/dash/urls.py @@ -5,6 +5,7 @@ from django.conf import settings INSTANCES = r'^(?P[^/]+)/instances/(?P[^/]+)/%s$' IMAGES = r'^(?P[^/]+)/images/(?P[^/]+)/%s$' +KEYPAIRS = r'^(?P[^/]+)/keypairs/(?P[^/]+)/%s$' urlpatterns = patterns('django_openstack.dash.views.instances', url(r'^(?P[^/]+)/$', 'usage', name='dash_usage'), @@ -17,3 +18,8 @@ urlpatterns += patterns('django_openstack.dash.views.images', url(r'^(?P[^/]+)/images/$', 'index', name='dash_images'), url(IMAGES % 'launch', 'launch', name='dash_images_launch'), ) + +urlpatterns += patterns('django_openstack.dash.views.keypairs', + url(r'^(?P[^/]+)/keypairs/$', 'index', name='dash_keypairs'), + url(KEYPAIRS % 'launch', 'launch', name='dash_keypairs_launch'), +) diff --git a/django-openstack/src/django_openstack/dash/views/keypairs.py b/django-openstack/src/django_openstack/dash/views/keypairs.py new file mode 100644 index 000000000..e2e781de4 --- /dev/null +++ b/django-openstack/src/django_openstack/dash/views/keypairs.py @@ -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)) diff --git a/openstack-dashboard/dashboard/templates/_delete_keypair.html b/openstack-dashboard/dashboard/templates/_delete_keypair.html new file mode 100644 index 000000000..185b4e8af --- /dev/null +++ b/openstack-dashboard/dashboard/templates/_delete_keypair.html @@ -0,0 +1,8 @@ +
+ {% csrf_token %} + {% for hidden in form.hidden_fields %} + {{hidden}} + {% endfor %} + + +
diff --git a/openstack-dashboard/dashboard/templates/_keypair_list.html b/openstack-dashboard/dashboard/templates/_keypair_list.html new file mode 100644 index 000000000..7df79aa6f --- /dev/null +++ b/openstack-dashboard/dashboard/templates/_keypair_list.html @@ -0,0 +1,20 @@ + + + + + + + + + {% for image in images %} + + + + + + {% endfor %} +
IDNameCreatedUpdatedStatus
{{ keypair.name }}{{ keypair.fingerprint }} +
    +
  • {% include "_delete_keypair.html" with form=delete_form %}
  • +
+
diff --git a/openstack-dashboard/dashboard/templates/dash_create_keypair.html b/openstack-dashboard/dashboard/templates/dash_create_keypair.html new file mode 100644 index 000000000..3290d6d1a --- /dev/null +++ b/openstack-dashboard/dashboard/templates/dash_create_keypair.html @@ -0,0 +1,34 @@ +{% extends 'dash_base.html' %} + +{% block sidebar %} + {% with current_sidebar="keypairs" %} + {{block.super}} + {% endwith %} +{% endblock %} + +{% block main %} + +` + {% include "_messages.html" %} + +
+
+
+

Create Keypair

+
+ + {% include "_create_keypair.html" %} + +
+

Description:

+

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.

+

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis ligula nec lacus mollis eu laoreet lectus porta.

+

Sed iaculis mauris et est consectetur egestas. Praesent dolor libero, semper sed aliquet

+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/openstack-dashboard/dashboard/templates/dash_keypairs.html b/openstack-dashboard/dashboard/templates/dash_keypairs.html new file mode 100644 index 000000000..b93e8386f --- /dev/null +++ b/openstack-dashboard/dashboard/templates/dash_keypairs.html @@ -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 %} + + {% include "_messages.html" %} + +
+ {% if keypairs %} +
+

Keypairs

+ +
+ + {% include '_kepair_list.html' %} + + {% endif %} +
+{% endblock %} + + + +{% extends 'base.html' %} +{% load sidebar_tags %} + +{% block nav_pages %} + {% sidebar_select keypairs %} + {{ block.super }} +{% endblock %} + +{% block main_content %} + + {% include "_messages.html" %} + {% if keypairs %} +
+
+

Keypairs

+ +
+ + + + + + + + {% for keypair in keypairs %} + + + + + + {% endfor %} + +
NameFingerprintActions
{{ keypair.name }}{{ keypair.fingerprint }} +
    +
  • +
    + {% csrf_token %} + + +
    +
  • +
+
+ {% else %} +
+

Info

+

There are currently no keypairs.

You can create a keypair here Images Page.

+
+ {% endif %} + Create New Keypair>> +
+ +{% endblock main_content %} + diff --git a/openstack-dashboard/local/local_settings.py.example b/openstack-dashboard/local/local_settings.py.example index 4d3aa5264..6b645b65b 100644 --- a/openstack-dashboard/local/local_settings.py.example +++ b/openstack-dashboard/local/local_settings.py.example @@ -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