Class: Fog::OpenStack::Model

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/models/model.rb

Direct Known Subclasses

Baremetal::OpenStack::Chassis, Baremetal::OpenStack::Driver, Baremetal::OpenStack::Node, Baremetal::OpenStack::Port, Compute::OpenStack::Address, Compute::OpenStack::Aggregate, Compute::OpenStack::AvailabilityZone, Compute::OpenStack::Flavor, Compute::OpenStack::Host, Compute::OpenStack::Image, Compute::OpenStack::KeyPair, Compute::OpenStack::Metadatum, Compute::OpenStack::Network, Compute::OpenStack::SecurityGroup, Compute::OpenStack::SecurityGroupRule, Compute::OpenStack::Service, Compute::OpenStack::Snapshot, Compute::OpenStack::Tenant, Compute::OpenStack::Volume, Identity::OpenStack::V2::Ec2Credential, Identity::OpenStack::V2::Role, Identity::OpenStack::V2::Tenant, Identity::OpenStack::V2::User, Identity::OpenStack::V3::Domain, Identity::OpenStack::V3::Endpoint, Identity::OpenStack::V3::Group, Identity::OpenStack::V3::OsCredential, Identity::OpenStack::V3::Policy, Identity::OpenStack::V3::Project, Identity::OpenStack::V3::Role, Identity::OpenStack::V3::RoleAssignment, Identity::OpenStack::V3::Service, Identity::OpenStack::V3::Token, Identity::OpenStack::V3::User, Image::OpenStack::Image, Metering::OpenStack::Resource, Network::OpenStack::FloatingIp, Network::OpenStack::LbHealthMonitor, Network::OpenStack::LbMember, Network::OpenStack::LbPool, Network::OpenStack::LbVip, Network::OpenStack::Network, Network::OpenStack::Port, Network::OpenStack::Router, Network::OpenStack::SecurityGroup, Network::OpenStack::SecurityGroupRule, Network::OpenStack::Subnet, Fog::Openstack::Planning::Plan, Fog::Openstack::Planning::Role, Fog::Orchestration::OpenStack::Event, Fog::Orchestration::OpenStack::Resource, Fog::Orchestration::OpenStack::Stack, Fog::Orchestration::OpenStack::Template, Storage::OpenStack::Directory, Storage::OpenStack::File, Volume::OpenStack::AvailabilityZone, Volume::OpenStack::Transfer, Volume::OpenStack::Volume, Volume::OpenStack::VolumeType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Model

Initialize a record



14
15
16
17
18
# File 'lib/fog/openstack/models/model.rb', line 14

def initialize(attributes)
  # Old 'connection' is renamed as service and should be used instead
  prepare_service_value(attributes)
  super
end

Instance Attribute Details

#projectObject

In some cases it's handy to be able to store the project for the record, e.g. swift doesn't contain project info in the result, so we can track it in this attribute based on what project was used in the request



8
9
10
# File 'lib/fog/openstack/models/model.rb', line 8

def project
  @project
end

Instance Method Details

#createObject

Creates a record



32
33
34
35
# File 'lib/fog/openstack/models/model.rb', line 32

def create
  # uncomment when exception is defined in another PR
  # raise Fog::OpenStack::Errors::InterfaceNotImplemented.new('Method :get is not implemented')
end

#destroyObject

Destroys a record



38
39
40
41
# File 'lib/fog/openstack/models/model.rb', line 38

def destroy
  # uncomment when exception is defined in another PR
  # raise Fog::OpenStack::Errors::InterfaceNotImplemented.new('Method :get is not implemented')
end

#saveObject

Saves a record, call create or update based on identity, which marks if object was already created



21
22
23
# File 'lib/fog/openstack/models/model.rb', line 21

def save
  identity ? update : create
end

#updateObject

Updates a record



26
27
28
29
# File 'lib/fog/openstack/models/model.rb', line 26

def update
  # uncomment when exception is defined in another PR
  # raise Fog::OpenStack::Errors::InterfaceNotImplemented.new('Method :get is not implemented')
end