commit
				
					
						784ed0976b
					
				
			
		
					 9 changed files with 90 additions and 9 deletions
				
			
		|  | @ -449,7 +449,6 @@ STRIPE_DESCRIPTION_ON_PAYMENT = "Payment for ungleich GmbH services" | |||
| REGISTRATION_MESSAGE = {'subject': "Validation mail", | ||||
|                         'message': 'Thank You for registering for account on Digital Glarus.\nPlease verify Your account under following link http://{host}/en-us/digitalglarus/login/validate/{slug}', | ||||
|                         } | ||||
| 
 | ||||
| STRIPE_API_PRIVATE_KEY = env('STRIPE_API_PRIVATE_KEY') | ||||
| STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY') | ||||
| 
 | ||||
|  |  | |||
|  | @ -13,7 +13,7 @@ class Command(BaseCommand): | |||
|             'memory_price': 5, | ||||
|             'disk_size_price': 1, | ||||
|             'description': 'VM auf einzelner HW, Raid1, kein HA', | ||||
|             'location':'DE' | ||||
|             'location': 'DE' | ||||
|         } | ||||
| 
 | ||||
|         return { | ||||
|  | @ -46,7 +46,7 @@ class Command(BaseCommand): | |||
|                 'memory_price': 7, | ||||
|                 'disk_size_price': 0.70, | ||||
|                 'description': "VM in Bern, HA Setup ohne HA Garantie", | ||||
|                 'location':'CH', | ||||
|                 'location': 'CH', | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -104,6 +104,20 @@ class VirtualMachinePlan(models.Model): | |||
|         instance = cls.objects.create(**data) | ||||
|         return instance | ||||
| 
 | ||||
|     @classmethod | ||||
|     def generate_RSA(bits=2048): | ||||
|         ''' | ||||
|         Generate an RSA keypair with an exponent of 65537 in PEM format | ||||
|         param: bits The key length in bits | ||||
|         Return private key and public key | ||||
|         ''' | ||||
|         from Crypto.PublicKey import RSA | ||||
|         import os | ||||
|         new_key = RSA.generate(2048, os.urandom) | ||||
|         public_key = new_key.publickey() | ||||
|         private_key = new_key.exportKey("OpenSSH") | ||||
|         return private_key, public_key | ||||
| 
 | ||||
| 
 | ||||
| class HostingOrder(models.Model): | ||||
| 
 | ||||
|  |  | |||
|  | @ -150,6 +150,9 @@ | |||
|     <script src="{% static 'hosting/js/jquery.js' %}"></script> | ||||
|     <script type="text/javascript" src="http://cdn.jsdelivr.net/jquery.validation/1.13.1/jquery.validate.min.js"></script> | ||||
| 
 | ||||
|     <!-- Copy Clipboard --> | ||||
|     <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.10/clipboard.min.js"></script> | ||||
| 
 | ||||
| 
 | ||||
|     <!-- Bootstrap Core JavaScript --> | ||||
|     <script src="{% static 'hosting/js/bootstrap.min.js' %}"></script> | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ | |||
| 
 | ||||
|                 {% block messages %} | ||||
|                     {% if request.GET.logged_out %} | ||||
|                             <div class="alert alert-warning">  <!-- singular --> | ||||
|                             <div class="alert">  <!-- singular --> | ||||
|                                 <a class="close" data-dismiss="alert">×</a> | ||||
|                                 You haven been logged out | ||||
|                             </div> | ||||
|  | @ -23,7 +23,7 @@ | |||
|                         {% for field in form %} | ||||
|                             {% bootstrap_field field show_label=False type='fields'%} | ||||
|                         {% endfor %} | ||||
|                         {% bootstrap_form_errors form type='non_fields'%} | ||||
|                         <p>{{form.non_field_errors|striptags}}</p> | ||||
|                         {% buttons %} | ||||
|                             <button type="submit" class="btn btn-default"> | ||||
|                                 Login | ||||
|  |  | |||
							
								
								
									
										37
									
								
								hosting/templates/hosting/virtual_machine_key.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								hosting/templates/hosting/virtual_machine_key.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| {% extends "hosting/base_short.html" %} | ||||
| {% load staticfiles bootstrap3 %} | ||||
| {% block content %}  | ||||
| <div> | ||||
| 	<div class="container virtual-machine-container dashboard-container "> | ||||
| 		<div class="row"> | ||||
| 			<div class="col-md-9 col-md-offset-2"> | ||||
| 				 <div  class="col-sm-12"> | ||||
| 				        <h3><i class="fa fa-key" aria-hidden="true"></i> Private Key</h3> | ||||
| 				        <hr/>	 | ||||
| 						<div class="form-group"> | ||||
| 						  <label for="comment">private_key.pem</label> | ||||
| 						  <textarea class="form-control" rows="8" id="ssh_key">{{private_key}}</textarea> | ||||
| 						  <span class="h3 pull-right"><button type="button" class="btn btn-default"><a href=""> Download </a></button></span>   | ||||
| 						   <span class="h3 pull-right"><button type="button" data-clipboard-target="#ssh_key" class="btn btn-default">Copy to Clipboard</button></span>  | ||||
| 						</div> | ||||
| 				        <div class="clearfix"></div> | ||||
| 				</div> | ||||
| 			</div> | ||||
| 
 | ||||
| 	    </div> | ||||
| 	</div> | ||||
| 
 | ||||
| </div> | ||||
| <script type="text/javascript">  | ||||
|      (function () {new Clipboard('.btn');})(); | ||||
| </script> | ||||
| {%endblock%} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | @ -3,7 +3,7 @@ from django.conf.urls import url | |||
| from .views import DjangoHostingView, RailsHostingView, PaymentVMView, \ | ||||
|     NodeJSHostingView, LoginView, SignupView, IndexView, \ | ||||
|     OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\ | ||||
|     OrdersHostingDeleteView,VirtualMachineDetailView | ||||
|     VirtualMachineDetailView, GenerateVMSSHKeysView, OrdersHostingDeleteView | ||||
| 
 | ||||
| urlpatterns = [ | ||||
|     # url(r'pricing/?$', VMPricingView.as_view(), name='pricing'), | ||||
|  | @ -14,10 +14,12 @@ urlpatterns = [ | |||
|     url(r'payment/?$', PaymentVMView.as_view(), name='payment'), | ||||
|     url(r'orders/?$', OrdersHostingListView.as_view(), name='orders'), | ||||
|     url(r'orders/(?P<pk>\d+)/?$', OrdersHostingDetailView.as_view(), name='orders'), | ||||
|     url(r'cancel_order/(?P<pk>\d+)/?$',OrdersHostingDeleteView.as_view(),name='delete_order'), | ||||
|     url(r'cancel_order/(?P<pk>\d+)/?$', OrdersHostingDeleteView.as_view(), name='delete_order'), | ||||
|     url(r'my-virtual-machines/?$', VirtualMachinesPlanListView.as_view(), name='virtual_machines'), | ||||
|     url(r'my-virtual-machines/(?P<pk>\d+)/?$', VirtualMachineDetailView.as_view(), | ||||
|         name='virtual_machines'), | ||||
|     url(r'my-virtual-machines/(?P<pk>\d+)/key/?$', GenerateVMSSHKeysView.as_view(), | ||||
|         name='virtual_machine_key'), | ||||
|     url(r'login/?$', LoginView.as_view(), name='login'), | ||||
|     url(r'signup/?$', SignupView.as_view(), name='signup'), | ||||
|     url(r'^logout/?$', 'django.contrib.auth.views.logout', | ||||
|  |  | |||
|  | @ -3,8 +3,8 @@ from django.shortcuts import get_object_or_404, render | |||
| from django.core.urlresolvers import reverse_lazy, reverse | ||||
| from django.contrib.auth.mixins import LoginRequiredMixin | ||||
| 
 | ||||
| from django.views.generic import View, CreateView, FormView, ListView, DetailView,DeleteView | ||||
| from django.http import HttpResponseRedirect | ||||
| from django.views.generic import View, CreateView, FormView, ListView, DetailView, UpdateView, DeleteView | ||||
| from django.http import HttpResponseRedirect, HttpResponse | ||||
| from django.contrib.auth import authenticate, login | ||||
| from django.conf import settings | ||||
| 
 | ||||
|  | @ -145,6 +145,31 @@ class SignupView(CreateView): | |||
|         return HttpResponseRedirect(self.get_success_url()) | ||||
| 
 | ||||
| 
 | ||||
| class GenerateVMSSHKeysView(LoginRequiredMixin, UpdateView): | ||||
|     model = VirtualMachinePlan | ||||
|     template_name = 'hosting/virtual_machine_key.html' | ||||
|     success_url = reverse_lazy('hosting:orders') | ||||
| 
 | ||||
|     def get_context_data(self, **kwargs): | ||||
|         private_key, public_key = VirtualMachinePlan.generate_RSA() | ||||
|         context = { | ||||
|             'private_key': private_key | ||||
|         } | ||||
|         return context | ||||
| 
 | ||||
|     # def get(self, *args, **kwargs): | ||||
|     #     vm = self.get_object() | ||||
|     #     private_key, public_key = VirtualMachinePlan.generate_RSA() | ||||
|     #     print(private_key) | ||||
|     #     print(public_key) | ||||
|     #     key_name = "private_key" | ||||
|     #     response = HttpResponse(content_type='text/plain') | ||||
|     #     response['Content-Disposition'] = 'attachment; filename="%s.pem"' % key_name | ||||
|     #     response.write(private_key) | ||||
|     #     return response | ||||
|         # return HttpResponseRedirect(reverse('')) | ||||
| 
 | ||||
| 
 | ||||
| class PaymentVMView(LoginRequiredMixin, FormView): | ||||
|     template_name = 'hosting/payment.html' | ||||
|     login_url = reverse_lazy('hosting:login') | ||||
|  |  | |||
|  | @ -17,6 +17,7 @@ django-mptt | |||
| easy_thumbnails | ||||
| django-polymorphic | ||||
| model-mommy | ||||
| pycryptodome | ||||
| 
 | ||||
| #PLUGINS | ||||
| djangocms_flash | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue