Class: Pcps
- Inherits:
-
Object
- Object
- Pcps
- Defined in:
- lib/imperituroard/projects/wttx/phpipamcps.rb
Instance Attribute Summary collapse
-
#client_cps ⇒ Object
Returns the value of attribute client_cps.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#wsdl ⇒ Object
Returns the value of attribute wsdl.
Instance Method Summary collapse
- #add_attribute(attlist, username) ⇒ Object
- #avp_attr_list(username) ⇒ Object
- #change_attr_cps(old_msisdn, new_msisdn) ⇒ Object
-
#del_attribute(username) ⇒ Object
delete avp attributes from CPS.
- #get_current_attributes(msisdn) ⇒ Object
-
#initialize(wsdl, endpoint, namespace) ⇒ Pcps
constructor
A new instance of Pcps.
Constructor Details
#initialize(wsdl, endpoint, namespace) ⇒ Pcps
Returns a new instance of Pcps.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 10 def initialize(wsdl, endpoint, namespace) @wsdl = wsdl @endpoint = endpoint @namespace = namespace @clientcps = Savon.client do ssl_verify_mode :none #wsdl "https://172.24.242.4:8443/ua/wsdl/UnifiedApi.wsdl" #endpoint "http://172.24.242.4:8080/ua/soap" wsdl wsdl endpoint endpoint namespace namespace end end |
Instance Attribute Details
#client_cps ⇒ Object
Returns the value of attribute client_cps.
8 9 10 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 8 def client_cps @client_cps end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
8 9 10 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 8 def endpoint @endpoint end |
#namespace ⇒ Object
Returns the value of attribute namespace.
8 9 10 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 8 def namespace @namespace end |
#wsdl ⇒ Object
Returns the value of attribute wsdl.
8 9 10 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 8 def wsdl @wsdl end |
Instance Method Details
#add_attribute(attlist, username) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 109 def add_attribute(attlist, username) = { :audit => {:id => "SOAPGW", :comment => "some procedure"}, :networkId => username, :newAvp => attlist } response = client_cps.call(:change_subscriber_avps) do () end response.to_hash answer = response.to_hash[:change_subscriber_avps_response][:error_code] end |
#avp_attr_list(username) ⇒ Object
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 54 55 56 57 58 59 60 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 24 def avp_attr_list(username) = {:networkId => username} response = client_cps.call(:get_subscriber) do () end aaa = response.to_hash[:get_subscriber_response][:subscriber][:avp] #li = {"FRAMED-IP-ADDRESS":0,"FRAMED-NETMASK":0,"Default-Gateway":0,"VRF-ID":0,"DHCP-CLASS":0,"IPV4-UNNUMB":0,"PREFIX":0} li = {'FRAMED-IP-ADDRESS' => 0, 'FRAMED-NETMASK' => 0, 'Default-Gateway' => 0, 'VRF-ID' => 0, 'DHCP-CLASS' => 0, 'IPV4-UNNUMB' => 0, 'FRAMED-ROUTE-1' => 0} is_hash = !aaa.is_a?(Hash) if is_hash aaa.each do |i| if i[:code]=='FRAMED-IP-ADDRESS' li['FRAMED-IP-ADDRESS']=1 elsif i[:code]=='FRAMED-NETMASK' li['FRAMED-NETMASK']=1 elsif i[:code]=='Default-Gateway' li['Default-Gateway']=1 elsif i[:code]=='VRF-ID' li['VRF-ID']=1 elsif i[:code]=='DHCP-CLASS' li['DHCP-CLASS']=1 elsif i[:code]=='IPV4-UNNUMB' li['IPV4-UNNUMB']=1 elsif i[:code]=='FRAMED-ROUTE-1' li['FRAMED-ROUTE-1']=1 end end end li end |
#change_attr_cps(old_msisdn, new_msisdn) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 122 def change_attr_cps(old_msisdn, new_msisdn) ans = "" current = get_current_attributes(old_msisdn) attr_act = ["FRAMED-IP-ADDRESS", "FRAMED-NETMASK", "Default-Gateway", "VRF-ID", "DHCP-CLASS", "IPV4-UNNUMB", "FRAMED-ROUTE-1"] res_list= [] for j in current if attr_act.include?(j[:code]) res_list << j end end added_res = add_attribute(res_list, new_msisdn) if added_res == "0" ans = del_attribute(old_msisdn) p ans end if ans == "0" "ok" else "error" end end |
#del_attribute(username) ⇒ Object
delete avp attributes from CPS
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 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 64 def del_attribute(username) begin list = avp_attr_list(username) answer = "" for iti in list if iti[1]==1 = { :audit => {:id => "SOAPGW", :comment => "some procedure"}, :networkId => username, :deletedAvp => [ {:code => iti[0]} # {:code => "FRAMED-NETMASK"}, # {:code => "Default-Gateway"}, # {:code => "VRF-ID"}, # {:code => "DHCP-CLASS"}, # {:code => "IPV4-UNNUMB"}, # {:code => "PREFIX"} ] } response = client_cps.call(:change_subscriber_avps) do () end response answer = response.to_hash[:change_subscriber_avps_response][:error_code] end end rescue answer = "error" end answer end |
#get_current_attributes(msisdn) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/imperituroard/projects/wttx/phpipamcps.rb', line 100 def get_current_attributes(msisdn) = {:networkId => msisdn} response = client_cps.call(:get_subscriber) do () end aaa = response.to_hash[:get_subscriber_response][:subscriber][:avp] p aaa end |