Skip to content

Commit

Permalink
admin: fixed display of statistics.
Browse files Browse the repository at this point in the history
  • Loading branch information
t-iwano committed Sep 27, 2012
1 parent a4c9c64 commit 86bf3a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion dcmgr/lib/dcmgr/endpoints/12.03/instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'dcmgr/endpoints/12.03/responses/instance'

Dcmgr::Endpoints::V1203::CoreAPI.namespace '/instances' do
INSTANCE_META_STATE=['alive', 'alive_with_terminated'].freeze
INSTANCE_META_STATE=['alive', 'alive_with_terminated', 'without_terminated'].freeze
INSTANCE_STATE=['running', 'stopped', 'terminated'].freeze
INSTANCE_STATE_PARAM_VALUES=(INSTANCE_STATE + INSTANCE_META_STATE).freeze

Expand All @@ -27,6 +27,8 @@
ds.lives
when 'alive_with_terminated'
ds.alives_and_termed
when 'without_terminated'
ds.without_terminated
else
raise E::InvalidParameter, :state
end
Expand Down
5 changes: 4 additions & 1 deletion dcmgr/lib/dcmgr/models/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class Instance < AccountResource
def_dataset_method(:alives_and_termed) { |term_period=Dcmgr.conf.recent_terminated_instance_period|
filter("terminated_at IS NULL OR terminated_at >= ?", (Time.now.utc - term_period))
}


def_dataset_method(:without_terminated) do
filter("state='running' OR state='stopped' OR state='halted'")
end
# serialization plugin must be defined at the bottom of all class
# method calls.
# Possible column data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
});

models.Statistics = models.Dcmgr.extend({
url: app.info.api_endpoints.dcmgr + '/api/12.03/instances.json?host_node_id=' + location.pathname.split('/')[2]
url: app.info.api_endpoints.dcmgr + '/api/12.03/instances.json?host_node_id=' + location.pathname.split('/')[2] + '&state=without_terminated'
});
})( app.models );

0 comments on commit 86bf3a9

Please sign in to comment.