2016-08-09 20 views
0

私はBluecat(IPAM)用のRubyでAPIスクリプトを作成しています。私は何の問題にログインできないんだけど、私は追加のIPv4コマンドを実行しようとすると、私はこのエラーを取得:Ruby Soapエラー。ログインしましたが、エラーでログインしていない

in `raise_soap_and_http_errors!': (env:Server) Not logged in (Savon::SOAPFault) 

(いくつかの余分なコードを取り出して)私のスクリプトは以下の通りです:

require 'savon' 
require 'csv' 

module Bluecat 
class Api 

WsdlUrl = 'http:/bluecat/Services/API?wsdl' 
User = 'username' 
Pass = 'password' 

attr_accessor :auth_cookies 
attr_accessor :client 
def initialize 
    @client = Savon.client(wsdl: WsdlUrl) 
    unless client.nil? 
    login 
    puts client.operations 
    addIP4Network 
    else 
    print "No client\n" 
    end 
    print "Got cookies %s\n" % auth_cookies 
    logout 
end 

def login 
    response = client.call(:login) do 
    message username: User, password: Pass 
    end 
    @auth_cookies = response.http.cookies 
end 

def logout 
    puts "logging out" 
    client.call(:logout) 
end 

def addIP4Network 
    CSV.foreach('CSV', :headers => true , :encoding => 'ISO-8859-1') do |row,i| 

    message = {'blockId' => 'example' , 'CIDR' => row[0] , 'properties' => "configuration = COV "} 
    response = client.call(:add_ip4_network, message: message) 

    end 
end 
end 
end 

なぜこのエラーが発生しているのですか?ありがとう

答えて

0

私は同じ問題がありました。どうやら、リクエストごとにクッキーを送信する必要があります。

response = client.call(:add_ip4_network, message: message, cookies: auth_cookies) 
+0

変更

response = client.call(:add_ip4_network, message: message) 

は、これが働いていました。ありがとう! – Jake

関連する問題