lib/yao/resources/router.rb in yao-0.15.0 vs lib/yao/resources/router.rb in yao-0.16.0
- old
+ new
@@ -1,17 +1,33 @@
module Yao::Resources
class Router < Base
- include TenantAssociationable
+ include ProjectAssociationable
friendly_attributes :name, :description, :admin_state_up, :status, :external_gateway_info,
- :network_id, :enable_snat, :external_fixed_ips, :routes, :destination, :nexthop, :distributed,
- :ha, :availability_zone_hints, :availability_zones
+ :routes, :distributed, :ha, :availability_zone_hints, :availability_zones
self.service = 'network'
self.resource_name = 'router'
self.resources_name = 'routers'
+ # @return [bool]
+ def enable_snat
+ external_gateway_info["enable_snat"]
+ end
+
+ # @return [Array<Hash>]
+ def external_fixed_ips
+ external_gateway_info["external_fixed_ips"]
+ end
+
+ # @return [Yao::Resource::Network]
+ def external_network
+ @external_network ||= if network_id = external_gateway_info["network_id"]
+ Yao::Network.get(network_id)
+ end
+ end
+
# @return [Array<Yao::Resources::Port>]
def interfaces
Yao::Port.list(device_id: id)
end
@@ -27,15 +43,8 @@
# @param param [Hash]
# @return [Hash]
def remove_interface(id, param)
PUT(['routers', id, 'remove_router_interface.json'].join('/'), param.to_json)
end
-
- # @param name [String]
- # @return [Array<Yao::Resources::Router>]
- def get_by_name(name)
- self.list(name: name)
- end
- alias find_by_name get_by_name
end
end
end