profitbricks 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
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.2'
16
+ VERSION = '0.9.3'
17
17
  end
18
18
 
19
19
  PB = Profitbricks
@@ -52,13 +52,24 @@ module Profitbricks
52
52
  Server.create(options.merge(:data_center_id => self.id))
53
53
  end
54
54
 
55
- def wait_for_provisioning
55
+ # Checks if the Data Center is successfully provisioned
56
+ #
57
+ # @return [Boolean] true if the Data Center is provisioned
58
+ def provisioned?
56
59
  self.update_state
57
- while @provisioning_state != 'AVAILABLE'
58
- self.update_state
60
+ if @provisioning_state == 'AVAILABLE'
61
+ self.reload
62
+ true
63
+ else
64
+ false
65
+ end
66
+ end
67
+
68
+ # Blocks until the Data Center is provisioned
69
+ def wait_for_provisioning
70
+ while !self.provisioned?
59
71
  sleep 1
60
72
  end
61
- self.reload
62
73
  end
63
74
 
64
75
  class << self
@@ -54,6 +54,14 @@ describe Profitbricks::DataCenter do
54
54
  dc.provisioning_state.should == 'AVAILABLE'
55
55
  end
56
56
 
57
+ it "should return true on provisioned?" do
58
+ savon.expects(:get_data_center).returns(:two_servers_with_storage)
59
+ dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
60
+ savon.expects(:get_data_center_state).returns(:success)
61
+ savon.expects(:get_data_center).returns(:two_servers_with_storage)
62
+ dc.provisioned?.should == true
63
+ end
64
+
57
65
  it "should wait for provisioning to finish" do
58
66
  savon.expects(:get_data_center).returns(:two_servers_with_storage)
59
67
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profitbricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -227,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
227
  requirements:
228
228
  - - ! '>='
229
229
  - !ruby/object:Gem::Version
230
- hash: -836053368831027153
230
+ hash: 1700274062029811460
231
231
  version: '0'
232
232
  segments:
233
233
  - 0