Sha256: e51e1bbfa65406a810e77f96a42ceaf439b75891c4688c311a430b21932e306b

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 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
          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

13 entries across 13 versions & 2 rubygems

Version Path
fog-openstack-0.1.6 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.5 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.4 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.3 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.2 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.1 lib/fog/openstack/models/compute/aggregate.rb
fog-openstack-0.1.0 lib/fog/openstack/models/compute/aggregate.rb
fog-1.37.0 lib/fog/openstack/models/compute/aggregate.rb
fog-1.36.0 lib/fog/openstack/models/compute/aggregate.rb
fog-1.35.0 lib/fog/openstack/models/compute/aggregate.rb
fog-2.0.0.pre.0 lib/fog/openstack/models/compute/aggregate.rb
fog-1.34.0 lib/fog/openstack/models/compute/aggregate.rb
fog-1.33.0 lib/fog/openstack/models/compute/aggregate.rb