Created
November 18, 2013 15:52
-
-
Save lutter/7530139 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command :unbind_node do |data| | |
data['name'] or error 400, | |
:error => "Supply 'name' to indicate which node to unbind" | |
if node = Razor::Data::Node.find_by_name(data['name']) | |
if node.policy | |
policy_name = node.policy.name | |
node.log_append(:event => :unbind, :policy => policy_name) | |
node.policy = nil | |
node.bound = false | |
node.save | |
action = "node unbound. policy was #{policy_name}" | |
elsif node.bound | |
# Node was bound, policy had been deleted some time before | |
node.bound = false | |
node.log_append(:event => :unbind) | |
else | |
action = "no changes; node #{data['name']} is not bound" | |
end | |
else | |
action = "no changes; node #{data['name']} does not exist" | |
end | |
{ :result => action } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment