Method: Larrow::Qingcloud::Instance#attach_keypair

Defined in:
lib/larrow/qingcloud/instance.rb

#attach_keypair(keypair_id) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/larrow/qingcloud/instance.rb', line 38

def attach_keypair(keypair_id)
  return self if self.keypair_id
  conn.service 'get', 'AttachKeyPairs',
               :'instances.1' => id,
               :'keypairs.1'  => keypair_id
  loop do
    if show(verbose: 1)['keypair_ids'].count > 0
      self.keypair_id = keypair_id
      info "instance attach keypair: #{id}"
      break self
    end
    sleep 2
  end
end