Commit aba1160b by Karsa Zoltán István

typo, add extra params to template creating via REST

parent 3ce140a8
......@@ -55,7 +55,7 @@ from .views import (
OpenSearchDescriptionView,
NodeActivityView,
UserList, TemplateREST, LeaseREST, DiskRest, InstanceREST,
InterfaceREST, InstanceFromTemplateREST, InstanceFTforUsers,
InterfaceREST, InstanceFromTemplateREST, InstanceFTforUsersREST,
StorageDetail, DiskDetail,
MessageList, MessageDetail, MessageCreate, MessageDelete,
EnableTwoFactorView, DisableTwoFactorView,
......@@ -72,7 +72,7 @@ urlpatterns = [
path('acpi/lease/', LeaseREST.as_view()),
path('acpi/disk/', DiskRest.as_view()),
path('acpi/interface/', InterfaceREST.as_view()),
path('acpi/ftusers/', InstanceFTforUsers.as_view()),
path('acpi/ftusers/', InstanceFTforUsersREST.as_view()),
url(r'^$', IndexView.as_view(), name="dashboard.index"),
url(r"^profile/list/$", UserList.as_view(),
name="dashboard.views.user-list"),
......
......@@ -225,6 +225,17 @@ class InstanceFromTemplateREST(APIView):
'owner': user,
}
amount = data.get("amount", 1)
if 'num_cores' in data:
ikwargs.update({'num_cores':data['num_cores']})
if 'ram_size' in data:
ikwargs.update({'ram_size':data['ram_size']})
if 'priority' in data:
ikwargs.update({'priority':data['priority']})
if 'max_ram_size' in data:
ikwargs.update({'max_ram_size':data['ram_size']})
instances = Instance.mass_create_from_template(amount=amount,
**ikwargs)
......@@ -235,13 +246,12 @@ class InstanceFromTemplateREST(APIView):
return JsonResponse({'instances': serializer.data}, status=201)
class InstanceFTforUsers(APIView):
class InstanceFTforUsersREST(APIView):
authentication_classes = [TokenAuthentication,BasicAuthentication]
permission_classes = [IsAdminUser]
def post(self, request, format=None):
data = JSONParser().parse(request)
user = User.objects.get(pk=request.user.pk)
template = InstanceTemplate.objects.get(pk=data['template'])
ikwargs = {
'name': data['name'],
......@@ -250,6 +260,17 @@ class InstanceFTforUsers(APIView):
'operator': data.get('operator', None),
'admin': data.get('admin', None)
}
if 'num_cores' in data:
ikwargs.update({'num_cores':data['num_cores']})
if 'ram_size' in data:
ikwargs.update({'ram_size':data['ram_size']})
if 'priority' in data:
ikwargs.update({'priority':data['priority']})
if 'max_ram_size' in data:
ikwargs.update({'max_ram_size':data['ram_size']})
missing_users, instances = Instance.mass_create_for_users(**ikwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment