Sha256: 67008056f4f98ffe61011e502be25606893edfe51ebea1e9f2f6ee9b5d235bb8

Contents?: true

Size: 1.62 KB

Versions: 59

Compression:

Stored size: 1.62 KB

Contents

module Fog
  module Compute
    class HP
      class Real

        # Retrieves the encrypted administrator password for a server running Windows.
        #
        # ==== Parameters
        # * server_id<~Integer> - Id of server
        #
        # ==== Returns
        # * password_data<~string>: Encrypted password for a server running Windows
        #
        def get_windows_password(server_id)
          # get console output assuming that the server is already in active state
          log_output = get_console_output(server_id, 400).body['output']
          # decrypt the log output to extract the encrypted, base64-encoded password
          encrypted_password = extract_password_from_log(log_output)
        end

      end

      class Mock

        def get_windows_password(server_id)
          # need to mock out the private key as well
          private_key = OpenSSL::PKey::RSA.generate(1024)
          public_key = private_key.public_key
          ### The original password is Passw0rd
          encoded_password = encrypt_using_public_key("Passw0rd", public_key)

          if list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
            # mock output for this call get_console_output(server_id, 400).body['output']
            log_output = "start junk [cloud-init] Encrypt random password\n-----BEGIN BASE64-ENCODED ENCRYPTED PASSWORD-----\n#{encoded_password}-----END BASE64-ENCODED ENCRYPTED PASSWORD-----\nend junk [cloud-init] Done\n"
            encrypted_password = extract_password_from_log(log_output)
          else
            raise Fog::Compute::HP::NotFound
          end
        end
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 6 rubygems

Version Path
fog-maestrodev-1.18.0.20131205181604 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131126122111 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131125111730 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/hp/requests/compute/get_windows_password.rb
gapinc-fog-1.12.1.2.1 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/hp/requests/compute/get_windows_password.rb
fog-1.18.0 lib/fog/hp/requests/compute/get_windows_password.rb
fog-1.17.0 lib/fog/hp/requests/compute/get_windows_password.rb
fog-1.16.0 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.15.0.20130927082724 lib/fog/hp/requests/compute/get_windows_password.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/hp/requests/compute/get_windows_password.rb