Sha256: baa5845c44cd6e6b8d3b786b4d998b32108e9e156218004a68f329ca3ae669ca

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

require 'fog/openstack/models/model'

module Fog
  module Compute
    class OpenStack
      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(self.name, self.attributes).body['aggregate'])
          self
        end

        def update
          requires :id
          merge_attributes(service.update_aggregate(self.id, self.attributes).body['aggregate'])
          self
        end

        def add_host(host_uuid)
          requires :id
          service.add_aggregate_host(self.id, host_uuid)
        end

        def remove_host(host_uuid)
          requires :id
          service.remove_aggregate_host(self.id, host_uuid)
        end

        def update_metadata(metadata)
          service.update_aggregate_metadata(self.id, metadata)
        end

        def destroy
          requires :id
          service.delete_aggregate(self.id)
          true
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.9 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.8 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.7 lib/fog/openstack/models/compute/aggregate.rb