class Kosmonavty_2
Attributes
cps_mongo[RW]
file_of_changed_prof[RW]
filename_failed_add[RW]
filename_failed_return[RW]
filename_processed_added[RW]
filename_processed_return[RW]
logfile[RW]
logfile_return[RW]
qps_connector[RW]
Public Class Methods
new(file_of_changed_prof)
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 15 def initialize(file_of_changed_prof) @file_of_changed_prof = file_of_changed_prof @qps_connector = Qps_2.new('http://172.24.220.65:8080/ua/wsdl/UnifiedApi.wsdl', 'http://172.24.220.65:8080/ua/soap', 'http://broadhop.com/unifiedapi/soap/types') @cps_mongo = MongoCPS_2.new('site1-ca-pri-sessionmgr01', '27720', 'spr') @filename_processed_added = 'testfile.txt' @filename_processed_return = 'testfile_return.txt' @logfile = 'day60log.txt' @logfile_return = 'day60log_return.txt' @filename_failed_add = 'testfile_failed.txt' @filename_failed_return = 'testfile_failed_return.txt' end
Public Instance Methods
add_line_to_file(new_line, filename)
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 32 def add_line_to_file(new_line, filename) File.open(file_of_changed_prof + filename, 'a') do |file| line = new_line + "\n" file.write line end end
get_msisdn_from_file()
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 39 def get_msisdn_from_file begin file = File.open(file_of_changed_prof + filename_processed_added) file_data = file.read output = [] splitted_lines = file_data.split("\n") splitted_lines.each do |aaa| if aaa != '' && aaa != "\n" && aaa.include?(';') msssisdn = aaa.split(';') output.push(msssisdn[0]) end end return output rescue return [] end end
get_msisdn_from_file_for_del()
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 57 def get_msisdn_from_file_for_del begin file = File.open(file_of_changed_prof + filename_processed_added) file_data = file.read output = [] splitted_lines = file_data.split("\n") splitted_lines.each do |aaa| if aaa != '' && aaa != "\n" && aaa.include?(';') msssisdn = aaa.split(';') output.push({:msisdn => msssisdn[0], :devId => msssisdn[1]}) end end return output rescue return [] end end
main_processor_add_acl()
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 75 def main_processor_add_acl process_json = {} process_msisdn_list = [] #dat_cps = cps_mongo.get_minsk_fttx_fizlic dat_cps = cps_mongo.get_minsk_fttx_zone2 dat_cps.each do |t| gg = t.split(';') process_json[gg[0]] = gg[1] process_msisdn_list.push(gg[0]) end from_file = get_msisdn_from_file list_for_process = process_msisdn_list - from_file uniq_list_for_proc = list_for_process.uniq uniq_list_for_proc.each do |ddd| ans = qps_connector.add_avp_acl(ddd, 'GTFU_IN') #ans = {:change_subscriber_avps_response => {:error_code => '0'}} begin if ans[:change_subscriber_avps_response][:error_code] == '0' add_line_to_file(ddd + ';' + process_json[ddd], filename_processed_added) resp = qps_connector.stop_session_username(process_json[ddd]) add_line_to_file(ddd + ';' + process_json[ddd] + 'stop_session: ' + resp.to_s, logfile) else add_line_to_file(ddd + ';' + process_json[ddd], filename_failed_add) add_line_to_file(ddd + ';' + process_json[ddd] + 'add_avps: ' + ans.to_s, logfile) end rescue add_line_to_file(ddd + ';' + process_json[ddd], filename_failed_add) add_line_to_file(ddd + ';' + process_json[ddd] + 'add_avps: ' + ans.to_s, logfile) end end end
main_processor_del_acl()
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 111 def main_processor_del_acl from_file = get_msisdn_from_file_for_del from_file.each do |ddd1| ans = qps_connector.delete_avp_acl(ddd1[:msisdn]) if ans[:change_subscriber_avps_response][:error_code] == '0' add_line_to_file(ddd1.to_s, filename_processed_return) resp = qps_connector.stop_session_username(ddd1[:devId]) add_line_to_file(ddd1.to_s + ';' + ddd1[:devId] + 'stop_session: ' + resp.to_s, logfile_return) else add_line_to_file(ddd1.to_s, filename_failed_return) add_line_to_file(ddd1.to_s + ';' + ddd1[:devId] + 'del_avp: ' + ans.to_s, logfile_return) end end end
test()
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 127 def test qps_connector.stop_session_username('Ethernet1/0/7:1907.0 Min_Rokossovskogo_145_5/0/0/1/0/7') end
test_mongo()
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 131 def test_mongo dat_cps = cps_mongo.get_minsk_fttx_zone2 dat_cps2 = cps_mongo.get_minsk_fttx_zone3_rokos dat_cps3 = cps_mongo.get_minsk_fttx_zone4_mega dat_cps4 = cps_mongo.get_minsk_fttx_zone5_koles dat_cps5 = cps_mongo.get_minsk_fttx_zone6_all dat_cps7 = cps_mongo.get_minsk_fttx_zone7_3last #1 p "get_minsk_fttx_zone2" p dat_cps p dat_cps.length #2 p "get_minsk_fttx_zone3_rokos" p dat_cps2 p dat_cps2.length #3 p "get_minsk_fttx_zone4_mega" p dat_cps3 p dat_cps3.length #4 p "get_minsk_fttx_zone5_koles" p dat_cps4 p dat_cps4.length #5 p "get_minsk_fttx_zone6_all" p dat_cps5 p dat_cps5.length p "get_minsk_fttx_zone7_3last" p dat_cps7 p dat_cps7.length end
write_to_file_rewr(new_text)
click to toggle source
# File lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb, line 28 def write_to_file_rewr(new_text) File.open(file_of_changed_prof + filename_processed_added, 'w') {|file| file.write(new_text)} end