Skip to content

Instantly share code, notes, and snippets.

@yuanying
Created February 27, 2012 05:04
Show Gist options
  • Save yuanying/1921530 to your computer and use it in GitHub Desktop.
Save yuanying/1921530 to your computer and use it in GitHub Desktop.
openstack-compute で keypairs を取得する。
require 'openstack/compute'
class OpenStack::Compute::Connection
def list_keypairs(options = {})
anti_cache_param="cacheid=#{Time.now.to_i}"
path = OpenStack::Compute.paginate(options).empty? ? "#{svrmgmtpath}/os-keypairs?#{anti_cache_param}" : "#{svrmgmtpath}/os-keypairs?#{OpenStack::Compute.paginate(options)}&#{anti_cache_param}"
response = csreq("GET",svrmgmthost,path,svrmgmtport,svrmgmtscheme)
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
OpenStack::Compute.symbolize_keys(JSON.parse(response.body)["keypairs"])
end
alias :keypairs :list_keypairs
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment