Class: Kosmonavty_2
- Inherits:
-
Object
- Object
- Kosmonavty_2
- Defined in:
- lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb
Instance Attribute Summary collapse
-
#cps_mongo ⇒ Object
Returns the value of attribute cps_mongo.
-
#file_of_changed_prof ⇒ Object
Returns the value of attribute file_of_changed_prof.
-
#filename_failed_add ⇒ Object
Returns the value of attribute filename_failed_add.
-
#filename_failed_return ⇒ Object
Returns the value of attribute filename_failed_return.
-
#filename_processed_added ⇒ Object
Returns the value of attribute filename_processed_added.
-
#filename_processed_return ⇒ Object
Returns the value of attribute filename_processed_return.
-
#logfile ⇒ Object
Returns the value of attribute logfile.
-
#logfile_return ⇒ Object
Returns the value of attribute logfile_return.
-
#qps_connector ⇒ Object
Returns the value of attribute qps_connector.
Instance Method Summary collapse
- #add_line_to_file(new_line, filename) ⇒ Object
- #get_msisdn_from_file ⇒ Object
- #get_msisdn_from_file_for_del ⇒ Object
-
#initialize(file_of_changed_prof) ⇒ Kosmonavty_2
constructor
A new instance of Kosmonavty_2.
- #main_processor_add_acl ⇒ Object
- #main_processor_del_acl ⇒ Object
- #test ⇒ Object
- #test_mongo ⇒ Object
- #write_to_file_rewr(new_text) ⇒ Object
Constructor Details
#initialize(file_of_changed_prof) ⇒ Kosmonavty_2
Returns a new instance of Kosmonavty_2.
15 16 17 18 19 20 21 22 23 24 25 26 |
# 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 |
Instance Attribute Details
#cps_mongo ⇒ Object
Returns the value of attribute cps_mongo.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def cps_mongo @cps_mongo end |
#file_of_changed_prof ⇒ Object
Returns the value of attribute file_of_changed_prof.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def file_of_changed_prof @file_of_changed_prof end |
#filename_failed_add ⇒ Object
Returns the value of attribute filename_failed_add.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def filename_failed_add @filename_failed_add end |
#filename_failed_return ⇒ Object
Returns the value of attribute filename_failed_return.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def filename_failed_return @filename_failed_return end |
#filename_processed_added ⇒ Object
Returns the value of attribute filename_processed_added.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def filename_processed_added @filename_processed_added end |
#filename_processed_return ⇒ Object
Returns the value of attribute filename_processed_return.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def filename_processed_return @filename_processed_return end |
#logfile ⇒ Object
Returns the value of attribute logfile.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def logfile @logfile end |
#logfile_return ⇒ Object
Returns the value of attribute logfile_return.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def logfile_return @logfile_return end |
#qps_connector ⇒ Object
Returns the value of attribute qps_connector.
5 6 7 |
# File 'lib/imperituroard/projects/oats/fttx_acl/add_acl_fttx.rb', line 5 def qps_connector @qps_connector end |
Instance Method Details
#add_line_to_file(new_line, filename) ⇒ Object
32 33 34 35 36 37 |
# 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 ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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 ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# 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 ⇒ Object
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 100 101 102 103 104 105 106 107 108 109 |
# 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 ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# 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 ⇒ Object
127 128 129 |
# 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 ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# 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) ⇒ Object
28 29 30 |
# 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 |