Class: Fog::OpenStack::Model

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

Direct Known Subclasses

Baremetal::Chassis, Baremetal::Driver, Baremetal::Node, Baremetal::Port, Compute::Address, Compute::Aggregate, Compute::AvailabilityZone, Compute::Flavor, Compute::Host, Compute::Image, Compute::KeyPair, Compute::Metadatum, Compute::Network, Compute::OsInterface, Compute::SecurityGroup, Compute::SecurityGroupRule, Compute::ServerGroup, Compute::Service, Compute::Snapshot, Compute::Tenant, Compute::Volume, ContainerInfra::Base, DNS::V2::Pool, DNS::V2::Recordset, DNS::V2::Zone, DNS::V2::ZoneTransferAccept, DNS::V2::ZoneTransferRequest, Event::Event, Identity::V2::Ec2Credential, Identity::V2::Role, Identity::V2::Tenant, Identity::V2::User, Identity::V3::Domain, Identity::V3::Endpoint, Identity::V3::Group, Identity::V3::OsCredential, Identity::V3::Policy, Identity::V3::Project, Identity::V3::Role, Identity::V3::RoleAssignment, Identity::V3::Service, Identity::V3::Token, Identity::V3::User, Image::V1::Image, Image::V2::Image, Introspection::Rules, KeyManager::ACL, KeyManager::Container, KeyManager::Secret, Fog::OpenStack::Metering::Event, Fog::OpenStack::Metering::Resource, Fog::OpenStack::Metric::Metric, Fog::OpenStack::Metric::Resource, Fog::OpenStack::Monitoring::Alarm, Fog::OpenStack::Monitoring::AlarmCount, Fog::OpenStack::Monitoring::AlarmDefinition, Fog::OpenStack::Monitoring::AlarmState, Fog::OpenStack::Monitoring::DimensionValue, Fog::OpenStack::Monitoring::Measurement, Fog::OpenStack::Monitoring::Metric, Fog::OpenStack::Monitoring::NotificationMethod, Fog::OpenStack::Monitoring::Statistic, NFV::Vnf, NFV::Vnfd, Network::Extension, Network::FloatingIp, Network::IkePolicy, Network::IpsecPolicy, Network::IpsecSiteConnection, Network::LbHealthMonitor, Network::LbMember, Network::LbPool, Network::LbVip, Network::Network, Network::NetworkIpAvailability, Network::Port, Network::RbacPolicy, Network::Router, Network::SecurityGroup, Network::SecurityGroupRule, Network::Subnet, Network::SubnetPool, Network::VpnService, Orchestration::Event, Orchestration::Resource, Orchestration::Stack, Orchestration::Template, Planning::Plan, Planning::Role, SharedFileSystem::AvailabilityZone, SharedFileSystem::Network, SharedFileSystem::Share, SharedFileSystem::ShareAccessRule, SharedFileSystem::ShareExportLocation, SharedFileSystem::Snapshot, Storage::Directory, Storage::File, Volume::AvailabilityZone, Volume::Backup, Volume::Snapshot, Volume::Transfer, Volume::Volume, Volume::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