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

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Network

Returns a new instance of Network.



20
21
22
23
24
# File 'lib/fog/openstack/models/network/network.rb', line 20

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

Instance Method Details

#createObject



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

def create
  merge_attributes(service.create_network(self.attributes).body['network'])
  self
end

#destroyObject



45
46
47
48
49
# File 'lib/fog/openstack/models/network/network.rb', line 45

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

#saveObject



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

def save
  identity ? update : create
end

#subnetsObject



30
31
32
# File 'lib/fog/openstack/models/network/network.rb', line 30

def subnets
  service.subnets.select {|s| s.network_id == self.id }
end

#updateObject



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

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