Module: VagrantPlugins::Openstack::RestUtils

Defined in:
lib/vagrant-openstack-provider/client/rest_utils.rb

Class Method Summary collapse

Class Method Details

._set_proxy(config) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/vagrant-openstack-provider/client/rest_utils.rb', line 6

def self._set_proxy(config)
  @logger = Log4r::Logger.new('vagrant_openstack::restutils')
  if config.http.proxy
    RestClient.proxy = config.http.proxy
    @logger.info "Setting up HTTP proxy to '#{config.http.proxy}'"
  end
end

.delete(env, url, headers = {}, &block) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/vagrant-openstack-provider/client/rest_utils.rb', line 30

def self.delete(env, url, headers = {}, &block)
  config = env[:machine].provider_config
  _set_proxy(config)
  RestClient::Request.execute(method: :delete, url: url, headers: headers,
                              timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
                              ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
end

.get(env, url, headers = {}, &block) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/vagrant-openstack-provider/client/rest_utils.rb', line 14

def self.get(env, url, headers = {}, &block)
  config = env[:machine].provider_config
  _set_proxy(config)
  RestClient::Request.execute(method: :get, url: url, headers: headers,
                              timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
                              ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
end

.post(env, url, payload, headers = {}, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/vagrant-openstack-provider/client/rest_utils.rb', line 22

def self.post(env, url, payload, headers = {}, &block)
  config = env[:machine].provider_config
  _set_proxy(config)
  RestClient::Request.execute(method: :post, url: url, payload: payload, headers: headers,
                              timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
                              ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
end