profitbricks 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9b9764ad2e524499c1c45274219ad62d1f5642e
4
- data.tar.gz: 85fc09ceeb64652682551f1acc3434a4aac4b409
3
+ metadata.gz: 927f517f665fe6a3edf1b95ba18d309a904cd921
4
+ data.tar.gz: ef29502801a32db332dfdd289ece88bb3aea3c0f
5
5
  SHA512:
6
- metadata.gz: 6c19e66e08af35556293a30f70d42331778f72403d6680a76eef06c7d96f45ea74e36c3eb5229763de794d551b9f2ab3f6b78e8d7b7d9fc42547ff417f980f4b
7
- data.tar.gz: 04c7c861e13c1d9a3c2edb0595b6e4fe8e9ea85eaf4a97dfdffbd2a1727b601daeef28a8242b55b1a84b5eead82cb859fd8b6d4cadc509318198808c8dbddc91
6
+ metadata.gz: 16b87afcb38284f88b8003180533a9c278849a93e065cda09319e1e89a8cab8e5c7117b880f427448bb09707172851dfc9033d9d44d6d20d60f19b49dc93ff1b
7
+ data.tar.gz: 4cc02ae79a0db4a940a22d701acbbc41ca093e391ec9a9554fedd776864f20a8631eb7bd2d77903ccea96d4a1db5d9ac9cd9645634bb31e9285db06969062b13
data/lib/profitbricks.rb CHANGED
@@ -13,7 +13,7 @@ require 'profitbricks/firewall'
13
13
  require 'profitbricks/rule'
14
14
 
15
15
  module Profitbricks
16
- VERSION = '0.9.7'
16
+ VERSION = '0.9.8'
17
17
  end
18
18
 
19
19
  PB = Profitbricks
@@ -52,6 +52,18 @@ module Profitbricks
52
52
  Server.create(options.merge(:data_center_id => self.id))
53
53
  end
54
54
 
55
+ # Creates a Storage in the current Virtual Data Center, automatically sets the :data_center_id
56
+ # @see Profitbricks::Storage#create
57
+ def create_storage(options)
58
+ Storage.create(options.merge(:data_center_id => self.id))
59
+ end
60
+
61
+ # Creates a Load Balancer in the current Virtual Data Center, automatically sets the :data_center_id
62
+ # @see Profitbricks::LoadBalancer#create
63
+ def create_load_balancer(options)
64
+ LoadBalancer.create(options.merge(:data_center_id => self.id))
65
+ end
66
+
55
67
  # Checks if the Data Center was successfully provisioned
56
68
  #
57
69
  # @return [Boolean] true if the Data Center was provisioned, false otherwise
@@ -31,8 +31,11 @@ module Profitbricks
31
31
  # @return [Boolean] true on success, false otherwise
32
32
  def register_servers(servers)
33
33
  raise "You have to provide at least one server" unless servers
34
- options = {:server_ids => servers.collect { |s| s.id }.join(','), :load_balancer_id=> self.id}
35
- xml = get_xml_and_update_attributes options, [:server_ids, :load_balancer_id]
34
+ options = {:load_balancer_id => self.id}
35
+ xml = get_xml_and_update_attributes options, [:load_balancer_id]
36
+ servers.each do |server|
37
+ xml += "<serverIds>#{server.id}</serverIds>"
38
+ end
36
39
  response = Profitbricks.request :register_servers_on_load_balancer, xml
37
40
  update_attributes(response.to_hash[:register_servers_on_load_balancer_response][:return])
38
41
  return true if response.to_hash[:register_servers_on_load_balancer_response][:return]
@@ -48,8 +51,11 @@ module Profitbricks
48
51
  # @return [Boolean] true on success, false otherwise
49
52
  def deregister_servers(servers)
50
53
  raise "You have to provide at least one server" unless servers
51
- options = {:server_ids => servers.collect { |s| s.id }.join(','), :load_balancer_id=> self.id}
52
- xml = get_xml_and_update_attributes options, [:server_ids, :load_balancer_id]
54
+ options = {:load_balancer_id => self.id}
55
+ xml = get_xml_and_update_attributes options, [:load_balancer_id]
56
+ servers.each do |server|
57
+ xml += "<serverIds>#{server.id}</serverIds>"
58
+ end
53
59
  response = Profitbricks.request :deregister_servers_on_load_balancer, xml
54
60
  return true if response.to_hash[:deregister_servers_on_load_balancer_response][:return]
55
61
  end
@@ -60,8 +66,11 @@ module Profitbricks
60
66
  # @return [Boolean] true on success, false otherwise
61
67
  def activate_servers(servers)
62
68
  raise "You have to provide at least one server" unless servers
63
- options = {:server_ids => servers.collect { |s| s.id }.join(','), :load_balancer_id=> self.id}
64
- xml = get_xml_and_update_attributes options, [:server_ids, :load_balancer_id]
69
+ options = {:load_balancer_id => self.id}
70
+ xml = get_xml_and_update_attributes options, [:load_balancer_id]
71
+ servers.each do |server|
72
+ xml += "<serverIds>#{server.id}</serverIds>"
73
+ end
65
74
  response = Profitbricks.request :activate_load_balancing_on_servers, xml
66
75
  return true if response.to_hash[:activate_load_balancing_on_servers_response][:return]
67
76
  end
@@ -72,8 +81,11 @@ module Profitbricks
72
81
  # @return [Boolean] true on success, false otherwise
73
82
  def deactivate_servers(servers)
74
83
  raise "You have to provide at least one server" unless servers
75
- options = {:server_ids => servers.collect { |s| s.id }.join(','), :load_balancer_id=> self.id}
76
- xml = get_xml_and_update_attributes options, [:server_ids, :load_balancer_id]
84
+ options = {:load_balancer_id => self.id}
85
+ xml = get_xml_and_update_attributes options, [:load_balancer_id]
86
+ servers.each do |server|
87
+ xml += "<serverIds>#{server.id}</serverIds>"
88
+ end
77
89
  response = Profitbricks.request :deactivate_load_balancing_on_servers, xml
78
90
  return true if response.to_hash[:deactivate_load_balancing_on_servers_response][:return]
79
91
  end
@@ -104,9 +116,13 @@ module Profitbricks
104
116
  # @option options [Array<Server>] :servers Array of servers to connect to the LoadBalancer
105
117
  # @return [LoadBalancer] The created LoadBalancer
106
118
  def create(options = {})
107
- options[:server_ids] = options[:servers].collect { |s| s.id }.join(',')
108
119
  xml = "<arg0>"
109
- xml += get_xml_and_update_attributes options, [:data_center_id, :lan_id, :ip, :name, :algorithm, :server_ids]
120
+ xml += get_xml_and_update_attributes options, [:data_center_id, :lan_id, :ip, :name, :algorithm]
121
+ unless options[:servers].nil?
122
+ options[:servers].each do |server|
123
+ xml += "<serverIds>#{server.id}</serverIds>"
124
+ end
125
+ end
110
126
  xml += "</arg0>"
111
127
  response = Profitbricks.request :create_load_balancer, xml
112
128
  self.find(:id => response.to_hash[:create_load_balancer_response][:return][:load_balancer_id])
@@ -124,4 +140,4 @@ module Profitbricks
124
140
  end
125
141
  end
126
142
  end
127
- end
143
+ end
@@ -12,7 +12,7 @@ module Profitbricks
12
12
  Savon.configure do |config|
13
13
  config.raise_errors = false
14
14
  config.log = Profitbricks::Config.log
15
-
15
+ config.pretty_print_xml = true
16
16
  end
17
17
  HTTPI.log = false
18
18
 
@@ -18,17 +18,16 @@ module Profitbricks
18
18
 
19
19
  # Updates parameters of an existing virtual Server device.
20
20
  # @param [Hash] options parameters for the new server
21
- # @option options [Fixnum] :cores Number of cores to be assigned to the specified server (required)
22
- # @option options [Fixnum] :ram Number of RAM memory (in MiB) to be assigned to the server. Must be at least 256 and a multiple of it. (required)
23
- # @option options [String] :name Name of the server to be created
24
- # @option options [String] :boot_from_image_id Defines an existing CD-ROM/DVD image ID to be set as boot device of the server. A virtual CD-ROM/DVD drive with the mounted image will be connected to the server.
25
- # @option options [String] :boot_from_storage_id Defines an existing storage device ID to be set as boot device of the server. The storage will be connected to the server implicitly.
26
- # @option options [String] :availability_zone Sets the availability zone in which the server is located (AUTO, ZONE_1, ZONE_2). If set to AUTO servers will be placed in a random zone.
27
- # @option options [String] :os_type Sets the OS type of the server. (WINDOWS, OTHER) If left empty, the server will inherit the OS Type of its selected boot image / storage.
21
+ # @option options [Fixnum] :cores Number of cores to be assigned to the specified server.
22
+ # @option options [Fixnum] :ram Number of RAM memory (in MiB) to be assigned to the server. Must be at least 256 and a multiple of it.
23
+ # @option options [String] :name Name of the server to be created.
24
+ # @option options [String] :boot_from_image_id Defines an existing CD-ROM/DVD image ID to be set as boot device of the server. A virtual CD-ROM/DVD drive with the mounted image will be connected to the server.
25
+ # @option options [String] :boot_from_storage_id Defines an existing storage device ID to be set as boot device of the server. The storage will be connected to the server implicitly.
26
+ # @option options [String] :availability_zone Sets the availability zone in which the server is located (AUTO, ZONE_1, ZONE_2). If set to AUTO servers will be placed in a random zone.
27
+ # @option options [String] :os_type Sets the OS type of the server. (WINDOWS, OTHER) If left empty, the server will inherit the OS Type of its selected boot image / storage.
28
28
  # @return [Boolean] true on success, false otherwise
29
29
  def update(options = {})
30
30
  return false if options.empty?
31
- raise ArgumentError.new(":ram and :cores are mandatory options.") unless options[:ram] or options[:core]
32
31
  raise ArgumentError.new(":ram has to be at least 256MiB and a multiple of it") if options[:ram] < 256 or (options[:ram] % 256) > 0
33
32
  raise ArgumentError.new(":availability_zone has to be either 'AUTO', 'ZONE_1', or 'ZONE_2'") if options[:availability_zone] and !['AUTO', 'ZONE_1', 'ZONE_2'].include? options[:availability_zone]
34
33
  raise ArgumentError.new(":os_type has to be either 'WINDOWS' or 'OTHER'") if options[:os_type] and !['WINDOWS', 'OTHER'].include? options[:os_type]
@@ -54,6 +53,12 @@ module Profitbricks
54
53
  end
55
54
  end
56
55
 
56
+ # Creates a Nic for the current Server, automatically sets the :server_id
57
+ # @see Profitbricks::Nic#create
58
+ def create_nic(options)
59
+ Nic.create(options.merge(:server_id => self.id))
60
+ end
61
+
57
62
  class << self
58
63
  # Creates a Virtual Server within an existing data center. Parameters can be specified to set up a
59
64
  # boot device and connect the server to an existing LAN or the Internet.
@@ -13,10 +13,11 @@ module Profitbricks
13
13
  #
14
14
  # @param [Hash] options Parameters to connect the Storage
15
15
  # @option options [:server_id] Identifier of the target virtual server (required)
16
- # @option options [:bus_type] Bus type to which the storage will be connected. Type can be IDE, SCSI or VIRTIO (required)
16
+ # @option options [:bus_type] Bus type to which the storage will be connected. Type can be IDE or VIRTIO. Default: VIRTIO
17
17
  # @option options [:device_number] Defines the device number of the virtual storage. If no device number is set, a device number will be automatically assigned
18
18
  # @return [Boolean] true on success, false otherwise
19
19
  def connect(options = {})
20
+ raise ArgumentError.new(":bus_type has to be either 'IDE' or 'VIRTIO'") if options[:bus_type] and !['IDE', 'VIRTIO'].include? options[:bus_type]
20
21
  xml = "<arg0>"
21
22
  xml += get_xml_and_update_attributes options.merge(:storage_id => self.id), [:server_id, :storage_id, :bus_type, :device_number]
22
23
  xml += "</arg0>"
@@ -81,4 +82,4 @@ module Profitbricks
81
82
  end
82
83
  end
83
84
  end
84
- end
85
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profitbricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Sander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-19 00:00:00.000000000 Z
11
+ date: 2013-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon