Permalink
Browse files

- Make the file optional to allow it to default

- Include the file name in the status output
- Raise errors using fail! instead of the more verbose way
  • Loading branch information...
1 parent 6f974ae commit 17021378c887aaec37a67ee025b1979f5effac73 @ripienaar committed Nov 11, 2010
Showing with 11 additions and 5 deletions.
  1. +7 −3 agent/filemgr/filemgr.ddl
  2. +4 −2 agent/filemgr/filemgr.rb
@@ -13,7 +13,7 @@ action "touch", :description => "Creates an empty file or touch it's timestamp"
:description => "File to touch",
:type => :string,
:validation => '^.+$',
- :optional => false,
+ :optional => true,
:maxlength => 256
end
@@ -23,7 +23,7 @@ action "remove", :description => "Removes a file" do
:description => "File to remove",
:type => :string,
:validation => '^.+$',
- :optional => false,
+ :optional => true,
:maxlength => 256
end
@@ -35,9 +35,13 @@ action "status", :description => "Basic information about a file" do
:description => "File to get information for",
:type => :string,
:validation => '^.+$',
- :optional => false,
+ :optional => true,
:maxlength => 256
+ output :name,
+ :description => "File name",
+ :display_as => "Name"
+
output :output,
:description => "Human readable information about the file",
:display_as => "Status"
@@ -36,6 +36,7 @@ def get_filename
def status
file = get_filename
+ reply[:name] = file
reply[:output] = "not present"
reply[:present] = 0
reply[:size] = 0
@@ -78,6 +79,7 @@ def status
reply[:type] = "blockdev" if stat.blockdev?
else
logger.debug("Asked for status of '#{file}' - it is not present")
+ reply.fail! "#{file} does not exist"
end
end
@@ -94,7 +96,7 @@ def remove
reply.statusmsg = "OK"
rescue
logger.warn("Could not remove file '#{file}'")
- reply.fail "Could not remove file '#{file}'", 1
+ reply.fail! "Could not remove file '#{file}'"
end
end
@@ -105,7 +107,7 @@ def touch
logger.debug("Touched file '#{file}'")
rescue
logger.warn("Could not touch file '#{file}'")
- reply.fail "Could not touch file '#{file}'", 1
+ reply.fail! "Could not touch file '#{file}'"
end
end
end

0 comments on commit 1702137

Please sign in to comment.