Class: Fog::Compute::QingCloud::KeyPairs
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::QingCloud::KeyPairs
- Defined in:
- lib/fog/qingcloud/models/compute/key_pairs.rb
Instance Method Summary collapse
-
#all(filters = filters) ⇒ Object
Returns an array of all key pairs that have been created.
-
#get(key_id) ⇒ Object
Used to retrieve a key pair that was created with the QingCloud.key_pairs.create method.
-
#initialize(attributes) ⇒ KeyPairs
constructor
Used to create a key pair.
Constructor Details
#initialize(attributes) ⇒ KeyPairs
Used to create a key pair. There are 4 optional arguments.
You can generate a new key_pair as follows: QingCloud.key_pairs.create(key_name = ”, mode = ‘system’, encrypt_method = ‘ssh-rsa’, public_key = ”) The key_pair can be retrieved by running QingCloud.key_pairs.get(“kp-keyid”). See get method below.
21 22 23 24 |
# File 'lib/fog/qingcloud/models/compute/key_pairs.rb', line 21 def initialize(attributes) self.filters ||= {} super end |
Instance Method Details
#all(filters = filters) ⇒ Object
Returns an array of all key pairs that have been created
QingCloud.key_pairs.all
30 31 32 33 34 |
# File 'lib/fog/qingcloud/models/compute/key_pairs.rb', line 30 def all(filters = filters) self.filters = filters data = service.describe_key_pairs(filters).body load(data['keypair_set']) end |
#get(key_id) ⇒ Object
Used to retrieve a key pair that was created with the QingCloud.key_pairs.create method. The name is required to get the associated key_pair information.
You can run the following command to get the details: QingCloud.key_pairs.get(“kp-deadbeef”)
42 43 44 45 46 |
# File 'lib/fog/qingcloud/models/compute/key_pairs.rb', line 42 def get(key_id) if key_id self.class.new(:service => service).all('keypair-id' => key_id).first end end |