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
|
||||
|
||||
def initialize(attributes={})
|
||||
@connection = attributes[:connection]
|
||||
@service = attributes[:service]
|
||||
super
|
||||
end
|
||||
|
||||
def metadata
|
||||
@metadata ||= begin
|
||||
Fog::Compute::RackspaceV2::Metadata.new({
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
:parent => self
|
||||
})
|
||||
end
|
||||
|
|
|
@ -17,13 +17,13 @@ module Fog
|
|||
def all
|
||||
requires :parent
|
||||
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)
|
||||
end
|
||||
|
||||
def get(key)
|
||||
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
|
||||
new(:key => datum[0], :value => datum[1])
|
||||
rescue Fog::Compute::RackspaceV2::NotFound
|
||||
|
@ -44,14 +44,14 @@ module Fog
|
|||
if datum
|
||||
datum.value = value
|
||||
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
|
||||
value
|
||||
end
|
||||
|
||||
def save
|
||||
requires :parent
|
||||
connection.set_metadata(collection_name, parent.id, to_hash)
|
||||
service.set_metadata(collection_name, parent.id, to_hash)
|
||||
end
|
||||
|
||||
def new(attributes = {})
|
||||
|
|
|
@ -9,12 +9,17 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
|
|||
options = {
|
||||
:name => "fog_server_#{Time.now.to_i.to_s}",
|
||||
:flavor_id => flavor_id,
|
||||
:image_id => image_id
|
||||
:image_id => image_id,
|
||||
:metadata => { 'fog_test' => 'true' }
|
||||
}
|
||||
|
||||
model_tests(service.servers, options, true) do
|
||||
@instance.wait_for(timeout=1500) { ready? }
|
||||
|
||||
tests('#metadata[\'fog_test\']').returns('true') do
|
||||
@instance.metadata['fog_test']
|
||||
end
|
||||
|
||||
tests('#update').succeeds do
|
||||
@instance.name = "fog_server_update"
|
||||
@instance.access_ipv4_address= "10.10.0.1"
|
||||
|
|
Loading…
Add table
Reference in a new issue