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