Class: Gaff::Slicehost_api

Inherits:
Object
  • Object
show all
Defined in:
lib/gaff/slicehost_api.rb

Class Method Summary collapse

Class Method Details

.exec(msg) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gaff/slicehost_api.rb', line 4

def self.exec(msg)
  parser = Yajl::Parser.new
  hash = parser.parse(msg)
 
  Gaff::Log.debug(hash)
  STDOUT.flush

  begin
    slicehost = Fog::Slicehost::Compute.new({:slicehost_password => hash["params"]["password"]})
  
    Gaff::Log.debug(slicehost)
    STDOUT.flush
    
    case hash["method"]      
    when "create_slice"
      result = slicehost.create_slice(
        hash["params"]["flavor_id"].to_i,
        hash["params"]["image_id"].to_i,
        hash["params"]["name"])
    when "delete_slice"
      result = slicehost.delete_slice(hash["params"]["slice_id"].to_i)   
    end
    
    Gaff::Log.info(result)
    STDOUT.flush
  rescue Exception => e
    Gaff::Log.error(e)
    STDOUT.flush
  end
end