Class: Ukaz60Staros_2
- Inherits:
-
Object
- Object
- Ukaz60Staros_2
- Defined in:
- lib/imperituroard/projects/ukaz60/staros.rb
Instance Attribute Summary collapse
-
#staros_hosts ⇒ Object
Returns the value of attribute staros_hosts.
-
#staros_platform_get ⇒ Object
Returns the value of attribute staros_platform_get.
-
#ukaz60_http_groups ⇒ Object
Returns the value of attribute ukaz60_http_groups.
-
#ukaz60_https_groups ⇒ Object
Returns the value of attribute ukaz60_https_groups.
Instance Method Summary collapse
-
#get_all_staros_ukaz60 ⇒ Object
procedure for get data from all MPC.
-
#get_data_staros(ip_staros) ⇒ Object
get data from staros and return urls from staros.
-
#initialize(star_login, star_password, ukaz60_http_groups, ukaz60_https_groups, staros_hosts) ⇒ Ukaz60Staros_2
constructor
A new instance of Ukaz60Staros_2.
Constructor Details
#initialize(star_login, star_password, ukaz60_http_groups, ukaz60_https_groups, staros_hosts) ⇒ Ukaz60Staros_2
Returns a new instance of Ukaz60Staros_2.
16 17 18 19 20 21 |
# File 'lib/imperituroard/projects/ukaz60/staros.rb', line 16 def initialize(star_login, star_password, ukaz60_http_groups, ukaz60_https_groups, staros_hosts) @staros_platform_get = StarosGet_2.new(star_login, star_password) @ukaz60_http_groups = ukaz60_http_groups @ukaz60_https_groups = ukaz60_https_groups @staros_hosts = staros_hosts end |
Instance Attribute Details
#staros_hosts ⇒ Object
Returns the value of attribute staros_hosts.
11 12 13 |
# File 'lib/imperituroard/projects/ukaz60/staros.rb', line 11 def staros_hosts @staros_hosts end |
#staros_platform_get ⇒ Object
Returns the value of attribute staros_platform_get.
11 12 13 |
# File 'lib/imperituroard/projects/ukaz60/staros.rb', line 11 def staros_platform_get @staros_platform_get end |
#ukaz60_http_groups ⇒ Object
Returns the value of attribute ukaz60_http_groups.
11 12 13 |
# File 'lib/imperituroard/projects/ukaz60/staros.rb', line 11 def ukaz60_http_groups @ukaz60_http_groups end |
#ukaz60_https_groups ⇒ Object
Returns the value of attribute ukaz60_https_groups.
11 12 13 |
# File 'lib/imperituroard/projects/ukaz60/staros.rb', line 11 def ukaz60_https_groups @ukaz60_https_groups end |
Instance Method Details
#get_all_staros_ukaz60 ⇒ Object
procedure for get data from all MPC
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/imperituroard/projects/ukaz60/staros.rb', line 103 def get_all_staros_ukaz60 returned_data = {:mpc_data => [], :add_format => {}} get_all_staros_ukaz60_1 = [] begin staros_hosts.each do |ggsn| get_all_staros_ukaz60_1 << Thread.new do begin mpc_data = self.get_data_staros(ggsn[1]) returned_data[:mpc_data].push({:code => 200, :result => "Success", :hostname => ggsn[0], :host_ip => ggsn[1], :body => mpc_data}) returned_data[:add_format][ggsn[0]] = mpc_data rescue returned_data[:mpc_data].push({:code => 507, :result => "Unknown thread error", :hostname => ggsn[0], :host_ip => ggsn[1], :body => {}}) end end end get_all_staros_ukaz60_1.each(&:join) returned_data[:code] = 200 returned_data[:result] = "get_all_staros_ukaz60: Success" rescue returned_data[:code] = 507 returned_data[:result] = "get_all_staros_ukaz60: Unknown SDK error" end returned_data end |
#get_data_staros(ip_staros) ⇒ Object
get data from staros and return urls from staros
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/imperituroard/projects/ukaz60/staros.rb', line 25 def get_data_staros(ip_staros) input_data = {:ip_staros => ip_staros} output_data = {} ecs_name = "" blocked_urls_http = [] blocked_urls_https = [] begin ecs_config_json = staros_platform_get.get_all_active_charging(ip_staros) if ecs_config_json[:code] == 200 #get ecs name ecs_sss = ecs_config_json[:parsed_data]["config"]["active-charging service"][0] ecs_sss.each do |hhh| ecs_name = hhh[0] end regexp_ruldef = /add-ruledef priority \d+ ruledef (.+)/ #for http urls begin ukaz60_http_groups.each do |rule| group_ruled_ukaz60 = ecs_config_json[:parsed_data]["config"]["active-charging service"][0][ecs_name]["group-of-ruledefs"][rule] group_ruled_ukaz60.each do |gr_rul_str| ruledef_name = gr_rul_str.match(regexp_ruldef)[1] rdef_config = ecs_config_json[:parsed_data]["config"]["active-charging service"][0][ecs_name]["ruledef"][ruledef_name] rdef_config.each do |g| if g[0..15] == "www url contains" blocked_urls_http.push({:url => g.gsub("www url contains ", ""), :ruledef => ruledef_name, :gr_of_ruledefs => rule, :gr_rul_str => gr_rul_str}) end end end end rescue blocked_urls_http.push("failed") end for https_rule in ukaz60_https_groups group_rule_https = ecs_config_json[:parsed_data]["config"]["active-charging service"][0][ecs_name]["group-of-ruledefs"][https_rule] end output_data = {:code => 200, :result => "Success", :ecs_name => ecs_name, :blocked_urls_http => blocked_urls_http, :http_rules_num => blocked_urls_http.length} else output_data = ecs_config_json end rescue output_data = {:code => 507, :result => "get_data_staros: Unknown SDK error"} end output_data # Net::SSH.start("172.24.214.17", "starscript", :password => "$rfv3EDC") do |ssh| # staros_answer = ssh.exec!("show configuration active-charging service all") # p staros_answer # # staros_answer = staros_answer.gsub("\n", "") # # regexp_ukaz60_9 = /group-of-ruledefs Ukaz60-9_HTTP.+HTTP\s+#exit/ # regexp_ukaz60_https = /group-of-ruledefs Ukaz60_HTTPS.+HTTPS\s+#exit/ # regexp_ukaz60_7 = /group-of-ruledefs Ukaz60-7_HTTP.+HTTP\s+#exit/ # # # # group_ruled_ukaz60_9 = staros_answer.match(regexp_ukaz60_9)[0] # group_ruled_ukaz60_https = staros_answer.match(regexp_ukaz60_https)[0] # group_ruled_ukaz60_7 = staros_answer.match(regexp_ukaz60_7)[0] # # p group_ruled_ukaz60_9 # p group_ruled_ukaz60_https # p group_ruled_ukaz60_7 # # end end |