Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uber hack to ignore disk_map #523

Merged
merged 1 commit into from
May 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion app/models/machine_info.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
require 'active_resource'

#########
## DiskMap only internally used to rewrite invalid key
## ie the 8:0 key in the example below
## 'disk_map' : {
# '8:0': {
# }
# }
#########
class DiskMap < BaseResource
include ActiveResource::Singleton

def find_or_create_resource_for(name)
name = name.to_s.gsub(':', '_').camelcase.to_sym
super("z_#{name}")
end
end

class MachineInfo < BaseResource
include ActiveResource::Singleton

self.site = "#{ENV['CADVISOR_PORT']}"

has_one :disk_map

def self.singleton_path(_prefix_options={}, _query_options=nil)
'/api/v1.0/machine'
'/api/v1.2/machine'
end
end
4 changes: 2 additions & 2 deletions spec/models/machine_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
it_behaves_like 'an active resource model'

describe '.singleton_path' do
it 'returns /api/v1.0/machine' do
expect(MachineInfo.singleton_path).to eq '/api/v1.0/machine'
it 'returns /api/v1.2/machine' do
expect(MachineInfo.singleton_path).to eq '/api/v1.2/machine'
end
end
end