lib/legion/extensions/health/runners/health.rb in lex-health-0.1.1 vs lib/legion/extensions/health/runners/health.rb in lex-health-0.1.2

- old
+ new

@@ -1,11 +1,11 @@ module Legion::Extensions::Health module Runners module Health include Legion::Extensions::Helpers::Lex - def self.update(hostname:, **opts) + def update(hostname:, **opts) item = Legion::Data::Model::Node.where(name: hostname).first return { success: insert(hostname: hostname, **opts), hostname: hostname, **opts } if item.nil? if opts.key?(:timestamp) && !item.values[:updated].nil? && item.values[:updated] > Time.parse(opts[:timestamp]) @@ -17,20 +17,19 @@ end { success: item.update(active: 1, status: opts[:status], name: hostname), hostname: hostname, **opts } end - def self.insert(hostname:, status: 'unknown', **opts) + def insert(hostname:, status: 'unknown', **opts) insert = { active: 1, status: status, name: hostname } insert[:datacenter_id] = opts[:datacenter_id] if opts.key? :datacenter_id insert[:environment_id] = opts[:environment_id] if opts.key? :environment_id insert[:active] = opts[:active] if opts.key? :active { success: true, hostname: hostname, node_id: Legion::Data::Model::Node.insert(insert), **insert } end - def self.delete(node_id:, **_opts) - # Legion::Data::Model::Node.where(payload[:key].to_sym == payload[:value]).delete + def delete(node_id:, **_opts) Legion::Data::Model::Node[node_id].delete { success: true, node_id: node_id } end end end