Class: Cloudscale::Monitor::InitMenus

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudscale/monitor/agent/init_menus.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agentInstanceId, path) ⇒ InitMenus

Returns a new instance of InitMenus.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cloudscale/monitor/agent/init_menus.rb', line 16

def initialize(agentInstanceId, path)
  if (agentInstanceId == nil)
    raise "InitMenu.new(): AgentInstanceId may not be null"
  end

  @log = Logger.new(STDOUT)
  @log.info("Initializing Menu")
  @client = RestClientWrapper.instance

  file = File.read(path);
  plugin = YAML.load(JSON.parse(file).to_yaml)
  plugin.each do | key, value |
    init_menu(value, agentInstanceId)
  end
end

Instance Attribute Details

#agentInstanceIdObject

Returns the value of attribute agentInstanceId.



14
15
16
# File 'lib/cloudscale/monitor/agent/init_menus.rb', line 14

def agentInstanceId
  @agentInstanceId
end

#clientObject

Returns the value of attribute client.



14
15
16
# File 'lib/cloudscale/monitor/agent/init_menus.rb', line 14

def client
  @client
end

#customerObject

Returns the value of attribute customer.



14
15
16
# File 'lib/cloudscale/monitor/agent/init_menus.rb', line 14

def customer
  @customer
end

#logObject

Returns the value of attribute log.



14
15
16
# File 'lib/cloudscale/monitor/agent/init_menus.rb', line 14

def log
  @log
end

#serverObject

Returns the value of attribute server.



14
15
16
# File 'lib/cloudscale/monitor/agent/init_menus.rb', line 14

def server
  @server
end

Instance Method Details

#init_menu(menuItem, agentInstanceId) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/cloudscale/monitor/agent/init_menus.rb', line 32

def init_menu(menuItem, agentInstanceId)
  menuItem["agentInstanceId"] = agentInstanceId
  test_menu = @client.searchOne("menus", "findByAgentInstanceIdAndMenuId", { :agentInstanceId => agentInstanceId, :menuId => menuItem["menuId"]})
  if (test_menu == nil)
    client.post("menus", menuItem)
  else
    client.patch("menus", RestClientWrapper.load_entity_id(test_menu), menuItem)
  end
end