Commit c2a42986 by Bach Dániel

dashboard: move vlan perm check to Instance.create

parent 77236999
......@@ -354,6 +354,12 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def create(cls, params, disks, networks, req_traits, tags):
""" Create new Instance object.
"""
# permission check
for network in networks:
if not network.vlan.has_level(params['owner'], 'user'):
raise PermissionDenied()
# create instance and do additional setup
inst = cls(**params)
......@@ -408,10 +414,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
networks = (template.interface_set.all() if networks is None
else networks)
for network in networks:
if not network.vlan.has_level(owner, 'user'):
raise PermissionDenied()
req_traits = (template.req_traits.all() if req_traits is None
else req_traits)
......
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