Sha256: 86603c8e6c1df225812274c4f2bf540747277a81b2cafb8efd29ea131b7ddeef

Contents?: true

Size: 1.61 KB

Versions: 36

Compression:

Stored size: 1.61 KB

Contents

require 'net/ssh'

require 'imperituroard/platforms/staros/staros_parser'

class StarosGet_2

  attr_accessor :staros_parser, :staros_login, :staros_password

  def initialize(staros_login, staros_password)
    @staros_parser = StarosParser_2.new
    @staros_login = staros_login
    @staros_password = staros_password
  end


  #get all active-charging data
  #host - staros device IP address
  #return parsed ECS configuration in JSON
  def get_all_active_charging(host_ip)

    input_data = {:host_ip => host_ip}
    out_data = {}
    config_all = []

    begin

      Net::SSH.start(host_ip, staros_login, :password => staros_password) do |ssh|
        staros_answer = ssh.exec!("show configuration active-charging service all")
        staros_answer = staros_answer.gsub("#exit", "exit")
        #staros_answer = staros_answer.gsub("\n", " ")
        #p staros_answer
        #host_pool_regexp = /(host-pool.+\s+exit)/
        #fff = staros_answer.scan(host_pool_regexp)
        #p fff

        staros_answer = staros_answer.split("\n")
        for ttt in staros_answer
          regexp_full_command = /\s+(.+)/
          group_ruled_ukaz60_9 = ttt.match(regexp_full_command)
          if group_ruled_ukaz60_9 != nil
            config_all.push(group_ruled_ukaz60_9[1])
          else
            config_all.push(ttt)
          end
        end
      end
      staros_json = staros_parser.ecs_config_parser(config_all)
      out_data = {:code => 200, :result => "Successfully completed", :parsed_data => staros_json}
    rescue
      out_data = {:code => 507, :result => "get_all_active_charging: Unknown SDK error"}
    end
    out_data
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
imperituroard-1.1.25 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.24 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.23 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.22 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.21 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.20 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.19 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.18 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.17 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.15 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.14 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.13 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.12 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.11 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.10 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.9 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.8 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.7 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.5 lib/imperituroard/platforms/staros/get_data_ssh.rb
imperituroard-1.1.4 lib/imperituroard/platforms/staros/get_data_ssh.rb