mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|compute_v2] fixing merge issues; added metadata test for servers
This commit is contained in:
commit
2021bf3595
3 changed files with 12 additions and 7 deletions
|
@ -25,14 +25,14 @@ module Fog
|
||||||
attribute :links
|
attribute :links
|
||||||
|
|
||||||
def initialize(attributes={})
|
def initialize(attributes={})
|
||||||
@connection = attributes[:connection]
|
@service = attributes[:service]
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def metadata
|
def metadata
|
||||||
@metadata ||= begin
|
@metadata ||= begin
|
||||||
Fog::Compute::RackspaceV2::Metadata.new({
|
Fog::Compute::RackspaceV2::Metadata.new({
|
||||||
:connection => connection,
|
:service => service,
|
||||||
:parent => self
|
:parent => self
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,13 +17,13 @@ module Fog
|
||||||
def all
|
def all
|
||||||
requires :parent
|
requires :parent
|
||||||
return unless parent.identity
|
return unless parent.identity
|
||||||
data = connection.list_metadata(collection_name, parent.id).body['metadata']
|
data = service.list_metadata(collection_name, parent.id).body['metadata']
|
||||||
from_hash(data)
|
from_hash(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(key)
|
def get(key)
|
||||||
requires :parent
|
requires :parent
|
||||||
data = connection.get_metadata_item(collection_name, parent.id, key).body["meta"]
|
data = service.get_metadata_item(collection_name, parent.id, key).body["meta"]
|
||||||
datum = data.first
|
datum = data.first
|
||||||
new(:key => datum[0], :value => datum[1])
|
new(:key => datum[0], :value => datum[1])
|
||||||
rescue Fog::Compute::RackspaceV2::NotFound
|
rescue Fog::Compute::RackspaceV2::NotFound
|
||||||
|
@ -44,14 +44,14 @@ module Fog
|
||||||
if datum
|
if datum
|
||||||
datum.value = value
|
datum.value = value
|
||||||
else
|
else
|
||||||
self << Fog::Compute::RackspaceV2::Metadatum.new(:key => key, :value => value, :connection => connection, :parent => parent)
|
self << Fog::Compute::RackspaceV2::Metadatum.new(:key => key, :value => value, :service => service, :parent => parent)
|
||||||
end
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
requires :parent
|
requires :parent
|
||||||
connection.set_metadata(collection_name, parent.id, to_hash)
|
service.set_metadata(collection_name, parent.id, to_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new(attributes = {})
|
def new(attributes = {})
|
||||||
|
|
|
@ -9,12 +9,17 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
|
||||||
options = {
|
options = {
|
||||||
:name => "fog_server_#{Time.now.to_i.to_s}",
|
:name => "fog_server_#{Time.now.to_i.to_s}",
|
||||||
:flavor_id => flavor_id,
|
:flavor_id => flavor_id,
|
||||||
:image_id => image_id
|
:image_id => image_id,
|
||||||
|
:metadata => { 'fog_test' => 'true' }
|
||||||
}
|
}
|
||||||
|
|
||||||
model_tests(service.servers, options, true) do
|
model_tests(service.servers, options, true) do
|
||||||
@instance.wait_for(timeout=1500) { ready? }
|
@instance.wait_for(timeout=1500) { ready? }
|
||||||
|
|
||||||
|
tests('#metadata[\'fog_test\']').returns('true') do
|
||||||
|
@instance.metadata['fog_test']
|
||||||
|
end
|
||||||
|
|
||||||
tests('#update').succeeds do
|
tests('#update').succeeds do
|
||||||
@instance.name = "fog_server_update"
|
@instance.name = "fog_server_update"
|
||||||
@instance.access_ipv4_address= "10.10.0.1"
|
@instance.access_ipv4_address= "10.10.0.1"
|
||||||
|
|
Loading…
Add table
Reference in a new issue