Skip to content

Commit

Permalink
OpenStack missing list unification of Network and Volume
Browse files Browse the repository at this point in the history
Missing summary methods under network. Missing common interface
in list_snapshots and detailed method under volume.
  • Loading branch information
Ladas committed Jun 30, 2015
1 parent 9b8e8e6 commit 7ae2025
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/floating_ips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_floating_ips(filters).body['floatingips'])
end

alias_method :summary, :all

def get(floating_network_id)
if floating_ip = service.get_floating_ip(floating_network_id).body['floatingip']
new(floating_ip)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/lb_health_monitors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_lb_health_monitors(filters).body['health_monitors'])
end

alias_method :summary, :all

def get(health_monitor_id)
if health_monitor = service.get_lb_health_monitor(health_monitor_id).body['health_monitor']
new(health_monitor)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/lb_members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_lb_members(filters).body['members'])
end

alias_method :summary, :all

def get(member_id)
if member = service.get_lb_member(member_id).body['member']
new(member)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/lb_pools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_lb_pools(filters).body['pools'])
end

alias_method :summary, :all

def get(pool_id)
if pool = service.get_lb_pool(pool_id).body['pool']
new(pool)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/lb_vips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_lb_vips(filters).body['vips'])
end

alias_method :summary, :all

def get(vip_id)
if vip = service.get_lb_vip(vip_id).body['vip']
new(vip)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_networks(filters).body['networks'])
end

alias_method :summary, :all

def get(network_id)
if network = service.get_network(network_id).body['network']
new(network)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_ports(filters).body['ports'])
end

alias_method :summary, :all

def get(port_id)
if port = service.get_port(port_id).body['port']
new(port)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/routers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_routers(filters).body['routers'])
end

alias_method :summary, :all

def get(router_id)
if router = service.get_router(router_id).body['router']
new(router)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/security_group_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_security_group_rules(filters).body['security_group_rules'])
end

alias_method :summary, :all

def get(sec_group_rule_id)
if sec_group_rule = service.get_security_group_rule(sec_group_rule_id).body['security_group_rule']
new(sec_group_rule)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/security_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_security_groups(filters).body['security_groups'])
end

alias_method :summary, :all

def get(security_group_id)
if security_group = service.get_security_group(security_group_id).body['security_group']
new(security_group)
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/openstack/models/network/subnets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def all(filters_arg = filters)
load(service.list_subnets(filters).body['subnets'])
end

alias_method :summary, :all

def get(subnet_id)
if subnet = service.get_subnet(subnet_id).body['subnet']
new(subnet)
Expand Down
19 changes: 16 additions & 3 deletions lib/fog/openstack/requests/volume/list_snapshots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@ module Fog
module Volume
class OpenStack
class Real
def list_snapshots(detailed=true, options={})
path = detailed ? 'snapshots/detail' : 'snapshots'
def list_snapshots(options = true, options_deprecated = {})
if options.is_a?(Hash)
path = 'snapshots'
query = options
else
# Backwards compatibility layer, when 'detailed' boolean was sent as first param
if options
Fog::Logger.deprecation('Calling OpenStack[:volume].list_snapshots(true) is deprecated, use .list_snapshots_detailed instead')
else
Fog::Logger.deprecation('Calling OpenStack[:volume].list_snapshots(false) is deprecated, use .list_snapshots({}) instead')
end
path = options ? 'snapshots/detail' : 'snapshots'
query = options_deprecated
end

request(
:expects => 200,
:method => 'GET',
:path => path,
:query => options
:query => query
)
end
end
Expand Down
27 changes: 27 additions & 0 deletions lib/fog/openstack/requests/volume/list_snapshots_detailed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Fog
module Volume
class OpenStack
class Real
def list_snapshots_detailed(options = {})
request(
:expects => 200,
:method => 'GET',
:path => 'snapshots/detail',
:query => options
)
end
end

class Mock
def list_snapshots_detailed(options = {})
response = Excon::Response.new
response.status = 200
response.body = {
'snapshots' => [get_snapshot_details.body["snapshot"]]
}
response
end
end
end
end
end

0 comments on commit 7ae2025

Please sign in to comment.