Created
February 27, 2012 05:04
-
-
Save yuanying/1921530 to your computer and use it in GitHub Desktop.
openstack-compute で keypairs を取得する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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