From 0ec13ab9defe143b0983476259667083356e7f03 Mon Sep 17 00:00:00 2001 From: Greg McCullough Date: Wed, 14 Jun 2017 17:18:21 -0400 Subject: [PATCH] Remove unused XML helper code Added in commit e7db2f07c2ed28de1aebc48c7fdd63f79518e57d Enhanced in commit 54dfb704e24cb3e606ac9a2c0b005787291fbd7a --- .../mixins/scanning_operations_mixin.rb | 1 - app/models/scanning_operations.rb | 1 - lib/xmldata_helper.rb | 72 ------------------- 3 files changed, 74 deletions(-) delete mode 100644 lib/xmldata_helper.rb diff --git a/app/models/mixins/scanning_operations_mixin.rb b/app/models/mixins/scanning_operations_mixin.rb index fa3d0416592..42f84981c80 100644 --- a/app/models/mixins/scanning_operations_mixin.rb +++ b/app/models/mixins/scanning_operations_mixin.rb @@ -1,4 +1,3 @@ -require 'xmldata_helper' require 'yaml' module ScanningOperationsMixin diff --git a/app/models/scanning_operations.rb b/app/models/scanning_operations.rb index f1ec8bd62d0..1fdce36ead4 100644 --- a/app/models/scanning_operations.rb +++ b/app/models/scanning_operations.rb @@ -1,4 +1,3 @@ -require 'xmldata_helper' require 'yaml' # TODO: Determine if this file can be removed. diff --git a/lib/xmldata_helper.rb b/lib/xmldata_helper.rb deleted file mode 100644 index 87b540dfc20..00000000000 --- a/lib/xmldata_helper.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'xml/xml_utils' - -class XmlData < ActiveRecord::Base - def self.emsinventory(emsId, data) - doc = REXML::Document.new(data) - _log.info "request received from ems id: #{emsId}" - Storage.save_emsinventory(emsId, Xml2Array.getNodeDetails(doc, "Datastores")) - Host.save_ems_inventory(emsId, Xml2Array.getNodeDetails(doc, "HostSystems")) - end - - def self.emsevents(emsId, data) - _log.info "request received from ems id: #{emsId}" - handler = EventXmlHandler.new - Document.parse_stream(data, handler) - $log.debug handler.result.inspect - - handler.result.each { |event| eval "VmwareEmsEvent.#{event[:type]}(event)" } - end -end - -# Generic event processor class -require 'rexml/document' -require 'rexml/streamlistener' - -class EventXmlHandler - include REXML - include StreamListener - - def initialize - @tags = [] - @result = [] - @event = {} - @host = {} - @vm = {} - end - - attr_reader :result - - def tag_start(name, _attrs) - @tags.push name - end - - def tag_end(name) - @tags.pop - - case name - when "emsEvents" - when "event" - @result.push(@event) - @event = {} - when "host", "srcHost", "destHost" - @event[name.to_sym] = @host - @host = {} - when "vm", "srcVm", "destVm" - @event[name.to_sym] = @vm - @vm = {} - end - end - - def text(value) - return if value.strip.blank? - obj, name = @tags.last(2) - case obj - when "event" - @event[name.to_sym] = value - when "host", "srcHost", "destHost" - @host[name.to_sym] = value - when "vm", "srcVm", "destVm" - @vm[name.to_sym] = value - end - end -end