Module: Profitbricks

Defined in:
lib/profitbricks.rb,
lib/profitbricks/cli.rb,
lib/profitbricks/nic.rb,
lib/profitbricks/rule.rb,
lib/profitbricks/image.rb,
lib/profitbricks/model.rb,
lib/profitbricks/config.rb,
lib/profitbricks/server.rb,
lib/profitbricks/storage.rb,
lib/profitbricks/firewall.rb,
lib/profitbricks/ip_block.rb,
lib/profitbricks/snapshot.rb,
lib/profitbricks/data_center.rb,
lib/profitbricks/profitbricks.rb,
lib/profitbricks/load_balancer.rb

Defined Under Namespace

Classes: AuthenticationError, CLI, Config, DataCenter, Firewall, FirewallRule, Image, Ip, IpBlock, LoadBalancer, Model, Nic, Server, Snapshot, Storage

Constant Summary collapse

VERSION =
'1.1.1'
NEED_PREFIX =
[:create_nic, :create_load_balancer, :update_storage, :create_storage,
:update_data_center, :rom_drive, :update_nic, :create_server,
:update_load_balancer, :connect_storage_to_server, :update_server,
:create_snapshot, :update_snapshot, :rollback_snapshot]

Class Method Summary collapse

Class Method Details

.configure {|Profitbricks::Config| ... } ⇒ Object

Configure the Profitbricks API client

Yields:

See Also:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/profitbricks/profitbricks.rb', line 11

def self.configure(&block)
  Profitbricks::Config.save_responses = false
  Profitbricks::Config.log = false
  Profitbricks::Config.global_classes = true
  Profitbricks::Config.polling_interval = 1
  yield Profitbricks::Config

  HTTPI.log = false

  @client = Savon::Client.new do |globals|
    # FIXME the WSDL currently returns a wrong endpoint
    globals.wsdl "https://api.profitbricks.com/1.2/wsdl"
    globals.convert_request_keys_to :lower_camelcase
    globals.raise_errors true
    globals.log Profitbricks::Config.log
    globals.pretty_print_xml true
    globals.open_timeout 10
    globals.read_timeout 10

    # Looks like ssl verifycation works with current jruby
    #if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && !ENV['SSL_CERT_DIR']
    #  puts "Warning: SSL certificate verification has been disabled"
    #  globals.ssl_verify_mode = :none
    #end
    globals.basic_auth [Profitbricks::Config.username, Profitbricks::Config.password]
  end

  Profitbricks.client = @client
  if Profitbricks::Config.global_classes
    Profitbricks.constants.select {|c| Class === Profitbricks.const_get(c)}.each do |klass|
      next if klass == :Config
      unless Kernel.const_defined?(klass)
        Kernel.const_set(klass, Profitbricks.const_get(klass))
      end
    end
  end
end