Commit 7fe79862 authored by Alex Pyrgiotis's avatar Alex Pyrgiotis
Browse files

admin: Remove old checks from projects/ips actions

These checks are rendered obsolete because they are fixed in
parent 95692332
......@@ -36,21 +36,26 @@ class IPAction(AdminAction):
AdminAction.__init__(self, name=name, target='ip', f=f, **kwargs)
# FIXME: This should be a function in cyclades
def check_destroy_ip(ip):
"""Check if we can destroy this IP."""
if not ip.floating_ip or ip.nic:
return False
return True
def check_ip_action(action):
"""Check if an action can apply to an IP.
This is a wrapper for `validate_ip_action` of the ips module, that handles
the tupples returned by it.
def check(ip, action):
res, _ = ips.validate_ip_action(ip, action)
return res
return lambda ip: check(ip, action)
def generate_actions():
"""Create a list of actions on ips."""
actions = OrderedDict()
actions['destroy'] = IPAction(name='Destroy', c=check_destroy_ip,
karma='bad', caution_level='dangerous',)
actions['destroy'] = IPAction(name='Destroy', c=check_ip_action("DELETE"),
f=ips.delete_floating_ip, karma='bad',
actions['reassign'] = IPAction(name='Reassign to project', f=noop,
karma='neutral', caution_level='dangerous',)
......@@ -18,9 +18,7 @@ import logging
from collections import OrderedDict
from synnefo_admin.admin.actions import AdminAction
from import (validate_project_action,
approve_application, deny_application,
suspend, unsuspend, terminate, reinstate)
from import functions as pactions
from synnefo_admin.admin.utils import update_actions_rbac, send_admin_email
......@@ -38,30 +36,22 @@ class ProjectAction(AdminAction):
AdminAction.__init__(self, name=name, target='project', f=f, **kwargs)
# FIXME: This check should be done by astakos
def custom_check_suspend(project):
if project.is_suspended:
return False
res, _ = validate_project_action(project, "SUSPEND")
return res
def do_project_action(action):
if action == 'approve':
return lambda p: approve_application(
return lambda p: pactions.approve_application(
elif action == 'deny':
return lambda p: deny_application(
return lambda p: pactions.deny_application(
# The action name is the same as the imported action. If the imported
# action name changes, then this code must change too.
return lambda p: globals()[action](
# The action name should be the same as the function name in
func = getattr(pactions, action)
return lambda p: func(
def check_project_action(action):
def check(p, action):
res, _ = validate_project_action(p, action)
res, _ = pactions.validate_project_action(p, action)
return res
return lambda p: check(p, action)
......@@ -97,7 +87,7 @@ def generate_actions():
actions['suspend'] = ProjectAction(name='Suspend',
karma='bad', caution_level='warning',)
actions['unsuspend'] = ProjectAction(name='Unsuspend',
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 to comment