Class: Service::Client
- Inherits:
-
Object
- Object
- Service::Client
- Defined in:
- opennebula/oneflow_client.rb
Instance Method Summary (collapse)
- - (Object) delete(path)
- - (Object) get(path)
-
- (Client) initialize(opts = {})
constructor
A new instance of Client.
- - (Object) login
- - (Object) logout
- - (Object) post(path, body)
- - (Object) put(path, body)
Constructor Details
- (Client) initialize(opts = {})
A new instance of Client
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'opennebula/oneflow_client.rb', line 302 def initialize(opts={}) @username = opts[:username] || ENV['ONEFLOW_USER'] @password = opts[:password] || ENV['ONEFLOW_PASSWORD'] url = opts[:url] || ENV['ONEFLOW_URL'] || 'http://localhost:2474' if @username.nil? && @password.nil? if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"]) one_auth = File.read(ENV["ONE_AUTH"]) elsif File.file?(ENV["HOME"]+"/.one/one_auth") one_auth = File.read(ENV["HOME"]+"/.one/one_auth") end one_auth.rstrip! @username, @password = one_auth.split(':') end @uri = URI.parse(url) @user_agent = "OpenNebula #{CloudClient::VERSION} " << "(#{opts[:user_agent]||"Ruby"})" @host = nil @port = nil if ENV['http_proxy'] uri_proxy = URI.parse(ENV['http_proxy']) @host = uri_proxy.host @port = uri_proxy.port end end |
Instance Method Details
- (Object) delete(path)
341 342 343 344 345 |
# File 'opennebula/oneflow_client.rb', line 341 def delete(path) req =Net::HTTP::Proxy(@host, @port)::Delete.new(path) do_request(req) end |
- (Object) get(path)
335 336 337 338 339 |
# File 'opennebula/oneflow_client.rb', line 335 def get(path) req = Net::HTTP::Proxy(@host, @port)::Get.new(path) do_request(req) end |
- (Object) login
361 362 363 364 365 |
# File 'opennebula/oneflow_client.rb', line 361 def login req = Net::HTTP::Proxy(@host, @port)::Post.new('/login') do_request(req) end |
- (Object) logout
367 368 369 370 371 |
# File 'opennebula/oneflow_client.rb', line 367 def logout req = Net::HTTP::Proxy(@host, @port)::Post.new('/logout') do_request(req) end |
- (Object) post(path, body)
347 348 349 350 351 352 |
# File 'opennebula/oneflow_client.rb', line 347 def post(path, body) req = Net::HTTP::Proxy(@host, @port)::Post.new(path) req.body = body do_request(req) end |
- (Object) put(path, body)
354 355 356 357 358 359 |
# File 'opennebula/oneflow_client.rb', line 354 def put(path, body) req = Net::HTTP::Proxy(@host, @port)::Put.new(path) req.body = body do_request(req) end |