Class: Fog::Network::OpenStack::Network
- Inherits:
-
Model
- Object
- Model
- Fog::Network::OpenStack::Network
- Defined in:
- lib/fog/openstack/models/network/network.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#initialize(attributes) ⇒ Network
constructor
A new instance of Network.
- #save ⇒ Object
- #subnets ⇒ Object
- #update ⇒ Object
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
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#save ⇒ Object
26 27 28 |
# File 'lib/fog/openstack/models/network/network.rb', line 26 def save identity ? update : create end |
#subnets ⇒ Object
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 |
#update ⇒ Object
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 |