Class: StarosGet_2

Inherits:
Object
  • Object
show all
Defined in:
lib/imperituroard/platforms/staros/get_data_ssh.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(staros_login, staros_password) ⇒ StarosGet_2

Returns a new instance of StarosGet_2.



9
10
11
12
13
# File 'lib/imperituroard/platforms/staros/get_data_ssh.rb', line 9

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

Instance Attribute Details

#staros_loginObject

Returns the value of attribute staros_login.



7
8
9
# File 'lib/imperituroard/platforms/staros/get_data_ssh.rb', line 7

def 
  @staros_login
end

#staros_parserObject

Returns the value of attribute staros_parser.



7
8
9
# File 'lib/imperituroard/platforms/staros/get_data_ssh.rb', line 7

def staros_parser
  @staros_parser
end

#staros_passwordObject

Returns the value of attribute staros_password.



7
8
9
# File 'lib/imperituroard/platforms/staros/get_data_ssh.rb', line 7

def staros_password
  @staros_password
end

Instance Method Details

#get_all_active_charging(host_ip) ⇒ Object

get all active-charging data host - staros device IP address return parsed ECS configuration in JSON



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/imperituroard/platforms/staros/get_data_ssh.rb', line 19

def get_all_active_charging(host_ip)

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

  begin

    Net::SSH.start(host_ip, , :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