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::OsInterface, Compute::OpenStack::SecurityGroup, Compute::OpenStack::SecurityGroupRule, Compute::OpenStack::ServerGroup, Compute::OpenStack::Service, Compute::OpenStack::Snapshot, Compute::OpenStack::Tenant, Compute::OpenStack::Volume, ContainerInfra::OpenStack::Base, DNS::OpenStack::V2::Pool, DNS::OpenStack::V2::Recordset, DNS::OpenStack::V2::Zone, DNS::OpenStack::V2::ZoneTransferAccept, DNS::OpenStack::V2::ZoneTransferRequest, Event::OpenStack::Event, 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::V1::Image, Image::OpenStack::V2::Image, Introspection::OpenStack::Rules, KeyManager::OpenStack::ACL, KeyManager::OpenStack::Container, KeyManager::OpenStack::Secret, Metering::OpenStack::Event, Metering::OpenStack::Resource, Metric::OpenStack::Metric, Metric::OpenStack::Resource, Monitoring::OpenStack::Alarm, Monitoring::OpenStack::AlarmCount, Monitoring::OpenStack::AlarmDefinition, Monitoring::OpenStack::AlarmState, Monitoring::OpenStack::DimensionValue, Monitoring::OpenStack::Measurement, Monitoring::OpenStack::Metric, Monitoring::OpenStack::NotificationMethod, Monitoring::OpenStack::Statistic, NFV::OpenStack::Vnf, NFV::OpenStack::Vnfd, Network::OpenStack::Extension, Network::OpenStack::FloatingIp, Network::OpenStack::IkePolicy, Network::OpenStack::IpsecPolicy, Network::OpenStack::IpsecSiteConnection, Network::OpenStack::LbHealthMonitor, Network::OpenStack::LbMember, Network::OpenStack::LbPool, Network::OpenStack::LbVip, Network::OpenStack::Network, Network::OpenStack::NetworkIpAvailability, Network::OpenStack::Port, Network::OpenStack::RbacPolicy, Network::OpenStack::Router, Network::OpenStack::SecurityGroup, Network::OpenStack::SecurityGroupRule, Network::OpenStack::Subnet, Network::OpenStack::SubnetPool, Network::OpenStack::VpnService, Planning::Plan, Planning::Role, Fog::Orchestration::OpenStack::Event, Fog::Orchestration::OpenStack::Resource, Fog::Orchestration::OpenStack::Stack, Fog::Orchestration::OpenStack::Template, SharedFileSystem::OpenStack::AvailabilityZone, SharedFileSystem::OpenStack::Network, SharedFileSystem::OpenStack::Share, SharedFileSystem::OpenStack::ShareAccessRule, SharedFileSystem::OpenStack::ShareExportLocation, SharedFileSystem::OpenStack::Snapshot, Storage::OpenStack::Directory, Storage::OpenStack::File, Volume::OpenStack::AvailabilityZone, Volume::OpenStack::Backup, Volume::OpenStack::Snapshot, 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