2013-03-28 18:13:49 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module HP
|
|
|
|
class Network
|
|
|
|
|
|
|
|
class Network < Fog::Model
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :name
|
|
|
|
attribute :tenant_id
|
|
|
|
attribute :status
|
|
|
|
attribute :shared
|
|
|
|
attribute :admin_state_up
|
|
|
|
attribute :router_external, :aliases => 'router:external'
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
service.delete_network(id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2013-04-12 17:12:33 -04:00
|
|
|
def ready?
|
|
|
|
self.status == 'ACTIVE'
|
|
|
|
end
|
|
|
|
|
2013-05-30 15:34:07 -04:00
|
|
|
def subnets
|
|
|
|
@subnets ||= begin
|
|
|
|
Fog::HP::Network::Subnets.new({
|
|
|
|
:service => service,
|
|
|
|
:filters => {:network_id => self.id}
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-28 18:13:49 -04:00
|
|
|
def save
|
|
|
|
identity ? update : create
|
|
|
|
end
|
|
|
|
|
2013-03-29 14:36:12 -04:00
|
|
|
private
|
|
|
|
|
2013-03-28 18:13:49 -04:00
|
|
|
def create
|
|
|
|
merge_attributes(service.create_network(attributes).body['network'])
|
2013-03-29 14:36:12 -04:00
|
|
|
true
|
2013-03-28 18:13:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
requires :id
|
|
|
|
merge_attributes(service.update_network(id, attributes).body['network'])
|
2013-03-29 14:36:12 -04:00
|
|
|
true
|
2013-03-28 18:13:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|