1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
require 'fog/openstack/models/model'
module Fog
module OpenStack
class Compute
class Aggregate < Fog::OpenStack::Model
identity :id
attribute :availability_zone
attribute :name
attribute :metadata
attribute :deleted
attribute :deleted_at
attribute :updated_at
attribute :created_at
# Detailed
attribute :hosts
def save
requires :name
identity ? update : create
end
def create
requires :name
merge_attributes(service.create_aggregate(name, attributes).body['aggregate'])
self
end
def update
requires :id
merge_attributes(service.update_aggregate(id, attributes).body['aggregate'])
self
end
def add_host(host_uuid)
requires :id
service.add_aggregate_host(id, host_uuid)
end
def remove_host(host_uuid)
requires :id
service.remove_aggregate_host(id, host_uuid)
end
def update_metadata(metadata)
service.update_aggregate_metadata(id, metadata)
end
def destroy
requires :id
service.delete_aggregate(id)
true
end
end
end
end
end
|