lib/profitbricks/data_center.rb in profitbricks-0.9.6 vs lib/profitbricks/data_center.rb in profitbricks-0.9.7

- old
+ new

@@ -66,11 +66,11 @@ end # Blocks until the Data Center is provisioned def wait_for_provisioning while !self.provisioned? - sleep 1 + sleep Profitbricks::Config.polling_interval end end class << self # Returns a list of all Virtual Data Centers created by the user, including ID, name and version number. @@ -85,13 +85,17 @@ end # Creates and saves a new, empty Virtual Data Center. # # @param [Hash] options - # @option options [String] :name Name of the Virtual Data Center (can not start with or contain (@, /, \\, |, ", ')) + # @option options [String] :name Name of the Virtual Data Center (can not start with or contain (@, /, \\, |, ", ')) + # @option options [String] :region Select region to create the data center (NORTH_AMERICA, EUROPE, DEFAULT). If DEFAULT or empty, the Virtual Data Center will be created in the default region of the user # @return [DataCenter] The newly created Virtual Data Center def create(options) - response = Profitbricks.request :create_data_center, "<dataCenterName>#{options[:name]}</dataCenterName>" + raise ArgumentError.new(":region has to be one of 'DEFAULT', 'NORTH_AMERICA', or 'EUROPE'") if options[:region] and !['DEFAULT', 'EUROPE', 'NORTH_AMERICA'].include? options[:region] + xml = "<dataCenterName>#{options[:name]}</dataCenterName>" + xml += get_xml_and_update_attributes options, [:region] + response = Profitbricks.request :create_data_center, xml self.find(:id => response.to_hash[:create_data_center_response][:return][:data_center_id] ) end # Finds a Virtual Data Center # @param [Hash] options either name or id of the Virtual Data Center