Class: Pipam

Inherits:
Object
  • Object
show all
Includes:
PhpipamModule
Defined in:
lib/imperituroard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PhpipamModule

#test

Constructor Details

#initialize(db_username, db_password, db_ip, cps_wsdl, cps_endpoint, cps_namespace) ⇒ Pipam

Returns a new instance of Pipam.



74
75
76
77
78
79
80
# File 'lib/imperituroard.rb', line 74

def initialize(db_username, db_password, db_ip, cps_wsdl, cps_endpoint, cps_namespace)
  @username = db_username
  @password = db_password
  @ip = db_ip
  @database_class = Pdb.new("phpipam", db_username, db_password, db_ip, "3306")
  @cps_class = Pcps.new(cps_wsdl, cps_endpoint, cps_namespace)
end

Instance Attribute Details

#cps_classObject

Returns the value of attribute cps_class.



72
73
74
# File 'lib/imperituroard.rb', line 72

def cps_class
  @cps_class
end

#database_classObject

Returns the value of attribute database_class.



72
73
74
# File 'lib/imperituroard.rb', line 72

def database_class
  @database_class
end

#ipObject

Returns the value of attribute ip.



72
73
74
# File 'lib/imperituroard.rb', line 72

def ip
  @ip
end

#passwordObject

Returns the value of attribute password.



72
73
74
# File 'lib/imperituroard.rb', line 72

def password
  @password
end

#usernameObject

Returns the value of attribute username.



72
73
74
# File 'lib/imperituroard.rb', line 72

def username
  @username
end

Instance Method Details

#final_change_msisdn(old_msisdn, new_msisdn) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/imperituroard.rb', line 93

def final_change_msisdn(old_msisdn, new_msisdn)
  dst_num_exists = database_class.check_if_msisdn_exists(new_msisdn, "ipaddresses")
  if dst_num_exists == 0
    response_from_db = database_class.update_database_rewrite_msisdn(old_msisdn, new_msisdn)
    if response_from_db=="success"
      response_from_cps = cps_class.change_attr_cps(old_msisdn, new_msisdn)
      if response_from_cps == "ok"
        "updated"
      else
        "cps failed"
      end
    else
      "db failed"
    end
  else
    "failed"
  end
end

#update_phpipam_rewr_msisdn(old_msisdn, new_msisdn) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/imperituroard.rb', line 82

def update_phpipam_rewr_msisdn(old_msisdn, new_msisdn)

  dst_num_exists = database_class.check_if_msisdn_exists(new_msisdn, "ipaddresses")
  if dst_num_exists == 0
    database_class.update_database_rewrite_msisdn(old_msisdn, new_msisdn)
    "updated"
  else
    "failed"
  end
end