Commit 0bc65ba4 by Karsa Zoltán István

variable delete method

parent cc827f1f
......@@ -127,7 +127,7 @@ class VariableREST(APIView):
def post(self, request, format=None):
data = JSONParser().parse(request)
serializer = VariableSerializer(data=data)
serializer = VariableSerializer(data=data, context={'request': request})
if serializer.is_valid():
serializer.save()
return JsonResponse(serializer.data, status=201)
......@@ -143,6 +143,11 @@ class GetVariableREST(APIView):
serializer = VariableSerializer(act, many=False, context={'request': request})
return JsonResponse(serializer.data, safe=False)
def delete(self, request, pk, format=None):
var = Variable.objects.get(pk=pk)
var.delete()
return JsonResponse({}, status=204)
class RedirectToLoginMixin(AccessMixin):
redirect_exception_classes = (PermissionDenied, )
......
......@@ -317,6 +317,8 @@ class NetTemplate:
self.ipv4 = str(net.host.ipv4)
self.ipv6 = str(net.host.ipv6)
self.name = str(net.vlan.name)
self.gateway4 = str(net.vlan.network4).split("/")[0]
self.mask4 = str(net.vlan.network4).split("/")[1]
self.mac = str(net.host.mac)
def __init__(self, instance):
......@@ -324,6 +326,10 @@ class NetTemplate:
self.ipv4 = str(instance.ipv4)
self.ipv6 = str(instance.ipv6)
self.mac = str(instance.mac)
if instance.primary_host:
addr = str(instance.primary_host.vlan.network4).split("/")
self.gateway4 = addr[0]
self.mask4 = addr[1]
class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
......@@ -604,7 +610,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
common_fields = ['name', 'description', 'num_cores', 'ram_size',
'max_ram_size', 'arch', 'priority', 'boot_menu',
'raw_data', 'lease', 'access_method', 'system',
'cloud_init', 'ci_meta_data', 'ci_user_data', 'has_agent']
'cloud_init', 'ci_meta_data', 'ci_user_data', 'ci_network_config', 'has_agent']
params = dict(template=template, owner=owner, pw=pwgen())
params.update([(f, getattr(template, f)) for f in common_fields])
params.update(kwargs) # override defaults w/ user supplied values
......
......@@ -889,6 +889,7 @@ class SaveAsTemplateOperation(InstanceOperation):
'cloud_init': self.instance.cloud_init,
'ci_meta_data': self.instance.ci_meta_data,
'ci_user_data': self.instance.ci_user_data,
'ci_network_config': self.instance.ci_network_config,
}
params.update(kwargs)
......
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