1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge remote-tracking branch 'scotje/master'

Conflicts:
	lib/fog/rackspace/models/compute_v2/server.rb
This commit is contained in:
Brian Hartsock 2012-11-09 20:37:22 -05:00
commit 49300e6260
4 changed files with 26 additions and 1 deletions

View file

@ -33,6 +33,7 @@ module Fog
attribute :tenant_id
attribute :links
attribute :metadata
attribute :personality
attribute :ipv4_address, :aliases => 'accessIPv4'
attribute :ipv6_address, :aliases => 'accessIPv6'
attribute :disk_config, :aliases => 'OS-DCF:diskConfig'
@ -54,9 +55,12 @@ module Fog
def create
requires :name, :image_id, :flavor_id
options = {}
options[:disk_config] = disk_config unless disk_config.nil?
options[:metadata] = metadata unless metadata.nil?
options[:personality] = personality unless personality.nil?
data = connection.create_server(name, image_id, flavor_id, 1, 1, options)
merge_attributes(data.body['server'])
true

View file

@ -13,6 +13,12 @@ module Fog
load(data)
end
def bootstrap(new_attributes = {})
server = create(new_attributes)
server.wait_for { ready? }
server
end
def get(server_id)
data = connection.get_server(server_id).body['server']
new(data)

View file

@ -1,5 +1,6 @@
require 'fog/core/model'
require 'fog/rackspace/models/dns/callback'
require 'ipaddr'
module Fog
module DNS
@ -55,7 +56,19 @@ module Fog
end
response = wait_for_job connection.add_records(@zone.identity, [options]).body['jobId']
merge_attributes(response.body['response']['records'].select {|record| record['name'] == self.name && record['type'] == self.type && record['data'] == self.value}.first)
matching_record = response.body['response']['records'].find do |record|
if ['A', 'AAAA'].include?(self.type.upcase)
# If this is an A or AAAA record, match by normalized IP address value.
(record['name'] == self.name) && (record['type'] == self.type) && (IPAddr.new(record['data']) == IPAddr.new(self.value))
else
# Other record types are matched by the raw value.
(record['name'] == self.name) && (record['type'] == self.type) && (record['data'] == self.value)
end
end
merge_attributes(matching_record)
true
end

View file

@ -15,6 +15,8 @@ module Fog
data['server']['metadata'] = options[:metadata] unless options[:metadata].nil?
data['server']['OS-DCF:diskConfig'] = options[:disk_config] unless options[:disk_config].nil?
data['server']['metadata'] = options[:metadata] unless options[:metadata].nil?
data['server']['personality'] = options[:personality] unless options[:personality].nil?
request(
:body => Fog::JSON.encode(data),