Class: Fog::Network::OpenStack::Router

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

Overview

The Layer-3 Networking Extensions (router)

A logical entity for forwarding packets across internal subnets and NATting them on external networks through an appropriate external gateway.

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(attributes) ⇒ Router

Returns a new instance of Router.



22
23
24
25
26
# File 'lib/fog/openstack/models/network/router.rb', line 22

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

Instance Method Details

#createObject



33
34
35
36
37
38
# File 'lib/fog/openstack/models/network/router.rb', line 33

def create
  requires :name
  merge_attributes(service.create_router(self.name,
                                          self.attributes).body['router'])
  self
end

#destroyObject



47
48
49
50
51
# File 'lib/fog/openstack/models/network/router.rb', line 47

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

#saveObject



28
29
30
31
# File 'lib/fog/openstack/models/network/router.rb', line 28

def save
  requires :name
  identity ? update : create
end

#updateObject



40
41
42
43
44
45
# File 'lib/fog/openstack/models/network/router.rb', line 40

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